Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::SkeletalModel Class Reference

Graphics class that represents a model with a skeleton. More...

Inheritance diagram for Nz::SkeletalModel:
Nz::Model Nz::InstancedRenderable Nz::Resource Nz::RefCounted

Public Member Functions

 SkeletalModel ()
 Constructs a SkeletalModel object by default.
 
 SkeletalModel (const SkeletalModel &model)=default
 
 SkeletalModel (SkeletalModel &&model)=default
 
void AddToRenderQueue (AbstractRenderQueue *renderQueue, const InstanceData &instanceData) const override
 Adds the skeletal mesh to the rendering queue. More...
 
void AdvanceAnimation (float elapsedTime)
 Updates the animation of the mesh. More...
 
SkeletalModelClone () const
 Clones this skeletal model. More...
 
SkeletalModelCreate () const
 Creates a default skeletal model. More...
 
void EnableAnimation (bool animation)
 Enables the animation of the model. More...
 
Animation * GetAnimation () const
 Gets the animation of the model. More...
 
Skeleton * GetSkeleton ()
 Gets the skeleton of the model. More...
 
const Skeleton * GetSkeleton () const
 Gets the skeleton of the model. More...
 
bool HasAnimation () const
 Checks whether the skeleton has an animation. More...
 
bool IsAnimated () const override
 Checks whether the skeleton is animated. More...
 
bool IsAnimationEnabled () const
 Checks whether the skeleton is currently animated. More...
 
bool LoadFromFile (const String &filePath, const SkeletalModelParameters &params=SkeletalModelParameters())
 Loads the skeleton model from file. More...
 
bool LoadFromMemory (const void *data, std::size_t size, const SkeletalModelParameters &params=SkeletalModelParameters())
 Loads the skeleton model from memory. More...
 
bool LoadFromStream (Stream &stream, const SkeletalModelParameters &params=SkeletalModelParameters())
 Loads the skeleton model from stream. More...
 
bool SetAnimation (Animation *animation)
 Sets the animation for the model. More...
 
void SetMesh (Mesh *mesh) override
 Sets the mesh for the model. More...
 
bool SetSequence (const String &sequenceName)
 Sets the sequence for the model. More...
 
void SetSequence (unsigned int sequenceIndex)
 Sets the sequence for the model. More...
 
SkeletalModeloperator= (const SkeletalModel &node)=default
 
SkeletalModeloperator= (SkeletalModel &&node)=default
 
- Public Member Functions inherited from Nz::Model
 Model ()
 Constructs a Model object by default.
 
 Model (const Model &model)=default
 
 Model (Model &&model)=default
 
virtual ~Model ()
 Destructs the object and cleans resources.
 
void AddToRenderQueue (AbstractRenderQueue *renderQueue, const Matrix4f &transformMatrix, unsigned int renderOrder=0)
 Adds this model to a render queue, using user-specified transform matrix and render order. More...
 
const MaterialRefGetMaterial (const String &subMeshName) const
 Gets the material of the named submesh. More...
 
const MaterialRefGetMaterial (std::size_t skinIndex, const String &subMeshName) const
 Gets the material by index of the named submesh. More...
 
Mesh * GetMesh () const
 Gets the mesh. More...
 
bool LoadFromFile (const String &filePath, const ModelParameters &params=ModelParameters())
 Loads the model from file. More...
 
bool LoadFromMemory (const void *data, std::size_t size, const ModelParameters &params=ModelParameters())
 Loads the model from memory. More...
 
bool LoadFromStream (Stream &stream, const ModelParameters &params=ModelParameters())
 Loads the model from stream. More...
 
bool SetMaterial (const String &subMeshName, MaterialRef material)
 Sets the material of the named submesh. More...
 
bool SetMaterial (std::size_t skinIndex, const String &subMeshName, MaterialRef material)
 Sets the material by index of the named submesh. More...
 
Modeloperator= (const Model &node)=default
 
Modeloperator= (Model &&node)=default
 
- Public Member Functions inherited from Nz::InstancedRenderable
 InstancedRenderable ()
 Constructs a InstancedRenderable object by default.
 
 InstancedRenderable (const InstancedRenderable &renderable)
 Constructs a InstancedRenderable object by assignation. More...
 
 InstancedRenderable (InstancedRenderable &&renderable)=delete
 
virtual ~InstancedRenderable ()
 Destructs the object and calls OnInstancedRenderableRelease. More...
 
virtual bool Cull (const Frustumf &frustum, const InstanceData &instanceData) const
 Culls the instanced if not in the frustum. More...
 
