FBXImporter: move MeshGeometry declaration into its own header

pull/814/head
Kim Kulling 2016-03-03 15:19:38 +01:00
parent 3079b90622
commit 2b09199f4a
10 changed files with 352 additions and 358 deletions

View File

@ -446,6 +446,7 @@ ADD_ASSIMP_IMPORTER(FBX
FBXDocument.cpp FBXDocument.cpp
FBXProperties.h FBXProperties.h
FBXProperties.cpp FBXProperties.cpp
FBXMeshGeometry.h
FBXMeshGeometry.cpp FBXMeshGeometry.cpp
FBXMaterial.cpp FBXMaterial.cpp
FBXModel.cpp FBXModel.cpp

View File

@ -44,18 +44,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
#include <iterator>
#include <sstream>
#include <boost/tuple/tuple.hpp>
#include <vector>
#include "FBXParser.h"
#include "FBXConverter.h" #include "FBXConverter.h"
#include "FBXParser.h"
#include "FBXMeshGeometry.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXUtil.h" #include "FBXUtil.h"
#include "FBXProperties.h" #include "FBXProperties.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "StringComparison.h" #include "StringComparison.h"
#include "../include/assimp/scene.h" #include "../include/assimp/scene.h"
#include <iterator>
#include <sstream>
#include <boost/tuple/tuple.hpp>
#include <vector>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
@ -63,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
using namespace Util; using namespace Util;
#define MAGIC_NODE_TAG "_$AssimpFbx$" #define MAGIC_NODE_TAG "_$AssimpFbx$"
@ -154,7 +156,6 @@ public:
private: private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// find scene root and trigger recursive scene conversion // find scene root and trigger recursive scene conversion
void ConvertRootNode() void ConvertRootNode()
@ -385,6 +386,7 @@ private:
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight(); out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
out_camera->mPosition = cam.Position(); out_camera->mPosition = cam.Position();
out_camera->mUp = cam.UpVector();
out_camera->mLookAt = cam.InterestPosition() - out_camera->mPosition; out_camera->mLookAt = cam.InterestPosition() - out_camera->mPosition;
out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView()); out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView());
} }
@ -426,6 +428,7 @@ private:
case TransformationComp_GeometricTranslation: case TransformationComp_GeometricTranslation:
return "GeometricTranslation"; return "GeometricTranslation";
case TransformationComp_MAXIMUM: // this is to silence compiler warnings case TransformationComp_MAXIMUM: // this is to silence compiler warnings
default:
break; break;
} }

View File

