OpenClonk
Ogre::Mesh::ChunkMesh Class Reference

#include <StdMeshLoaderBinaryChunks.h>

Inheritance diagram for Ogre::Mesh::ChunkMesh:
[legend]
Collaboration diagram for Ogre::Mesh::ChunkMesh:
[legend]

Public Member Functions

 ChunkMesh ()=default
 
Type GetType () const
 
size_t GetSize () const
 

Static Public Member Functions

static std::unique_ptr< ChunkRead (DataStream *stream)
 
static Type Peek (const DataStream *stream)
 

Public Attributes

bool hasAnimatedSkeleton {false}
 
std::string skeletonFile
 
std::unique_ptr< ChunkGeometrygeometry
 
unique_ptr_vector< ChunkSubmeshsubmeshes
 
std::vector< BoneAssignmentboneAssignments
 
StdMeshBox bounds
 
float radius {0.0f}
 

Static Public Attributes

static const size_t ChunkHeaderLength
 

Protected Types

typedef ChunkID Type
 

Protected Member Functions

void ReadImpl (DataStream *stream) override
 

Protected Attributes

Type type
 
size_t size
 

Detailed Description

Definition at line 381 of file StdMeshLoaderBinaryChunks.h.

Member Typedef Documentation

◆ Type

typedef ChunkID Ogre::ChunkBase< ChunkID >::Type
protectedinherited

Definition at line 286 of file StdMeshLoaderBinaryChunks.h.

Constructor & Destructor Documentation

◆ ChunkMesh()

Ogre::Mesh::ChunkMesh::ChunkMesh ( )
default

Member Function Documentation

◆ GetSize()

◆ GetType()

Type Ogre::ChunkBase< ChunkID >::GetType ( ) const
inlineinherited

◆ Peek()

◆ Read()

std::unique_ptr< Chunk > Ogre::Mesh::Chunk::Read ( DataStream stream)
staticinherited

Definition at line 42 of file StdMeshLoaderBinaryChunks.cpp.

References Ogre::ChunkBase< ChunkID >::ChunkHeaderLength, Ogre::Mesh::CID_Edge_List, Ogre::Mesh::CID_Geometry, Ogre::Mesh::CID_Geometry_Vertex_Buffer, Ogre::Mesh::CID_Geometry_Vertex_Data, Ogre::Mesh::CID_Geometry_Vertex_Decl, Ogre::Mesh::CID_Geometry_Vertex_Decl_Element, Ogre::Mesh::CID_Header, Ogre::Mesh::CID_Invalid, Ogre::Mesh::CID_Mesh, Ogre::Mesh::CID_Mesh_Bone_Assignment, Ogre::Mesh::CID_Mesh_Bounds, Ogre::Mesh::CID_Mesh_Skeleton_Link, Ogre::Mesh::CID_Submesh, Ogre::Mesh::CID_Submesh_Bone_Assignment, Ogre::Mesh::CID_Submesh_Name_Table, Ogre::Mesh::CID_Submesh_Op, Ogre::DataStream::GetRemainingBytes(), LogF(), Ogre::DataStream::Read(), and Ogre::ChunkBase< ChunkID >::size.

Referenced by StdMeshLoader::LoadMeshBinary(), ReadImpl(), Ogre::Mesh::ChunkSubmesh::ReadImpl(), Ogre::Mesh::ChunkGeometry::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexDecl::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexBuffer::ReadImpl(), Ogre::Skeleton::ChunkAnimation::ReadImpl(), and Ogre::Skeleton::ChunkAnimationTrack::ReadImpl().

43  {
44  assert(stream->GetRemainingBytes() >= ChunkHeaderLength);
45 
46  // Read metadata
47  ChunkID id = CID_Invalid;
48  id = static_cast<ChunkID>(stream->Read<uint16_t>());
49  size_t size = 0;
50  // Special case: CID_Header doesn't have any size info.
51  if (id != CID_Header)
52  {
53  // All others are proper chunks.
54  size = stream->Read<uint32_t>();
55  size -= ChunkHeaderLength;
56  }
57 
58  // Create chunk
59  std::unique_ptr<Chunk> chunk;
60  switch (id)
61  {
62  case CID_Header: chunk = std::make_unique<Ogre::Mesh::ChunkFileHeader>(); break;
63  case CID_Mesh: chunk = std::make_unique<Ogre::Mesh::ChunkMesh>(); break;
66  chunk = std::make_unique<Ogre::Mesh::ChunkMeshBoneAssignments>(); break;
67  case CID_Mesh_Skeleton_Link: chunk = std::make_unique<Ogre::Mesh::ChunkMeshSkeletonLink>(); break;
68  case CID_Mesh_Bounds: chunk = std::make_unique<Ogre::Mesh::ChunkMeshBounds>(); break;
69  case CID_Submesh: chunk = std::make_unique<Ogre::Mesh::ChunkSubmesh>(); break;
70  case CID_Submesh_Op: chunk = std::make_unique<Ogre::Mesh::ChunkSubmeshOp>(); break;
71  case CID_Geometry: chunk = std::make_unique<Ogre::Mesh::ChunkGeometry>(); break;
72  case CID_Geometry_Vertex_Buffer: chunk = std::make_unique<Ogre::Mesh::ChunkGeometryVertexBuffer>(); break;
73  case CID_Geometry_Vertex_Data: chunk = std::make_unique<Ogre::Mesh::ChunkGeometryVertexData>(); break;
74  case CID_Geometry_Vertex_Decl: chunk = std::make_unique<Ogre::Mesh::ChunkGeometryVertexDecl>(); break;
75  case CID_Geometry_Vertex_Decl_Element: chunk = std::make_unique<Ogre::Mesh::ChunkGeometryVertexDeclElement>(); break;
76  default:
77  LogF("StdMeshLoader: I don't know what to do with a chunk of type 0x%xu", id);
78  // Fall through
80  // We don't care about these
81  chunk = std::make_unique<Ogre::Mesh::ChunkUnknown>(); break;
82  };
83  chunk->type = id;
84  chunk->size = size;
85  chunk->ReadImpl(stream);
86  return chunk;
87  }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadImpl()

