added chunk structs for all possible types of chunks that can be written to the output mesh file

This commit is contained in:
gered 2012-12-10 19:01:09 -05:00
parent 0770dc01e4
commit 2404757ce7
9 changed files with 350 additions and 0 deletions

36
src/chunks/animations.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef __CHUNKS_ANIMATIONS_H_INCLUDED__
#define __CHUNKS_ANIMATIONS_H_INCLUDED__
#include "../common.h"
#include "../assets/animationsequence.h"
#include <vector>
struct AnimationsChunk
{
std::vector<AnimationSequence> animations;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t AnimationsChunk::GetCount() const
{
return animations.size();
}
inline uint32_t AnimationsChunk::GetSize() const
{
if (animations.size() == 0)
return 0;
uint32_t size = sizeof(uint32_t);
for (uint32_t i = 0; i < animations.size(); ++i)
{
size += animations[i].name.length() + 1; // include null terminator
size += sizeof(uint32_t) * 2; // start + end
}
return size;
}
#endif

36
src/chunks/groups.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef __CHUNKS_GROUPS_H_INCLUDED__
#define __CHUNKS_GROUPS_H_INCLUDED__
#include "../common.h"
#include "../geometry/group.h"
struct GroupsChunk
{
std::vector<Group> groups;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t GroupsChunk::GetCount() const
{
return groups.size();
}
inline uint32_t GroupsChunk::GetSize() const
{
if (groups.size() == 0)
return 0;
uint32_t size = sizeof(uint32_t); // count
for (uint32_t i = 0; i < groups.size(); ++i)
{
const Group *group = &groups[i];
size += group->GetSize();
}
return size;
}
#endif

37
src/chunks/joints.h Normal file
View file

@ -0,0 +1,37 @@
#ifndef __CHUNKS_JOINTS_H_INCLUDED__
#define __CHUNKS_JOINTS_H_INCLUDED__
#include "../common.h"
#include "../geometry/joint.h"
#include <vector>
struct JointsChunk
{
std::vector<Joint> joints;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t JointsChunk::GetCount() const
{
return joints.size();
}
inline uint32_t JointsChunk::GetSize() const
{
if (joints.size() == 0)
return 0;
uint32_t size = sizeof(uint32_t); // count
for (uint32_t i = 0; i < joints.size(); ++i)
{
const Joint *joint = &joints[i];
size += joint->GetSize();
}
return size;
}
#endif

View file

@ -0,0 +1,37 @@
#ifndef __CHUNKS_JOINTTOVERTICES_H_INCLUDED__
#define __CHUNKS_JOINTTOVERTICES_H_INCLUDED__
#include "../common.h"
#include "../geometry/jointvertexinfo.h"
#include <vector>
struct JointToVerticesChunk
{
std::vector<JointVertexInfo> jointVertexInfo;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t JointToVerticesChunk::GetCount() const
{
return jointVertexInfo.size();
}
inline uint32_t JointToVerticesChunk::GetSize() const
{
if (jointVertexInfo.size() == 0)
return 0;
uint32_t size = sizeof(uint32_t); // count
for (uint32_t i = 0; i < jointVertexInfo.size(); ++i)
{
const JointVertexInfo *info = &jointVertexInfo[i];
size += info->GetSize();
}
return size;
}
#endif

65
src/chunks/keyframes.h Normal file
View file

@ -0,0 +1,65 @@
#ifndef __CHUNKS_KEYFRAMES_H_INCLUDED__
#define __CHUNKS_KEYFRAMES_H_INCLUDED__
#include "../common.h"
#include "../geometry/keyframe.h"
#include <vector>
struct KeyframesChunk
{
KeyframesChunk(uint32_t numJointsPerFrame);
virtual ~KeyframesChunk();
uint32_t numJointsPerFrame;
std::vector<Keyframe*> frames;
Keyframe* AddFrame();
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline KeyframesChunk::KeyframesChunk(uint32_t numJointsPerFrame)
{
this->numJointsPerFrame = numJointsPerFrame;
}
inline KeyframesChunk::~KeyframesChunk()
{
for (uint32_t i = 0; i < frames.size(); ++i)
{
Keyframe *frame = frames[i];
SAFE_DELETE(frame);
}
}
inline Keyframe* KeyframesChunk::AddFrame()
{
Keyframe *newFrame = new Keyframe(numJointsPerFrame);
frames.push_back(newFrame);
return newFrame;
}
inline uint32_t KeyframesChunk::GetCount() const
{
return frames.size();
}
inline uint32_t KeyframesChunk::GetSize() const
{
if (frames.size() == 0)
return 0;
uint32_t size = sizeof(uint32_t); // count
for (uint32_t i = 0; i < frames.size(); ++i)
{
Keyframe *frame = frames[i];
size += frame->GetSize();
}
return size;
}
#endif

34
src/chunks/normals.h Normal file
View file

@ -0,0 +1,34 @@
#ifndef __CHUNKS_NORMALS_H_INCLUDED__
#define __CHUNKS_NORMALS_H_INCLUDED__
#include "../common.h"
#include "../geometry/vector3.h"
#include <vector>
struct NormalsChunk
{
std::vector<Vector3> normals;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t NormalsChunk::GetCount() const
{
return normals.size();
}
inline uint32_t NormalsChunk::GetSize() const
{
if (normals.size() == 0)
return 0;
uint32_t normalsSize = sizeof(float) * 3; // xyz
uint32_t size = sizeof(uint32_t); // count
size += normalsSize * normals.size();
return size;
}
#endif

34
src/chunks/texcoords.h Normal file
View file

@ -0,0 +1,34 @@
#ifndef __CHUNKS_TEXCOORDS_H_INCLUDED__
#define __CHUNKS_TEXCOORDS_H_INCLUDED__
#include "../common.h"
#include "../geometry/vector2.h"
#include <vector>
struct TexCoordsChunk
{
std::vector<Vector2> texCoords;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t TexCoordsChunk::GetCount() const
{
return texCoords.size();
}
inline uint32_t TexCoordsChunk::GetSize() const
{
if (texCoords.size() == 0)
return 0;
uint32_t texCoordSize = sizeof(float) * 2; // uv
uint32_t size = sizeof(uint32_t); // count
size += texCoordSize * texCoords.size();
return size;
}
#endif

37
src/chunks/triangles.h Normal file
View file

@ -0,0 +1,37 @@
#ifndef __CHUNKS_TRIANGLES_H_INCLUDED__
#define __CHUNKS_TRIANGLES_H_INCLUDED__
#include "../common.h"
#include "../geometry/triangle.h"
#include <vector>
struct TrianglesChunk
{
std::vector<Triangle> triangles;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t TrianglesChunk::GetCount() const
{
return triangles.size();
}
inline uint32_t TrianglesChunk::GetSize() const
{
if (triangles.size() == 0)
return 0;
uint32_t size = sizeof(uint32_t); // count
for (uint32_t i = 0; i < triangles.size(); ++i)
{
const Triangle *triangle = &triangles[i];
size += triangle->GetSize();
}
return size;
}
#endif

34
src/chunks/vertices.h Normal file
View file

@ -0,0 +1,34 @@
#ifndef __CHUNKS_VERTICES_H_INCLUDED__
#define __CHUNKS_VERTICES_H_INCLUDED__
#include "../common.h"
#include "../geometry/vector3.h"
#include <vector>
struct VerticesChunk
{
std::vector<Vector3> vertices;
uint32_t GetCount() const;
uint32_t GetSize() const;
};
inline uint32_t VerticesChunk::GetCount() const
{
return vertices.size();
}
inline uint32_t VerticesChunk::GetSize() const
{
if (vertices.size() == 0)
return 0;
uint32_t verticesSize = sizeof(float) * 3; // xyz
uint32_t size = sizeof(uint32_t); // count
size += verticesSize * vertices.size();
return size;
}
#endif