2012-06-26 16:31:19 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2016-01-01 20:07:24 +00:00
|
|
|
Copyright (c) 2006-2016, assimp team
|
2012-06-26 16:31:19 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
2012-06-26 16:31:19 +00:00
|
|
|
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.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2012-06-26 16:31:19 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 03:52:10 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2012-06-26 16:31:19 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 03:52:10 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2012-06-26 16:31:19 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 03:52:10 +00:00
|
|
|
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
|
2012-06-26 16:31:19 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file FBXDocument.h
|
|
|
|
* @brief FBX DOM
|
|
|
|
*/
|
|
|
|
#ifndef INCLUDED_AI_FBX_DOCUMENT_H
|
|
|
|
#define INCLUDED_AI_FBX_DOCUMENT_H
|
|
|
|
|
2015-04-15 19:22:26 +00:00
|
|
|
#include <numeric>
|
2016-02-28 19:27:31 +00:00
|
|
|
#include <stdint.h>
|
2016-06-06 20:04:29 +00:00
|
|
|
#include <assimp/mesh.h>
|
2012-08-10 20:58:54 +00:00
|
|
|
#include "FBXProperties.h"
|
2015-04-15 19:22:26 +00:00
|
|
|
#include "FBXParser.h"
|
|
|
|
|
|
|
|
#define _AI_CONCAT(a,b) a ## b
|
|
|
|
#define AI_CONCAT(a,b) _AI_CONCAT(a,b)
|
2012-08-10 20:58:54 +00:00
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
namespace Assimp {
|
|
|
|
namespace FBX {
|
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
class Parser;
|
|
|
|
class Object;
|
|
|
|
struct ImportSettings;
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
class PropertyTable;
|
|
|
|
class Document;
|
|
|
|
class Material;
|
|
|
|
class Geometry;
|
2012-07-02 14:51:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
class Video;
|
2015-11-23 18:49:54 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
class AnimationCurve;
|
|
|
|
class AnimationCurveNode;
|
|
|
|
class AnimationLayer;
|
|
|
|
class AnimationStack;
|
2012-07-26 17:13:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
class Skin;
|
|
|
|
class Cluster;
|
2012-07-26 17:13:19 +00:00
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
|
|
|
|
/** Represents a delay-parsed FBX objects. Many objects in the scene
|
|
|
|
* are not needed by assimp, so it makes no sense to parse them
|
|
|
|
* upfront. */
|
|
|
|
class LazyObject
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
LazyObject(uint64_t id, const Element& element, const Document& doc);
|
|
|
|
~LazyObject();
|
2012-06-26 16:31:19 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Object* Get(bool dieOnError = false);
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
template <typename T>
|
|
|
|
const T* Get(bool dieOnError = false) {
|
|
|
|
const Object* const ob = Get(dieOnError);
|
|
|
|
return ob ? dynamic_cast<const T*>(ob) : NULL;
|
|
|
|
}
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
uint64_t ID() const {
|
|
|
|
return id;
|
|
|
|
}
|
2012-07-03 17:36:38 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
bool IsBeingConstructed() const {
|
|
|
|
return (flags & BEING_CONSTRUCTED) != 0;
|
|
|
|
}
|
2012-07-21 18:02:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
bool FailedToConstruct() const {
|
|
|
|
return (flags & FAILED_TO_CONSTRUCT) != 0;
|
|
|
|
}
|
2012-07-21 15:12:04 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Element& GetElement() const {
|
|
|
|
return element;
|
|
|
|
}
|
2012-07-21 16:02:10 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Document& GetDocument() const {
|
|
|
|
return doc;
|
|
|
|
}
|
2012-07-21 16:02:10 +00:00
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
const Document& doc;
|
|
|
|
const Element& element;
|
2016-04-05 21:23:53 +00:00
|
|
|
std::unique_ptr<const Object> object;
|
2012-07-03 17:36:38 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const uint64_t id;
|
2012-07-21 18:02:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
enum Flags {
|
|
|
|
BEING_CONSTRUCTED = 0x1,
|
|
|
|
FAILED_TO_CONSTRUCT = 0x2
|
|
|
|
};
|
2012-07-21 18:02:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
unsigned int flags;
|
2012-06-26 16:31:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Base class for in-memory (DOM) representations of FBX objects */
|
|
|
|
class Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Object(uint64_t id, const Element& element, const std::string& name);
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
virtual ~Object();
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Element& SourceElement() const {
|
|
|
|
return element;
|
|
|
|
}
|
2012-07-02 17:59:31 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& Name() const {
|
|
|
|
return name;
|
|
|
|
}
|
2012-07-02 17:59:31 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
uint64_t ID() const {
|
|
|
|
return id;
|
|
|
|
}
|
2012-07-03 17:36:38 +00:00
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
protected:
|
2015-05-19 03:57:13 +00:00
|
|
|
const Element& element;
|
|
|
|
const std::string name;
|
|
|
|
const uint64_t id;
|
2012-06-26 16:31:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-26 01:42:02 +00:00
|
|
|
|
2012-07-26 01:45:37 +00:00
|
|
|
/** DOM class for generic FBX NoteAttribute blocks. NoteAttribute's just hold a property table,
|
|
|
|
* fixed members are added by deriving classes. */
|
2012-07-26 01:42:02 +00:00
|
|
|
class NodeAttribute : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
NodeAttribute(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~NodeAttribute();
|
2012-07-26 01:42:02 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-26 01:42:02 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2012-07-26 01:42:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** DOM base class for FBX camera settings attached to a node */
|
2012-07-26 01:58:42 +00:00
|
|
|
class CameraSwitcher : public NodeAttribute
|
2012-07-26 01:42:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~CameraSwitcher();
|
2012-07-26 01:42:02 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
int CameraID() const {
|
|
|
|
return cameraId;
|
|
|
|
}
|
2012-07-26 01:42:02 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& CameraName() const {
|
|
|
|
return cameraName;
|
|
|
|
}
|
2012-07-26 01:42:02 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& CameraIndexName() const {
|
|
|
|
return cameraIndexName;
|
|
|
|
}
|
2012-07-26 01:42:02 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
int cameraId;
|
|
|
|
std::string cameraName;
|
|
|
|
std::string cameraIndexName;
|
2012-07-26 01:42:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-10 20:58:54 +00:00
|
|
|
#define fbx_stringize(a) #a
|
|
|
|
|
|
|
|
#define fbx_simple_property(name, type, default_value) \
|
2015-05-19 03:57:13 +00:00
|
|
|
type name() const { \
|
|
|
|
return PropertyGet<type>(Props(), fbx_stringize(name), (default_value)); \
|
|
|
|
}
|
2012-08-10 20:58:54 +00:00
|
|
|
|
2012-08-10 23:51:04 +00:00
|
|
|
// XXX improve logging
|
|
|
|
#define fbx_simple_enum_property(name, type, default_value) \
|
2015-05-19 03:57:13 +00:00
|
|
|
type name() const { \
|
|
|
|
const int ival = PropertyGet<int>(Props(), fbx_stringize(name), static_cast<int>(default_value)); \
|
|
|
|
if (ival < 0 || ival >= AI_CONCAT(type, _MAX)) { \
|
|
|
|
ai_assert(static_cast<int>(default_value) >= 0 && static_cast<int>(default_value) < AI_CONCAT(type, _MAX)); \
|
|
|
|
return static_cast<type>(default_value); \
|
|
|
|
} \
|
|
|
|
return static_cast<type>(ival); \
|
2012-08-10 23:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-10 20:58:54 +00:00
|
|
|
/** DOM base class for FBX cameras attached to a node */
|
|
|
|
class Camera : public NodeAttribute
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Camera();
|
2012-08-10 20:58:54 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(Position, aiVector3D, aiVector3D(0,0,0))
|
|
|
|
fbx_simple_property(UpVector, aiVector3D, aiVector3D(0,1,0))
|
|
|
|
fbx_simple_property(InterestPosition, aiVector3D, aiVector3D(0,0,0))
|
2012-08-10 20:58:54 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(AspectWidth, float, 1.0f)
|
|
|
|
fbx_simple_property(AspectHeight, float, 1.0f)
|
|
|
|
fbx_simple_property(FilmWidth, float, 1.0f)
|
|
|
|
fbx_simple_property(FilmHeight, float, 1.0f)
|
2012-08-10 20:58:54 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(FilmAspectRatio, float, 1.0f)
|
|
|
|
fbx_simple_property(ApertureMode, int, 0)
|
2012-08-10 20:58:54 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(FieldOfView, float, 1.0f)
|
|
|
|
fbx_simple_property(FocalLength, float, 1.0f)
|
2012-08-10 20:58:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-25 18:12:53 +00:00
|
|
|
/** DOM base class for FBX null markers attached to a node */
|
|
|
|
class Null : public NodeAttribute
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Null(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Null();
|
2012-08-25 18:12:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-26 16:53:15 +00:00
|
|
|
/** DOM base class for FBX limb node markers attached to a node */
|
|
|
|
class LimbNode : public NodeAttribute
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
LimbNode(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~LimbNode();
|
2012-08-26 16:53:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-10 20:58:54 +00:00
|
|
|
/** DOM base class for FBX lights attached to a node */
|
|
|
|
class Light : public NodeAttribute
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Light(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Light();
|
2012-08-10 20:58:54 +00:00
|
|
|
|
2012-08-10 23:51:04 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
Type_Point,
|
|
|
|
Type_Directional,
|
|
|
|
Type_Spot,
|
|
|
|
Type_Area,
|
|
|
|
Type_Volume,
|
2012-08-10 23:51:04 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
Type_MAX // end-of-enum sentinel
|
|
|
|
};
|
2012-08-10 23:51:04 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
enum Decay
|
|
|
|
{
|
|
|
|
Decay_None,
|
|
|
|
Decay_Linear,
|
|
|
|
Decay_Quadratic,
|
|
|
|
Decay_Cubic,
|
2012-08-10 23:51:04 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
Decay_MAX // end-of-enum sentinel
|
|
|
|
};
|
2012-08-10 23:51:04 +00:00
|
|
|
|
2012-08-10 20:58:54 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(Color, aiVector3D, aiVector3D(1,1,1))
|
|
|
|
fbx_simple_enum_property(LightType, Type, 0)
|
|
|
|
fbx_simple_property(CastLightOnObject, bool, false)
|
|
|
|
fbx_simple_property(DrawVolumetricLight, bool, true)
|
|
|
|
fbx_simple_property(DrawGroundProjection, bool, true)
|
|
|
|
fbx_simple_property(DrawFrontFacingVolumetricLight, bool, false)
|
|
|
|
fbx_simple_property(Intensity, float, 1.0f)
|
|
|
|
fbx_simple_property(InnerAngle, float, 0.0f)
|
|
|
|
fbx_simple_property(OuterAngle, float, 45.0f)
|
|
|
|
fbx_simple_property(Fog, int, 50)
|
|
|
|
fbx_simple_enum_property(DecayType, Decay, 0)
|
|
|
|
fbx_simple_property(DecayStart, int, 0)
|
|
|
|
fbx_simple_property(FileName, std::string, "")
|
|
|
|
|
|
|
|
fbx_simple_property(EnableNearAttenuation, bool, false)
|
|
|
|
fbx_simple_property(NearAttenuationStart, float, 0.0f)
|
|
|
|
fbx_simple_property(NearAttenuationEnd, float, 0.0f)
|
|
|
|
fbx_simple_property(EnableFarAttenuation, bool, false)
|
|
|
|
fbx_simple_property(FarAttenuationStart, float, 0.0f)
|
|
|
|
fbx_simple_property(FarAttenuationEnd, float, 0.0f)
|
|
|
|
|
|
|
|
fbx_simple_property(CastShadows, bool, true)
|
|
|
|
fbx_simple_property(ShadowColor, aiVector3D, aiVector3D(0,0,0))
|
|
|
|
|
|
|
|
fbx_simple_property(AreaLightShape, int, 0)
|
|
|
|
|
|
|
|
fbx_simple_property(LeftBarnDoor, float, 20.0f)
|
|
|
|
fbx_simple_property(RightBarnDoor, float, 20.0f)
|
|
|
|
fbx_simple_property(TopBarnDoor, float, 20.0f)
|
|
|
|
fbx_simple_property(BottomBarnDoor, float, 20.0f)
|
|
|
|
fbx_simple_property(EnableBarnDoor, bool, true)
|
2012-08-10 20:58:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-20 22:45:37 +00:00
|
|
|
/** DOM base class for FBX models (even though its semantics are more "node" than "model" */
|
2012-07-04 14:33:21 +00:00
|
|
|
class Model : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Model(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Model();
|
2012-07-04 14:33:21 +00:00
|
|
|
|
2012-08-10 23:57:32 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
enum RotOrder
|
|
|
|
{
|
|
|
|
RotOrder_EulerXYZ = 0,
|
|
|
|
RotOrder_EulerXZY,
|
|
|
|
RotOrder_EulerYZX,
|
|
|
|
RotOrder_EulerYXZ,
|
|
|
|
RotOrder_EulerZXY,
|
|
|
|
RotOrder_EulerZYX,
|
2012-08-10 23:57:32 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
RotOrder_SphericXYZ,
|
2012-08-10 23:57:32 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
RotOrder_MAX // end-of-enum sentinel
|
|
|
|
};
|
2012-08-10 23:57:32 +00:00
|
|
|
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
enum TransformInheritance
|
|
|
|
{
|
|
|
|
TransformInheritance_RrSs = 0,
|
|
|
|
TransformInheritance_RSrs,
|
|
|
|
TransformInheritance_Rrs,
|
2012-08-10 23:57:32 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
TransformInheritance_MAX // end-of-enum sentinel
|
|
|
|
};
|
2012-08-10 23:57:32 +00:00
|
|
|
|
2012-08-10 21:40:02 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(QuaternionInterpolate, int, 0)
|
|
|
|
|
|
|
|
fbx_simple_property(RotationOffset, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(RotationPivot, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(ScalingOffset, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(ScalingPivot, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(TranslationActive, bool, false)
|
|
|
|
|
|
|
|
fbx_simple_property(TranslationMin, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(TranslationMax, aiVector3D, aiVector3D())
|
|
|
|
|
|
|
|
fbx_simple_property(TranslationMinX, bool, false)
|
|
|
|
fbx_simple_property(TranslationMaxX, bool, false)
|
|
|
|
fbx_simple_property(TranslationMinY, bool, false)
|
|
|
|
fbx_simple_property(TranslationMaxY, bool, false)
|
|
|
|
fbx_simple_property(TranslationMinZ, bool, false)
|
|
|
|
fbx_simple_property(TranslationMaxZ, bool, false)
|
|
|
|
|
|
|
|
fbx_simple_enum_property(RotationOrder, RotOrder, 0)
|
|
|
|
fbx_simple_property(RotationSpaceForLimitOnly, bool, false)
|
|
|
|
fbx_simple_property(RotationStiffnessX, float, 0.0f)
|
|
|
|
fbx_simple_property(RotationStiffnessY, float, 0.0f)
|
|
|
|
fbx_simple_property(RotationStiffnessZ, float, 0.0f)
|
|
|
|
fbx_simple_property(AxisLen, float, 0.0f)
|
|
|
|
|
|
|
|
fbx_simple_property(PreRotation, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(PostRotation, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(RotationActive, bool, false)
|
|
|
|
|
|
|
|
fbx_simple_property(RotationMin, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(RotationMax, aiVector3D, aiVector3D())
|
|
|
|
|
|
|
|
fbx_simple_property(RotationMinX, bool, false)
|
|
|
|
fbx_simple_property(RotationMaxX, bool, false)
|
|
|
|
fbx_simple_property(RotationMinY, bool, false)
|
|
|
|
fbx_simple_property(RotationMaxY, bool, false)
|
|
|
|
fbx_simple_property(RotationMinZ, bool, false)
|
|
|
|
fbx_simple_property(RotationMaxZ, bool, false)
|
|
|
|
fbx_simple_enum_property(InheritType, TransformInheritance, 0)
|
|
|
|
|
|
|
|
fbx_simple_property(ScalingActive, bool, false)
|
|
|
|
fbx_simple_property(ScalingMin, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(ScalingMax, aiVector3D, aiVector3D(1.f,1.f,1.f))
|
|
|
|
fbx_simple_property(ScalingMinX, bool, false)
|
|
|
|
fbx_simple_property(ScalingMaxX, bool, false)
|
|
|
|
fbx_simple_property(ScalingMinY, bool, false)
|
|
|
|
fbx_simple_property(ScalingMaxY, bool, false)
|
|
|
|
fbx_simple_property(ScalingMinZ, bool, false)
|
|
|
|
fbx_simple_property(ScalingMaxZ, bool, false)
|
|
|
|
|
|
|
|
fbx_simple_property(GeometricTranslation, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(GeometricRotation, aiVector3D, aiVector3D())
|
|
|
|
fbx_simple_property(GeometricScaling, aiVector3D, aiVector3D(1.f, 1.f, 1.f))
|
|
|
|
|
|
|
|
fbx_simple_property(MinDampRangeX, float, 0.0f)
|
|
|
|
fbx_simple_property(MinDampRangeY, float, 0.0f)
|
|
|
|
fbx_simple_property(MinDampRangeZ, float, 0.0f)
|
|
|
|
fbx_simple_property(MaxDampRangeX, float, 0.0f)
|
|
|
|
fbx_simple_property(MaxDampRangeY, float, 0.0f)
|
|
|
|
fbx_simple_property(MaxDampRangeZ, float, 0.0f)
|
|
|
|
|
|
|
|
fbx_simple_property(MinDampStrengthX, float, 0.0f)
|
|
|
|
fbx_simple_property(MinDampStrengthY, float, 0.0f)
|
|
|
|
fbx_simple_property(MinDampStrengthZ, float, 0.0f)
|
|
|
|
fbx_simple_property(MaxDampStrengthX, float, 0.0f)
|
|
|
|
fbx_simple_property(MaxDampStrengthY, float, 0.0f)
|
|
|
|
fbx_simple_property(MaxDampStrengthZ, float, 0.0f)
|
|
|
|
|
|
|
|
fbx_simple_property(PreferredAngleX, float, 0.0f)
|
|
|
|
fbx_simple_property(PreferredAngleY, float, 0.0f)
|
|
|
|
fbx_simple_property(PreferredAngleZ, float, 0.0f)
|
|
|
|
|
|
|
|
fbx_simple_property(Show, bool, true)
|
|
|
|
fbx_simple_property(LODBox, bool, false)
|
|
|
|
fbx_simple_property(Freeze, bool, false)
|
2012-08-10 21:40:02 +00:00
|
|
|
|
2012-07-04 14:33:21 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& Shading() const {
|
|
|
|
return shading;
|
|
|
|
}
|
2012-07-04 14:33:21 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& Culling() const {
|
|
|
|
return culling;
|
|
|
|
}
|
2012-07-04 14:33:21 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-04 14:33:21 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** Get material links */
|
|
|
|
const std::vector<const Material*>& GetMaterials() const {
|
|
|
|
return materials;
|
|
|
|
}
|
2012-07-04 14:33:21 +00:00
|
|
|
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** Get geometry links */
|
|
|
|
const std::vector<const Geometry*>& GetGeometry() const {
|
|
|
|
return geometry;
|
|
|
|
}
|
2012-07-04 14:33:21 +00:00
|
|
|
|
2012-07-26 01:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** Get node attachments */
|
|
|
|
const std::vector<const NodeAttribute*>& GetAttributes() const {
|
|
|
|
return attributes;
|
|
|
|
}
|
2012-07-26 01:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** convenience method to check if the node has a Null node marker */
|
|
|
|
bool IsNull() const;
|
2012-08-25 20:24:08 +00:00
|
|
|
|
|
|
|
|
2012-07-04 14:33:21 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
void ResolveLinks(const Element& element, const Document& doc);
|
2012-07-04 14:33:21 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
std::vector<const Material*> materials;
|
|
|
|
std::vector<const Geometry*> geometry;
|
|
|
|
std::vector<const NodeAttribute*> attributes;
|
2012-07-04 14:33:21 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::string shading;
|
|
|
|
std::string culling;
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2012-07-04 14:33:21 +00:00
|
|
|
};
|
|
|
|
|
2012-07-03 12:59:40 +00:00
|
|
|
/** DOM class for generic FBX textures */
|
|
|
|
class Texture : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Texture(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Texture();
|
2012-07-03 12:59:40 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& Type() const {
|
|
|
|
return type;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& FileName() const {
|
|
|
|
return fileName;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& RelativeFilename() const {
|
|
|
|
return relativeFileName;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& AlphaSource() const {
|
|
|
|
return alphaSource;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const aiVector2D& UVTranslation() const {
|
|
|
|
return uvTrans;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const aiVector2D& UVScaling() const {
|
|
|
|
return uvScaling;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// return a 4-tuple
|
|
|
|
const unsigned int* Crop() const {
|
|
|
|
return crop;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-11-23 18:49:54 +00:00
|
|
|
const Video* Media() const {
|
|
|
|
return media;
|
|
|
|
}
|
|
|
|
|
2012-07-03 12:59:40 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
aiVector2D uvTrans;
|
|
|
|
aiVector2D uvScaling;
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::string type;
|
|
|
|
std::string relativeFileName;
|
|
|
|
std::string fileName;
|
|
|
|
std::string alphaSource;
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
unsigned int crop[4];
|
2015-11-23 18:49:54 +00:00
|
|
|
|
|
|
|
const Video* media;
|
2012-07-03 12:59:40 +00:00
|
|
|
};
|
|
|
|
|
2014-03-24 10:46:36 +00:00
|
|
|
/** DOM class for layered FBX textures */
|
|
|
|
class LayeredTexture : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
LayeredTexture(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~LayeredTexture();
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
//Can only be called after construction of the layered texture object due to construction flag.
|
|
|
|
void fillTexture(const Document& doc);
|
|
|
|
|
|
|
|
enum BlendMode
|
|
|
|
{
|
|
|
|
BlendMode_Translucent,
|
|
|
|
BlendMode_Additive,
|
|
|
|
BlendMode_Modulate,
|
|
|
|
BlendMode_Modulate2,
|
|
|
|
BlendMode_Over,
|
|
|
|
BlendMode_Normal,
|
|
|
|
BlendMode_Dissolve,
|
|
|
|
BlendMode_Darken,
|
|
|
|
BlendMode_ColorBurn,
|
|
|
|
BlendMode_LinearBurn,
|
|
|
|
BlendMode_DarkerColor,
|
|
|
|
BlendMode_Lighten,
|
|
|
|
BlendMode_Screen,
|
|
|
|
BlendMode_ColorDodge,
|
|
|
|
BlendMode_LinearDodge,
|
|
|
|
BlendMode_LighterColor,
|
|
|
|
BlendMode_SoftLight,
|
|
|
|
BlendMode_HardLight,
|
|
|
|
BlendMode_VividLight,
|
|
|
|
BlendMode_LinearLight,
|
|
|
|
BlendMode_PinLight,
|
|
|
|
BlendMode_HardMix,
|
|
|
|
BlendMode_Difference,
|
|
|
|
BlendMode_Exclusion,
|
|
|
|
BlendMode_Subtract,
|
|
|
|
BlendMode_Divide,
|
|
|
|
BlendMode_Hue,
|
|
|
|
BlendMode_Saturation,
|
|
|
|
BlendMode_Color,
|
|
|
|
BlendMode_Luminosity,
|
|
|
|
BlendMode_Overlay,
|
|
|
|
BlendMode_BlendModeCount
|
|
|
|
};
|
|
|
|
|
|
|
|
const Texture* getTexture() const
|
|
|
|
{
|
|
|
|
return texture;
|
|
|
|
}
|
2016-03-03 14:19:38 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
BlendMode GetBlendMode()
|
|
|
|
{
|
|
|
|
return blendMode;
|
|
|
|
}
|
2016-03-03 14:19:38 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
float Alpha()
|
|
|
|
{
|
|
|
|
return alpha;
|
|
|
|
}
|
2016-03-03 14:19:38 +00:00
|
|
|
|
2014-03-24 10:46:36 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
const Texture* texture;
|
|
|
|
BlendMode blendMode;
|
|
|
|
float alpha;
|
2014-03-24 10:46:36 +00:00
|
|
|
};
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2012-07-03 17:42:14 +00:00
|
|
|
typedef std::fbx_unordered_map<std::string, const Texture*> TextureMap;
|
2014-03-24 10:46:36 +00:00
|
|
|
typedef std::fbx_unordered_map<std::string, const LayeredTexture*> LayeredTextureMap;
|
2012-07-03 12:59:40 +00:00
|
|
|
|
|
|
|
|
2015-11-23 18:49:54 +00:00
|
|
|
/** DOM class for generic FBX videos */
|
|
|
|
class Video : public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Video(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Video();
|
2015-11-23 18:49:54 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
const std::string& Type() const {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& FileName() const {
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& RelativeFilename() const {
|
|
|
|
return relativeFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t* Content() const {
|
|
|
|
ai_assert(content);
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t ContentLength() const {
|
|
|
|
return contentLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t* RelinquishContent() {
|
|
|
|
uint8_t* ptr = content;
|
|
|
|
content = 0;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string type;
|
|
|
|
std::string relativeFileName;
|
|
|
|
std::string fileName;
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2015-11-23 18:49:54 +00:00
|
|
|
|
|
|
|
uint32_t contentLength;
|
|
|
|
uint8_t* content;
|
|
|
|
};
|
|
|
|
|
2012-07-02 15:37:00 +00:00
|
|
|
/** DOM class for generic FBX materials */
|
|
|
|
class Material : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Material(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Material();
|
2012-07-02 15:37:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& GetShadingModel() const {
|
|
|
|
return shading;
|
|
|
|
}
|
2012-07-02 15:37:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
bool IsMultilayer() const {
|
|
|
|
return multilayer;
|
|
|
|
}
|
2012-07-02 15:37:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-02 15:37:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const TextureMap& Textures() const {
|
|
|
|
return textures;
|
|
|
|
}
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const LayeredTextureMap& LayeredTextures() const {
|
|
|
|
return layeredTextures;
|
|
|
|
}
|
2014-03-24 10:46:36 +00:00
|
|
|
|
2012-07-02 15:37:00 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
std::string shading;
|
|
|
|
bool multilayer;
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2012-07-03 12:59:40 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
TextureMap textures;
|
|
|
|
LayeredTextureMap layeredTextures;
|
2012-07-02 15:37:00 +00:00
|
|
|
};
|
|
|
|
|
2015-03-25 22:43:41 +00:00
|
|
|
typedef std::vector<int64_t> KeyTimeList;
|
2012-07-21 19:28:02 +00:00
|
|
|
typedef std::vector<float> KeyValueList;
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
/** Represents a FBX animation curve (i.e. a 1-dimensional set of keyframes and values therefor) */
|
|
|
|
class AnimationCurve : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
AnimationCurve(uint64_t id, const Element& element, const std::string& name, const Document& doc);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~AnimationCurve();
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** get list of keyframe positions (time).
|
|
|
|
* Invariant: |GetKeys()| > 0 */
|
|
|
|
const KeyTimeList& GetKeys() const {
|
|
|
|
return keys;
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** get list of keyframe values.
|
|
|
|
* Invariant: |GetKeys()| == |GetValues()| && |GetKeys()| > 0*/
|
|
|
|
const KeyValueList& GetValues() const {
|
|
|
|
return values;
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::vector<float>& GetAttributes() const {
|
|
|
|
return attributes;
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::vector<unsigned int>& GetFlags() const {
|
|
|
|
return flags;
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
KeyTimeList keys;
|
|
|
|
KeyValueList values;
|
|
|
|
std::vector<float> attributes;
|
|
|
|
std::vector<unsigned int> flags;
|
2012-07-20 22:45:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// property-name -> animation curve
|
|
|
|
typedef std::map<std::string, const AnimationCurve*> AnimationCurveMap;
|
|
|
|
|
|
|
|
|
|
|
|
/** Represents a FBX animation curve (i.e. a mapping from single animation curves to nodes) */
|
|
|
|
class AnimationCurveNode : public Object
|
|
|
|
{
|
|
|
|
public:
|
2016-02-28 16:30:11 +00:00
|
|
|
/* the optional white list specifies a list of property names for which the caller
|
2015-05-19 03:57:13 +00:00
|
|
|
wants animations for. If the curve node does not match one of these, std::range_error
|
|
|
|
will be thrown. */
|
|
|
|
AnimationCurveNode(uint64_t id, const Element& element, const std::string& name, const Document& doc,
|
|
|
|
const char* const * target_prop_whitelist = NULL, size_t whitelist_size = 0);
|
2012-08-26 16:40:04 +00:00
|
|
|
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~AnimationCurveNode();
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const AnimationCurveMap& Curves() const;
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** Object the curve is assigned to, this can be NULL if the
|
|
|
|
* target object has no DOM representation or could not
|
|
|
|
* be read for other reasons.*/
|
|
|
|
const Object* Target() const {
|
|
|
|
return target;
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Model* TargetAsModel() const {
|
|
|
|
return dynamic_cast<const Model*>(target);
|
|
|
|
}
|
2012-07-26 01:58:42 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const NodeAttribute* TargetAsNodeAttribute() const {
|
|
|
|
return dynamic_cast<const NodeAttribute*>(target);
|
|
|
|
}
|
2012-07-26 01:58:42 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** Property of Target() that is being animated*/
|
|
|
|
const std::string& TargetProperty() const {
|
|
|
|
return prop;
|
|
|
|
}
|
2012-07-21 02:15:10 +00:00
|
|
|
|
2012-07-20 22:45:37 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
const Object* target;
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2015-05-19 03:57:13 +00:00
|
|
|
mutable AnimationCurveMap curves;
|
2012-07-21 02:15:10 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::string prop;
|
|
|
|
const Document& doc;
|
2012-07-20 22:45:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<const AnimationCurveNode*> AnimationCurveNodeList;
|
|
|
|
|
|
|
|
|
|
|
|
/** Represents a FBX animation layer (i.e. a list of node animations) */
|
|
|
|
class AnimationLayer : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
AnimationLayer(uint64_t id, const Element& element, const std::string& name, const Document& doc);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~AnimationLayer();
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2016-02-28 16:30:11 +00:00
|
|
|
/* the optional white list specifies a list of property names for which the caller
|
2015-05-19 03:57:13 +00:00
|
|
|
wants animations for. Curves not matching this list will not be added to the
|
|
|
|
animation layer. */
|
|
|
|
AnimationCurveNodeList Nodes(const char* const * target_prop_whitelist = NULL, size_t whitelist_size = 0) const;
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2015-05-19 03:57:13 +00:00
|
|
|
const Document& doc;
|
2012-07-20 22:45:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<const AnimationLayer*> AnimationLayerList;
|
|
|
|
|
|
|
|
|
|
|
|
/** Represents a FBX animation stack (i.e. a list of animation layers) */
|
|
|
|
class AnimationStack : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
AnimationStack(uint64_t id, const Element& element, const std::string& name, const Document& doc);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~AnimationStack();
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
fbx_simple_property(LocalStart, int64_t, 0L)
|
|
|
|
fbx_simple_property(LocalStop, int64_t, 0L)
|
|
|
|
fbx_simple_property(ReferenceStart, int64_t, 0L)
|
|
|
|
fbx_simple_property(ReferenceStop, int64_t, 0L)
|
2012-08-25 17:53:46 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const AnimationLayerList& Layers() const {
|
|
|
|
return layers;
|
|
|
|
}
|
2012-07-20 22:45:37 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2015-05-19 03:57:13 +00:00
|
|
|
AnimationLayerList layers;
|
2012-07-20 22:45:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-26 16:05:24 +00:00
|
|
|
/** DOM class for deformers */
|
|
|
|
class Deformer : public Object
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Deformer();
|
2012-07-26 16:05:24 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
2012-07-26 16:05:24 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2012-07-26 16:05:24 +00:00
|
|
|
};
|
|
|
|
|
2012-07-26 20:53:31 +00:00
|
|
|
typedef std::vector<float> WeightArray;
|
2012-07-26 16:05:24 +00:00
|
|
|
typedef std::vector<unsigned int> WeightIndexArray;
|
|
|
|
|
|
|
|
|
|
|
|
/** DOM class for skin deformer clusters (aka subdeformers) */
|
|
|
|
class Cluster : public Deformer
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-03-03 14:19:38 +00:00
|
|
|
virtual ~Cluster();
|
2012-07-26 16:05:24 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** get the list of deformer weights associated with this cluster.
|
|
|
|
* Use #GetIndices() to get the associated vertices. Both arrays
|
|
|
|
* have the same size (and may also be empty). */
|
|
|
|
const WeightArray& GetWeights() const {
|
|
|
|
return weights;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** get indices into the vertex data of the geometry associated
|
|
|
|
* with this cluster. Use #GetWeights() to get the associated weights.
|
|
|
|
* Both arrays have the same size (and may also be empty). */
|
|
|
|
const WeightIndexArray& GetIndices() const {
|
|
|
|
return indices;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** */
|
|
|
|
const aiMatrix4x4& Transform() const {
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
const aiMatrix4x4& TransformLink() const {
|
|
|
|
return transformLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Model* TargetNode() const {
|
|
|
|
return node;
|
|
|
|
}
|
2012-07-26 17:13:19 +00:00
|
|
|
|
2012-07-26 16:05:24 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
WeightArray weights;
|
|
|
|
WeightIndexArray indices;
|
2012-07-26 16:05:24 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
aiMatrix4x4 transform;
|
|
|
|
aiMatrix4x4 transformLink;
|
2012-07-26 17:13:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Model* node;
|
2012-07-26 16:05:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** DOM class for skin deformers */
|
|
|
|
class Skin : public Deformer
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
2016-02-28 16:30:11 +00:00
|
|
|
virtual ~Skin();
|
2012-07-26 16:05:24 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
float DeformAccuracy() const {
|
|
|
|
return accuracy;
|
|
|
|
}
|
2012-07-26 16:05:24 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::vector<const Cluster*>& Clusters() const {
|
|
|
|
return clusters;
|
|
|
|
}
|
2012-07-26 16:05:24 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
float accuracy;
|
|
|
|
std::vector<const Cluster*> clusters;
|
2012-07-26 16:05:24 +00:00
|
|
|
};
|
|
|
|
|
2012-07-03 14:50:58 +00:00
|
|
|
/** Represents a link between two FBX objects. */
|
|
|
|
class Connection
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Connection(uint64_t insertionOrder, uint64_t src, uint64_t dest, const std::string& prop, const Document& doc);
|
|
|
|
~Connection();
|
|
|
|
|
|
|
|
// note: a connection ensures that the source and dest objects exist, but
|
|
|
|
// not that they have DOM representations, so the return value of one of
|
|
|
|
// these functions can still be NULL.
|
|
|
|
const Object* SourceObject() const;
|
|
|
|
const Object* DestinationObject() const;
|
|
|
|
|
|
|
|
// these, however, are always guaranteed to be valid
|
|
|
|
LazyObject& LazySourceObject() const;
|
|
|
|
LazyObject& LazyDestinationObject() const;
|
|
|
|
|
|
|
|
|
|
|
|
/** return the name of the property the connection is attached to.
|
|
|
|
* this is an empty string for object to object (OO) connections. */
|
|
|
|
const std::string& PropertyName() const {
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t InsertionOrder() const {
|
|
|
|
return insertionOrder;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CompareTo(const Connection* c) const {
|
2016-03-03 14:19:38 +00:00
|
|
|
ai_assert( NULL != c );
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// note: can't subtract because this would overflow uint64_t
|
|
|
|
if(InsertionOrder() > c->InsertionOrder()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(InsertionOrder() < c->InsertionOrder()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Compare(const Connection* c) const {
|
2016-03-03 14:19:38 +00:00
|
|
|
ai_assert( NULL != c );
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
return InsertionOrder() < c->InsertionOrder();
|
|
|
|
}
|
2012-07-05 15:18:54 +00:00
|
|
|
|
2012-07-03 14:50:58 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
uint64_t insertionOrder;
|
|
|
|
const std::string prop;
|
2012-07-03 14:50:58 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
uint64_t src, dest;
|
|
|
|
const Document& doc;
|
2012-07-03 14:50:58 +00:00
|
|
|
};
|
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
// XXX again, unique_ptr would be useful. shared_ptr is too
|
|
|
|
// bloated since the objects have a well-defined single owner
|
|
|
|
// during their entire lifetime (Document). FBX files have
|
|
|
|
// up to many thousands of objects (most of which we never use),
|
|
|
|
// so the memory overhead for them should be kept at a minimum.
|
|
|
|
typedef std::map<uint64_t, LazyObject*> ObjectMap;
|
2016-04-05 21:23:53 +00:00
|
|
|
typedef std::fbx_unordered_map<std::string, std::shared_ptr<const PropertyTable> > PropertyTemplateMap;
|
2012-07-03 14:50:58 +00:00
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
typedef std::multimap<uint64_t, const Connection*> ConnectionMap;
|
2012-07-03 14:50:58 +00:00
|
|
|
|
2012-07-03 15:57:21 +00:00
|
|
|
|
2012-08-25 14:15:13 +00:00
|
|
|
/** DOM class for global document settings, a single instance per document can
|
|
|
|
* be accessed via Document.Globals(). */
|
|
|
|
class FileGlobalSettings
|
|
|
|
{
|
|
|
|
public:
|
2016-04-05 21:23:53 +00:00
|
|
|
FileGlobalSettings(const Document& doc, std::shared_ptr<const PropertyTable> props);
|
2015-05-19 03:57:13 +00:00
|
|
|
~FileGlobalSettings();
|
2012-08-25 14:15:13 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTable& Props() const {
|
|
|
|
ai_assert(props.get());
|
|
|
|
return *props.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Document& GetDocument() const {
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
fbx_simple_property(UpAxis, int, 1)
|
|
|
|
fbx_simple_property(UpAxisSign, int, 1)
|
|
|
|
fbx_simple_property(FrontAxis, int, 2)
|
|
|
|
fbx_simple_property(FrontAxisSign, int, 1)
|
|
|
|
fbx_simple_property(CoordAxis, int, 0)
|
|
|
|
fbx_simple_property(CoordAxisSign, int, 1)
|
|
|
|
fbx_simple_property(OriginalUpAxis, int, 0)
|
|
|
|
fbx_simple_property(OriginalUpAxisSign, int, 1)
|
|
|
|
fbx_simple_property(UnitScaleFactor, double, 1)
|
|
|
|
fbx_simple_property(OriginalUnitScaleFactor, double, 1)
|
|
|
|
fbx_simple_property(AmbientColor, aiVector3D, aiVector3D(0,0,0))
|
|
|
|
fbx_simple_property(DefaultCamera, std::string, "")
|
|
|
|
|
|
|
|
|
|
|
|
enum FrameRate {
|
|
|
|
FrameRate_DEFAULT = 0,
|
|
|
|
FrameRate_120 = 1,
|
|
|
|
FrameRate_100 = 2,
|
|
|
|
FrameRate_60 = 3,
|
|
|
|
FrameRate_50 = 4,
|
|
|
|
FrameRate_48 = 5,
|
|
|
|
FrameRate_30 = 6,
|
|
|
|
FrameRate_30_DROP = 7,
|
|
|
|
FrameRate_NTSC_DROP_FRAME = 8,
|
|
|
|
FrameRate_NTSC_FULL_FRAME = 9,
|
|
|
|
FrameRate_PAL = 10,
|
|
|
|
FrameRate_CINEMA = 11,
|
|
|
|
FrameRate_1000 = 12,
|
|
|
|
FrameRate_CINEMA_ND = 13,
|
|
|
|
FrameRate_CUSTOM = 14,
|
|
|
|
|
|
|
|
FrameRate_MAX// end-of-enum sentinel
|
|
|
|
};
|
|
|
|
|
|
|
|
fbx_simple_enum_property(TimeMode, FrameRate, FrameRate_DEFAULT)
|
|
|
|
fbx_simple_property(TimeSpanStart, uint64_t, 0L)
|
|
|
|
fbx_simple_property(TimeSpanStop, uint64_t, 0L)
|
|
|
|
fbx_simple_property(CustomFrameRate, float, -1.0f)
|
2012-08-25 14:15:13 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-05 21:23:53 +00:00
|
|
|
std::shared_ptr<const PropertyTable> props;
|
2015-05-19 03:57:13 +00:00
|
|
|
const Document& doc;
|
2012-08-25 14:15:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
/** DOM root for a FBX file */
|
2015-05-19 03:52:10 +00:00
|
|
|
class Document
|
2012-06-26 16:31:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
Document(const Parser& parser, const ImportSettings& settings);
|
|
|
|
~Document();
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
LazyObject* GetObject(uint64_t id) const;
|
2012-07-03 14:50:58 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
bool IsBinary() const {
|
|
|
|
return parser.IsBinary();
|
|
|
|
}
|
2012-07-06 20:46:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
unsigned int FBXVersion() const {
|
|
|
|
return fbxVersion;
|
|
|
|
}
|
2012-07-06 20:46:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& Creator() const {
|
|
|
|
return creator;
|
|
|
|
}
|
2012-07-06 20:46:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
// elements (in this order): Year, Month, Day, Hour, Second, Millisecond
|
2015-05-19 03:57:13 +00:00
|
|
|
const unsigned int* CreationTimeStamp() const {
|
|
|
|
return creationTimeStamp;
|
|
|
|
}
|
2012-07-06 20:46:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const FileGlobalSettings& GlobalSettings() const {
|
|
|
|
ai_assert(globals.get());
|
|
|
|
return *globals.get();
|
|
|
|
}
|
2012-08-25 14:15:13 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const PropertyTemplateMap& Templates() const {
|
|
|
|
return templates;
|
|
|
|
}
|
2012-07-02 14:51:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const ObjectMap& Objects() const {
|
|
|
|
return objects;
|
|
|
|
}
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const ImportSettings& Settings() const {
|
|
|
|
return settings;
|
|
|
|
}
|
2012-06-28 17:16:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const ConnectionMap& ConnectionsBySource() const {
|
|
|
|
return src_connections;
|
|
|
|
}
|
2012-07-03 14:50:58 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const ConnectionMap& ConnectionsByDestination() const {
|
|
|
|
return dest_connections;
|
|
|
|
}
|
2012-07-03 14:50:58 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// note: the implicit rule in all DOM classes is to always resolve
|
|
|
|
// from destination to source (since the FBX object hierarchy is,
|
|
|
|
// with very few exceptions, a DAG, this avoids cycles). In all
|
|
|
|
// cases that may involve back-facing edges in the object graph,
|
|
|
|
// use LazyObject::IsBeingConstructed() to check.
|
2012-07-21 18:02:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::vector<const Connection*> GetConnectionsBySourceSequenced(uint64_t source) const;
|
|
|
|
std::vector<const Connection*> GetConnectionsByDestinationSequenced(uint64_t dest) const;
|
2012-07-03 15:57:21 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::vector<const Connection*> GetConnectionsBySourceSequenced(uint64_t source, const char* classname) const;
|
|
|
|
std::vector<const Connection*> GetConnectionsByDestinationSequenced(uint64_t dest, const char* classname) const;
|
2012-07-21 18:02:00 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::vector<const Connection*> GetConnectionsBySourceSequenced(uint64_t source,
|
|
|
|
const char* const* classnames, size_t count) const;
|
|
|
|
std::vector<const Connection*> GetConnectionsByDestinationSequenced(uint64_t dest,
|
|
|
|
const char* const* classnames,
|
|
|
|
size_t count) const;
|
2012-07-21 16:02:10 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::vector<const AnimationStack*>& AnimationStacks() const;
|
2012-07-20 22:45:37 +00:00
|
|
|
|
2012-07-21 16:02:10 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
std::vector<const Connection*> GetConnectionsSequenced(uint64_t id, const ConnectionMap&) const;
|
|
|
|
std::vector<const Connection*> GetConnectionsSequenced(uint64_t id, bool is_src,
|
|
|
|
const ConnectionMap&,
|
|
|
|
const char* const* classnames,
|
|
|
|
size_t count) const;
|
2012-07-21 16:02:10 +00:00
|
|
|
|
2012-07-02 14:51:19 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
void ReadHeader();
|
|
|
|
void ReadObjects();
|
|
|
|
void ReadPropertyTemplates();
|
|
|
|
void ReadConnections();
|
|
|
|
void ReadGlobalSettings();
|
2012-07-02 14:51:19 +00:00
|
|
|
|
2012-06-26 16:31:19 +00:00
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
const ImportSettings& settings;
|
2012-06-28 17:16:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
ObjectMap objects;
|
|
|
|
const Parser& parser;
|
2012-07-02 14:51:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
PropertyTemplateMap templates;
|
|
|
|
ConnectionMap src_connections;
|
|
|
|
ConnectionMap dest_connections;
|
2012-07-06 20:46:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
unsigned int fbxVersion;
|
|
|
|
std::string creator;
|
|
|
|
unsigned int creationTimeStamp[7];
|
2012-07-06 20:46:19 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
std::vector<uint64_t> animationStacks;
|
|
|
|
mutable std::vector<const AnimationStack*> animationStacksResolved;
|
2012-08-25 14:15:13 +00:00
|
|
|
|
2016-04-05 21:23:53 +00:00
|
|
|
std::unique_ptr<FileGlobalSettings> globals;
|
2012-06-26 16:31:19 +00:00
|
|
|
};
|
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
} // Namespace FBX
|
|
|
|
} // Namespace Assimp
|
2012-06-26 16:31:19 +00:00
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
#endif // INCLUDED_AI_FBX_DOCUMENT_H
|