void EnsureBoundingVolumeUpdated () const
 Ensures that the bounding volume is up to date.
 
virtual const BoundingVolumefGetBoundingVolume () const
 Gets the bounding volume. More...
 
const MaterialRefGetMaterial (std::size_t matIndex=0) const
 Gets one of the material used by the object. More...
 
const MaterialRefGetMaterial (std::size_t skinIndex, std::size_t matIndex) const
 Gets one of the material used by the object, independently from the active skin. More...
 
std::size_t GetMaterialCount () const
 Gets the number of material per skin. More...
 
std::size_t GetSkin () const
 Gets the current active skin index. More...
 
std::size_t GetSkinCount () const
 Gets the number of skins this object has. More...
 
virtual void InvalidateData (InstanceData *instanceData, UInt32 flags) const
 Invalidates data for instanced. More...
 
void SetSkin (std::size_t skinIndex)
 Changes the active skin. More...
 
void SetSkinCount (std::size_t skinCount)
 Changes the maximum skin count of the object. More...
 
virtual void UpdateBoundingVolume (InstanceData *instanceData) const
 Updates the bounding volume. More...
 
virtual void UpdateData (InstanceData *instanceData) const
 Updates the instance data. More...
 
InstancedRenderableoperator= (const InstancedRenderable &renderable)
 Sets the current instanced renderable with the content of the other one. More...
 
InstancedRenderableoperator= (InstancedRenderable &&renderable)=delete
 
 NazaraSignal (OnInstancedRenderableInvalidateBoundingVolume, const InstancedRenderable *)
 
 NazaraSignal (OnInstancedRenderableInvalidateData, const InstancedRenderable *, UInt32)
 
 NazaraSignal (OnInstancedRenderableInvalidateMaterial, const InstancedRenderable *, std::size_t, std::size_t, const MaterialRef &)
 
 NazaraSignal (OnInstancedRenderableRelease, const InstancedRenderable *)
 
 NazaraSignal (OnInstancedRenderableResetMaterials, const InstancedRenderable *, std::size_t)
 
 NazaraSignal (OnInstancedRenderableSkinChange, const InstancedRenderable *, std::size_t)
 
- Public Member Functions inherited from Nz::RefCounted
 RefCounted (bool persistent=true)
 Constructs a RefCounted object with a persistance aspect. More...
 
 RefCounted (const RefCounted &)=delete
 
 RefCounted (RefCounted &&)=default
 
virtual ~RefCounted ()
 Destructs the object. More...
 
void AddReference () const
 Adds a reference to the object.
 
unsigned int GetReferenceCount () const
 Gets the number of references to the object. More...
 
bool IsPersistent () const
 Checks whether the object is persistent. More...
 
bool RemoveReference () const
 Removes a reference to the object. More...
 
bool SetPersistent (bool persistent=true, bool checkReferenceCount=false)
 Sets the persistence of the object. More...
 
RefCountedoperator= (const RefCounted &)=delete
 
RefCountedoperator= (RefCounted &&)=default
 
- Public Member Functions inherited from Nz::Resource
 Resource (const Resource &)=default
 
 Resource (Resource &&) noexcept=default
 
const StringGetFilePath () const
 Gets the file path associated with the resource. More...
 
void SetFilePath (const String &filePath)
 Sets the file path associated with the resource. More...
 
Resourceoperator= (const Resource &)=default
 
Resourceoperator= (Resource &&) noexcept=default
 

Additional Inherited Members

- Static Public Member Functions inherited from Nz::Model
template<typename... Args>
static ModelRef New (Args &&... args)
 Creates a new Model from the arguments. More...
 
- Protected Member Functions inherited from Nz::InstancedRenderable
void InvalidateBoundingVolume ()
 Invalidates the bounding volume.
 
void InvalidateInstanceData (UInt32 flags)
 Invalidates the instance data based on flags. More...
 
void ResetMaterials (std::size_t matCount, std::size_t skinCount=1)
 Resets the materials, material count and skin count. More...
 
void SetMaterial (std::size_t matIndex, MaterialRef material)
 Changes the material used at the specified index by another one. More...
 
void SetMaterial (std::size_t skinIndex, std::size_t matIndex, MaterialRef material)
 Changes the material used at the specified index by another one, independently from the active skin. More...
 
- Protected Attributes inherited from Nz::Model
MeshRef m_mesh
 
- Protected Attributes inherited from Nz::InstancedRenderable
BoundingVolumef m_boundingVolume
 
- Static Protected Attributes inherited from Nz::Model
static ModelLoader::LoaderList s_loaders
 

Detailed Description

Graphics class that represents a model with a skeleton.

Member Function Documentation

◆ AddToRenderQueue()

void Nz::SkeletalModel::AddToRenderQueue ( AbstractRenderQueue renderQueue,
const InstanceData &  instanceData 
) const
overridevirtual

Adds the skeletal mesh to the rendering queue.

Parameters
renderQueueQueue to be added
instanceDataData for the instance

Reimplemented from Nz::Model.

◆ AdvanceAnimation()

void Nz::SkeletalModel::AdvanceAnimation ( float  elapsedTime)

Updates the animation of the mesh.

Parameters
elapsedTimeDelta time between two frames
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if there is no animation

◆ Clone()

SkeletalModel * Nz::SkeletalModel::Clone ( ) const

Clones this skeletal model.

Returns
Pointer to newly allocated SkeletalModel

◆ Create()

SkeletalModel * Nz::SkeletalModel::Create ( ) const

Creates a default skeletal model.

Returns
Pointer to newly allocated SkeletalModel

◆ EnableAnimation()

void Nz::SkeletalModel::EnableAnimation ( bool  animation)

Enables the animation of the model.

Parameters
animationShould the model be animated

◆ GetAnimation()

Animation * Nz::SkeletalModel::GetAnimation ( ) const

Gets the animation of the model.

Returns
Pointer to the animation

◆ GetSkeleton() [1/2]

Skeleton * Nz::SkeletalModel::GetSkeleton ( )

Gets the skeleton of the model.

Returns
Pointer to the skeleton

◆ GetSkeleton() [2/2]

const Skeleton * Nz::SkeletalModel::GetSkeleton ( ) const

Gets the skeleton of the model.

Returns
Constant pointer to the skeleton

◆ HasAnimation()

bool Nz::SkeletalModel::HasAnimation ( ) const

Checks whether the skeleton has an animation.

Returns
true If it is the case
See also
IsAnimated, IsAnimationEnabled

◆ IsAnimated()

bool Nz::SkeletalModel::IsAnimated ( ) const
overridevirtual

Checks whether the skeleton is animated.

Returns
true
See also
HasAnimation, IsAnimationEnabled

Reimplemented from Nz::Model.

◆ IsAnimationEnabled()

bool Nz::SkeletalModel::IsAnimationEnabled ( ) const

Checks whether the skeleton is currently animated.

Returns
true If it is the case
See also
HasAnimation, IsAnimated

◆ LoadFromFile()

bool Nz::SkeletalModel::LoadFromFile ( const String filePath,
const SkeletalModelParameters &  params = SkeletalModelParameters() 
)

Loads the skeleton model from file.

Returns
true if loading is successful
Parameters
filePathPath to the file
paramsParameters for the skeleton model

◆ LoadFromMemory()

bool Nz::SkeletalModel::LoadFromMemory ( const void *  data,
std::size_t  size,
const SkeletalModelParameters &  params = SkeletalModelParameters() 
)

Loads the skeleton model from memory.

Returns
true if loading is successful
Parameters
dataRaw memory
sizeSize of the memory
paramsParameters for the skeleton model

◆ LoadFromStream()

bool Nz::SkeletalModel::LoadFromStream ( Stream stream,
const SkeletalModelParameters &  params = SkeletalModelParameters() 
)

Loads the skeleton model from stream.

Returns
true if loading is successful
Parameters
streamStream to the skeleton model
paramsParameters for the skeleton model

◆ SetAnimation()

bool Nz::SkeletalModel::SetAnimation ( Animation *  animation)

Sets the animation for the model.

Returns
true If successful
Parameters
animationAnimation for the model
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if animation is invalid

◆ SetMesh()

void Nz::SkeletalModel::SetMesh ( Mesh *  mesh)
overridevirtual

Sets the mesh for the model.

Parameters
meshMesh for the model
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh or if invalid

Reimplemented from Nz::Model.

◆ SetSequence() [1/2]

bool Nz::SkeletalModel::SetSequence ( const String sequenceName)

Sets the sequence for the model.

Returns
true If successful
Parameters
sequenceNameName for the sequence animation
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation

TODO: Make this error "safe" with the new system of error handling (No-log)

◆ SetSequence() [2/2]

void Nz::SkeletalModel::SetSequence ( unsigned int  sequenceIndex)

Sets the sequence for the model.

Parameters
sequenceIndexIndex for the sequence animation
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation

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