RobWorkProject  23.9.11-
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 and color. he 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...
 
class  Texture
 

Public Types

enum  SmoothMethod { AVERAGED_NORMALS , WEIGHTED_NORMALS }
 Method to do smoothing. More...
 
typedef rw::core::Ptr< Model3DPtr
 smart pointer type to this class
 
using TextureList = std::vector< rw::core::Ptr< Texture > >
 The data type for the texture list.
 
using MaterialPolys = rw::geometry::Object3DGeneric::MaterialPolys
 
using Object3DGeneric = rw::geometry::Object3DGeneric
 
template<class T = uint16_t>
using Object3D = rw::geometry::Object3D< T >
 

Public Member Functions

 Model3D (const std::string &name)
 
 Model3D (const Model3D &model)
 Copy constructor, make a copy of the 3D object. More...
 
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::core::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...
 
void addTriMesh (const Material &mat, rw::core::Ptr< const rw::geometry::TriMesh > geom)
 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)
 Scale all vertices in the mesh. 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
 
std::vector< rw::core::Ptr< Texture > > & getTextures ()
 Get/set the object Textures. More...
 

Public Attributes

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

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 and color. he 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() [1/2]

Model3D ( const std::string &  name)

Constructor.

Parameters
name[in] name of the model.

◆ Model3D() [2/2]

Model3D ( const Model3D model)

Copy constructor, make a copy of the 3D object.

Parameters
model

Member Function Documentation

◆ addGeometry()

void addGeometry ( const Material mat,
rw::core::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() [1/2]

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.

◆ addTriMesh() [2/2]

void addTriMesh ( const Material mat,
rw::core::Ptr< const rw::geometry::TriMesh geom 
)

add a triangle mesh to this model3d

Parameters
mat[in] the material properties to use for the mesh.
geom[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

◆ getTextures()

std::vector<rw::core::Ptr<Texture> >& getTextures ( )
inline

Get/set the object Textures.

Returns
std::vector< rw::core::Ptr< Texture > >&

◆ 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)

Scale all vertices in the mesh.

◆ 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: