Fix xml-migration bild.
parent
6f77d2e06d
commit
582a8b1887
|
@ -121,6 +121,14 @@ ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) :
|
||||||
if (nullptr == root) {
|
if (nullptr == root) {
|
||||||
ThrowException("Unable to read file, malformed XML");
|
ThrowException("Unable to read file, malformed XML");
|
||||||
}
|
}
|
||||||
|
bool res = root->empty();
|
||||||
|
if (!res) {
|
||||||
|
for (XmlNode &n : root->children()) {
|
||||||
|
const std::string nm = n.name();
|
||||||
|
}
|
||||||
|
XmlNode node = root->first_child();
|
||||||
|
std::string name = node.name();
|
||||||
|
}
|
||||||
|
|
||||||
// start reading
|
// start reading
|
||||||
ReadContents(*root);
|
ReadContents(*root);
|
||||||
|
@ -664,7 +672,7 @@ void ColladaParser::ReadController(XmlNode &node, Collada::Controller &pControll
|
||||||
}
|
}
|
||||||
} else if (currentName == "source") {
|
} else if (currentName == "source") {
|
||||||
ReadSource(currentNode);
|
ReadSource(currentNode);
|
||||||
} else if (currentName == "joints" ) {
|
} else if (currentName == "joints") {
|
||||||
ReadControllerJoints(currentNode, pController);
|
ReadControllerJoints(currentNode, pController);
|
||||||
} else if (currentName == "vertex_weights") {
|
} else if (currentName == "vertex_weights") {
|
||||||
ReadControllerWeights(currentNode, pController);
|
ReadControllerWeights(currentNode, pController);
|
||||||
|
@ -2244,7 +2252,7 @@ void ColladaParser::ReadNodeGeometry(XmlNode &node, Node *pNode) {
|
||||||
|
|
||||||
for (XmlNode ¤tNode : node.children()) {
|
for (XmlNode ¤tNode : node.children()) {
|
||||||
const std::string ¤tName = currentNode.name();
|
const std::string ¤tName = currentNode.name();
|
||||||
if (currentName=="instance_material") {
|
if (currentName == "instance_material") {
|
||||||
// read ID of the geometry subgroup and the target material
|
// read ID of the geometry subgroup and the target material
|
||||||
std::string group;
|
std::string group;
|
||||||
XmlParser::getStdStrAttribute(currentNode, "symbol", group);
|
XmlParser::getStdStrAttribute(currentNode, "symbol", group);
|
||||||
|
@ -2256,7 +2264,6 @@ void ColladaParser::ReadNodeGeometry(XmlNode &node, Node *pNode) {
|
||||||
|
|
||||||
s.mMatName = urlMat;
|
s.mMatName = urlMat;
|
||||||
|
|
||||||
|
|
||||||
// store the association
|
// store the association
|
||||||
instance.mMaterials[group] = s;
|
instance.mMaterials[group] = s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,9 @@ using namespace std;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Default constructor
|
// Default constructor
|
||||||
ObjFileImporter::ObjFileImporter() :
|
ObjFileImporter::ObjFileImporter() :
|
||||||
m_Buffer(), m_pRootObject(nullptr), m_strAbsPath(std::string(1, DefaultIOSystem().getOsSeparator())) {}
|
m_Buffer(),
|
||||||
|
m_pRootObject(nullptr),
|
||||||
|
m_strAbsPath(std::string(1, DefaultIOSystem().getOsSeparator())) {}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor.
|
// Destructor.
|
||||||
|
@ -589,18 +591,18 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc
|
||||||
// convert illumination model
|
// convert illumination model
|
||||||
int sm = 0;
|
int sm = 0;
|
||||||
switch (pCurrentMaterial->illumination_model) {
|
switch (pCurrentMaterial->illumination_model) {
|
||||||
case 0:
|
case 0:
|
||||||
sm = aiShadingMode_NoShading;
|
sm = aiShadingMode_NoShading;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sm = aiShadingMode_Gouraud;
|
sm = aiShadingMode_Gouraud;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sm = aiShadingMode_Phong;
|
sm = aiShadingMode_Phong;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sm = aiShadingMode_Gouraud;
|
sm = aiShadingMode_Gouraud;
|
||||||
ASSIMP_LOG_ERROR("OBJ: unexpected illumination model (0-2 recognized)");
|
ASSIMP_LOG_ERROR("OBJ: unexpected illumination model (0-2 recognized)");
|
||||||
}
|
}
|
||||||
|
|
||||||
mat->AddProperty<int>(&sm, 1, AI_MATKEY_SHADING_MODEL);
|
mat->AddProperty<int>(&sm, 1, AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -48,16 +47,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "OgreStructs.h"
|
#include "OgreStructs.h"
|
||||||
#include <assimp/StreamReader.h>
|
#include <assimp/StreamReader.h>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
namespace Ogre {
|
||||||
namespace Ogre
|
|
||||||
{
|
|
||||||
|
|
||||||
typedef Assimp::StreamReaderLE MemoryStreamReader;
|
typedef Assimp::StreamReaderLE MemoryStreamReader;
|
||||||
typedef std::shared_ptr<MemoryStreamReader> MemoryStreamReaderPtr;
|
typedef std::shared_ptr<MemoryStreamReader> MemoryStreamReaderPtr;
|
||||||
|
|
||||||
class OgreBinarySerializer
|
class OgreBinarySerializer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/// Imports mesh and returns the result.
|
/// Imports mesh and returns the result.
|
||||||
/** @note Fatal unrecoverable errors will throw a DeadlyImportError. */
|
/** @note Fatal unrecoverable errors will throw a DeadlyImportError. */
|
||||||
|
@ -71,17 +67,15 @@ public:
|
||||||
static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh);
|
static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *mesh);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum AssetMode
|
enum AssetMode {
|
||||||
{
|
|
||||||
AM_Mesh,
|
AM_Mesh,
|
||||||
AM_Skeleton
|
AM_Skeleton
|
||||||
};
|
};
|
||||||
|
|
||||||
OgreBinarySerializer(MemoryStreamReader *reader, AssetMode mode) :
|
OgreBinarySerializer(MemoryStreamReader *reader, AssetMode mode) :
|
||||||
m_currentLen(0),
|
m_currentLen(0),
|
||||||
m_reader(reader),
|
m_reader(reader),
|
||||||
assetMode(mode)
|
assetMode(mode) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MemoryStreamReaderPtr OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename);
|
static MemoryStreamReaderPtr OpenReader(Assimp::IOSystem *pIOHandler, const std::string &filename);
|
||||||
|
@ -136,7 +130,7 @@ private:
|
||||||
// Reader utils
|
// Reader utils
|
||||||
bool AtEnd() const;
|
bool AtEnd() const;
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
inline T Read();
|
inline T Read();
|
||||||
|
|
||||||
void ReadBytes(char *dest, size_t numBytes);
|
void ReadBytes(char *dest, size_t numBytes);
|
||||||
|
@ -158,155 +152,154 @@ private:
|
||||||
AssetMode assetMode;
|
AssetMode assetMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MeshChunkId
|
enum MeshChunkId {
|
||||||
{
|
|
||||||
M_HEADER = 0x1000,
|
M_HEADER = 0x1000,
|
||||||
// char* version : Version number check
|
// char* version : Version number check
|
||||||
M_MESH = 0x3000,
|
M_MESH = 0x3000,
|
||||||
// bool skeletallyAnimated // important flag which affects h/w buffer policies
|
// bool skeletallyAnimated // important flag which affects h/w buffer policies
|
||||||
// Optional M_GEOMETRY chunk
|
// Optional M_GEOMETRY chunk
|
||||||
M_SUBMESH = 0x4000,
|
M_SUBMESH = 0x4000,
|
||||||
// char* materialName
|
// char* materialName
|
||||||
// bool useSharedVertices
|
// bool useSharedVertices
|
||||||
// unsigned int indexCount
|
// unsigned int indexCount
|
||||||
// bool indexes32Bit
|
// bool indexes32Bit
|
||||||
// unsigned int* faceVertexIndices (indexCount)
|
// unsigned int* faceVertexIndices (indexCount)
|
||||||
// OR
|
// OR
|
||||||
// unsigned short* faceVertexIndices (indexCount)
|
// unsigned short* faceVertexIndices (indexCount)
|
||||||
// M_GEOMETRY chunk (Optional: present only if useSharedVertices = false)
|
// M_GEOMETRY chunk (Optional: present only if useSharedVertices = false)
|
||||||
M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing
|
M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing
|
||||||
// unsigned short operationType
|
// unsigned short operationType
|
||||||
M_SUBMESH_BONE_ASSIGNMENT = 0x4100,
|
M_SUBMESH_BONE_ASSIGNMENT = 0x4100,
|
||||||
// Optional bone weights (repeating section)
|
// Optional bone weights (repeating section)
|
||||||
// unsigned int vertexIndex;
|
// unsigned int vertexIndex;
|
||||||
// unsigned short boneIndex;
|
// unsigned short boneIndex;
|
||||||
// float weight;
|
// float weight;
|
||||||
// Optional chunk that matches a texture name to an alias
|
// Optional chunk that matches a texture name to an alias
|
||||||
// a texture alias is sent to the submesh material to use this texture name
|
// a texture alias is sent to the submesh material to use this texture name
|
||||||
// instead of the one in the texture unit with a matching alias name
|
// instead of the one in the texture unit with a matching alias name
|
||||||
M_SUBMESH_TEXTURE_ALIAS = 0x4200, // Repeating section
|
M_SUBMESH_TEXTURE_ALIAS = 0x4200, // Repeating section
|
||||||
// char* aliasName;
|
// char* aliasName;
|
||||||
// char* textureName;
|
// char* textureName;
|
||||||
|
|
||||||
M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH
|
M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH
|
||||||
// unsigned int vertexCount
|
// unsigned int vertexCount
|
||||||
M_GEOMETRY_VERTEX_DECLARATION = 0x5100,
|
M_GEOMETRY_VERTEX_DECLARATION = 0x5100,
|
||||||
M_GEOMETRY_VERTEX_ELEMENT = 0x5110, // Repeating section
|
M_GEOMETRY_VERTEX_ELEMENT = 0x5110, // Repeating section
|
||||||
// unsigned short source; // buffer bind source
|
// unsigned short source; // buffer bind source
|
||||||
// unsigned short type; // VertexElementType
|
// unsigned short type; // VertexElementType
|
||||||
// unsigned short semantic; // VertexElementSemantic
|
// unsigned short semantic; // VertexElementSemantic
|
||||||
// unsigned short offset; // start offset in buffer in bytes
|
// unsigned short offset; // start offset in buffer in bytes
|
||||||
// unsigned short index; // index of the semantic (for colours and texture coords)
|
// unsigned short index; // index of the semantic (for colours and texture coords)
|
||||||
M_GEOMETRY_VERTEX_BUFFER = 0x5200, // Repeating section
|
M_GEOMETRY_VERTEX_BUFFER = 0x5200, // Repeating section
|
||||||
// unsigned short bindIndex; // Index to bind this buffer to
|
// unsigned short bindIndex; // Index to bind this buffer to
|
||||||
// unsigned short vertexSize; // Per-vertex size, must agree with declaration at this index
|
// unsigned short vertexSize; // Per-vertex size, must agree with declaration at this index
|
||||||
M_GEOMETRY_VERTEX_BUFFER_DATA = 0x5210,
|
M_GEOMETRY_VERTEX_BUFFER_DATA = 0x5210,
|
||||||
// raw buffer data
|
// raw buffer data
|
||||||
M_MESH_SKELETON_LINK = 0x6000,
|
M_MESH_SKELETON_LINK = 0x6000,
|
||||||
// Optional link to skeleton
|
// Optional link to skeleton
|
||||||
// char* skeletonName : name of .skeleton to use
|
// char* skeletonName : name of .skeleton to use
|
||||||
M_MESH_BONE_ASSIGNMENT = 0x7000,
|
M_MESH_BONE_ASSIGNMENT = 0x7000,
|
||||||
// Optional bone weights (repeating section)
|
// Optional bone weights (repeating section)
|
||||||
// unsigned int vertexIndex;
|
// unsigned int vertexIndex;
|
||||||
// unsigned short boneIndex;
|
// unsigned short boneIndex;
|
||||||
// float weight;
|
// float weight;
|
||||||
M_MESH_LOD = 0x8000,
|
M_MESH_LOD = 0x8000,
|
||||||
// Optional LOD information
|
// Optional LOD information
|
||||||
// string strategyName;
|
// string strategyName;
|
||||||
// unsigned short numLevels;
|
// unsigned short numLevels;
|
||||||
// bool manual; (true for manual alternate meshes, false for generated)
|
// bool manual; (true for manual alternate meshes, false for generated)
|
||||||
M_MESH_LOD_USAGE = 0x8100,
|
M_MESH_LOD_USAGE = 0x8100,
|
||||||
// Repeating section, ordered in increasing depth
|
// Repeating section, ordered in increasing depth
|
||||||
// NB LOD 0 (full detail from 0 depth) is omitted
|
// NB LOD 0 (full detail from 0 depth) is omitted
|
||||||
// LOD value - this is a distance, a pixel count etc, based on strategy
|
// LOD value - this is a distance, a pixel count etc, based on strategy
|
||||||
// float lodValue;
|
// float lodValue;
|
||||||
M_MESH_LOD_MANUAL = 0x8110,
|
M_MESH_LOD_MANUAL = 0x8110,
|
||||||
// Required if M_MESH_LOD section manual = true
|
// Required if M_MESH_LOD section manual = true
|
||||||
// String manualMeshName;
|
// String manualMeshName;
|
||||||
M_MESH_LOD_GENERATED = 0x8120,
|
M_MESH_LOD_GENERATED = 0x8120,
|
||||||
// Required if M_MESH_LOD section manual = false
|
// Required if M_MESH_LOD section manual = false
|
||||||
// Repeating section (1 per submesh)
|
// Repeating section (1 per submesh)
|
||||||
// unsigned int indexCount;
|
// unsigned int indexCount;
|
||||||
// bool indexes32Bit
|
// bool indexes32Bit
|
||||||
// unsigned short* faceIndexes; (indexCount)
|
// unsigned short* faceIndexes; (indexCount)
|
||||||
// OR
|
// OR
|
||||||
// unsigned int* faceIndexes; (indexCount)
|
// unsigned int* faceIndexes; (indexCount)
|
||||||
M_MESH_BOUNDS = 0x9000,
|
M_MESH_BOUNDS = 0x9000,
|
||||||
// float minx, miny, minz
|
// float minx, miny, minz
|
||||||
// float maxx, maxy, maxz
|
// float maxx, maxy, maxz
|
||||||
// float radius
|
// float radius
|
||||||
|
|
||||||
// Added By DrEvil
|
// Added By DrEvil
|
||||||
// optional chunk that contains a table of submesh indexes and the names of
|
// optional chunk that contains a table of submesh indexes and the names of
|
||||||
// the sub-meshes.
|
// the sub-meshes.
|
||||||
M_SUBMESH_NAME_TABLE = 0xA000,
|
M_SUBMESH_NAME_TABLE = 0xA000,
|
||||||
// Subchunks of the name table. Each chunk contains an index & string
|
// Subchunks of the name table. Each chunk contains an index & string
|
||||||
M_SUBMESH_NAME_TABLE_ELEMENT = 0xA100,
|
M_SUBMESH_NAME_TABLE_ELEMENT = 0xA100,
|
||||||
// short index
|
// short index
|
||||||
// char* name
|
// char* name
|
||||||
// Optional chunk which stores precomputed edge data
|
// Optional chunk which stores precomputed edge data
|
||||||
M_EDGE_LISTS = 0xB000,
|
M_EDGE_LISTS = 0xB000,
|
||||||
// Each LOD has a separate edge list
|
// Each LOD has a separate edge list
|
||||||
M_EDGE_LIST_LOD = 0xB100,
|
M_EDGE_LIST_LOD = 0xB100,
|
||||||
// unsigned short lodIndex
|
// unsigned short lodIndex
|
||||||
// bool isManual // If manual, no edge data here, loaded from manual mesh
|
// bool isManual // If manual, no edge data here, loaded from manual mesh
|
||||||
// bool isClosed
|
// bool isClosed
|
||||||
// unsigned long numTriangles
|
// unsigned long numTriangles
|
||||||
// unsigned long numEdgeGroups
|
// unsigned long numEdgeGroups
|
||||||
// Triangle* triangleList
|
// Triangle* triangleList
|
||||||
// unsigned long indexSet
|
// unsigned long indexSet
|
||||||
// unsigned long vertexSet
|
// unsigned long vertexSet
|
||||||
// unsigned long vertIndex[3]
|
// unsigned long vertIndex[3]
|
||||||
// unsigned long sharedVertIndex[3]
|
// unsigned long sharedVertIndex[3]
|
||||||
// float normal[4]
|
// float normal[4]
|
||||||
|
|
||||||
M_EDGE_GROUP = 0xB110,
|
M_EDGE_GROUP = 0xB110,
|
||||||
// unsigned long vertexSet
|
// unsigned long vertexSet
|
||||||
// unsigned long triStart
|
// unsigned long triStart
|
||||||
// unsigned long triCount
|
// unsigned long triCount
|
||||||
// unsigned long numEdges
|
// unsigned long numEdges
|
||||||
// Edge* edgeList
|
// Edge* edgeList
|
||||||
// unsigned long triIndex[2]
|
// unsigned long triIndex[2]
|
||||||
// unsigned long vertIndex[2]
|
// unsigned long vertIndex[2]
|
||||||
// unsigned long sharedVertIndex[2]
|
// unsigned long sharedVertIndex[2]
|
||||||
// bool degenerate
|
// bool degenerate
|
||||||
// Optional poses section, referred to by pose keyframes
|
// Optional poses section, referred to by pose keyframes
|
||||||
M_POSES = 0xC000,
|
M_POSES = 0xC000,
|
||||||
M_POSE = 0xC100,
|
M_POSE = 0xC100,
|
||||||
// char* name (may be blank)
|
// char* name (may be blank)
|
||||||
// unsigned short target // 0 for shared geometry,
|
// unsigned short target // 0 for shared geometry,
|
||||||
// 1+ for submesh index + 1
|
// 1+ for submesh index + 1
|
||||||
// bool includesNormals [1.8+]
|
// bool includesNormals [1.8+]
|
||||||
M_POSE_VERTEX = 0xC111,
|
M_POSE_VERTEX = 0xC111,
|
||||||
// unsigned long vertexIndex
|
// unsigned long vertexIndex
|
||||||
// float xoffset, yoffset, zoffset
|
// float xoffset, yoffset, zoffset
|
||||||
// float xnormal, ynormal, znormal (optional, 1.8+)
|
// float xnormal, ynormal, znormal (optional, 1.8+)
|
||||||
// Optional vertex animation chunk
|
// Optional vertex animation chunk
|
||||||
M_ANIMATIONS = 0xD000,
|
M_ANIMATIONS = 0xD000,
|
||||||
M_ANIMATION = 0xD100,
|
M_ANIMATION = 0xD100,
|
||||||
// char* name
|
// char* name
|
||||||
// float length
|
// float length
|
||||||
M_ANIMATION_BASEINFO = 0xD105,
|
M_ANIMATION_BASEINFO = 0xD105,
|
||||||
// [Optional] base keyframe information (pose animation only)
|
// [Optional] base keyframe information (pose animation only)
|
||||||
// char* baseAnimationName (blank for self)
|
// char* baseAnimationName (blank for self)
|
||||||
// float baseKeyFrameTime
|
// float baseKeyFrameTime
|
||||||
M_ANIMATION_TRACK = 0xD110,
|
M_ANIMATION_TRACK = 0xD110,
|
||||||
// unsigned short type // 1 == morph, 2 == pose
|
// unsigned short type // 1 == morph, 2 == pose
|
||||||
// unsigned short target // 0 for shared geometry,
|
// unsigned short target // 0 for shared geometry,
|
||||||
// 1+ for submesh index + 1
|
// 1+ for submesh index + 1
|
||||||
M_ANIMATION_MORPH_KEYFRAME = 0xD111,
|
M_ANIMATION_MORPH_KEYFRAME = 0xD111,
|
||||||
// float time
|
// float time
|
||||||
// bool includesNormals [1.8+]
|
// bool includesNormals [1.8+]
|
||||||
// float x,y,z // repeat by number of vertices in original geometry
|
// float x,y,z // repeat by number of vertices in original geometry
|
||||||
M_ANIMATION_POSE_KEYFRAME = 0xD112,
|
M_ANIMATION_POSE_KEYFRAME = 0xD112,
|
||||||
// float time
|
// float time
|
||||||
M_ANIMATION_POSE_REF = 0xD113, // repeat for number of referenced poses
|
M_ANIMATION_POSE_REF = 0xD113, // repeat for number of referenced poses
|
||||||
// unsigned short poseIndex
|
// unsigned short poseIndex
|
||||||
// float influence
|
// float influence
|
||||||
// Optional submesh extreme vertex list chink
|
// Optional submesh extreme vertex list chink
|
||||||
M_TABLE_EXTREMES = 0xE000
|
M_TABLE_EXTREMES = 0xE000
|
||||||
// unsigned short submesh_index;
|
// unsigned short submesh_index;
|
||||||
// float extremes [n_extremes][3];
|
// float extremes [n_extremes][3];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -353,49 +346,48 @@ static std::string MeshHeaderToString(MeshChunkId id)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum SkeletonChunkId
|
enum SkeletonChunkId {
|
||||||
{
|
SKELETON_HEADER = 0x1000,
|
||||||
SKELETON_HEADER = 0x1000,
|
// char* version : Version number check
|
||||||
// char* version : Version number check
|
SKELETON_BLENDMODE = 0x1010, // optional
|
||||||
SKELETON_BLENDMODE = 0x1010, // optional
|
// unsigned short blendmode : SkeletonAnimationBlendMode
|
||||||
// unsigned short blendmode : SkeletonAnimationBlendMode
|
SKELETON_BONE = 0x2000,
|
||||||
SKELETON_BONE = 0x2000,
|
|
||||||
// Repeating section defining each bone in the system.
|
// Repeating section defining each bone in the system.
|
||||||
// Bones are assigned indexes automatically based on their order of declaration
|
// Bones are assigned indexes automatically based on their order of declaration
|
||||||
// starting with 0.
|
// starting with 0.
|
||||||
// char* name : name of the bone
|
// char* name : name of the bone
|
||||||
// unsigned short handle : handle of the bone, should be contiguous & start at 0
|
// unsigned short handle : handle of the bone, should be contiguous & start at 0
|
||||||
// Vector3 position : position of this bone relative to parent
|
// Vector3 position : position of this bone relative to parent
|
||||||
// Quaternion orientation : orientation of this bone relative to parent
|
// Quaternion orientation : orientation of this bone relative to parent
|
||||||
// Vector3 scale : scale of this bone relative to parent
|
// Vector3 scale : scale of this bone relative to parent
|
||||||
SKELETON_BONE_PARENT = 0x3000,
|
SKELETON_BONE_PARENT = 0x3000,
|
||||||
// Record of the parent of a single bone, used to build the node tree
|
// Record of the parent of a single bone, used to build the node tree
|
||||||
// Repeating section, listed in Bone Index order, one per Bone
|
// Repeating section, listed in Bone Index order, one per Bone
|
||||||
// unsigned short handle : child bone
|
// unsigned short handle : child bone
|
||||||
// unsigned short parentHandle : parent bone
|
// unsigned short parentHandle : parent bone
|
||||||
SKELETON_ANIMATION = 0x4000,
|
SKELETON_ANIMATION = 0x4000,
|
||||||
// A single animation for this skeleton
|
// A single animation for this skeleton
|
||||||
// char* name : Name of the animation
|
// char* name : Name of the animation
|
||||||
// float length : Length of the animation in seconds
|
// float length : Length of the animation in seconds
|
||||||
SKELETON_ANIMATION_BASEINFO = 0x4010,
|
SKELETON_ANIMATION_BASEINFO = 0x4010,
|
||||||
// [Optional] base keyframe information
|
// [Optional] base keyframe information
|
||||||
// char* baseAnimationName (blank for self)
|
// char* baseAnimationName (blank for self)
|
||||||
// float baseKeyFrameTime
|
// float baseKeyFrameTime
|
||||||
SKELETON_ANIMATION_TRACK = 0x4100,
|
SKELETON_ANIMATION_TRACK = 0x4100,
|
||||||
// A single animation track (relates to a single bone)
|
// A single animation track (relates to a single bone)
|
||||||
// Repeating section (within SKELETON_ANIMATION)
|
// Repeating section (within SKELETON_ANIMATION)
|
||||||
// unsigned short boneIndex : Index of bone to apply to
|
// unsigned short boneIndex : Index of bone to apply to
|
||||||
SKELETON_ANIMATION_TRACK_KEYFRAME = 0x4110,
|
SKELETON_ANIMATION_TRACK_KEYFRAME = 0x4110,
|
||||||
// A single keyframe within the track
|
// A single keyframe within the track
|
||||||
// Repeating section
|
// Repeating section
|
||||||
// float time : The time position (seconds)
|
// float time : The time position (seconds)
|
||||||
// Quaternion rotate : Rotation to apply at this keyframe
|
// Quaternion rotate : Rotation to apply at this keyframe
|
||||||
// Vector3 translate : Translation to apply at this keyframe
|
// Vector3 translate : Translation to apply at this keyframe
|
||||||
// Vector3 scale : Scale to apply at this keyframe
|
// Vector3 scale : Scale to apply at this keyframe
|
||||||
SKELETON_ANIMATION_LINK = 0x5000
|
SKELETON_ANIMATION_LINK = 0x5000
|
||||||
// Link to another skeleton, to re-use its animations
|
// Link to another skeleton, to re-use its animations
|
||||||
// char* skeletonName : name of skeleton to get animations from
|
// char* skeletonName : name of skeleton to get animations from
|
||||||
// float scale : scale to apply to trans/scale keys
|
// float scale : scale to apply to trans/scale keys
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -416,8 +408,8 @@ static std::string SkeletonHeaderToString(SkeletonChunkId id)
|
||||||
return "Unknown_SkeletonChunkId";
|
return "Unknown_SkeletonChunkId";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} // Ogre
|
} // namespace Ogre
|
||||||
} // Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_OGRE_IMPORTER
|
#endif // ASSIMP_BUILD_NO_OGRE_IMPORTER
|
||||||
#endif // AI_OGREBINARYSERIALIZER_H_INC
|
#endif // AI_OGREBINARYSERIALIZER_H_INC
|
||||||
|
|
|
@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Ogre {
|
namespace Ogre {
|
||||||
|
|
||||||
AI_WONT_RETURN void ThrowAttibuteError(const XmlParser *reader, const std::string &name, const std::string &error = "") AI_WONT_RETURN_SUFFIX;
|
//AI_WONT_RETURN void ThrowAttibuteError(const XmlParser *reader, const std::string &name, const std::string &error = "") AI_WONT_RETURN_SUFFIX;
|
||||||
|
|
||||||
AI_WONT_RETURN void ThrowAttibuteError(const std::string &nodeName, const std::string &name, const std::string &error) {
|
AI_WONT_RETURN void ThrowAttibuteError(const std::string &nodeName, const std::string &name, const std::string &error) {
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
|
@ -69,7 +69,7 @@ AI_WONT_RETURN void ThrowAttibuteError(const std::string &nodeName, const std::s
|
||||||
template <>
|
template <>
|
||||||
int32_t OgreXmlSerializer::ReadAttribute<int32_t>(XmlNode &xmlNode, const char *name) const {
|
int32_t OgreXmlSerializer::ReadAttribute<int32_t>(XmlNode &xmlNode, const char *name) const {
|
||||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||||
ThrowAttibuteError(mParser, name);
|
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||||
}
|
}
|
||||||
pugi::xml_attribute attr = xmlNode.attribute(name);
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
||||||
return static_cast<int32_t>(attr.as_int());
|
return static_cast<int32_t>(attr.as_int());
|
||||||
|
@ -78,14 +78,14 @@ int32_t OgreXmlSerializer::ReadAttribute<int32_t>(XmlNode &xmlNode, const char *
|
||||||
template <>
|
template <>
|
||||||
uint32_t OgreXmlSerializer::ReadAttribute<uint32_t>(XmlNode &xmlNode, const char *name) const {
|
uint32_t OgreXmlSerializer::ReadAttribute<uint32_t>(XmlNode &xmlNode, const char *name) const {
|
||||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||||
ThrowAttibuteError(mParser, name);
|
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @note This is hackish. But we are never expecting unsigned values that go outside the
|
// @note This is hackish. But we are never expecting unsigned values that go outside the
|
||||||
// int32_t range. Just monitor for negative numbers and kill the import.
|
// int32_t range. Just monitor for negative numbers and kill the import.
|
||||||
int32_t temp = ReadAttribute<int32_t>(xmlNode, name);
|
int32_t temp = ReadAttribute<int32_t>(xmlNode, name);
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
ThrowAttibuteError(mParser, name, "Found a negative number value where expecting a uint32_t value");
|
ThrowAttibuteError(xmlNode.name(), name, "Found a negative number value where expecting a uint32_t value");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<uint32_t>(temp);
|
return static_cast<uint32_t>(temp);
|
||||||
|
@ -94,7 +94,7 @@ uint32_t OgreXmlSerializer::ReadAttribute<uint32_t>(XmlNode &xmlNode, const char
|
||||||
template <>
|
template <>
|
||||||
uint16_t OgreXmlSerializer::ReadAttribute<uint16_t>(XmlNode &xmlNode, const char *name) const {
|
uint16_t OgreXmlSerializer::ReadAttribute<uint16_t>(XmlNode &xmlNode, const char *name) const {
|
||||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||||
ThrowAttibuteError(mParser, name);
|
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<uint16_t>(xmlNode.attribute(name).as_int());
|
return static_cast<uint16_t>(xmlNode.attribute(name).as_int());
|
||||||
|
@ -103,7 +103,7 @@ uint16_t OgreXmlSerializer::ReadAttribute<uint16_t>(XmlNode &xmlNode, const char
|
||||||
template <>
|
template <>
|
||||||
float OgreXmlSerializer::ReadAttribute<float>(XmlNode &xmlNode, const char *name) const {
|
float OgreXmlSerializer::ReadAttribute<float>(XmlNode &xmlNode, const char *name) const {
|
||||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||||
ThrowAttibuteError(mParser, name);
|
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return xmlNode.attribute(name).as_float();
|
return xmlNode.attribute(name).as_float();
|
||||||
|
@ -112,7 +112,7 @@ float OgreXmlSerializer::ReadAttribute<float>(XmlNode &xmlNode, const char *name
|
||||||
template <>
|
template <>
|
||||||
std::string OgreXmlSerializer::ReadAttribute<std::string>(XmlNode &xmlNode, const char *name) const {
|
std::string OgreXmlSerializer::ReadAttribute<std::string>(XmlNode &xmlNode, const char *name) const {
|
||||||
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
if (!XmlParser::hasAttribute(xmlNode, name)) {
|
||||||
ThrowAttibuteError(mParser, name);
|
ThrowAttibuteError(xmlNode.name(), name, "Not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return xmlNode.attribute(name).as_string();
|
return xmlNode.attribute(name).as_string();
|
||||||
|
@ -127,7 +127,7 @@ bool OgreXmlSerializer::ReadAttribute<bool>(XmlNode &xmlNode, const char *name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrowAttibuteError(mParser, name, "Boolean value is expected to be 'true' or 'false', encountered '" + value + "'");
|
ThrowAttibuteError(xmlNode.name(), name, "Boolean value is expected to be 'true' or 'false', encountered '" + value + "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,16 @@ void X3DImporter::Clear() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void X3DImporter::ParseFile(const std::string &file, IOSystem *pIOHandler) {
|
||||||
|
ai_assert(nullptr != pIOHandler);
|
||||||
|
|
||||||
|
static const std::string mode = "rb";
|
||||||
|
std::unique_ptr<IOStream> fileStream(pIOHandler->Open(file, mode));
|
||||||
|
if (!fileStream.get()) {
|
||||||
|
throw DeadlyImportError("Failed to open file " + file + ".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************************************************************************/
|
/*********************************************************************************************************************************************/
|
||||||
/************************************************************ Functions: find set ************************************************************/
|
/************************************************************ Functions: find set ************************************************************/
|
||||||
/*********************************************************************************************************************************************/
|
/*********************************************************************************************************************************************/
|
||||||
|
@ -154,7 +164,9 @@ void X3DImporter::Clear() {
|
||||||
bool X3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const {
|
bool X3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const {
|
||||||
const std::string extension = GetExtension(pFile);
|
const std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
if ((extension == "x3d") || (extension == "x3db")) return true;
|
if ((extension == "x3d") || (extension == "x3db")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!extension.length() || pCheckSig) {
|
if (!extension.length() || pCheckSig) {
|
||||||
const char *tokens[] = { "DOCTYPE X3D PUBLIC", "http://www.web3d.org/specifications/x3d" };
|
const char *tokens[] = { "DOCTYPE X3D PUBLIC", "http://www.web3d.org/specifications/x3d" };
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -119,6 +118,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
TNodeType *parse(IOStream *stream) {
|
TNodeType *parse(IOStream *stream) {
|
||||||
|
mRoot = nullptr;
|
||||||
if (nullptr == stream) {
|
if (nullptr == stream) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,9 @@ public:
|
||||||
mData.resize(stream->FileSize());
|
mData.resize(stream->FileSize());
|
||||||
stream->Read(&mData[0], mData.size(), 1);
|
stream->Read(&mData[0], mData.size(), 1);
|
||||||
mDoc = new pugi::xml_document();
|
mDoc = new pugi::xml_document();
|
||||||
pugi::xml_parse_result result = mDoc->load_string(&mData[0]);
|
pugi::xml_parse_result result = mDoc->load_string(&mData[0], pugi::parse_default | pugi::parse_declaration);
|
||||||
if (result.status == pugi::status_ok) {
|
if (result.status == pugi::status_ok) {
|
||||||
pugi::xml_node root = *(mDoc->children().begin());
|
pugi::xml_node root = mDoc->document_element();
|
||||||
|
|
||||||
mRoot = &root;
|
mRoot = &root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006-2020, assimp team
|
# Copyright (c) 2006-2020, assimp team
|
||||||
|
#
|
||||||
|
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use of this software in source and binary forms,
|
# Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -88,6 +87,7 @@ SET( COMMON
|
||||||
unit/Common/utLineSplitter.cpp
|
unit/Common/utLineSplitter.cpp
|
||||||
unit/Common/utSpatialSort.cpp
|
unit/Common/utSpatialSort.cpp
|
||||||
unit/Common/utAssertHandler.cpp
|
unit/Common/utAssertHandler.cpp
|
||||||
|
unit/Common/utXmlParser.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( IMPORTERS
|
SET( IMPORTERS
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
Loading…
Reference in New Issue