void Ogre::Mesh::ChunkMesh::ReadImpl ( DataStream stream)
overrideprotectedvirtual

Implements Ogre::ChunkBase< ChunkID >.

Definition at line 99 of file StdMeshLoaderBinaryChunks.cpp.

References Ogre::Mesh::ChunkMeshBoneAssignments::assignments, Ogre::DataStream::AtEof(), Ogre::Mesh::CID_Animation_List, Ogre::Mesh::CID_Edge_List, Ogre::Mesh::CID_Geometry, Ogre::Mesh::CID_Mesh_Bone_Assignment, Ogre::Mesh::CID_Mesh_Bounds, Ogre::Mesh::CID_Mesh_LOD, Ogre::Mesh::CID_Mesh_Skeleton_Link, Ogre::Mesh::CID_Pose_List, Ogre::Mesh::CID_Submesh, Ogre::Mesh::CID_Submesh_Name_Table, LogF(), Ogre::ChunkBase< ChunkID >::Peek(), Ogre::DataStream::Read(), Ogre::Mesh::Chunk::Read(), and static_unique_cast().

100  {
101  hasAnimatedSkeleton = stream->Read<bool>();
102  for (ChunkID id = Chunk::Peek(stream);
104  id = Chunk::Peek(stream)
105  )
106  {
107  std::unique_ptr<Chunk> chunk = Chunk::Read(stream);
108  switch (chunk->GetType())
109  {
110  case CID_Geometry:
111  if (geometry)
112  throw MultipleSingletonChunks("There's only one CID_Geometry chunk allowed within a CID_Mesh chunk");
113  geometry = static_unique_cast<ChunkGeometry>(move(chunk));
114  break;
115  case CID_Submesh:
116  submeshes.push_back(static_unique_cast<ChunkSubmesh>(move(chunk)));
117  break;
119  if (!skeletonFile.empty())
120  throw MultipleSingletonChunks("There's only one CID_Mesh_Skeleton_Link chunk allowed within a CID_Mesh chunk");
121  skeletonFile = static_cast<ChunkMeshSkeletonLink*>(chunk.get())->skeleton;
122  break;
123  case CID_Mesh_Bounds:
124  bounds = static_cast<ChunkMeshBounds*>(chunk.get())->bounds;
125  radius = static_cast<ChunkMeshBounds*>(chunk.get())->radius;
126  break;
128  // Collect bone assignments
129  {
130  ChunkMeshBoneAssignments *assignments = static_cast<ChunkMeshBoneAssignments*>(chunk.get());
131  boneAssignments.insert(boneAssignments.end(), assignments->assignments.begin(), assignments->assignments.end());
132  break;
133  }
134  default:
135  LogF("StdMeshLoader: I don't know what to do with a chunk of type 0x%xu inside a CID_Mesh chunk", chunk->GetType());
136  // Fall through
138  case CID_Edge_List:
139  // Ignore those
140  break;
141  }
142  if (stream->AtEof()) break;
143  }
144  }
std::unique_ptr< ChunkGeometry > geometry
static Type Peek(const DataStream *stream)
std::unique_ptr< To > static_unique_cast(From &&p)
unique_ptr_vector< ChunkSubmesh > submeshes
std::vector< BoneAssignment > boneAssignments
static std::unique_ptr< Chunk > Read(DataStream *stream)
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260
Here is the call graph for this function:

Member Data Documentation

◆ boneAssignments

std::vector<BoneAssignment> Ogre::Mesh::ChunkMesh::boneAssignments

Definition at line 389 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary().

◆ bounds

StdMeshBox Ogre::Mesh::ChunkMesh::bounds

Definition at line 390 of file StdMeshLoaderBinaryChunks.h.

◆ ChunkHeaderLength

const size_t Ogre::ChunkBase< ChunkID >::ChunkHeaderLength
staticinherited

◆ geometry

std::unique_ptr<ChunkGeometry> Ogre::Mesh::ChunkMesh::geometry

Definition at line 387 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary().

◆ hasAnimatedSkeleton

bool Ogre::Mesh::ChunkMesh::hasAnimatedSkeleton {false}

Definition at line 385 of file StdMeshLoaderBinaryChunks.h.

◆ radius

float Ogre::Mesh::ChunkMesh::radius {0.0f}

Definition at line 391 of file StdMeshLoaderBinaryChunks.h.

◆ size

size_t Ogre::ChunkBase< ChunkID >::size
protectedinherited

◆ skeletonFile

std::string Ogre::Mesh::ChunkMesh::skeletonFile

Definition at line 386 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary().

◆ submeshes

unique_ptr_vector<ChunkSubmesh> Ogre::Mesh::ChunkMesh::submeshes

Definition at line 388 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary().

◆ type

Type Ogre::ChunkBase< ChunkID >::type
protectedinherited

The documentation for this class was generated from the following files: