A 3d model that can be rendered to the screen. More...

#include <Model.h>

Inherits IDrawable.

Inherited by Sprite.

Public Types

typedef std::unordered_map< std::string, GeometryPtrGroupMap
 
typedef std::shared_ptr< std::unordered_map< ShaderPtr, PropertiesPtr > > InstanceMapPtr
 
typedef std::unordered_map< std::string, InstanceMapPtrInstancesMap
 

Public Member Functions

 Model ()
 Constructor. More...
 
 Model (ObjectManager *o, const ModelData &modelData, GLuint shaderMaxLights, bool variableNumberOfLights, bool shaderFromFile, bool ambientLighting, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 Model (ObjectManager *o, const ModelData &modelData, ShaderPtr shader, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 Model (const ModelData &modelData, MaterialPtr material, PropertiesPtr properties=nullptr)
 Constructor. More...
 
virtual ~Model ()
 Virtual destructor. More...
 
virtual void draw (GLenum mode=GL_TRIANGLES) override
 Draws the model to the screen. More...
 
virtual void draw (const std::string &geometryName, GLenum mode=GL_TRIANGLES)
 Draws the specified group of geometry to the screen. More...
 
virtual void drawInstance (const std::string &instanceName, GLenum mode=GL_TRIANGLES) override
 Draws an instance of the model to the screen. More...
 
virtual InstanceMapPtr addInstance (const std::string &instanceName)
 Creates an instance of this model and associated geometry. More...
 
virtual PropertiesPtr getInstanceProperties (const std::string &instanceName, const std::string &geometryName)
 Get the properties of a geometry instance. More...
 
virtual InstanceMapPtr getInstanceProperties (const std::string &instanceName)
 Get the instance properties for every shader used in the model. More...
 
virtual void removeInstance (const std::string &instanceName)
 Removes an instance of the model and associated geometry. More...
 
virtual void clearInstances ()
 Removes all instances of the model and associated geometry. More...
 
MaterialPtr getMaterial ()
 Returns the material of the model. More...
 
void setMaterial (MaterialPtr arg)
 Sets the material of the model. More...
 
PropertiesPtr getProperties ()
 Returns the properties of the model. More...
 
void setProperties (PropertiesPtr arg)
 Sets the properties of the model. More...
 
GroupMapgetGroups ()
 Returns the groups of geometry of the model. More...
 
vmml::AABBf & getBoundingBoxObjectSpace ()
 Returns the bounding box of the geometry in object space. More...
 
void setBoundingBoxObjectSpace (vmml::AABBf arg)
 Sets the bounding box of the geometry in object space. More...
 
virtual void addGeometry (const std::string &name, GeometryPtr geometry)
 Adds geometry to the model. More...
 
virtual void removeGeometry (const std::string &name)
 Removes geometry from the model. More...
 
virtual void deleteModelGeometry ()
 Deletes all geometry of the model. More...
 
- Public Member Functions inherited from IDrawable
virtual ~IDrawable ()
 Virtual destructor. More...
 

Detailed Description

A 3d model that can be rendered to the screen.

Author
Rahul Mukhi, David Steiner

Member Typedef Documentation

typedef std::unordered_map< std::string, GeometryPtr > Model::GroupMap
typedef std::shared_ptr< std::unordered_map< ShaderPtr, PropertiesPtr > > Model::InstanceMapPtr
typedef std::unordered_map< std::string, InstanceMapPtr > Model::InstancesMap

Constructor & Destructor Documentation

Model::Model ( )
inline

Constructor.

Model::Model ( ObjectManager o,
const ModelData modelData,
GLuint  shaderMaxLights,
bool  variableNumberOfLights,
bool  shaderFromFile,
bool  ambientLighting,
PropertiesPtr  properties = nullptr 
)

Constructor.

Parameters
[in]oObject management
[in]modelData
[in]shaderMaxLightsThe maximum light sources to be used
[in]variableNumberOfLightsTrue if the number of lights may vary, otherwise the number of lights has to be the same as specified as maximum number of lights
[in]shaderFromFileSet true if for every material a shader file with the same name should be loaded
[in]ambientLightingSet true if the shader supports ambient lighting
[in]propertiesProperties that will be passed to the shader of the model (optional)
Model::Model ( ObjectManager o,
const ModelData modelData,
ShaderPtr  shader,
PropertiesPtr  properties = nullptr 
)

Constructor.

Parameters
[in]oObject management
[in]modelData
[in]shader
[in]propertiesProperties that will be passed to the shader of the model (optional)
Model::Model ( const ModelData modelData,
MaterialPtr  material,
PropertiesPtr  properties = nullptr 
)

Constructor.

Parameters
[in]modelData
[in]material
[in]propertiesProperties that will be passed to the shader of the model (optional)
virtual Model::~Model ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

void Model::addGeometry ( const std::string &  name,
GeometryPtr  geometry 
)
virtual

Adds geometry to the model.

Parameters
[in]nameName of the geometry
[in]geometryA pointer to the geometry
Model::InstanceMapPtr Model::addInstance ( const std::string &  instanceName)
virtual

Creates an instance of this model and associated geometry.

All geometry that belong to this model get additional properties

Parameters
[in]instanceNameName of the instance
void Model::clearInstances ( )
virtual

Removes all instances of the model and associated geometry.

virtual void Model::deleteModelGeometry ( )
inlinevirtual

Deletes all geometry of the model.

void Model::draw ( GLenum  mode = GL_TRIANGLES)
overridevirtual

Draws the model to the screen.

Parameters
[in]mode

Implements IDrawable.

void Model::draw ( const std::string &  geometryName,
GLenum  mode = GL_TRIANGLES 
)
virtual

Draws the specified group of geometry to the screen.

Parameters
[in]geometryNameName of the group to draw
[in]mode
void Model::drawInstance ( const std::string &  instanceName,
GLenum  mode = GL_TRIANGLES 
)
overridevirtual

Draws an instance of the model to the screen.

Parameters
[in]instanceName
[in]mode

Implements IDrawable.

vmml::AABBf& Model::getBoundingBoxObjectSpace ( )
inline

Returns the bounding box of the geometry in object space.

GroupMap& Model::getGroups ( )
inline

Returns the groups of geometry of the model.

PropertiesPtr Model::getInstanceProperties ( const std::string &  instanceName,
const std::string &  geometryName 
)
virtual

Get the properties of a geometry instance.

Parameters
[in]instanceNameName of the instance
[in]geometryNameName of the geometry
Model::InstanceMapPtr Model::getInstanceProperties ( const std::string &  instanceName)
virtual

Get the instance properties for every shader used in the model.

Parameters
[in]instanceNameName of the instance
MaterialPtr Model::getMaterial ( )
inline

Returns the material of the model.

PropertiesPtr Model::getProperties ( )
inline

Returns the properties of the model.

virtual void Model::removeGeometry ( const std::string &  name)
inlinevirtual

Removes geometry from the model.

Parameters
[in]nameName of the geometry
void Model::removeInstance ( const std::string &  instanceName)
virtual

Removes an instance of the model and associated geometry.

Parameters
[in]instanceNameName of the instance
void Model::setBoundingBoxObjectSpace ( vmml::AABBf  arg)
inline

Sets the bounding box of the geometry in object space.

Parameters
[in]argThe bounding box for the geometry in object space
void Model::setMaterial ( MaterialPtr  arg)
inline

Sets the material of the model.

Parameters
[in]argThe material for the model
void Model::setProperties ( PropertiesPtr  arg)
inline

Sets the properties of the model.

Parameters
[in]argThe properties for the model