Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Engine::Model Class Reference

This object is a storage container for meshes. More...

#include <Model.hpp>

Public Member Functions

eastl::vector< eastl::shared_ptr< Mesh > > & GetModelMeshes ()
 This method allows you to get a reference of all the meshes in this model. More...
 
eastl::string GetName ()
 This method allows you to get the name of this model. More...
 
void SetSkeleton (eastl::shared_ptr< Skeleton > skeleton)
 
eastl::shared_ptr< SkeletonGetSkeleton () const
 Returns the animation data of the model. The animation data contains the skeleton of the model, As well as the progress of the animation and a list of animation that can be used by the model. More...
 
eastl::vector< eastl::string > GetAnimations ()
 Returns a list of the loaded animations as a vector of names. Use these names to load a specific animation. More...
 
void SetAnimation (eastl::string animation, bool resetTime)
 Sets the current animation of the mesh. More...
 
void ResetAnimation ()
 Sets the current animation to 0, returning the model to the default pose. More...
 
void SetAnimationTime (float time)
 Sets the point in the animation the model is in. Set to 0 to reset the animation. Animation automatically loops unless specified otherwise by assimp. More...
 
void Update (float deltaTime)
 Updates the model (doesn't do anything right now). More...
 
void UpdateAnimation (float deltaTime)
 Updates animation related values, such as the progress of the animation. More...
 
float GetAnimationTime () const
 Returns the current progress of the animation. More...
 
float GetAnimationDuration () const
 Returns the duration of a single loop of the animation. More...
 
void SetPaused (bool paused)
 Pauses or unpauses the animation. More...
 
bool IsPaused () const
 Tells if the animation is paused or not. More...
 
bool HasAnimations () const
 Whether or not any animations have been loaded. More...
 
void SetLooping (bool looping)
 Whether or not the animation should loop after finishing. More...
 
bool IsLooping () const
 Returns a boolean indicating if the animation is looping or not. More...
 
void SetSpeed (float speed)
 Set the speed modifier of the animation. Default is 1.f. More...
 
float GetSpeed () const
 Returns the speed modifier of the current animation. More...
 
eastl::string GetCurrentAnimationName () const
 Returns the name of the currently selected animation. More...
 
size_t GetCurrentAnimationIndex () const
 Returns the index of the currently selected animation. More...
 
eastl::shared_ptr< MaterialGetMeshMaterial (eastl::shared_ptr< Mesh > mesh)
 Returns the material used by this model for the specified mesh. If the model doesn't contain a material for the specified mesh a nullptr is returned. More...
 
void SetMeshMaterial (eastl::shared_ptr< Mesh > mesh, eastl::shared_ptr< Material > material)
 Associates a material with the given mesh. Warning: If building for vulkan, make sure that the specified material is created as a VulkanMaterial. More...
 
bool operator== (Model &other)
 This method allows you to compare a model against another model. More...
 
bool operator!= (Model &other)
 This method allows you to compare a model against another model. More...
 
 ~Model ()=default
 

Protected Member Functions

 Model (const aiScene *scene, eastl::string name="")
 
void AddMesh (eastl::shared_ptr< Mesh > meshToAdd)
 

Protected Attributes

eastl::string name
 
eastl::shared_ptr< Skeletonskeleton
 
eastl::vector< eastl::shared_ptr< Mesh > > meshes
 
eastl::map< eastl::shared_ptr< Mesh >, eastl::shared_ptr< Material > > meshMaterialMap
 
float speed
 
bool looping
 
bool paused
 
float time
 
size_t currentAnimation
 
eastl::string currentAnimationName
 

Friends

class ResourceManager
 

Detailed Description

This object is a storage container for meshes.

Definition at line 15 of file Model.hpp.

Constructor & Destructor Documentation

Engine::Model::Model ( const aiScene *  scene,
eastl::string  name = "" 
)
explicitprotected

Definition at line 8 of file Model.cpp.

Engine::Model::~Model ( )
default

Member Function Documentation

void Engine::Model::AddMesh ( eastl::shared_ptr< Mesh meshToAdd)
protected

Definition at line 214 of file Model.cpp.

float Engine::Model::GetAnimationDuration ( ) const

Returns the duration of a single loop of the animation.

Returns
Duration of the animation in seconds.

Definition at line 98 of file Model.cpp.

eastl::vector< eastl::string > Engine::Model::GetAnimations ( )

Returns a list of the loaded animations as a vector of names. Use these names to load a specific animation.

Returns
A vector containing animation names

Definition at line 40 of file Model.cpp.

float Engine::Model::GetAnimationTime ( ) const

Returns the current progress of the animation.

Returns
The time of the animation in seconds (wraps around when looping).

Definition at line 93 of file Model.cpp.

size_t Engine::Model::GetCurrentAnimationIndex ( ) const

Returns the index of the currently selected animation.

Returns
The index of the current animation as a size_t.

Definition at line 148 of file Model.cpp.

eastl::string Engine::Model::GetCurrentAnimationName ( ) const

Returns the name of the currently selected animation.

Returns
The name of the currently selected animation.

Definition at line 143 of file Model.cpp.

eastl::shared_ptr< Material > Engine::Model::GetMeshMaterial ( eastl::shared_ptr< Mesh mesh)

Returns the material used by this model for the specified mesh. If the model doesn't contain a material for the specified mesh a nullptr is returned.

Parameters
meshThe mesh to get the material for.
Returns
The material associated with the mesh.

Definition at line 153 of file Model.cpp.

eastl::vector< eastl::shared_ptr< Mesh > > & Engine::Model::GetModelMeshes ( )

This method allows you to get a reference of all the meshes in this model.

Returns
Returns a shared pointer vector of the meshes bound to this model.

Definition at line 20 of file Model.cpp.

eastl::string Engine::Model::GetName ( )

This method allows you to get the name of this model.

Returns
Returns the name of this model as a eastl::string.

Definition at line 25 of file Model.cpp.

eastl::shared_ptr< Skeleton > Engine::Model::GetSkeleton ( ) const

Returns the animation data of the model. The animation data contains the skeleton of the model, As well as the progress of the animation and a list of animation that can be used by the model.

Returns
The animation data of this model.

Definition at line 35 of file Model.cpp.

float Engine::Model::GetSpeed ( ) const

Returns the speed modifier of the current animation.

Returns
The speed modifier.

Definition at line 138 of file Model.cpp.

bool Engine::Model::HasAnimations ( ) const

Whether or not any animations have been loaded.

Returns
Boolean indicating if animations have been loaded or not.

Definition at line 116 of file Model.cpp.

bool Engine::Model::IsLooping ( ) const

Returns a boolean indicating if the animation is looping or not.

Returns
Boolean indicating if the animation is looping or not.

Definition at line 128 of file Model.cpp.

bool Engine::Model::IsPaused ( ) const

Tells if the animation is paused or not.

Returns
Boolean containing the status of the animation.

Definition at line 111 of file Model.cpp.

bool Engine::Model::operator!= ( Model other)

This method allows you to compare a model against another model.

Parameters
otherThe model you want to compare against.
Returns
Returns true if the models are not equal.

Definition at line 190 of file Model.cpp.

bool Engine::Model::operator== ( Model other)

This method allows you to compare a model against another model.

Parameters
otherThe model you want to compare against.
Returns
Returns true if both models are equal.

Definition at line 166 of file Model.cpp.

void Engine::Model::ResetAnimation ( )

Sets the current animation to 0, returning the model to the default pose.

Definition at line 64 of file Model.cpp.

void Engine::Model::SetAnimation ( eastl::string  animation,
bool  resetTime 
)

Sets the current animation of the mesh.

Parameters
animationThe name of the animation to use.
resetTimeIf the animation should be reset to the starting point.

Definition at line 48 of file Model.cpp.

void Engine::Model::SetAnimationTime ( float  time)

Sets the point in the animation the model is in. Set to 0 to reset the animation. Animation automatically loops unless specified otherwise by assimp.

Parameters
timeThe time in seconds to set the animation to.

Definition at line 70 of file Model.cpp.

void Engine::Model::SetLooping ( bool  looping)

Whether or not the animation should loop after finishing.

Parameters
loopingboolean indicating if the animation should loop or not.

Definition at line 123 of file Model.cpp.

void Engine::Model::SetMeshMaterial ( eastl::shared_ptr< Mesh mesh,
eastl::shared_ptr< Material material 
)

Associates a material with the given mesh. Warning: If building for vulkan, make sure that the specified material is created as a VulkanMaterial.

Parameters
meshThe mesh to use the material for.
materialThe material to bind to the mesh. Note: If you update the material, any mesh that's associated with this material will change.

Definition at line 161 of file Model.cpp.

void Engine::Model::SetPaused ( bool  paused)

Pauses or unpauses the animation.

Parameters
pausedBoolean indicating the state of the animation

Definition at line 106 of file Model.cpp.

void Engine::Model::SetSkeleton ( eastl::shared_ptr< Skeleton skeleton)

Definition at line 30 of file Model.cpp.

void Engine::Model::SetSpeed ( float  speed)

Set the speed modifier of the animation. Default is 1.f.

Parameters
speedThe new speed modifier.

Definition at line 133 of file Model.cpp.

void Engine::Model::Update ( float  deltaTime)

Updates the model (doesn't do anything right now).

Parameters
deltaTimeTime since last frame in seconds.

Definition at line 75 of file Model.cpp.

void Engine::Model::UpdateAnimation ( float  deltaTime)

Updates animation related values, such as the progress of the animation.

Parameters
deltaTimeTime since last frame in seconds.

Definition at line 80 of file Model.cpp.

Friends And Related Function Documentation

friend class ResourceManager
friend

Definition at line 176 of file Model.hpp.

Member Data Documentation

size_t Engine::Model::currentAnimation
protected

Definition at line 199 of file Model.hpp.

eastl::string Engine::Model::currentAnimationName
protected

Definition at line 201 of file Model.hpp.

bool Engine::Model::looping
protected

Definition at line 193 of file Model.hpp.

eastl::vector<eastl::shared_ptr<Mesh> > Engine::Model::meshes
protected

Definition at line 185 of file Model.hpp.

eastl::map<eastl::shared_ptr<Mesh>, eastl::shared_ptr<Material> > Engine::Model::meshMaterialMap
protected

Definition at line 187 of file Model.hpp.

eastl::string Engine::Model::name
protected

Definition at line 175 of file Model.hpp.

bool Engine::Model::paused
protected

Definition at line 195 of file Model.hpp.

eastl::shared_ptr<Skeleton> Engine::Model::skeleton
protected

Definition at line 182 of file Model.hpp.

float Engine::Model::speed
protected

Definition at line 191 of file Model.hpp.

float Engine::Model::time
protected

Definition at line 197 of file Model.hpp.


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