Documentation for module: Graphics

Former-commit-id: 1757c33318443aade1dc38e16d053240d7dc885c
This commit is contained in:
Gawaboumga
2016-05-30 14:21:36 +02:00
parent 7721fd2284
commit 2c941827ed
94 changed files with 4858 additions and 504 deletions

View File

@@ -14,6 +14,17 @@
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::SkeletalModel
* \brief Graphics class that represents a model with a skeleton
*/
/*!
* \brief Checks whether the parameters for the skeletal mesh are correct
* \return true If parameters are valid
*/
bool SkeletalModelParameters::IsValid() const
{
if (!ModelParameters::IsValid())
@@ -25,12 +36,23 @@ namespace Nz
return true;
}
/*!
* \brief Constructs a SkeletalModel object by default
*/
SkeletalModel::SkeletalModel() :
m_currentSequence(nullptr),
m_animationEnabled(true)
{
}
/*!
* \brief Adds the skeletal mesh to the rendering queue
*
* \param renderQueue Queue to be added
* \param instanceData Data for the instance
*/
void SkeletalModel::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const
{
if (!m_mesh)
@@ -51,6 +73,14 @@ namespace Nz
}
}
/*!
* \brief Updates the animation of the mesh
*
* \param elapsedTime Delta time between two frames
*
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if there is no animation
*/
void SkeletalModel::AdvanceAnimation(float elapsedTime)
{
#if NAZARA_GRAPHICS_SAFE
@@ -67,7 +97,7 @@ namespace Nz
m_interpolation -= 1.f;
unsigned lastFrame = m_currentSequence->firstFrame + m_currentSequence->frameCount - 1;
if (m_nextFrame+1 > lastFrame)
if (m_nextFrame + 1 > lastFrame)
{
if (m_animation->IsLoopPointInterpolationEnabled())
{
@@ -77,7 +107,7 @@ namespace Nz
else
{
m_currentFrame = m_currentSequence->firstFrame;
m_nextFrame = m_currentFrame+1;
m_nextFrame = m_currentFrame + 1;
}
}
else
@@ -92,26 +122,52 @@ namespace Nz
InvalidateBoundingVolume();
}
/*!
* \brief Clones this skeletal model
* \return Pointer to newly allocated SkeletalModel
*/
SkeletalModel* SkeletalModel::Clone() const
{
return new SkeletalModel(*this);
}
/*!
* \brief Creates a default skeletal model
* \return Pointer to newly allocated SkeletalModel
*/
SkeletalModel* SkeletalModel::Create() const
{
return new SkeletalModel;
}
/*!
* \brief Enables the animation of the model
*
* \param animation Should the model be animated
*/
void SkeletalModel::EnableAnimation(bool animation)
{
m_animationEnabled = animation;
}
/*!
* \brief Gets the animation of the model
* \return Pointer to the animation
*/
Animation* SkeletalModel::GetAnimation() const
{
return m_animation;
}
/*!
* \brief Gets the skeleton of the model
* \return Pointer to the skeleton
*/
Skeleton* SkeletalModel::GetSkeleton()
{
InvalidateBoundingVolume();
@@ -119,41 +175,96 @@ namespace Nz
return &m_skeleton;
}
/*!
* \brief Gets the skeleton of the model
* \return Constant pointer to the skeleton
*/
const Skeleton* SkeletalModel::GetSkeleton() const
{
return &m_skeleton;
}
/*!
* \brief Checks whether the skeleton has an animation
* \return true If it is the case
*
* \see IsAnimated, IsAnimationEnabled
*/
bool SkeletalModel::HasAnimation() const
{
return m_animation != nullptr;
}
/*!
* \brief Checks whether the skeleton is animated
* \return true
*
* \see HasAnimation, IsAnimationEnabled
*/
bool SkeletalModel::IsAnimated() const
{
return true;
}
/*!
* \brief Checks whether the skeleton is currently animated
* \return true If it is the case
*
* \see HasAnimation, IsAnimated
*/
bool SkeletalModel::IsAnimationEnabled() const
{
return m_animationEnabled;
}
/*!
* \brief Loads the skeleton model from file
* \return true if loading is successful
*
* \param filePath Path to the file
* \param params Parameters for the skeleton model
*/
bool SkeletalModel::LoadFromFile(const String& filePath, const SkeletalModelParameters& params)
{
return SkeletalModelLoader::LoadFromFile(this, filePath, params);
}
/*!
* \brief Loads the skeleton model from memory
* \return true if loading is successful
*
* \param data Raw memory
* \param size Size of the memory
* \param params Parameters for the skeleton model
*/
bool SkeletalModel::LoadFromMemory(const void* data, std::size_t size, const SkeletalModelParameters& params)
{
return SkeletalModelLoader::LoadFromMemory(this, data, size, params);
}
/*!
* \brief Loads the skeleton model from stream
* \return true if loading is successful
*
* \param stream Stream to the skeleton model
* \param params Parameters for the skeleton model
*/
bool SkeletalModel::LoadFromStream(Stream& stream, const SkeletalModelParameters& params)
{
return SkeletalModelLoader::LoadFromStream(this, stream, params);
}
/*!
* \brief Resets the model
*/
void SkeletalModel::Reset()
{
Model::Reset();
@@ -161,6 +272,16 @@ namespace Nz
m_skeleton.Destroy();
}
/*!
* \brief Sets the animation for the model
* \return true If successful
*
* \param animation Animation for the model
*
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if animation is invalid
*/
bool SkeletalModel::SetAnimation(Animation* animation)
{
#if NAZARA_GRAPHICS_SAFE
@@ -204,6 +325,14 @@ namespace Nz
return true;
}
/*!
* \brief Sets the mesh for the model
*
* \param mesh Mesh for the model
*
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh or if invalid
*/
void SkeletalModel::SetMesh(Mesh* mesh)
{
#if NAZARA_GRAPHICS_SAFE
@@ -224,13 +353,23 @@ namespace Nz
SetAnimation(nullptr);
}
m_skeleton = *m_mesh->GetSkeleton(); // Copie du squelette template
m_skeleton = *m_mesh->GetSkeleton(); // Copy of skeleton template
}
}
/*!
* \brief Sets the sequence for the model
* \return true If successful
*
* \param sequenceName Name for the sequence animation
*
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation
*/
bool SkeletalModel::SetSequence(const String& sequenceName)
{
///TODO: Rendre cette erreur "safe" avec le nouveau système de gestions d'erreur (No-log)
///TODO: Make this error "safe" with the new system of error handling (No-log)
#if NAZARA_GRAPHICS_SAFE
if (!m_animation)
{
@@ -240,11 +379,13 @@ namespace Nz
#endif
const Sequence* currentSequence = m_animation->GetSequence(sequenceName);
#if NAZARA_GRAPHICS_SAFE
if (!currentSequence)
{
NazaraError("Sequence not found");
return false;
}
#endif
m_currentSequence = currentSequence;
m_nextFrame = m_currentSequence->firstFrame;
@@ -252,6 +393,15 @@ namespace Nz
return true;
}
/*!
* \brief Sets the sequence for the model
*
* \param sequenceIndex Index for the sequence animation
*
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation
*/
void SkeletalModel::SetSequence(unsigned int sequenceIndex)
{
#if NAZARA_GRAPHICS_SAFE
@@ -275,13 +425,22 @@ namespace Nz
m_nextFrame = m_currentSequence->firstFrame;
}
/*
* \brief Makes the bounding volume of this text
*/
void SkeletalModel::MakeBoundingVolume() const
{
m_boundingVolume.Set(m_skeleton.GetAABB());
}
/*!
* \brief Updates the model
*/
void SkeletalModel::Update()
{
///TODO
/*if (m_animationEnabled && m_animation)
AdvanceAnimation(m_scene->GetUpdateTime());*/
}