RobWorkProject
Classes | Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
Model3D Class Reference

a 3d model that has geometry but also material, color and texture information. the model can be composed of multiple objects that are connected in a hierarchical manner. The model is designed for efficient drawing and as such special structures are used to order the indexes such that efficient drawing is possible. More...

#include <Model3D.hpp>

Classes

struct  Material
 describes material properties. A material can be either simple or "advanced" and in both cases it can be textured. A simple material is described by a 4-tuple of RGBA values. The advanced material defines multiple properties: diffuse, ambient, emissive, specular, shininess and transparency More...
 
struct  MaterialPolys
 ordering polygons by material consumes more memmory but reduce switches between textures. All indices _subFaces share material _matIndex. More...
 
class  Object3D
 A concrete 3d object consisting of geometry information, material and texture. More...
 
class  Object3DGeneric
 An abstract 3d object consisting of geometry information, material and texture. More...
 

Public Types

enum  SmoothMethod { AVERAGED_NORMALS, WEIGHTED_NORMALS }
 Method to do smoothing. More...
 
typedef rw::common::Ptr< Model3DPtr
 smart pointer type to this class
 

Public Member Functions

 Model3D (const std::string &name)
 
virtual ~Model3D ()
 destructor
 
void optimize (double smooth_angle, SmoothMethod method=WEIGHTED_NORMALS)
 optimize vertices and vertice normals More...
 
int addObject (Object3DGeneric::Ptr obj)
 add an Object to this Model3D More...
 
void addGeometry (const Material &mat, rw::common::Ptr< class rw::geometry::Geometry > geom)
 add geometry to this model3d More...
 
void addTriMesh (const Material &mat, const rw::geometry::TriMesh &mesh)
 add a triangle mesh to this model3d More...
 
int addMaterial (const Material &mat)
 all objects in a model use the materials defined on the model More...
 
MaterialgetMaterial (const std::string &matid)
 get material with string id matid More...
 
bool hasMaterial (const std::string &matid)
 check if model has material with id matid More...
 
void removeObject (const std::string &name)
 remove object with string id name More...
 
void scale (float scale)
 Scales the object by scale. More...
 
std::vector< Material > & getMaterials ()
 get all materials that are available in this model
 
std::vector< Object3DGeneric::Ptr > & getObjects ()
 get all objects that make out this model
 
const rw::math::Transform3DgetTransform ()
 get pose of this Model3D
 
void setTransform (const rw::math::Transform3D<> &t3d)
 set the pose of this Model3D
 
const std::string & getName ()
 get string identifier of this model3d
 
const std::string & getFilePath ()
 get filePath of this model3d
 
void setName (const std::string &name)
 set string identifier of this model3d
 
void setFilePath (const std::string &name)
 set filePath this model3d
 
int getMask ()
 get mask of this model3d
 
void setMask (int mask)
 set mask of this model3d
 
rw::geometry::GeometryData::Ptr toGeometryData ()
 convert this model3d to a geometry. Notice that geometry does not hold any color information. More...
 
bool isDynamic () const
 true if data in the model are expected to change
 
void setDynamic (bool dynamic)
 set to true if data in the model are expected to change
 

Public Attributes

std::vector< Material_materials
 The array of materials.
 
std::vector< Object3DGeneric::Ptr_objects
 The array of objects in the model.
 
std::vector< TextureData_textures
 The array of textures.
 

Protected Attributes

rw::math::Transform3D _transform
 The transform of the model.
 
std::string _name
 Name of the model.
 
std::string _filePath
 FilePath of the model, if model was constructed from file.
 
int _mask
 The DrawableNode::DrawableTypeMask.
 
bool _isDynamic
 If the data can be expected to change.
 

Detailed Description

a 3d model that has geometry but also material, color and texture information. the model can be composed of multiple objects that are connected in a hierarchical manner. The model is designed for efficient drawing and as such special structures are used to order the indexes such that efficient drawing is possible.

Member Enumeration Documentation

◆ SmoothMethod

Method to do smoothing.

Enumerator
AVERAGED_NORMALS 

vertex normal is determine as an avarage of all adjacent face normals

WEIGHTED_NORMALS 

vertex normal is determined as AVARAGED_NORMALS, but with the face normals scaled by the face area

Constructor & Destructor Documentation

◆ Model3D()

Model3D ( const std::string &  name)

Constructor.

Parameters
name[in] name of the model.

Member Function Documentation

◆ addGeometry()

void addGeometry ( const Material mat,
rw::common::Ptr< class rw::geometry::Geometry geom 
)

add geometry to this model3d

Parameters
mat[in] the material properties to use for the geometry.
geom[in] the geometry to add.

◆ addMaterial()

int addMaterial ( const Material mat)

all objects in a model use the materials defined on the model

Parameters
mat[in] material to add.
Returns
id of the newly added material.

◆ addObject()

int addObject ( Object3DGeneric::Ptr  obj)

add an Object to this Model3D

Parameters
obj[in] the geometric object to add.
Returns
index of object in model3d

◆ addTriMesh()

void addTriMesh ( const Material mat,
const rw::geometry::TriMesh mesh 
)

add a triangle mesh to this model3d

Parameters
mat[in] the material properties to use for the mesh.
mesh[in] the mesh geometry.

◆ getMaterial()

Material* getMaterial ( const std::string &  matid)

get material with string id matid

Parameters
matid[in] string id
Returns
pointer to Matrial data

◆ hasMaterial()

bool hasMaterial ( const std::string &  matid)

check if model has material with id matid

Parameters
matid[in] string id of material
Returns
true if exists in model

◆ optimize()

void optimize ( double  smooth_angle,
SmoothMethod  method = WEIGHTED_NORMALS 
)

optimize vertices and vertice normals

removes redundant vertices and recalculates all vertice normals based on the face normals and the angle between face normals smooth_angle.

Parameters
smooth_angle
method

◆ removeObject()

void removeObject ( const std::string &  name)

remove object with string id name

Parameters
name[in] name of object to remove

◆ scale()

void scale ( float  scale)

Scales the object by scale.

Parameters
scale[in] The scaling factor.

◆ toGeometryData()

rw::geometry::GeometryData::Ptr toGeometryData ( )

convert this model3d to a geometry. Notice that geometry does not hold any color information.

Returns
a geometry of this model3d

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