Documentation for module: Graphics
Former-commit-id: 1757c33318443aade1dc38e16d053240d7dc885c
This commit is contained in:
@@ -12,11 +12,26 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup graphics
|
||||
* \class Nz::Model
|
||||
* \brief Graphics class that represents a model
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a ModelParameters object by default
|
||||
*/
|
||||
|
||||
ModelParameters::ModelParameters()
|
||||
{
|
||||
material.shaderName = "PhongLighting";
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the parameters for the model are correct
|
||||
* \return true If parameters are valid
|
||||
*/
|
||||
|
||||
bool ModelParameters::IsValid() const
|
||||
{
|
||||
if (loadMaterials && !material.IsValid())
|
||||
@@ -25,6 +40,10 @@ namespace Nz
|
||||
return mesh.IsValid();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Model object by default
|
||||
*/
|
||||
|
||||
Model::Model() :
|
||||
m_matCount(0),
|
||||
m_skin(0),
|
||||
@@ -32,11 +51,24 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Destructs the object and calls Reset
|
||||
*
|
||||
* \see Reset
|
||||
*/
|
||||
|
||||
Model::~Model()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds this model to the render queue
|
||||
*
|
||||
* \param renderQueue Queue to be added
|
||||
* \param instanceData Data used for this instance
|
||||
*/
|
||||
|
||||
void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const
|
||||
{
|
||||
unsigned int submeshCount = m_mesh->GetSubMeshCount();
|
||||
@@ -54,6 +86,17 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material of the named submesh
|
||||
* \return Pointer to the current material
|
||||
*
|
||||
* \param subMeshName Name of the subMesh
|
||||
*
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh
|
||||
* \remark Produces a NazaraError if there is no subMesh with that name
|
||||
* \remark Produces a NazaraError if material is invalid
|
||||
*/
|
||||
|
||||
Material* Model::GetMaterial(const String& subMeshName) const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -78,9 +121,18 @@ namespace Nz
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return m_materials[m_skin*m_matCount + matIndex];
|
||||
return m_materials[m_skin * m_matCount + matIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material by index
|
||||
* \return Pointer to the current material
|
||||
*
|
||||
* \param matIndex Index of the material
|
||||
*
|
||||
* \remark Produces a NazaraError if index is invalid
|
||||
*/
|
||||
|
||||
Material* Model::GetMaterial(unsigned int matIndex) const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -91,9 +143,21 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_materials[m_skin*m_matCount + matIndex];
|
||||
return m_materials[m_skin * m_matCount + matIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material by index of the named submesh
|
||||
* \return Pointer to the current material
|
||||
*
|
||||
* \param skinIndex Index of the skin
|
||||
* \param subMeshName Name of the subMesh
|
||||
*
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid
|
||||
* \remark Produces a NazaraError if there is no subMesh with that name
|
||||
* \remark Produces a NazaraError if material index is invalid
|
||||
*/
|
||||
|
||||
Material* Model::GetMaterial(unsigned int skinIndex, const String& subMeshName) const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -118,9 +182,20 @@ namespace Nz
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return m_materials[skinIndex*m_matCount + matIndex];
|
||||
return m_materials[skinIndex * m_matCount + matIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the material by index with skin
|
||||
* \return Pointer to the current material
|
||||
*
|
||||
* \param skinIndex Index of the skin
|
||||
* \param matIndex Index of the material
|
||||
*
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if matIndex is invalid
|
||||
*/
|
||||
|
||||
Material* Model::GetMaterial(unsigned int skinIndex, unsigned int matIndex) const
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -137,49 +212,103 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_materials[skinIndex*m_matCount + matIndex];
|
||||
return m_materials[skinIndex * m_matCount + matIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the number of materials
|
||||
* \return Current number of materials
|
||||
*/
|
||||
|
||||
unsigned int Model::GetMaterialCount() const
|
||||
{
|
||||
return m_matCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the mesh
|
||||
* \return Current mesh
|
||||
*/
|
||||
|
||||
Mesh* Model::GetMesh() const
|
||||
{
|
||||
return m_mesh;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the skin
|
||||
* \return Current skin
|
||||
*/
|
||||
|
||||
unsigned int Model::GetSkin() const
|
||||
{
|
||||
return m_skin;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the number of skins
|
||||
* \return Current number of skins
|
||||
*/
|
||||
|
||||
unsigned int Model::GetSkinCount() const
|
||||
{
|
||||
return m_skinCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the model is animated
|
||||
* \return false
|
||||
*/
|
||||
|
||||
bool Model::IsAnimated() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Loads the model from file
|
||||
* \return true if loading is successful
|
||||
*
|
||||
* \param filePath Path to the file
|
||||
* \param params Parameters for the model
|
||||
*/
|
||||
|
||||
bool Model::LoadFromFile(const String& filePath, const ModelParameters& params)
|
||||
{
|
||||
return ModelLoader::LoadFromFile(this, filePath, params);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Loads the model from memory
|
||||
* \return true if loading is successful
|
||||
*
|
||||
* \param data Raw memory
|
||||
* \param size Size of the memory
|
||||
* \param params Parameters for the model
|
||||
*/
|
||||
|
||||
bool Model::LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params)
|
||||
{
|
||||
return ModelLoader::LoadFromMemory(this, data, size, params);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Loads the model from stream
|
||||
* \return true if loading is successful
|
||||
*
|
||||
* \param stream Stream to the model
|
||||
* \param params Parameters for the model
|
||||
*/
|
||||
|
||||
bool Model::LoadFromStream(Stream& stream, const ModelParameters& params)
|
||||
{
|
||||
return ModelLoader::LoadFromStream(this, stream, params);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets the model, cleans everything
|
||||
*/
|
||||
|
||||
void Model::Reset()
|
||||
{
|
||||
m_matCount = 0;
|
||||
@@ -192,6 +321,17 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the material of the named submesh
|
||||
* \return true If successful
|
||||
*
|
||||
* \param subMeshName Name of the subMesh
|
||||
* \param material Pointer to the material
|
||||
*
|
||||
* \remark Produces a NazaraError if there is no subMesh with that name
|
||||
* \remark Produces a NazaraError if material index is invalid
|
||||
*/
|
||||
|
||||
bool Model::SetMaterial(const String& subMeshName, Material* material)
|
||||
{
|
||||
SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
|
||||
@@ -208,7 +348,7 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int index = m_skin*m_matCount + matIndex;
|
||||
unsigned int index = m_skin * m_matCount + matIndex;
|
||||
|
||||
if (material)
|
||||
m_materials[index] = material;
|
||||
@@ -218,6 +358,16 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the material by index
|
||||
* \return true If successful
|
||||
*
|
||||
* \param matIndex Index of the material
|
||||
* \param material Pointer to the material
|
||||
*
|
||||
* \remark Produces a NazaraError with if NAZARA_GRAPHICS_SAFE defined index is invalid
|
||||
*/
|
||||
|
||||
void Model::SetMaterial(unsigned int matIndex, Material* material)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -228,7 +378,7 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int index = m_skin*m_matCount + matIndex;
|
||||
unsigned int index = m_skin * m_matCount + matIndex;
|
||||
|
||||
if (material)
|
||||
m_materials[index] = material;
|
||||
@@ -236,6 +386,19 @@ namespace Nz
|
||||
m_materials[index] = Material::GetDefault();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the material by index of the named submesh
|
||||
* \return true If successful
|
||||
*
|
||||
* \param skinIndex Index of the skin
|
||||
* \param subMeshName Name of the subMesh
|
||||
* \param material Pointer to the material
|
||||
*
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid
|
||||
* \remark Produces a NazaraError if there is no subMesh with that name
|
||||
* \remark Produces a NazaraError if material index is invalid
|
||||
*/
|
||||
|
||||
bool Model::SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -260,7 +423,7 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int index = skinIndex*m_matCount + matIndex;
|
||||
unsigned int index = skinIndex * m_matCount + matIndex;
|
||||
|
||||
if (material)
|
||||
m_materials[index] = material;
|
||||
@@ -270,6 +433,18 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the material by index with skin
|
||||
* \return true If successful
|
||||
*
|
||||
* \param skinIndex Index of the skin
|
||||
* \param matIndex Index of the material
|
||||
* \param material Pointer to the material
|
||||
*
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if matIndex is invalid
|
||||
*/
|
||||
|
||||
void Model::SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -286,7 +461,7 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int index = skinIndex*m_matCount + matIndex;
|
||||
unsigned int index = skinIndex * m_matCount + matIndex;
|
||||
|
||||
if (material)
|
||||
m_materials[index] = material;
|
||||
@@ -294,6 +469,14 @@ namespace Nz
|
||||
m_materials[index] = Material::GetDefault();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the mesh
|
||||
*
|
||||
* \param pointer to the mesh
|
||||
*
|
||||
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if mesh is invalid
|
||||
*/
|
||||
|
||||
void Model::SetMesh(Mesh* mesh)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -323,6 +506,14 @@ namespace Nz
|
||||
InvalidateBoundingVolume();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the skin
|
||||
*
|
||||
* \param skin Skin to use
|
||||
*
|
||||
* \remark Produces a NazaraError if skin is invalid
|
||||
*/
|
||||
|
||||
void Model::SetSkin(unsigned int skin)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -336,6 +527,14 @@ namespace Nz
|
||||
m_skin = skin;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the number of skins
|
||||
*
|
||||
* \param skinCount Number of skins
|
||||
*
|
||||
* \remark Produces a NazaraError if skinCount equals zero
|
||||
*/
|
||||
|
||||
void Model::SetSkinCount(unsigned int skinCount)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
@@ -350,6 +549,10 @@ namespace Nz
|
||||
m_skinCount = skinCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Makes the bounding volume of this billboard
|
||||
*/
|
||||
|
||||
void Model::MakeBoundingVolume() const
|
||||
{
|
||||
if (m_mesh)
|
||||
|
||||
Reference in New Issue
Block a user