1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2016, assimp team 6 All rights reserved. 7 8 Redistribution and use of this software in source and binary forms, 9 with or without modification, are permitted provided that the 10 following conditions are met: 11 12 * Redistributions of source code must retain the above 13 copyright notice, this list of conditions and the 14 following disclaimer. 15 16 * Redistributions in binary form must reproduce the above 17 copyright notice, this list of conditions and the 18 following disclaimer in the documentation and/or other 19 materials provided with the distribution. 20 21 * Neither the name of the assimp team, nor the names of its 22 contributors may be used to endorse or promote products 23 derived from this software without specific prior 24 written permission of the assimp team. 25 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 38 ---------------------------------------------------------------------- 39 */ 40 41 /** @file FBXImporter.h 42 * @brief Declaration of the FBX main importer class 43 */ 44 #ifndef INCLUDED_AI_FBX_MESHGEOMETRY_H 45 #define INCLUDED_AI_FBX_MESHGEOMETRY_H 46 47 #include "FBXParser.h" 48 #include "FBXDocument.h" 49 50 namespace Assimp { 51 namespace FBX { 52 53 /** 54 * DOM base class for all kinds of FBX geometry 55 */ 56 class Geometry : public Object 57 { 58 public: 59 Geometry( uint64_t id, const Element& element, const std::string& name, const Document& doc ); 60 virtual ~Geometry(); 61 62 /** Get the Skin attached to this geometry or NULL */ 63 const Skin* DeformerSkin() const; 64 65 private: 66 const Skin* skin; 67 }; 68 69 70 typedef std::vector<int> MatIndexArray; 71 72 73 /** 74 * DOM class for FBX geometry of type "Mesh" 75 */ 76 class MeshGeometry : public Geometry 77 { 78 public: 79 /** The class constructor */ 80 MeshGeometry( uint64_t id, const Element& element, const std::string& name, const Document& doc ); 81 82 /** The class destructor */ 83 virtual ~MeshGeometry(); 84 85 /** Get a list of all vertex points, non-unique*/ 86 const std::vector<aiVector3D>& GetVertices() const; 87 88 /** Get a list of all vertex normals or an empty array if 89 * no normals are specified. */ 90 const std::vector<aiVector3D>& GetNormals() const; 91 92 /** Get a list of all vertex tangents or an empty array 93 * if no tangents are specified */ 94 const std::vector<aiVector3D>& GetTangents() const; 95 96 /** Get a list of all vertex binormals or an empty array 97 * if no binormals are specified */ 98 const std::vector<aiVector3D>& GetBinormals() const; 99 100 /** Return list of faces - each entry denotes a face and specifies 101 * how many vertices it has. Vertices are taken from the 102 * vertex data arrays in sequential order. */ 103 const std::vector<unsigned int>& GetFaceIndexCounts() const; 104 105 /** Get a UV coordinate slot, returns an empty array if 106 * the requested slot does not exist. */ 107 const std::vector<aiVector2D>& GetTextureCoords( unsigned int index ) const; 108 109 /** Get a UV coordinate slot, returns an empty array if 110 * the requested slot does not exist. */ 111 std::string GetTextureCoordChannelName( unsigned int index ) const; 112 113 /** Get a vertex color coordinate slot, returns an empty array if 114 * the requested slot does not exist. */ 115 const std::vector<aiColor4D>& GetVertexColors( unsigned int index ) const; 116 117 /** Get per-face-vertex material assignments */ 118 const MatIndexArray& GetMaterialIndices() const; 119 120 /** Convert from a fbx file vertex index (for example from a #Cluster weight) or NULL 121 * if the vertex index is not valid. */ 122 const unsigned int* ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const; 123 124 /** Determine the face to which a particular output vertex index belongs. 125 * This mapping is always unique. */ 126 unsigned int FaceForVertexIndex( unsigned int in_index ) const; 127 128 private: 129 void ReadLayer( const Scope& layer ); 130 void ReadLayerElement( const Scope& layerElement ); 131 void ReadVertexData( const std::string& type, int index, const Scope& source ); 132 133 void ReadVertexDataUV( std::vector<aiVector2D>& uv_out, const Scope& source, 134 const std::string& MappingInformationType, 135 const std::string& ReferenceInformationType ); 136 137 void ReadVertexDataNormals( std::vector<aiVector3D>& normals_out, const Scope& source, 138 const std::string& MappingInformationType, 139 const std::string& ReferenceInformationType ); 140 141 void ReadVertexDataColors( std::vector<aiColor4D>& colors_out, const Scope& source, 142 const std::string& MappingInformationType, 143 const std::string& ReferenceInformationType ); 144 145 void ReadVertexDataTangents( std::vector<aiVector3D>& tangents_out, const Scope& source, 146 const std::string& MappingInformationType, 147 const std::string& ReferenceInformationType ); 148 149 void ReadVertexDataBinormals( std::vector<aiVector3D>& binormals_out, const Scope& source, 150 const std::string& MappingInformationType, 151 const std::string& ReferenceInformationType ); 152 153 void ReadVertexDataMaterials( MatIndexArray& materials_out, const Scope& source, 154 const std::string& MappingInformationType, 155 const std::string& ReferenceInformationType ); 156 157 private: 158 // cached data arrays 159 MatIndexArray materials; 160 std::vector<aiVector3D> vertices; 161 std::vector<unsigned int> faces; 162 mutable std::vector<unsigned int> facesVertexStartIndices; 163 std::vector<aiVector3D> tangents; 164 std::vector<aiVector3D> binormals; 165 std::vector<aiVector3D> normals; 166 167 std::string uvNames[ AI_MAX_NUMBER_OF_TEXTURECOORDS ]; 168 std::vector<aiVector2D> uvs[ AI_MAX_NUMBER_OF_TEXTURECOORDS ]; 169 std::vector<aiColor4D> colors[ AI_MAX_NUMBER_OF_COLOR_SETS ]; 170 171 std::vector<unsigned int> mapping_counts; 172 std::vector<unsigned int> mapping_offsets; 173 std::vector<unsigned int> mappings; 174 }; 175 176 } 177 } 178 179 #endif // INCLUDED_AI_FBX_MESHGEOMETRY_H 180 181