OpenClonk
Ogre::Skeleton::ChunkAnimation Class Reference

#include <StdMeshLoaderBinaryChunks.h>

Inheritance diagram for Ogre::Skeleton::ChunkAnimation:
[legend]
Collaboration diagram for Ogre::Skeleton::ChunkAnimation:
[legend]

Public Member Functions

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 name
 
float duration
 
unique_ptr_vector< ChunkAnimationTracktracks
 

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

Member Typedef Documentation

◆ Type

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

Definition at line 286 of file StdMeshLoaderBinaryChunks.h.

Member Function Documentation

◆ GetSize()

◆ GetType()

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

◆ Peek()

◆ Read()

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

Definition at line 322 of file StdMeshLoaderBinaryChunks.cpp.

References Ogre::ChunkBase< ChunkID >::ChunkHeaderLength, Ogre::Mesh::CID_Animation, Ogre::Skeleton::CID_Animation_BaseInfo, Ogre::Skeleton::CID_Animation_Link, Ogre::Mesh::CID_Animation_Track, Ogre::Skeleton::CID_Animation_Track_KF, Ogre::Skeleton::CID_BlendMode, Ogre::Skeleton::CID_Bone, Ogre::Skeleton::CID_Bone_Parent, Ogre::Mesh::CID_Header, Ogre::Mesh::CID_Invalid, Ogre::DataStream::GetRemainingBytes(), LogF(), Ogre::DataStream::Read(), and Ogre::ChunkBase< ChunkID >::size.

Referenced by StdMeshSkeletonLoader::LoadSkeletonBinary().

323  {
324  assert(stream->GetRemainingBytes() >= ChunkHeaderLength);
325 
326  // Read metadata
327  ChunkID id = CID_Invalid;
328  id = static_cast<ChunkID>(stream->Read<uint16_t>());
329  size_t size = 0;
330  // Special case: CID_Header doesn't have any size info.
331  if (id != CID_Header)
332  {
333  // All others are proper chunks.
334  size = stream->Read<uint32_t>();
335  size -= ChunkHeaderLength;
336  }
337 
338  // Create chunk
339  std::unique_ptr<Chunk> chunk;
340  switch (id)
341  {
342  case CID_Header: chunk = std::make_unique<Ogre::Skeleton::ChunkFileHeader>(); break;
343  case CID_BlendMode: chunk = std::make_unique<Ogre::Skeleton::ChunkBlendMode>(); break;
344  case CID_Bone: chunk = std::make_unique<Ogre::Skeleton::ChunkBone>(); break;
345  case CID_Bone_Parent: chunk = std::make_unique<Ogre::Skeleton::ChunkBoneParent>(); break;
346  case CID_Animation: chunk = std::make_unique<Ogre::Skeleton::ChunkAnimation>(); break;
347  case CID_Animation_BaseInfo: chunk = std::make_unique<Ogre::Skeleton::ChunkAnimationBaseInfo>(); break;
348  case CID_Animation_Track: chunk = std::make_unique<Ogre::Skeleton::ChunkAnimationTrack>(); break;
349  case CID_Animation_Track_KF: chunk = std::make_unique<Ogre::Skeleton::ChunkAnimationTrackKF>(); break;
350  case CID_Animation_Link: chunk = std::make_unique<Ogre::Skeleton::ChunkAnimationLink>(); break;
351  default:
352  LogF("StdMeshLoader: I don't know what to do with a chunk of type 0x%xu", id);
353  chunk = std::make_unique<Ogre::Skeleton::ChunkUnknown>(); break;
354  };
355  chunk->type = id;
356  chunk->size = size;
357  chunk->ReadImpl(stream);
358  return chunk;
359  }
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::Skeleton::ChunkAnimation::ReadImpl ( DataStream stream)
overrideprotectedvirtual

Implements Ogre::ChunkBase< ChunkID >.

Definition at line 406 of file StdMeshLoaderBinaryChunks.cpp.

References Ogre::DataStream::AtEof(), Ogre::Skeleton::CID_Animation_BaseInfo, Ogre::Mesh::CID_Animation_Track, LogF(), Ogre::ChunkBase< ChunkID >::Peek(), Ogre::DataStream::Read(), and Ogre::Mesh::Chunk::Read().

407  {
408  name = stream->Read<std::string>();
409  duration = stream->Read<float>();
410 
411  if(!stream->AtEof() && Chunk::Peek(stream) == CID_Animation_BaseInfo)
412  {
413  std::unique_ptr<Chunk> chunk = Chunk::Read(stream);
414  assert(chunk->GetType() == CID_Animation_BaseInfo);
415  // TODO: Handle it
416  LogF("StdMeshLoader: CID_Animation_BaseInfo not implemented. Skeleton might not be imported properly.");
417  }
418 
419  while (!stream->AtEof() && Chunk::Peek(stream) == CID_Animation_Track)
420  {
421  std::unique_ptr<Chunk> chunk = Chunk::Read(stream);
422  assert(chunk->GetType() == CID_Animation_Track);
423  tracks.push_back(static_unique_cast<ChunkAnimationTrack>(move(chunk)));
424  }
425  }
static Type Peek(const DataStream *stream)
unique_ptr_vector< ChunkAnimationTrack > tracks
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260
static std::unique_ptr< Chunk > Read(DataStream *stream)
Here is the call graph for this function:

Member Data Documentation

◆ ChunkHeaderLength

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

◆ duration

float Ogre::Skeleton::ChunkAnimation::duration

Definition at line 612 of file StdMeshLoaderBinaryChunks.h.

◆ name

std::string Ogre::Skeleton::ChunkAnimation::name

Definition at line 611 of file StdMeshLoaderBinaryChunks.h.

◆ size

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

◆ tracks

unique_ptr_vector<ChunkAnimationTrack> Ogre::Skeleton::ChunkAnimation::tracks

Definition at line 613 of file StdMeshLoaderBinaryChunks.h.

◆ type

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

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