@ -44,17 +44,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
#include <functional>
#include "FBXParser.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXMeshGeometry.h"
#include "FBXParser.h"
#include "FBXUtil.h" #include "FBXUtil.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h" #include "FBXImportSettings.h"
#include "FBXDocumentUtil.h" #include "FBXDocumentUtil.h"
#include "FBXProperties.h" #include "FBXProperties.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <functional>
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
@ -135,6 +137,8 @@ const Object* LazyObject::Get(bool dieOnError)
// so avoid constructing strings all the time. // so avoid constructing strings all the time.
const char* obtype = key.begin(); const char* obtype = key.begin();
const size_t length = static_cast<size_t>(key.end()-key.begin()); const size_t length = static_cast<size_t>(key.end()-key.begin());
DefaultLogger::get()->debug( "obtype: " + std::string(obtype ));
DefaultLogger::get()->debug( "Classtag: " + classtag );
if (!strncmp(obtype,"Geometry",length)) { if (!strncmp(obtype,"Geometry",length)) {
if (!strcmp(classtag.c_str(),"Mesh")) { if (!strcmp(classtag.c_str(),"Mesh")) {
object.reset(new MeshGeometry(id,element,name,doc)); object.reset(new MeshGeometry(id,element,name,doc));
@ -165,10 +169,10 @@ const Object* LazyObject::Get(bool dieOnError)
object.reset(new Skin(id,element,doc,name)); object.reset(new Skin(id,element,doc,name));
} }
} }
else if (!strncmp(obtype,"Model",length)) { else if ( !strncmp( obtype, "Model", length ) ) {
// FK and IK effectors are not supported // FK and IK effectors are not supported
if (strcmp(classtag.c_str(),"IKEffector") && strcmp(classtag.c_str(),"FKEffector")) { if ( strcmp( classtag.c_str(), "IKEffector" ) && strcmp( classtag.c_str(), "FKEffector" ) ) {
object.reset(new Model(id,element,doc,name)); object.reset( new Model( id, element, doc, name ) );
} }
} }
else if (!strncmp(obtype,"Material",length)) { else if (!strncmp(obtype,"Material",length)) {
@ -408,7 +412,6 @@ void Document::ReadObjects()
} }
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Document::ReadPropertyTemplates() void Document::ReadPropertyTemplates()
{ {

View File

@ -56,24 +56,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
class Parser; class Parser;
class Object; class Object;
struct ImportSettings; struct ImportSettings;
class PropertyTable; class PropertyTable;
class Document; class Document;
class Material; class Material;
class Geometry; class Geometry;
class Video; class Video;
class AnimationCurve; class AnimationCurve;
class AnimationCurveNode; class AnimationCurveNode;
class AnimationLayer; class AnimationLayer;
class AnimationStack; class AnimationStack;
class Skin; class Skin;
class Cluster; class Cluster;
/** Represents a delay-parsed FBX objects. Many objects in the scene /** Represents a delay-parsed FBX objects. Many objects in the scene
@ -82,7 +82,6 @@ namespace FBX {
class LazyObject class LazyObject
{ {
public: public:
LazyObject(uint64_t id, const Element& element, const Document& doc); LazyObject(uint64_t id, const Element& element, const Document& doc);
~LazyObject(); ~LazyObject();
@ -117,7 +116,6 @@ public:
} }
private: private:
const Document& doc; const Document& doc;
const Element& element; const Element& element;
boost::scoped_ptr<const Object> object; boost::scoped_ptr<const Object> object;
@ -138,11 +136,9 @@ private:
class Object class Object
{ {
public: public:
Object(uint64_t id, const Element& element, const std::string& name); Object(uint64_t id, const Element& element, const std::string& name);
virtual ~Object();
public: virtual ~Object();
const Element& SourceElement() const { const Element& SourceElement() const {
return element; return element;
@ -169,19 +165,15 @@ protected:
class NodeAttribute : public Object class NodeAttribute : public Object
{ {
public: public:
NodeAttribute(uint64_t id, const Element& element, const Document& doc, const std::string& name); NodeAttribute(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~NodeAttribute(); virtual ~NodeAttribute();
public:
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
} }
private: private:
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
}; };
@ -190,12 +182,9 @@ private:
class CameraSwitcher : public NodeAttribute class CameraSwitcher : public NodeAttribute
{ {
public: public:
CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name); CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~CameraSwitcher(); virtual ~CameraSwitcher();
public:
int CameraID() const { int CameraID() const {
return cameraId; return cameraId;
} }
@ -204,13 +193,11 @@ public:
return cameraName; return cameraName;
} }
const std::string& CameraIndexName() const { const std::string& CameraIndexName() const {
return cameraIndexName; return cameraIndexName;
} }
private: private:
int cameraId; int cameraId;
std::string cameraName; std::string cameraName;
std::string cameraIndexName; std::string cameraIndexName;
@ -236,17 +223,14 @@ private:
} }
/** DOM base class for FBX cameras attached to a node */ /** DOM base class for FBX cameras attached to a node */
class Camera : public NodeAttribute class Camera : public NodeAttribute
{ {
public: public:
Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name); Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Camera(); virtual ~Camera();
public: public:
fbx_simple_property(Position, aiVector3D, aiVector3D(0,0,0)) fbx_simple_property(Position, aiVector3D, aiVector3D(0,0,0))
fbx_simple_property(UpVector, aiVector3D, aiVector3D(0,1,0)) fbx_simple_property(UpVector, aiVector3D, aiVector3D(0,1,0))
fbx_simple_property(InterestPosition, aiVector3D, aiVector3D(0,0,0)) fbx_simple_property(InterestPosition, aiVector3D, aiVector3D(0,0,0))
@ -261,8 +245,6 @@ public:
fbx_simple_property(FieldOfView, float, 1.0f) fbx_simple_property(FieldOfView, float, 1.0f)
fbx_simple_property(FocalLength, float, 1.0f) fbx_simple_property(FocalLength, float, 1.0f)
private:
}; };
@ -270,7 +252,6 @@ private:
class Null : public NodeAttribute class Null : public NodeAttribute
{ {
public: public:
Null(uint64_t id, const Element& element, const Document& doc, const std::string& name); Null(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Null(); virtual ~Null();
}; };
@ -280,7 +261,6 @@ public:
class LimbNode : public NodeAttribute class LimbNode : public NodeAttribute
{ {
public: public:
LimbNode(uint64_t id, const Element& element, const Document& doc, const std::string& name); LimbNode(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~LimbNode(); virtual ~LimbNode();
}; };
@ -294,7 +274,6 @@ public:
virtual ~Light(); virtual ~Light();
public: public:
enum Type enum Type
{ {
Type_Point, Type_Point,
@ -317,7 +296,6 @@ public:
}; };
public: public:
fbx_simple_property(Color, aiVector3D, aiVector3D(1,1,1)) fbx_simple_property(Color, aiVector3D, aiVector3D(1,1,1))
fbx_simple_enum_property(LightType, Type, 0) fbx_simple_enum_property(LightType, Type, 0)
fbx_simple_property(CastLightOnObject, bool, false) fbx_simple_property(CastLightOnObject, bool, false)
@ -349,9 +327,6 @@ public:
fbx_simple_property(TopBarnDoor, float, 20.0f) fbx_simple_property(TopBarnDoor, float, 20.0f)
fbx_simple_property(BottomBarnDoor, float, 20.0f) fbx_simple_property(BottomBarnDoor, float, 20.0f)
fbx_simple_property(EnableBarnDoor, bool, true) fbx_simple_property(EnableBarnDoor, bool, true)
private:
}; };
@ -359,12 +334,10 @@ private:
class Model : public Object class Model : public Object
{ {
public: public:
Model(uint64_t id, const Element& element, const Document& doc, const std::string& name); Model(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Model(); virtual ~Model();
public: public:
enum RotOrder enum RotOrder
{ {
RotOrder_EulerXYZ = 0, RotOrder_EulerXYZ = 0,
@ -390,7 +363,6 @@ public:
}; };
public: public:
fbx_simple_property(QuaternionInterpolate, int, 0) fbx_simple_property(QuaternionInterpolate, int, 0)
fbx_simple_property(RotationOffset, aiVector3D, aiVector3D()) fbx_simple_property(RotationOffset, aiVector3D, aiVector3D())
@ -468,7 +440,6 @@ public:
fbx_simple_property(Freeze, bool, false) fbx_simple_property(Freeze, bool, false)
public: public:
const std::string& Shading() const { const std::string& Shading() const {
return shading; return shading;
} }
@ -499,18 +470,14 @@ public:
return attributes; return attributes;
} }
public:
/** convenience method to check if the node has a Null node marker */ /** convenience method to check if the node has a Null node marker */
bool IsNull() const; bool IsNull() const;
private: private:
void ResolveLinks(const Element& element, const Document& doc); void ResolveLinks(const Element& element, const Document& doc);
private: private:
std::vector<const Material*> materials; std::vector<const Material*> materials;
std::vector<const Geometry*> geometry; std::vector<const Geometry*> geometry;
std::vector<const NodeAttribute*> attributes; std::vector<const NodeAttribute*> attributes;
@ -524,12 +491,10 @@ private:
class Texture : public Object class Texture : public Object
{ {
public: public:
Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name); Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Texture(); virtual ~Texture();
public: public:
const std::string& Type() const { const std::string& Type() const {
return type; return type;
} }
@ -569,7 +534,6 @@ public:
} }
private: private:
aiVector2D uvTrans; aiVector2D uvTrans;
aiVector2D uvScaling; aiVector2D uvScaling;
@ -588,7 +552,6 @@ private:
class LayeredTexture : public Object class LayeredTexture : public Object
{ {
public: public:
LayeredTexture(uint64_t id, const Element& element, const Document& doc, const std::string& name); LayeredTexture(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~LayeredTexture(); virtual ~LayeredTexture();
@ -635,14 +598,17 @@ public:
{ {
return texture; return texture;
} }
BlendMode GetBlendMode() BlendMode GetBlendMode()
{ {
return blendMode; return blendMode;
} }
float Alpha() float Alpha()
{ {
return alpha; return alpha;
} }
private: private:
const Texture* texture; const Texture* texture;
BlendMode blendMode; BlendMode blendMode;
@ -657,12 +623,10 @@ typedef std::fbx_unordered_map<std::string, const LayeredTexture*> LayeredTextur
class Video : public Object class Video : public Object
{ {
public: public:
Video(uint64_t id, const Element& element, const Document& doc, const std::string& name); Video(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Video(); virtual ~Video();
public: public:
const std::string& Type() const { const std::string& Type() const {
return type; return type;
} }
@ -696,7 +660,6 @@ public:
} }
private: private:
std::string type; std::string type;
std::string relativeFileName; std::string relativeFileName;
std::string fileName; std::string fileName;
@ -710,12 +673,9 @@ private:
class Material : public Object class Material : public Object
{ {
public: public:
Material(uint64_t id, const Element& element, const Document& doc, const std::string& name); Material(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Material(); virtual ~Material();
public:
const std::string& GetShadingModel() const { const std::string& GetShadingModel() const {
return shading; return shading;
} }
@ -738,7 +698,6 @@ public:
} }
private: private:
std::string shading; std::string shading;
bool multilayer; bool multilayer;
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
@ -747,191 +706,6 @@ private:
LayeredTextureMap layeredTextures; LayeredTextureMap layeredTextures;
}; };
/** DOM base class for all kinds of FBX geometry */
class Geometry : public Object
{
public:
Geometry(uint64_t id, const Element& element, const std::string& name, const Document& doc);
virtual ~Geometry();
public:
/** Get the Skin attached to this geometry or NULL */
const Skin* DeformerSkin() const {
return skin;
}
private:
const Skin* skin;
};
typedef std::vector<int> MatIndexArray;
/** DOM class for FBX geometry of type "Mesh"*/
class MeshGeometry : public Geometry
{
public:
MeshGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc);
virtual ~MeshGeometry();
public:
/** Get a list of all vertex points, non-unique*/
const std::vector<aiVector3D>& GetVertices() const {
return vertices;
}
/** Get a list of all vertex normals or an empty array if
* no normals are specified. */
const std::vector<aiVector3D>& GetNormals() const {
return normals;
}
/** Get a list of all vertex tangents or an empty array
* if no tangents are specified */
const std::vector<aiVector3D>& GetTangents() const {
return tangents;
}
/** Get a list of all vertex binormals or an empty array
* if no binormals are specified */
const std::vector<aiVector3D>& GetBinormals() const {
return binormals;
}
/** Return list of faces - each entry denotes a face and specifies
* how many vertices it has. Vertices are taken from the
* vertex data arrays in sequential order. */
const std::vector<unsigned int>& GetFaceIndexCounts() const {
return faces;
}
/** Get a UV coordinate slot, returns an empty array if
* the requested slot does not exist. */
const std::vector<aiVector2D>& GetTextureCoords(unsigned int index) const {
static const std::vector<aiVector2D> empty;
return index >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? empty : uvs[index];
}
/** Get a UV coordinate slot, returns an empty array if
* the requested slot does not exist. */
std::string GetTextureCoordChannelName(unsigned int index) const {
return index >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? "" : uvNames[index];
}
/** Get a vertex color coordinate slot, returns an empty array if
* the requested slot does not exist. */
const std::vector<aiColor4D>& GetVertexColors(unsigned int index) const {
static const std::vector<aiColor4D> empty;
return index >= AI_MAX_NUMBER_OF_COLOR_SETS ? empty : colors[index];
}
/** Get per-face-vertex material assignments */
const MatIndexArray& GetMaterialIndices() const {
return materials;
}
/** Convert from a fbx file vertex index (for example from a #Cluster weight) or NULL
* if the vertex index is not valid. */
const unsigned int* ToOutputVertexIndex(unsigned int in_index, unsigned int& count) const {
if(in_index >= mapping_counts.size()) {
return NULL;
}
ai_assert(mapping_counts.size() == mapping_offsets.size());
count = mapping_counts[in_index];
ai_assert(count != 0);
ai_assert(mapping_offsets[in_index] + count <= mappings.size());
return &mappings[mapping_offsets[in_index]];
}
/** Determine the face to which a particular output vertex index belongs.
* This mapping is always unique. */
unsigned int FaceForVertexIndex(unsigned int in_index) const {
ai_assert(in_index < vertices.size());
// in the current conversion pattern this will only be needed if
// weights are present, so no need to always pre-compute this table
if (facesVertexStartIndices.empty()) {
facesVertexStartIndices.resize(faces.size() + 1, 0);
std::partial_sum(faces.begin(), faces.end(), facesVertexStartIndices.begin() + 1);
facesVertexStartIndices.pop_back();
}
ai_assert(facesVertexStartIndices.size() == faces.size());
const std::vector<unsigned int>::iterator it = std::upper_bound(
facesVertexStartIndices.begin(),
facesVertexStartIndices.end(),
in_index
);
return static_cast<unsigned int>(std::distance(facesVertexStartIndices.begin(), it - 1));
}
private:
void ReadLayer(const Scope& layer);
void ReadLayerElement(const Scope& layerElement);
void ReadVertexData(const std::string& type, int index, const Scope& source);
void ReadVertexDataUV(std::vector<aiVector2D>& uv_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType);
void ReadVertexDataNormals(std::vector<aiVector3D>& normals_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType);
void ReadVertexDataColors(std::vector<aiColor4D>& colors_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType);
void ReadVertexDataTangents(std::vector<aiVector3D>& tangents_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType);
void ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType);
void ReadVertexDataMaterials(MatIndexArray& materials_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType);
private:
// cached data arrays
MatIndexArray materials;
std::vector<aiVector3D> vertices;
std::vector<unsigned int> faces;
mutable std::vector<unsigned int> facesVertexStartIndices;
std::vector<aiVector3D> tangents;
std::vector<aiVector3D> binormals;
std::vector<aiVector3D> normals;
std::string uvNames[AI_MAX_NUMBER_OF_TEXTURECOORDS];
std::vector<aiVector2D> uvs[AI_MAX_NUMBER_OF_TEXTURECOORDS];
std::vector<aiColor4D> colors[AI_MAX_NUMBER_OF_COLOR_SETS];
std::vector<unsigned int> mapping_counts;
std::vector<unsigned int> mapping_offsets;
std::vector<unsigned int> mappings;
};
typedef std::vector<int64_t> KeyTimeList; typedef std::vector<int64_t> KeyTimeList;
typedef std::vector<float> KeyValueList; typedef std::vector<float> KeyValueList;
@ -939,12 +713,9 @@ typedef std::vector<float> KeyValueList;
class AnimationCurve : public Object class AnimationCurve : public Object
{ {
public: public:
AnimationCurve(uint64_t id, const Element& element, const std::string& name, const Document& doc); AnimationCurve(uint64_t id, const Element& element, const std::string& name, const Document& doc);
virtual ~AnimationCurve(); virtual ~AnimationCurve();
public:
/** get list of keyframe positions (time). /** get list of keyframe positions (time).
* Invariant: |GetKeys()| > 0 */ * Invariant: |GetKeys()| > 0 */
const KeyTimeList& GetKeys() const { const KeyTimeList& GetKeys() const {
@ -968,7 +739,6 @@ public:
} }
private: private:
KeyTimeList keys; KeyTimeList keys;
KeyValueList values; KeyValueList values;
std::vector<float> attributes; std::vector<float> attributes;
@ -983,7 +753,6 @@ typedef std::map<std::string, const AnimationCurve*> AnimationCurveMap;
class AnimationCurveNode : public Object class AnimationCurveNode : public Object
{ {
public: public:
/* the optional white list specifies a list of property names for which the caller /* the optional white list specifies a list of property names for which the caller
wants animations for. If the curve node does not match one of these, std::range_error wants animations for. If the curve node does not match one of these, std::range_error
will be thrown. */ will be thrown. */
@ -992,8 +761,6 @@ public:
virtual ~AnimationCurveNode(); virtual ~AnimationCurveNode();
public:
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
@ -1023,7 +790,6 @@ public:
} }
private: private:
const Object* target; const Object* target;
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
mutable AnimationCurveMap curves; mutable AnimationCurveMap curves;
@ -1039,13 +805,9 @@ typedef std::vector<const AnimationCurveNode*> AnimationCurveNodeList;
class AnimationLayer : public Object class AnimationLayer : public Object
{ {
public: public:
AnimationLayer(uint64_t id, const Element& element, const std::string& name, const Document& doc); AnimationLayer(uint64_t id, const Element& element, const std::string& name, const Document& doc);
virtual ~AnimationLayer(); virtual ~AnimationLayer();
public:
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
@ -1057,7 +819,6 @@ public:
AnimationCurveNodeList Nodes(const char* const * target_prop_whitelist = NULL, size_t whitelist_size = 0) const; AnimationCurveNodeList Nodes(const char* const * target_prop_whitelist = NULL, size_t whitelist_size = 0) const;
private: private:
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
const Document& doc; const Document& doc;
}; };
@ -1070,31 +831,25 @@ typedef std::vector<const AnimationLayer*> AnimationLayerList;
class AnimationStack : public Object class AnimationStack : public Object
{ {
public: public:
AnimationStack(uint64_t id, const Element& element, const std::string& name, const Document& doc); AnimationStack(uint64_t id, const Element& element, const std::string& name, const Document& doc);
virtual ~AnimationStack(); virtual ~AnimationStack();
public: public:
fbx_simple_property(LocalStart, int64_t, 0L) fbx_simple_property(LocalStart, int64_t, 0L)
fbx_simple_property(LocalStop, int64_t, 0L) fbx_simple_property(LocalStop, int64_t, 0L)
fbx_simple_property(ReferenceStart, int64_t, 0L) fbx_simple_property(ReferenceStart, int64_t, 0L)
fbx_simple_property(ReferenceStop, int64_t, 0L) fbx_simple_property(ReferenceStop, int64_t, 0L)
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
} }
const AnimationLayerList& Layers() const { const AnimationLayerList& Layers() const {
return layers; return layers;
} }
private: private:
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
AnimationLayerList layers; AnimationLayerList layers;
}; };
@ -1104,19 +859,15 @@ private:
class Deformer : public Object class Deformer : public Object
{ {
public: public:
Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name); Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Deformer(); virtual ~Deformer();
public:
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
} }
private: private:
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
}; };
@ -1128,11 +879,8 @@ typedef std::vector<unsigned int> WeightIndexArray;
class Cluster : public Deformer class Cluster : public Deformer
{ {
public: public:
Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name); Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name);
~Cluster(); virtual ~Cluster();
public:
/** get the list of deformer weights associated with this cluster. /** get the list of deformer weights associated with this cluster.
* Use #GetIndices() to get the associated vertices. Both arrays * Use #GetIndices() to get the associated vertices. Both arrays
@ -1162,7 +910,6 @@ public:
} }
private: private:
WeightArray weights; WeightArray weights;
WeightIndexArray indices; WeightIndexArray indices;
@ -1178,34 +925,26 @@ private:
class Skin : public Deformer class Skin : public Deformer
{ {
public: public:
Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name); Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name);
virtual ~Skin(); virtual ~Skin();
public:
float DeformAccuracy() const { float DeformAccuracy() const {
return accuracy; return accuracy;
} }
const std::vector<const Cluster*>& Clusters() const { const std::vector<const Cluster*>& Clusters() const {
return clusters; return clusters;
} }
private: private:
float accuracy; float accuracy;
std::vector<const Cluster*> clusters; std::vector<const Cluster*> clusters;
}; };
/** Represents a link between two FBX objects. */ /** Represents a link between two FBX objects. */
class Connection class Connection
{ {
public: public:
Connection(uint64_t insertionOrder, uint64_t src, uint64_t dest, const std::string& prop, const Document& doc); Connection(uint64_t insertionOrder, uint64_t src, uint64_t dest, const std::string& prop, const Document& doc);
~Connection(); ~Connection();
@ -1231,6 +970,8 @@ public:
} }
int CompareTo(const Connection* c) const { int CompareTo(const Connection* c) const {
ai_assert( NULL != c );
// note: can't subtract because this would overflow uint64_t // note: can't subtract because this would overflow uint64_t
if(InsertionOrder() > c->InsertionOrder()) { if(InsertionOrder() > c->InsertionOrder()) {
return 1; return 1;
@ -1242,11 +983,12 @@ public:
} }
bool Compare(const Connection* c) const { bool Compare(const Connection* c) const {
ai_assert( NULL != c );
return InsertionOrder() < c->InsertionOrder(); return InsertionOrder() < c->InsertionOrder();
} }
public: public:
uint64_t insertionOrder; uint64_t insertionOrder;
const std::string prop; const std::string prop;
@ -1254,17 +996,16 @@ public:
const Document& doc; const Document& doc;
}; };
// XXX again, unique_ptr would be useful. shared_ptr is too
// XXX again, unique_ptr would be useful. shared_ptr is too // bloated since the objects have a well-defined single owner
// bloated since the objects have a well-defined single owner // during their entire lifetime (Document). FBX files have
// during their entire lifetime (Document). FBX files have // up to many thousands of objects (most of which we never use),
// up to many thousands of objects (most of which we never use), // so the memory overhead for them should be kept at a minimum.
// so the memory overhead for them should be kept at a minimum. typedef std::map<uint64_t, LazyObject*> ObjectMap;
typedef std::map<uint64_t, LazyObject*> ObjectMap; typedef std::fbx_unordered_map<std::string, boost::shared_ptr<const PropertyTable> > PropertyTemplateMap;
typedef std::fbx_unordered_map<std::string, boost::shared_ptr<const PropertyTable> > PropertyTemplateMap;
typedef std::multimap<uint64_t, const Connection*> ConnectionMap; typedef std::multimap<uint64_t, const Connection*> ConnectionMap;
/** DOM class for global document settings, a single instance per document can /** DOM class for global document settings, a single instance per document can
@ -1272,12 +1013,9 @@ public:
class FileGlobalSettings class FileGlobalSettings
{ {
public: public:
FileGlobalSettings(const Document& doc, boost::shared_ptr<const PropertyTable> props); FileGlobalSettings(const Document& doc, boost::shared_ptr<const PropertyTable> props);
~FileGlobalSettings(); ~FileGlobalSettings();
public:
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
@ -1287,7 +1025,6 @@ public:
return doc; return doc;
} }
fbx_simple_property(UpAxis, int, 1) fbx_simple_property(UpAxis, int, 1)
fbx_simple_property(UpAxisSign, int, 1) fbx_simple_property(UpAxisSign, int, 1)
fbx_simple_property(FrontAxis, int, 2) fbx_simple_property(FrontAxis, int, 2)
@ -1327,9 +1064,7 @@ public:
fbx_simple_property(TimeSpanStop, uint64_t, 0L) fbx_simple_property(TimeSpanStop, uint64_t, 0L)
fbx_simple_property(CustomFrameRate, float, -1.0f) fbx_simple_property(CustomFrameRate, float, -1.0f)
private: private:
boost::shared_ptr<const PropertyTable> props; boost::shared_ptr<const PropertyTable> props;
const Document& doc; const Document& doc;
}; };
@ -1341,12 +1076,9 @@ private:
class Document class Document
{ {
public: public:
Document(const Parser& parser, const ImportSettings& settings); Document(const Parser& parser, const ImportSettings& settings);
~Document(); ~Document();
public:
LazyObject* GetObject(uint64_t id) const; LazyObject* GetObject(uint64_t id) const;
bool IsBinary() const { bool IsBinary() const {
@ -1361,7 +1093,7 @@ public:
return creator; return creator;
} }
// elements (in this order): Uear, Month, Day, Hour, Second, Millisecond // elements (in this order): Year, Month, Day, Hour, Second, Millisecond
const unsigned int* CreationTimeStamp() const { const unsigned int* CreationTimeStamp() const {
return creationTimeStamp; return creationTimeStamp;
} }
@ -1412,7 +1144,6 @@ public:
const std::vector<const AnimationStack*>& AnimationStacks() const; const std::vector<const AnimationStack*>& AnimationStacks() const;
private: private:
std::vector<const Connection*> GetConnectionsSequenced(uint64_t id, const ConnectionMap&) const; std::vector<const Connection*> GetConnectionsSequenced(uint64_t id, const ConnectionMap&) const;
std::vector<const Connection*> GetConnectionsSequenced(uint64_t id, bool is_src, std::vector<const Connection*> GetConnectionsSequenced(uint64_t id, bool is_src,
const ConnectionMap&, const ConnectionMap&,
@ -1420,7 +1151,6 @@ private:
size_t count) const; size_t count) const;
private: private:
void ReadHeader(); void ReadHeader();
void ReadObjects(); void ReadObjects();
void ReadPropertyTemplates(); void ReadPropertyTemplates();
@ -1428,7 +1158,6 @@ private:
void ReadGlobalSettings(); void ReadGlobalSettings();
private: private:
const ImportSettings& settings; const ImportSettings& settings;
ObjectMap objects; ObjectMap objects;
@ -1448,7 +1177,7 @@ private:
boost::scoped_ptr<FileGlobalSettings> globals; boost::scoped_ptr<FileGlobalSettings> globals;
}; };
} } // Namespace FBX
} } // Namespace Assimp
#endif #endif // INCLUDED_AI_FBX_DOCUMENT_H

View File

@ -51,12 +51,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
// TinyFormatter.h // TinyFormatter.h
namespace Formatter { namespace Formatter {
template <typename T,typename TR, typename A> class basic_formatter; template <typename T,typename TR, typename A> class basic_formatter;
typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format; typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format;
} }
// ------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------
/** Load the Autodesk FBX file format. /** Load the Autodesk FBX file format.
@ -68,10 +67,7 @@ class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter>
{ {
public: public:
FBXImporter(); FBXImporter();
~FBXImporter(); virtual ~FBXImporter();
public:
// -------------------- // --------------------
bool CanRead( const std::string& pFile, bool CanRead( const std::string& pFile,
@ -94,12 +90,7 @@ protected:
); );
private: private:
private:
FBX::ImportSettings settings; FBX::ImportSettings settings;
}; // !class FBXImporter }; // !class FBXImporter
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <functional> #include <functional>
#include "FBXParser.h" #include "FBXMeshGeometry.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h" #include "FBXImportSettings.h"
@ -57,8 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
using namespace Util; using namespace Util;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Geometry::Geometry(uint64_t id, const Element& element, const std::string& name, const Document& doc) Geometry::Geometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
@ -82,6 +81,9 @@ Geometry::~Geometry()
} }
const Skin* Geometry::DeformerSkin() const {
return skin;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -182,14 +184,93 @@ MeshGeometry::MeshGeometry(uint64_t id, const Element& element, const std::strin
} }
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
MeshGeometry::~MeshGeometry() MeshGeometry::~MeshGeometry()
{ {
} }
// ------------------------------------------------------------------------------------------------
const std::vector<aiVector3D>& MeshGeometry::GetVertices() const {
return vertices;
}
// ------------------------------------------------------------------------------------------------
const std::vector<aiVector3D>& MeshGeometry::GetNormals() const {
return normals;
}
// ------------------------------------------------------------------------------------------------
const std::vector<aiVector3D>& MeshGeometry::GetTangents() const {
return tangents;
}
// ------------------------------------------------------------------------------------------------
const std::vector<aiVector3D>& MeshGeometry::GetBinormals() const {
return binormals;
}
// ------------------------------------------------------------------------------------------------
const std::vector<unsigned int>& MeshGeometry::GetFaceIndexCounts() const {
return faces;
}
// ------------------------------------------------------------------------------------------------
const std::vector<aiVector2D>& MeshGeometry::GetTextureCoords( unsigned int index ) const {
static const std::vector<aiVector2D> empty;
return index >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? empty : uvs[ index ];
}
std::string MeshGeometry::GetTextureCoordChannelName( unsigned int index ) const {
return index >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? "" : uvNames[ index ];
}
const std::vector<aiColor4D>& MeshGeometry::GetVertexColors( unsigned int index ) const {
static const std::vector<aiColor4D> empty;
return index >= AI_MAX_NUMBER_OF_COLOR_SETS ? empty : colors[ index ];
}
const MatIndexArray& MeshGeometry::GetMaterialIndices() const {
return materials;
}
// ------------------------------------------------------------------------------------------------
const unsigned int* MeshGeometry::ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const {
if ( in_index >= mapping_counts.size() ) {
return NULL;
}
ai_assert( mapping_counts.size() == mapping_offsets.size() );
count = mapping_counts[ in_index ];
ai_assert( count != 0 );
ai_assert( mapping_offsets[ in_index ] + count <= mappings.size() );
return &mappings[ mapping_offsets[ in_index ] ];
}
// ------------------------------------------------------------------------------------------------
unsigned int MeshGeometry::FaceForVertexIndex( unsigned int in_index ) const {
ai_assert( in_index < vertices.size() );
// in the current conversion pattern this will only be needed if
// weights are present, so no need to always pre-compute this table
if ( facesVertexStartIndices.empty() ) {
facesVertexStartIndices.resize( faces.size() + 1, 0 );
std::partial_sum( faces.begin(), faces.end(), facesVertexStartIndices.begin() + 1 );
facesVertexStartIndices.pop_back();
}
ai_assert( facesVertexStartIndices.size() == faces.size() );
const std::vector<unsigned int>::iterator it = std::upper_bound(
facesVertexStartIndices.begin(),
facesVertexStartIndices.end(),
in_index
);
return static_cast< unsigned int >( std::distance( facesVertexStartIndices.begin(), it - 1 ) );
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void MeshGeometry::ReadLayer(const Scope& layer) void MeshGeometry::ReadLayer(const Scope& layer)

View File

@ -0,0 +1,180 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file FBXImporter.h
* @brief Declaration of the FBX main importer class
*/
#ifndef INCLUDED_AI_FBX_MESHGEOMETRY_H
#define INCLUDED_AI_FBX_MESHGEOMETRY_H
#include "FBXParser.h"
#include "FBXDocument.h"
namespace Assimp {
namespace FBX {
/**
* DOM base class for all kinds of FBX geometry
*/
class Geometry : public Object
{
public:
Geometry( uint64_t id, const Element& element, const std::string& name, const Document& doc );
virtual ~Geometry();
/** Get the Skin attached to this geometry or NULL */
const Skin* DeformerSkin() const;
private:
const Skin* skin;
};
typedef std::vector<int> MatIndexArray;
/**
* DOM class for FBX geometry of type "Mesh"
*/
class MeshGeometry : public Geometry
{
public:
/** The class constructor */
MeshGeometry( uint64_t id, const Element& element, const std::string& name, const Document& doc );
/** The class destructor */
virtual ~MeshGeometry();
/** Get a list of all vertex points, non-unique*/
const std::vector<aiVector3D>& GetVertices() const;
/** Get a list of all vertex normals or an empty array if
* no normals are specified. */
const std::vector<aiVector3D>& GetNormals() const;
/** Get a list of all vertex tangents or an empty array
* if no tangents are specified */
const std::vector<aiVector3D>& GetTangents() const;
/** Get a list of all vertex binormals or an empty array
* if no binormals are specified */
const std::vector<aiVector3D>& GetBinormals() const;
/** Return list of faces - each entry denotes a face and specifies
* how many vertices it has. Vertices are taken from the
* vertex data arrays in sequential order. */
const std::vector<unsigned int>& GetFaceIndexCounts() const;
/** Get a UV coordinate slot, returns an empty array if
* the requested slot does not exist. */
const std::vector<aiVector2D>& GetTextureCoords( unsigned int index ) const;
/** Get a UV coordinate slot, returns an empty array if
* the requested slot does not exist. */
std::string GetTextureCoordChannelName( unsigned int index ) const;
/** Get a vertex color coordinate slot, returns an empty array if
* the requested slot does not exist. */
const std::vector<aiColor4D>& GetVertexColors( unsigned int index ) const;
/** Get per-face-vertex material assignments */
const MatIndexArray& GetMaterialIndices() const;
/** Convert from a fbx file vertex index (for example from a #Cluster weight) or NULL
* if the vertex index is not valid. */
const unsigned int* ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const;
/** Determine the face to which a particular output vertex index belongs.
* This mapping is always unique. */
unsigned int FaceForVertexIndex( unsigned int in_index ) const;
private:
void ReadLayer( const Scope& layer );
void ReadLayerElement( const Scope& layerElement );
void ReadVertexData( const std::string& type, int index, const Scope& source );
void ReadVertexDataUV( std::vector<aiVector2D>& uv_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType );
void ReadVertexDataNormals( std::vector<aiVector3D>& normals_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType );
void ReadVertexDataColors( std::vector<aiColor4D>& colors_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType );
void ReadVertexDataTangents( std::vector<aiVector3D>& tangents_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType );
void ReadVertexDataBinormals( std::vector<aiVector3D>& binormals_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType );
void ReadVertexDataMaterials( MatIndexArray& materials_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType );
private:
// cached data arrays
MatIndexArray materials;
std::vector<aiVector3D> vertices;
std::vector<unsigned int> faces;
mutable std::vector<unsigned int> facesVertexStartIndices;
std::vector<aiVector3D> tangents;
std::vector<aiVector3D> binormals;
std::vector<aiVector3D> normals;
std::string uvNames[ AI_MAX_NUMBER_OF_TEXTURECOORDS ];
std::vector<aiVector2D> uvs[ AI_MAX_NUMBER_OF_TEXTURECOORDS ];
std::vector<aiColor4D> colors[ AI_MAX_NUMBER_OF_COLOR_SETS ];
std::vector<unsigned int> mapping_counts;
std::vector<unsigned int> mapping_offsets;
std::vector<unsigned int> mappings;
};
}
}
#endif // INCLUDED_AI_FBX_MESHGEOMETRY_H

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
#include "FBXParser.h" #include "FBXParser.h"
#include "FBXMeshGeometry.h"
#include "FBXDocument.h" #include "FBXDocument.h"
#include "FBXImporter.h" #include "FBXImporter.h"
#include "FBXImportSettings.h" #include "FBXImportSettings.h"

