Commit c77b66a5 authored by hybrid's avatar hybrid

Support for Ogre skeletons. Animations are not correctly working, yet. Also...

Support for Ogre skeletons. Animations are not correctly working, yet. Also flipping mesh from right-handed to left-handed now, so expect some changes with loaded meshes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2827 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1aa52165
...@@ -31,6 +31,7 @@ namespace scene ...@@ -31,6 +31,7 @@ namespace scene
# error compiler not supported # error compiler not supported
#endif #endif
namespace {
// File header // File header
struct MS3DHeader struct MS3DHeader
{ {
...@@ -99,6 +100,8 @@ struct MS3DVertexWeights ...@@ -99,6 +100,8 @@ struct MS3DVertexWeights
u8 weights[3]; u8 weights[3];
} PACK_STRUCT; } PACK_STRUCT;
} // end namespace
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing ) # pragma pack( pop, packing )
......
This diff is collapsed.
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "SMeshBufferLightMap.h" #include "SMeshBufferLightMap.h"
#include "IMeshManipulator.h" #include "IMeshManipulator.h"
#include "matrix4.h" #include "matrix4.h"
#include "quaternion.h"
#include "CSkinnedMesh.h"
namespace irr namespace irr
{ {
...@@ -168,6 +170,13 @@ private: ...@@ -168,6 +170,13 @@ private:
core::stringc Alias; core::stringc Alias;
}; };
struct OgreBoneAssignment
{
s32 VertexID;
u16 BoneID;
f32 Weight;
};
struct OgreSubMesh struct OgreSubMesh
{ {
core::stringc Material; core::stringc Material;
...@@ -176,6 +185,7 @@ private: ...@@ -176,6 +185,7 @@ private:
OgreGeometry Geometry; OgreGeometry Geometry;
u16 Operation; u16 Operation;
core::array<OgreTextureAlias> TextureAliases; core::array<OgreTextureAlias> TextureAliases;
core::array<OgreBoneAssignment> BoneAssignments;
bool Indices32Bit; bool Indices32Bit;
}; };
...@@ -184,11 +194,44 @@ private: ...@@ -184,11 +194,44 @@ private:
bool SkeletalAnimation; bool SkeletalAnimation;
OgreGeometry Geometry; OgreGeometry Geometry;
core::array<OgreSubMesh> SubMeshes; core::array<OgreSubMesh> SubMeshes;
core::array<OgreBoneAssignment> BoneAssignments;
core::vector3df BBoxMinEdge; core::vector3df BBoxMinEdge;
core::vector3df BBoxMaxEdge; core::vector3df BBoxMaxEdge;
f32 BBoxRadius; f32 BBoxRadius;
}; };
struct OgreBone
{
core::stringc Name;
core::vector3df Position;
core::quaternion Orientation;
core::vector3df Scale;
u16 Handle;
u16 Parent;
};
struct OgreKeyframe
{
u16 BoneID;
f32 Time;
core::vector3df Position;
core::quaternion Orientation;
core::vector3df Scale;
};
struct OgreAnimation
{
core::stringc Name;
f32 Length;
core::array<OgreKeyframe> Keyframes;
};
struct OgreSkeleton
{
core::array<OgreBone> Bones;
core::array<OgreAnimation> Animations;
};
bool readChunk(io::IReadFile* file); bool readChunk(io::IReadFile* file);
bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh); bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh);
bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry);
...@@ -203,16 +246,19 @@ private: ...@@ -203,16 +246,19 @@ private:
void readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num=1); void readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num=1);
void readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num=1); void readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num=1);
void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out); void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out);
void readQuaternion(io::IReadFile* file, ChunkData& data, core::quaternion& out);
void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName); void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName);
scene::SMeshBuffer* composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom); scene::SMeshBuffer* composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom);
scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom); scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom);
scene::IMeshBuffer* composeMeshBufferSkinned(scene::CSkinnedMesh& mesh, const core::array<s32>& indices, const OgreGeometry& geom);
void composeObject(void); void composeObject(void);
bool readColor(io::IReadFile* meshFile, video::SColor& col); bool readColor(io::IReadFile* meshFile, video::SColor& col);
void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false); void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false);
void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat); void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat);
void readPass(io::IReadFile* file, OgreTechnique& technique); void readPass(io::IReadFile* file, OgreTechnique& technique);
void loadMaterials(io::IReadFile* file); void loadMaterials(io::IReadFile* file);
bool loadSkeleton(io::IReadFile* meshFile, const core::stringc& name);
core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model); core::stringc getTextureFileName(const core::stringc& texture, core::stringc& model);
void clearMeshes(); void clearMeshes();
...@@ -225,8 +271,9 @@ private: ...@@ -225,8 +271,9 @@ private:
io::path CurrentlyLoadingFromPath; io::path CurrentlyLoadingFromPath;
core::array<OgreMaterial> Materials; core::array<OgreMaterial> Materials;
OgreSkeleton Skeleton;
SMesh* Mesh; IMesh* Mesh;
u32 NumUV; u32 NumUV;
}; };
......
...@@ -1448,12 +1448,6 @@ void CSkinnedMesh::calculateTangents( ...@@ -1448,12 +1448,6 @@ void CSkinnedMesh::calculateTangents(
} }
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment