sofa::component::visualmodel::VisualModelImpl Class Reference

Abstract class which implements partially VisualModel. More...

#include <VisualModelImpl.h>

Inheritance diagram for sofa::component::visualmodel::VisualModelImpl:

Inheritance graph
[legend]
Collaboration diagram for sofa::component::visualmodel::VisualModelImpl:

Collaboration graph
[legend]

Public Member Functions

 VisualModelImpl ()
 ~VisualModelImpl ()
void parse (core::objectmodel::BaseObjectDescription *arg)
 Parse the given description to assign values to this object's fields and potentially other parameters.
bool isTransparent ()
void drawVisual ()
 Display the VisualModel object.
void drawTransparent ()
 Display transparent surfaces.
void drawShadow ()
 Display shadow-casting surfaces.
virtual bool loadTexture (const std::string &)
bool load (const std::string &filename, const std::string &loader, const std::string &textureName)
void applyTranslation (const double dx, const double dy, const double dz)
 Translate the positions.
void applyRotation (const double rx, const double ry, const double rz)
 Rotate the positions using Euler Angles in degree.
void applyRotation (const Quat q)
 Rotate the positions.
void applyScale (const double s)
 Scale the positions.
void applyUVTranslation (const double dU, const double dV)
void applyUVScale (const double su, const double sv)
void flipFaces ()
void setFilename (std::string s)
std::string getFilename ()
void setColor (float r, float g, float b, float a)
void setColor (std::string color)
void setUseNormals (bool val)
bool getUseNormals () const
void setCastShadow (bool val)
bool getCastShadow () const
void setMesh (helper::io::Mesh &m, bool tex=false)
bool isUsingTopology () const
ResizableExtVector< Coord > * getVertices ()
void setVertices (ResizableExtVector< Coord > *x)
ResizableExtVector< Triangle > * getTriangles ()
void setTriangles (ResizableExtVector< Triangle > *t)
virtual void computePositions ()
virtual void computeMesh ()
virtual void computeNormals ()
virtual void computeBBox ()
virtual void updateVisual ()
 used to update the model if necessary.
virtual void handleTopologyChange ()
 Handle topological Changes.
void init ()
 Initialization method called at graph modification, during bottom-up traversal.
void initVisual ()
 Initialize the textures, or other graphical resources.
bool addBBox (double *minBBox, double *maxBBox)
 used to add the bounding-box of this visual model to the given bounding box in order to compute the scene bounding box or cull hidden objects.
virtual void exportOBJ (std::string name, std::ostream *out, std::ostream *mtl, int &vindex, int &nindex, int &tindex)
 Append this mesh to an OBJ format stream.
virtual std::string getTemplateName () const
 Get the template type names (if any) used to instantiate this object.

Static Public Member Functions

static std::string templateName (const VisualModelImpl *p=NULL)

Data Fields

Data
< sofa::helper::io::Mesh::Material > 
material

Protected Types

typedef ExtVec3fTypes::Real Real
 Scalar values (float or double).
typedef ExtVec3fTypes::Coord Coord
 Position values.
typedef ExtVec3fTypes::VecCoord VecCoord
 Container of Coord values with the same API as sofa::helper::vector.
typedef ExtVec3fTypes::Deriv Deriv
 Derivative values (velocity, forces, displacements).
typedef ExtVec3fTypes::VecDeriv VecDeriv
 Container of Deriv values with the same API as sofa::helper::vector.
typedef Vec< 2, float > TexCoord
typedef helper::fixed_array
< int, 3 > 
Triangle
typedef helper::fixed_array
< int, 4 > 
Quad

Protected Member Functions

virtual void internalDraw ()

Protected Attributes

bool useTopology
 True if list of facets should be taken from the attached topology.
int lastMeshRev
 Time stamps from the last time the mesh was updated from the topology.
bool useNormals
 True if normals should be read from file.
bool castShadow
 True if object cast shadows.
sofa::core::componentmodel::topology::BaseMeshTopology * _topology
DataPtr< ResizableExtVector
< Coord > > 
field_vertices
ResizableExtVector< Coord > vertices
DataPtr< ResizableExtVector
< Coord > > 
field_vnormals
ResizableExtVector< Coord > vnormals
DataPtr< ResizableExtVector
< TexCoord > > 
field_vtexcoords
ResizableExtVector< TexCoord > vtexcoords
DataPtr< ResizableExtVector
< Triangle > > 
field_triangles
ResizableExtVector< Triangle > triangles
DataPtr< ResizableExtVector
< Quad > > 
field_quads
ResizableExtVector< Quad > quads
ResizableExtVector< int > vertPosIdx
 If vertices have multiple normals/texcoords, then we need to separate them This vector store which input position is used for each vertice If it is empty then each vertex correspond to one position.
ResizableExtVector< int > vertNormIdx
 Similarly this vector store which input normal is used for each vertice If it is empty then each vertex correspond to one normal.
float scaleTex
Data< std::string > filename
Data< std::string > texturename
Data< Vector3 > translation
Data< Vector3 > rotation
Data< SReal > scale
Vec3f bbox [2]

Detailed Description

Abstract class which implements partially VisualModel.

This class implemented all non-hardware (i.e OpenGL or DirectX) specific functions for rendering. It takes a 3D model (basically a .OBJ model) and apply transformations on it. At the moment, it is only implemented by OglModel for OpenGL systems.

Definition at line 103 of file VisualModelImpl.h.


Member Typedef Documentation

Position values.

Reimplemented from sofa::core::componentmodel::behavior::MappedModel< TDataTypes >.

Reimplemented in SofaFlowVR::FlowVRRenderMesh.

Definition at line 109 of file VisualModelImpl.h.

Derivative values (velocity, forces, displacements).

Reimplemented from sofa::core::componentmodel::behavior::MappedModel< TDataTypes >.

Definition at line 111 of file VisualModelImpl.h.

Definition at line 117 of file VisualModelImpl.h.

Scalar values (float or double).

Reimplemented from sofa::core::componentmodel::behavior::MappedModel< TDataTypes >.

Definition at line 108 of file VisualModelImpl.h.

Definition at line 115 of file VisualModelImpl.h.

Definition at line 116 of file VisualModelImpl.h.

Container of Coord values with the same API as sofa::helper::vector.

Reimplemented from sofa::core::componentmodel::behavior::MappedModel< TDataTypes >.

Reimplemented in SofaFlowVR::FlowVRRenderMesh.

Definition at line 110 of file VisualModelImpl.h.

Container of Deriv values with the same API as sofa::helper::vector.

Reimplemented from sofa::core::componentmodel::behavior::MappedModel< TDataTypes >.

Definition at line 112 of file VisualModelImpl.h.


Constructor & Destructor Documentation

sofa::component::visualmodel::VisualModelImpl::VisualModelImpl (  ) 

Definition at line 127 of file VisualModelImpl.cpp.

sofa::component::visualmodel::VisualModelImpl::~VisualModelImpl (  ) 


Member Function Documentation

bool sofa::component::visualmodel::VisualModelImpl::addBBox ( double *  ,
double *   
) [virtual]

used to add the bounding-box of this visual model to the given bounding box in order to compute the scene bounding box or cull hidden objects.

Returns:
false if the visual model does not define any bounding box, which should only be the case for "debug" objects, as this lack of information might affect performances and leads to incorrect scene bounding box.

Reimplemented from sofa::core::VisualModel.

Definition at line 582 of file VisualModelImpl.cpp.

References bbox, sofa::helper::Quater< Real >::rotate(), sofa::defaulttype::ExtVector< T >::size(), and sofa::component::visualmodel::RigidMappedModel::xforms.

void sofa::component::visualmodel::VisualModelImpl::applyRotation ( const Quat   )  [virtual]

Rotate the positions.

This method is optional, it is used when the user want to interactively change the position of an object

Reimplemented from sofa::core::VisualModel.

Definition at line 398 of file VisualModelImpl.cpp.

References sofa::component::visualmodel::ExtVec3fMappedModel::getVecX(), sofa::helper::Quater< Real >::rotate(), and updateVisual().

void sofa::component::visualmodel::VisualModelImpl::applyRotation ( const double  double,
const double  double,
const double  double 
) [virtual]

Rotate the positions using Euler Angles in degree.

This method is optional, it is used when the user want to interactively change the position of an object

Reimplemented from sofa::core::VisualModel.

Definition at line 393 of file VisualModelImpl.cpp.

Referenced by init().

void sofa::component::visualmodel::VisualModelImpl::applyScale ( const double  double  )  [virtual]

Scale the positions.

This method is optional, it is used when the user want to interactively change the position of an object

Reimplemented from sofa::core::VisualModel.

Definition at line 408 of file VisualModelImpl.cpp.

References sofa::component::visualmodel::ExtVec3fMappedModel::getVecX(), and updateVisual().

Referenced by init(), and main().

void sofa::component::visualmodel::VisualModelImpl::applyTranslation ( const double  double,
const double  double,
const double  double 
) [virtual]

Translate the positions.

This method is optional, it is used when the user want to interactively change the position of an object

Reimplemented from sofa::core::VisualModel.

Definition at line 381 of file VisualModelImpl.cpp.

References sofa::component::visualmodel::ExtVec3fMappedModel::getVecX(), and updateVisual().

Referenced by init(), and main().

void sofa::component::visualmodel::VisualModelImpl::applyUVScale ( const double  su,
const double  sv 
)

Definition at line 427 of file VisualModelImpl.cpp.

References vtexcoords.

Referenced by parse().

void sofa::component::visualmodel::VisualModelImpl::applyUVTranslation ( const double  dU,
const double  dV 
)

Definition at line 418 of file VisualModelImpl.cpp.

References vtexcoords.

Referenced by parse().

void sofa::component::visualmodel::VisualModelImpl::computeBBox (  )  [virtual]

Definition at line 564 of file VisualModelImpl.cpp.

References bbox, and vertices.

Referenced by load(), setMesh(), and updateVisual().

void sofa::component::visualmodel::VisualModelImpl::computeMesh (  )  [virtual]

void sofa::component::visualmodel::VisualModelImpl::computeNormals (  )  [virtual]

void sofa::component::visualmodel::VisualModelImpl::computePositions (  )  [virtual]

void sofa::component::visualmodel::VisualModelImpl::drawShadow (  )  [virtual]

Display shadow-casting surfaces.

This method default to calling draw(). Object that do not cast any shadows, or that use a different LOD for them should reimplement it.

Reimplemented from sofa::core::VisualModel.

Definition at line 167 of file VisualModelImpl.cpp.

References getCastShadow(), internalDraw(), and isTransparent().

void sofa::component::visualmodel::VisualModelImpl::drawTransparent (  )  [virtual]

Display transparent surfaces.

Transparent objects should use this method to get a correct display order.

Reimplemented from sofa::core::VisualModel.

Definition at line 161 of file VisualModelImpl.cpp.

References internalDraw(), and isTransparent().

void sofa::component::visualmodel::VisualModelImpl::drawVisual (  )  [virtual]

Display the VisualModel object.

Reimplemented from sofa::core::VisualModel.

Definition at line 155 of file VisualModelImpl.cpp.

References internalDraw(), and isTransparent().

void sofa::component::visualmodel::VisualModelImpl::exportOBJ ( std::string  name,
std::ostream *  out,
std::ostream *  mtl,
int &  vindex,
int &  nindex,
int &  tindex 
) [virtual]

Append this mesh to an OBJ format stream.

The number of vertices position, normal, and texture coordinates already written is given as parameters This method should update them

Reimplemented from sofa::core::VisualModel.

Definition at line 1163 of file VisualModelImpl.cpp.

References sofa::defaulttype::ExtVector< T >::empty(), sofa::core::objectmodel::Data< T >::getValue(), sofa::component::visualmodel::ExtVec3fMappedModel::inputVertices, material, quads, sofa::defaulttype::ExtVector< T >::size(), triangles, vertNormIdx, vertPosIdx, vnormals, and vtexcoords.

void sofa::component::visualmodel::VisualModelImpl::flipFaces (  ) 

Definition at line 603 of file VisualModelImpl.cpp.

References quads, sofa::defaulttype::ExtVector< T >::size(), triangles, and vnormals.

Referenced by parse().

bool sofa::component::visualmodel::VisualModelImpl::getCastShadow (  )  const [inline]

Definition at line 203 of file VisualModelImpl.h.

References castShadow.

Referenced by drawShadow().

std::string sofa::component::visualmodel::VisualModelImpl::getFilename (  )  [inline]

Definition at line 194 of file VisualModelImpl.h.

References filename, and sofa::core::objectmodel::Data< T >::getValue().

virtual std::string sofa::component::visualmodel::VisualModelImpl::getTemplateName (  )  const [inline, virtual]

Get the template type names (if any) used to instantiate this object.

Reimplemented from sofa::core::componentmodel::behavior::State< TDataTypes >.

Definition at line 240 of file VisualModelImpl.h.

ResizableExtVector<Triangle>* sofa::component::visualmodel::VisualModelImpl::getTriangles (  )  [inline]

Definition at line 210 of file VisualModelImpl.h.

References triangles.

bool sofa::component::visualmodel::VisualModelImpl::getUseNormals (  )  const [inline]

Definition at line 200 of file VisualModelImpl.h.

References useNormals.

ResizableExtVector<Coord>* sofa::component::visualmodel::VisualModelImpl::getVertices (  )  [inline]

Definition at line 208 of file VisualModelImpl.h.

References vertices.

void sofa::component::visualmodel::VisualModelImpl::handleTopologyChange (  )  [virtual]

void sofa::component::visualmodel::VisualModelImpl::init ( void   )  [virtual]

void sofa::component::visualmodel::VisualModelImpl::initVisual (  )  [virtual]

Initialize the textures, or other graphical resources.

Called once before the first frame is drawn, and if the graphical context has been recreated.

Reimplemented from sofa::core::VisualModel.

Reimplemented in sofa::component::visualmodel::OglModel.

Definition at line 1155 of file VisualModelImpl.cpp.

virtual void sofa::component::visualmodel::VisualModelImpl::internalDraw (  )  [inline, protected, virtual]

Reimplemented in sofa::component::visualmodel::OglModel.

Definition at line 161 of file VisualModelImpl.h.

Referenced by drawShadow(), drawTransparent(), and drawVisual().

bool sofa::component::visualmodel::VisualModelImpl::isTransparent (  ) 

bool sofa::component::visualmodel::VisualModelImpl::isUsingTopology (  )  const [inline]

Definition at line 206 of file VisualModelImpl.h.

References useTopology.

bool sofa::component::visualmodel::VisualModelImpl::load ( const std::string &  filename,
const std::string &  loader,
const std::string &  textureName 
)

virtual bool sofa::component::visualmodel::VisualModelImpl::loadTexture ( const std::string &   )  [inline, virtual]

Reimplemented in sofa::component::visualmodel::OglModel, and SofaFlowVR::FlowVRRenderMesh.

Definition at line 179 of file VisualModelImpl.h.

Referenced by load().

void sofa::component::visualmodel::VisualModelImpl::parse ( core::objectmodel::BaseObjectDescription *  arg  )  [virtual]

void sofa::component::visualmodel::VisualModelImpl::setCastShadow ( bool  val  )  [inline]

Definition at line 202 of file VisualModelImpl.h.

References castShadow.

Referenced by parse().

void sofa::component::visualmodel::VisualModelImpl::setColor ( std::string  color  ) 

Definition at line 641 of file VisualModelImpl.cpp.

References sofa::component::visualmodel::hexval(), and setColor().

void sofa::component::visualmodel::VisualModelImpl::setColor ( float  r,
float  g,
float  b,
float  a 
)

void sofa::component::visualmodel::VisualModelImpl::setFilename ( std::string  s  )  [inline]

Definition at line 193 of file VisualModelImpl.h.

References filename, and sofa::core::objectmodel::Data< T >::setValue().

void sofa::component::visualmodel::VisualModelImpl::setMesh ( helper::io::Mesh &  m,
bool  tex = false 
)

void sofa::component::visualmodel::VisualModelImpl::setTriangles ( ResizableExtVector< Triangle > *  t  )  [inline]

Definition at line 211 of file VisualModelImpl.h.

References triangles.

void sofa::component::visualmodel::VisualModelImpl::setUseNormals ( bool  val  )  [inline]

Definition at line 199 of file VisualModelImpl.h.

References useNormals.

Referenced by parse().

void sofa::component::visualmodel::VisualModelImpl::setVertices ( ResizableExtVector< Coord > *  x  )  [inline]

Definition at line 209 of file VisualModelImpl.h.

References vertices.

static std::string sofa::component::visualmodel::VisualModelImpl::templateName ( const VisualModelImpl *  p = NULL  )  [inline, static]

Definition at line 245 of file VisualModelImpl.h.

void sofa::component::visualmodel::VisualModelImpl::updateVisual (  )  [virtual]


Field Documentation

Definition at line 127 of file VisualModelImpl.h.

Referenced by computeMesh(), handleTopologyChange(), init(), and updateVisual().

True if object cast shadows.

Definition at line 125 of file VisualModelImpl.h.

Referenced by getCastShadow(), and setCastShadow().

Definition at line 140 of file VisualModelImpl.h.

Referenced by init().

Definition at line 138 of file VisualModelImpl.h.

Referenced by init().

Definition at line 130 of file VisualModelImpl.h.

Referenced by init().

Definition at line 133 of file VisualModelImpl.h.

Referenced by init().

Definition at line 135 of file VisualModelImpl.h.

Referenced by init().

Time stamps from the last time the mesh was updated from the topology.

Definition at line 123 of file VisualModelImpl.h.

Referenced by computeMesh(), SofaFlowVR::FlowVRRenderMesh::renderUpdate(), and updateVisual().

Definition at line 156 of file VisualModelImpl.h.

Referenced by init(), parse(), and SofaFlowVR::FlowVRRenderMesh::renderUpdate().

Definition at line 152 of file VisualModelImpl.h.

Referenced by parse().

Definition at line 155 of file VisualModelImpl.h.

Referenced by init(), and parse().

True if normals should be read from file.

Definition at line 124 of file VisualModelImpl.h.

Referenced by getUseNormals(), setMesh(), and setUseNormals().

Similarly this vector store which input normal is used for each vertice If it is empty then each vertex correspond to one normal.

Definition at line 150 of file VisualModelImpl.h.

Referenced by computeNormals(), sofa::component::visualmodel::OgreVisualModel::computeNormals(), exportOBJ(), and setMesh().

If vertices have multiple normals/texcoords, then we need to separate them This vector store which input position is used for each vertice If it is empty then each vertex correspond to one position.

Definition at line 146 of file VisualModelImpl.h.

Referenced by computePositions(), exportOBJ(), and setMesh().


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

Generated on Sun Nov 23 04:21:54 2008 for Sofa by  doxygen 1.5.7.1