diff --git a/src/chunks/animations.h b/src/chunks/animations.h new file mode 100644 index 0000000..4f1a8c3 --- /dev/null +++ b/src/chunks/animations.h @@ -0,0 +1,36 @@ +#ifndef __CHUNKS_ANIMATIONS_H_INCLUDED__ +#define __CHUNKS_ANIMATIONS_H_INCLUDED__ + +#include "../common.h" +#include "../assets/animationsequence.h" +#include + +struct AnimationsChunk +{ + std::vector 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 diff --git a/src/chunks/groups.h b/src/chunks/groups.h new file mode 100644 index 0000000..ceb3a1e --- /dev/null +++ b/src/chunks/groups.h @@ -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 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 diff --git a/src/chunks/joints.h b/src/chunks/joints.h new file mode 100644 index 0000000..117623b --- /dev/null +++ b/src/chunks/joints.h @@ -0,0 +1,37 @@ +#ifndef __CHUNKS_JOINTS_H_INCLUDED__ +#define __CHUNKS_JOINTS_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/joint.h" +#include + +struct JointsChunk +{ + std::vector 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 diff --git a/src/chunks/jointtovertices.h b/src/chunks/jointtovertices.h new file mode 100644 index 0000000..4db1f4d --- /dev/null +++ b/src/chunks/jointtovertices.h @@ -0,0 +1,37 @@ +#ifndef __CHUNKS_JOINTTOVERTICES_H_INCLUDED__ +#define __CHUNKS_JOINTTOVERTICES_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/jointvertexinfo.h" +#include + +struct JointToVerticesChunk +{ + std::vector 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 diff --git a/src/chunks/keyframes.h b/src/chunks/keyframes.h new file mode 100644 index 0000000..6d36e1a --- /dev/null +++ b/src/chunks/keyframes.h @@ -0,0 +1,65 @@ +#ifndef __CHUNKS_KEYFRAMES_H_INCLUDED__ +#define __CHUNKS_KEYFRAMES_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/keyframe.h" +#include + +struct KeyframesChunk +{ + KeyframesChunk(uint32_t numJointsPerFrame); + virtual ~KeyframesChunk(); + + uint32_t numJointsPerFrame; + std::vector 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 diff --git a/src/chunks/normals.h b/src/chunks/normals.h new file mode 100644 index 0000000..42aff65 --- /dev/null +++ b/src/chunks/normals.h @@ -0,0 +1,34 @@ +#ifndef __CHUNKS_NORMALS_H_INCLUDED__ +#define __CHUNKS_NORMALS_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/vector3.h" +#include + +struct NormalsChunk +{ + std::vector 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 diff --git a/src/chunks/texcoords.h b/src/chunks/texcoords.h new file mode 100644 index 0000000..249cde5 --- /dev/null +++ b/src/chunks/texcoords.h @@ -0,0 +1,34 @@ +#ifndef __CHUNKS_TEXCOORDS_H_INCLUDED__ +#define __CHUNKS_TEXCOORDS_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/vector2.h" +#include + +struct TexCoordsChunk +{ + std::vector 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 diff --git a/src/chunks/triangles.h b/src/chunks/triangles.h new file mode 100644 index 0000000..6e6e6fb --- /dev/null +++ b/src/chunks/triangles.h @@ -0,0 +1,37 @@ +#ifndef __CHUNKS_TRIANGLES_H_INCLUDED__ +#define __CHUNKS_TRIANGLES_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/triangle.h" +#include + +struct TrianglesChunk +{ + std::vector 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 diff --git a/src/chunks/vertices.h b/src/chunks/vertices.h new file mode 100644 index 0000000..b311c42 --- /dev/null +++ b/src/chunks/vertices.h @@ -0,0 +1,34 @@ +#ifndef __CHUNKS_VERTICES_H_INCLUDED__ +#define __CHUNKS_VERTICES_H_INCLUDED__ + +#include "../common.h" +#include "../geometry/vector3.h" +#include + +struct VerticesChunk +{ + std::vector 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