OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Ogre::Mesh::ChunkSubmesh Class Reference

#include <StdMeshLoaderBinaryChunks.h>

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

Public Types

enum  SubmeshOperation {
  SO_PointList = 1, SO_LineList = 2, SO_LineStrip = 3, SO_TriList = 4,
  SO_TriStrip = 5, SO_TriFan = 6, SO_MIN = SO_PointList, SO_MAX = SO_TriFan
}
 

Public Member Functions

 ChunkSubmesh ()=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

std::string material
 
bool hasSharedVertices
 
std::vector< size_t > faceVertices
 
std::unique_ptr< ChunkGeometrygeometry
 
enum
Ogre::Mesh::ChunkSubmesh::SubmeshOperation 
SO_TriList
 
std::vector< BoneAssignmentboneAssignments
 

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 405 of file StdMeshLoaderBinaryChunks.h.

Member Typedef Documentation

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

Definition at line 286 of file StdMeshLoaderBinaryChunks.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

Ogre::Mesh::ChunkSubmesh::ChunkSubmesh ( )
default

Member Function Documentation

size_t Ogre::ChunkBase< ChunkID >::GetSize ( ) const
inlineinherited

Definition at line 292 of file StdMeshLoaderBinaryChunks.h.

References Ogre::ChunkBase< _Type >::size.

Referenced by Ogre::Mesh::ChunkUnknown::ReadImpl(), Ogre::Mesh::ChunkMeshBoneAssignments::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexData::ReadImpl(), Ogre::Skeleton::ChunkUnknown::ReadImpl(), Ogre::Skeleton::ChunkBone::ReadImpl(), and Ogre::Skeleton::ChunkAnimationTrackKF::ReadImpl().

Here is the caller graph for this function:

Type Ogre::ChunkBase< ChunkID >::GetType ( ) const
inlineinherited
static Type Ogre::ChunkBase< ChunkID >::Peek ( const DataStream stream)
inlinestaticinherited

Definition at line 295 of file StdMeshLoaderBinaryChunks.h.

References Ogre::DataStream::Peek().

Referenced by StdMeshSkeletonLoader::LoadSkeletonBinary(), Ogre::Mesh::ChunkMesh::ReadImpl(), ReadImpl(), Ogre::Mesh::ChunkGeometry::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexDecl::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexBuffer::ReadImpl(), Ogre::Skeleton::ChunkAnimation::ReadImpl(), and Ogre::Skeleton::ChunkAnimationTrack::ReadImpl().

296  {
297  return static_cast<Type>(stream->Peek<uint16_t>());
298  }

Here is the call graph for this function:

Here is the caller graph for this function:

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(), Ogre::Mesh::ChunkMesh::ReadImpl(), ReadImpl(), Ogre::Mesh::ChunkGeometry::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexDecl::ReadImpl(), and Ogre::Mesh::ChunkGeometryVertexBuffer::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:250

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements Ogre::ChunkBase< ChunkID >.

Definition at line 151 of file StdMeshLoaderBinaryChunks.cpp.

References Ogre::Mesh::ChunkMeshBoneAssignments::assignments, Ogre::DataStream::AtEof(), boneAssignments, Ogre::Mesh::CID_Geometry, Ogre::Mesh::CID_Submesh_Bone_Assignment, Ogre::Mesh::CID_Submesh_Op, faceVertices, geometry, hasSharedVertices, LogF(), material, Ogre::ChunkBase< ChunkID >::Peek(), Ogre::DataStream::Read(), Ogre::Mesh::Chunk::Read(), SO_TriList, and static_unique_cast().

152  {
153  operation = SO_TriList; // default if no CID_Submesh_Op chunk exists
154  material = stream->Read<std::string>();
155  hasSharedVertices = stream->Read<bool>();
156  size_t index_count = stream->Read<uint32_t>();
157  bool indexes_are_32bit = stream->Read<bool>();
158  faceVertices.reserve(index_count);
159  while (index_count--)
160  {
161  size_t index;
162  if (indexes_are_32bit)
163  index = stream->Read<uint32_t>();
164  else
165  index = stream->Read<uint16_t>();
166  faceVertices.push_back(index);
167  }
168  for (ChunkID id = Chunk::Peek(stream);
170  id = Chunk::Peek(stream)
171  )
172  {
173  std::unique_ptr<Chunk> chunk = Chunk::Read(stream);
174 
175  switch (chunk->GetType())
176  {
177  case CID_Geometry:
178  if (hasSharedVertices)
179  // Can't have own vertices and at the same time use those of the parent
180  throw SharedVertexGeometryForbidden();
181  if (geometry)
182  throw MultipleSingletonChunks("There's only one CID_Geometry chunk allowed within a CID_Submesh chunk");
183  geometry = static_unique_cast<ChunkGeometry>(move(chunk));
184  break;
185  case CID_Submesh_Op:
186  operation = static_cast<ChunkSubmeshOp*>(chunk.get())->operation;
187  break;
189  {
190  // Collect bone assignments
191  ChunkMeshBoneAssignments *assignments = static_cast<ChunkMeshBoneAssignments*>(chunk.get());
192  boneAssignments.insert(boneAssignments.end(), assignments->assignments.begin(), assignments->assignments.end());
193  }
194  break;
195  default:
196  LogF("StdMeshLoader: I don't know what to do with a chunk of type 0x%xu inside a CID_Submesh chunk", chunk->GetType());
197  break;
198  }
199  if (stream->AtEof()) break;
200  }
201  }
static Type Peek(const DataStream *stream)
std::unique_ptr< To > static_unique_cast(From &&p)
std::unique_ptr< ChunkGeometry > geometry
std::vector< BoneAssignment > boneAssignments
enum Ogre::Mesh::ChunkSubmesh::SubmeshOperation SO_TriList
static std::unique_ptr< Chunk > Read(DataStream *stream)
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250
std::vector< size_t > faceVertices

Here is the call graph for this function:

Member Data Documentation

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

Definition at line 424 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary(), and ReadImpl().

const size_t Ogre::ChunkBase< ChunkID >::ChunkHeaderLength
staticinherited
std::vector<size_t> Ogre::Mesh::ChunkSubmesh::faceVertices

Definition at line 411 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary(), and ReadImpl().

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

Definition at line 412 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary(), and ReadImpl().

bool Ogre::Mesh::ChunkSubmesh::hasSharedVertices

Definition at line 410 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary(), and ReadImpl().

std::string Ogre::Mesh::ChunkSubmesh::material

Definition at line 409 of file StdMeshLoaderBinaryChunks.h.

Referenced by StdMeshLoader::LoadMeshBinary(), and ReadImpl().

size_t Ogre::ChunkBase< ChunkID >::size
protectedinherited
enum Ogre::Mesh::ChunkSubmesh::SubmeshOperation Ogre::Mesh::ChunkSubmesh::SO_TriList
Type Ogre::ChunkBase< ChunkID >::type
protectedinherited

Definition at line 287 of file StdMeshLoaderBinaryChunks.h.


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