View File

@ -61,6 +61,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include "ByteSwapper.h" #include "ByteSwapper.h"
#include <iostream>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::FBX; using namespace Assimp::FBX;
@ -611,7 +613,7 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha
// read an array of float3 tuples // read an array of float3 tuples
void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el) void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
@ -653,6 +655,13 @@ void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
static_cast<float>(d[1]), static_cast<float>(d[1]),
static_cast<float>(d[2]))); static_cast<float>(d[2])));
} }
for ( size_t i = 0; i < out.size(); i++ ) {
aiVector3D vec3( out[ i ] );
std::stringstream stream;
stream << " vec3.x = " << vec3.x << " vec3.y = " << vec3.y << " vec3.z = " << vec3.z << std::endl;
DefaultLogger::get()->info( stream.str() );
}
} }
else if (type == 'f') { else if (type == 'f') {
const float* f = reinterpret_cast<const float*>(&buff[0]); const float* f = reinterpret_cast<const float*>(&buff[0]);
@ -692,7 +701,7 @@ void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
// read an array of color4 tuples // read an array of color4 tuples
void ParseVectorDataArray(std::vector<aiColor4D>& out, const Element& el) void ParseVectorDataArray(std::vector<aiColor4D>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
ParseError("unexpected empty element",&el); ParseError("unexpected empty element",&el);
@ -771,7 +780,7 @@ void ParseVectorDataArray(std::vector<aiColor4D>& out, const Element& el)
// read an array of float2 tuples // read an array of float2 tuples
void ParseVectorDataArray(std::vector<aiVector2D>& out, const Element& el) void ParseVectorDataArray(std::vector<aiVector2D>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
ParseError("unexpected empty element",&el); ParseError("unexpected empty element",&el);
@ -847,7 +856,7 @@ void ParseVectorDataArray(std::vector<aiVector2D>& out, const Element& el)
// read an array of ints // read an array of ints
void ParseVectorDataArray(std::vector<int>& out, const Element& el) void ParseVectorDataArray(std::vector<int>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
ParseError("unexpected empty element",&el); ParseError("unexpected empty element",&el);
@ -905,7 +914,7 @@ void ParseVectorDataArray(std::vector<int>& out, const Element& el)
// read an array of floats // read an array of floats
void ParseVectorDataArray(std::vector<float>& out, const Element& el) void ParseVectorDataArray(std::vector<float>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
ParseError("unexpected empty element",&el); ParseError("unexpected empty element",&el);
@ -967,7 +976,7 @@ void ParseVectorDataArray(std::vector<float>& out, const Element& el)
// read an array of uints // read an array of uints
void ParseVectorDataArray(std::vector<unsigned int>& out, const Element& el) void ParseVectorDataArray(std::vector<unsigned int>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
ParseError("unexpected empty element",&el); ParseError("unexpected empty element",&el);
@ -1032,7 +1041,7 @@ void ParseVectorDataArray(std::vector<unsigned int>& out, const Element& el)
// read an array of uint64_ts // read an array of uint64_ts
void ParseVectorDataArray(std::vector<uint64_t>& out, const Element& el) void ParseVectorDataArray(std::vector<uint64_t>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if(tok.empty()) { if(tok.empty()) {
ParseError("unexpected empty element",&el); ParseError("unexpected empty element",&el);
@ -1090,7 +1099,7 @@ void ParseVectorDataArray(std::vector<uint64_t>& out, const Element& el)
// read an array of int64_ts // read an array of int64_ts
void ParseVectorDataArray(std::vector<int64_t>& out, const Element& el) void ParseVectorDataArray(std::vector<int64_t>& out, const Element& el)
{ {
out.clear(); out.resize( 0 );
const TokenList& tok = el.Tokens(); const TokenList& tok = el.Tokens();
if (tok.empty()) { if (tok.empty()) {
ParseError("unexpected empty element", &el); ParseError("unexpected empty element", &el);

View File

@ -55,15 +55,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
class Scope; class Scope;
class Parser; class Parser;
class Element; class Element;
// XXX should use C++11's unique_ptr - but assimp's need to keep working with 03 // XXX should use C++11's unique_ptr - but assimp's need to keep working with 03
typedef std::vector< Scope* > ScopeList; typedef std::vector< Scope* > ScopeList;
typedef std::fbx_unordered_multimap< std::string, Element* > ElementMap; typedef std::fbx_unordered_multimap< std::string, Element* > ElementMap;
typedef std::pair<ElementMap::const_iterator,ElementMap::const_iterator> ElementCollection; typedef std::pair<ElementMap::const_iterator,ElementMap::const_iterator> ElementCollection;
# define new_Scope new Scope # define new_Scope new Scope
# define new_Element new Element # define new_Element new Element
@ -162,7 +162,6 @@ public:
~Parser(); ~Parser();
public: public:
const Scope& GetRootScope() const { const Scope& GetRootScope() const {
return *root.get(); return *root.get();
} }
@ -173,7 +172,6 @@ public:
} }
private: private:
friend class Scope; friend class Scope;
friend class Element; friend class Element;
@ -183,9 +181,7 @@ private:
TokenPtr CurrentToken() const; TokenPtr CurrentToken() const;
private: private:
const TokenList& tokens; const TokenList& tokens;
TokenPtr last, current; TokenPtr last, current;