RobWorkProject
23.9.11-
|
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< Model3D > | Ptr |
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... | |
Material * | getMaterial (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::Transform3D & | getTransform () |
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. | |
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.
enum SmoothMethod |
Model3D | ( | const std::string & | name | ) |
Constructor.
name | [in] name of the model. |
void addGeometry | ( | const Material & | mat, |
rw::core::Ptr< class rw::geometry::Geometry > | geom | ||
) |
add geometry to this model3d
mat | [in] the material properties to use for the geometry. |
geom | [in] the geometry to add. |
int addMaterial | ( | const Material & | mat | ) |
all objects in a model use the materials defined on the model
mat | [in] material to add. |
int addObject | ( | Object3DGeneric::Ptr | obj | ) |
add an Object to this Model3D
obj | [in] the geometric object to add. |
void addTriMesh | ( | const Material & | mat, |
const rw::geometry::TriMesh & | mesh | ||
) |
add a triangle mesh to this model3d
mat | [in] the material properties to use for the mesh. |
mesh | [in] the mesh geometry. |
void addTriMesh | ( | const Material & | mat, |
rw::core::Ptr< const rw::geometry::TriMesh > | geom | ||
) |
add a triangle mesh to this model3d
mat | [in] the material properties to use for the mesh. |
geom | [in] the mesh geometry. |
Material* getMaterial | ( | const std::string & | matid | ) |
get material with string id matid
matid | [in] string id |
|
inline |
Get/set the object Textures.
bool hasMaterial | ( | const std::string & | matid | ) |
check if model has material with id matid
matid | [in] string id of material |
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.
smooth_angle | |
method |
void removeObject | ( | const std::string & | name | ) |
remove object with string id name
name | [in] name of object to remove |
void scale | ( | float | scale | ) |
Scale all vertices in the mesh.
rw::geometry::GeometryData::Ptr toGeometryData | ( | ) |
convert this model3d to a geometry. Notice that geometry does not hold any color information.