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

Graphics class that represents a model. More...

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

Public Member Functions

 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 InstanceData &instanceData) const override
 Adds this model to the render queue. More...
 
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...
 
virtual bool IsAnimated () const
 Checks whether the model is animated. 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...
 
virtual void SetMesh (Mesh *mesh)
 Sets the mesh. 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
 

Static Public Member Functions

template<typename... Args>
static ModelRef New (Args &&... args)
 Creates a new Model from the arguments. More...
 

Protected Member Functions

void MakeBoundingVolume () const override
 
- 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

MeshRef m_mesh
 
- Protected Attributes inherited from Nz::InstancedRenderable
BoundingVolumef m_boundingVolume
 

Static Protected Attributes

static ModelLoader::LoaderList s_loaders
 

Detailed Description

Graphics class that represents a model.

Member Function Documentation

◆ AddToRenderQueue() [1/2]

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

Adds this model to the render queue.

Parameters
renderQueueQueue to be added
instanceDataData used for this instance

Implements Nz::InstancedRenderable.

Reimplemented in Nz::SkeletalModel.

◆ AddToRenderQueue() [2/2]

void Nz::Model::AddToRenderQueue ( AbstractRenderQueue renderQueue,
const Matrix4f transformMatrix,
unsigned int  renderOrder = 0 
)
inline

Adds this model to a render queue, using user-specified transform matrix and render order.

This can be useful when drawing particles

Parameters
renderQueueQueue to be added
transformMatrixTransform matrix to be used for rendering the model
renderOrderSpecify the renderqueue layer to be used

◆ GetMaterial() [1/2]

const MaterialRef & Nz::Model::GetMaterial ( const String subMeshName) const

Gets the material of the named submesh.

Returns
Pointer to the current material
Parameters
subMeshNameName of the subMesh
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh
Produces a NazaraError if there is no subMesh with that name
Produces a NazaraError if material is invalid

◆ GetMaterial() [2/2]

const MaterialRef & Nz::Model::GetMaterial ( std::size_t  skinIndex,
const String subMeshName 
) const

Gets the material by index of the named submesh.

Returns
Pointer to the current material
Parameters
skinIndexIndex of the skin
subMeshNameName of the subMesh
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid
Produces a NazaraError if there is no subMesh with that name
Produces a NazaraError if material index is invalid

◆ GetMesh()

Mesh * Nz::Model::GetMesh ( ) const

Gets the mesh.

Returns
Current mesh

◆ IsAnimated()

bool Nz::Model::IsAnimated ( ) const
virtual

Checks whether the model is animated.

Returns
false

Reimplemented in Nz::SkeletalModel.

◆ LoadFromFile()

bool Nz::Model::LoadFromFile ( const String filePath,
const ModelParameters &  params = ModelParameters() 
)

Loads the model from file.

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

◆ LoadFromMemory()

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

Loads the model from memory.

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

◆ LoadFromStream()

bool Nz::Model::LoadFromStream ( Stream stream,
const ModelParameters &  params = ModelParameters() 
)

Loads the model from stream.

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

◆ New()

template<typename... Args>
ModelRef Nz::Model::New ( Args &&...  args)
static

Creates a new Model from the arguments.

Returns
A reference to the newly created model
Parameters
argsArguments for the model

◆ SetMaterial() [1/2]

bool Nz::Model::SetMaterial ( const String subMeshName,
MaterialRef  material 
)

Sets the material of the named submesh.

Returns
true If successful
Parameters
subMeshNameName of the subMesh
materialPointer to the material
Remarks
Produces a NazaraError if there is no subMesh with that name
Produces a NazaraError if material index is invalid

◆ SetMaterial() [2/2]

bool Nz::Model::SetMaterial ( std::size_t  skinIndex,
const String subMeshName,
MaterialRef  material 
)

Sets the material by index of the named submesh.

Returns
true If successful
Parameters
skinIndexIndex of the skin
subMeshNameName of the subMesh
materialPointer to the material
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid
Produces a NazaraError if there is no subMesh with that name
Produces a NazaraError if material index is invalid

◆ SetMesh()

void Nz::Model::SetMesh ( Mesh *  mesh)
virtual

Sets the mesh.

Parameters
pointerto the mesh
Remarks
Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if mesh is invalid

Reimplemented in Nz::SkeletalModel.


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