OpenFrames
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OpenFrames::Model Class Reference

A Reference Frame that contains a 3D model. More...

#include <Model.hpp>

Inheritance diagram for OpenFrames::Model:
OpenFrames::ReferenceFrame

Public Member Functions

 Model (const std::string &name)
 
 Model (const std::string &name, const osg::Vec3 &color)
 
 Model (const std::string &name, const osg::Vec4 &color)
 
 Model (const std::string &name, float r, float g, float b, float a=1.0)
 
virtual osg::Group * getGroup () const
 
bool setModel (const std::string &filename, bool force_reload=false)
 
osg::Node * getModel () const
 
osg::Geode * getExtras () const
 
bool shareModel (const Model *otherModel)
 
void setModelPosition (const double &x, const double &y, const double &z)
 
void setModelPosition (const osg::Vec3d &pos)
 
void getModelPosition (double &x, double &y, double &z) const
 
void getModelPosition (osg::Vec3d &pos) const
 
void setModelAttitude (const osg::Quat &att)
 
void getModelAttitude (osg::Quat &att) const
 
void setModelScale (const double &sx, const double &sy, const double &sz)
 
void getModelScale (double &sx, double &sy, double &sz) const
 
void setModelPivot (const double &px, const double &py, const double &pz)
 
void getModelPivot (double &px, double &py, double &pz) const
 
const FrameTransformgetModelTransform () const
 
void addDraggerCallback (osgManipulator::DraggerCallback *callback)
 
virtual const osg::BoundingSphere & getBound () const
 
- Public Member Functions inherited from OpenFrames::ReferenceFrame
 ReferenceFrame (const std::string &name)
 
 ReferenceFrame (const std::string &name, const osg::Vec3 &color)
 
 ReferenceFrame (const std::string &name, const osg::Vec4 &color)
 
 ReferenceFrame (const std::string &name, float r, float g, float b, float a=1.0)
 
void setName (const std::string &name)
 
const std::string & getName () const
 
virtual void setColor (const osg::Vec4 &color)
 
virtual void setColor (float r, float g, float b, float a=1.0)
 
virtual const osg::Vec4 & getColor () const
 
virtual void getColor (float &r, float &g, float &b, float &a) const
 
FrameTransformgetTransform () const
 
void setPosition (const double &x, const double &y, const double &z)
 
void setPosition (const osg::Vec3d &pos)
 
void getPosition (double &x, double &y, double &z) const
 
void getPosition (osg::Vec3d &pos) const
 
void setAttitude (const double &rx, const double &ry, const double &rz, const double &angle)
 
void setAttitude (const osg::Quat &att)
 
void getAttitude (double &rx, double &ry, double &rz, double &angle) const
 
void getAttitude (osg::Quat &att) const
 
virtual void showAxes (unsigned int axes)
 
virtual void showAxesLabels (unsigned int labels)
 
virtual void showNameLabel (bool namelabel)
 
virtual void showContents (bool showContents)
 
virtual bool getContentsShown () const
 
void moveXAxis (osg::Vec3d base, double len, double headRatio=0.3, double bodyRadius=0.0, double headRadius=0.0) const
 
void moveYAxis (osg::Vec3d base, double len, double headRatio=0.3, double bodyRadius=0.0, double headRadius=0.0) const
 
void moveZAxis (osg::Vec3d base, double len, double headRatio=0.3, double bodyRadius=0.0, double headRadius=0.0) const
 
void setXLabel (const std::string &str)
 
void setYLabel (const std::string &str)
 
void setZLabel (const std::string &str)
 
bool addChild (ReferenceFrame *frame)
 
bool removeChild (ReferenceFrame *frame)
 
void setLightSourceEnabled (bool enable)
 
bool getLightSourceEnabled () const
 
osg::LightSource * getLightSource () const
 
int getNumChildren ()
 
ReferenceFramegetChild (int i)
 
void createFrameString (std::string &str, std::string prefix=" ") const
 
virtual std::string frameInfo () const
 
void addParent (ReferenceFrame *frame)
 
void removeParent (ReferenceFrame *frame)
 
int getNumParents () const
 
ReferenceFramegetParent (int i)
 
void addTracker (FrameTracker *t)
 
void removeTracker (FrameTracker *t)
 
int getNumTrackers () const
 
FrameTrackergetTracker (int i)
 
int getChildIndex (const ReferenceFrame *frame) const
 
int getParentIndex (const ReferenceFrame *frame) const
 
int getTrackerIndex (const FrameTracker *t) const
 

Protected Member Functions

void init ()
 
void repositionAxes ()
 

Protected Attributes

osg::ref_ptr< osg::Group > _group
 
osg::ref_ptr< osg::Node > _model
 
osg::ref_ptr< FrameTransform_modelXform
 
osg::ref_ptr< osg::Geode > _extras
 
osg::ref_ptr< osgManipulator::TrackballDragger > _dragger
 
osg::ref_ptr< osg::MatrixTransform > _draggerXform
 
- Protected Attributes inherited from OpenFrames::ReferenceFrame
std::string _name
 Name of reference frame.
 
osg::ref_ptr< Vector_xAxis
 Vector of frame's x-axis.
 
osg::ref_ptr< Vector_yAxis
 Vector of frame's y-axis.
 
osg::ref_ptr< Vector_zAxis
 Vector of frame's z-axis.
 
osg::ref_ptr< osgText::Text > _xLabel
 X-Axes label.
 
osg::ref_ptr< osgText::Text > _yLabel
 Y-Axes label.
 
osg::ref_ptr< osgText::Text > _zLabel
 Z-Axes label.
 
osg::ref_ptr< osgText::Text > _nameLabel
 Name of reference frame that is displayed.
 
osg::ref_ptr< osg::Geode > _axes
 x,y,z axes together
 
osg::ref_ptr< osg::Geode > _labels
 axes and name labels
 
osg::BoundingSphere _bound
 Frame's bounding sphere.
 
osg::ref_ptr< FrameTransform_xform
 The transform that all contained objects will undergo.
 

Additional Inherited Members

- Public Types inherited from OpenFrames::ReferenceFrame
enum  AxesType { NO_AXES = 0, X_AXIS = 1, Y_AXIS = 2, Z_AXIS = 4 }
 
typedef std::vector< ReferenceFrame * > ParentList
 
typedef std::vector< osg::ref_ptr< ReferenceFrame > > ChildList
 
typedef std::vector< FrameTracker * > TrackerList
 

Detailed Description

A Reference Frame that contains a 3D model.

A Model is a Reference Frame that also contains a 3D model at the origin. Any model can be loaded as long as the format is supported by OSG.

Member Function Documentation

◆ addDraggerCallback()

void OpenFrames::Model::addDraggerCallback ( osgManipulator::DraggerCallback *  callback)

Enable model dragging. Call with NULL to set up dragger without installing a callback

◆ getBound()

virtual const osg::BoundingSphere& OpenFrames::Model::getBound ( ) const
virtual

Inherited function to compute the bounds of the model

Reimplemented from OpenFrames::ReferenceFrame.

◆ getGroup()

virtual osg::Group* OpenFrames::Model::getGroup ( ) const
virtual

We will maintain our own osg::Group, because loaded models might have ParticleSystems or other things which need to reside in world space. Therefore, our group will contain the ReferenceFrame's transform as well as any ParticleSystems and other such things.

Reimplemented from OpenFrames::ReferenceFrame.

◆ getModelTransform()

const FrameTransform* OpenFrames::Model::getModelTransform ( ) const
inline

Get the transformation that applies to the model

◆ setModel()

bool OpenFrames::Model::setModel ( const std::string &  filename,
bool  force_reload = false 
)

Set the model that should be displayed

◆ setModelAttitude()

void OpenFrames::Model::setModelAttitude ( const osg::Quat &  att)
inline

Set/get the attitude of the model wrt the local frame.

◆ setModelPivot()

void OpenFrames::Model::setModelPivot ( const double &  px,
const double &  py,
const double &  pz 
)

Set/get the pivot point of the model. This is the point about which all rotations happen, and wrt which all points are moved during a scale.

◆ setModelPosition()

void OpenFrames::Model::setModelPosition ( const double &  x,
const double &  y,
const double &  z 
)

Set/get the position of the model wrt the local frame. This is useful e.g. if the model's defined origin is not where you want it to be.

◆ setModelScale()

void OpenFrames::Model::setModelScale ( const double &  sx,
const double &  sy,
const double &  sz 
)

Set/get the scale of the model wrt the pivot point.

◆ shareModel()

bool OpenFrames::Model::shareModel ( const Model otherModel)

Use a model that has already been loaded by another Model object

Member Data Documentation

◆ _extras

osg::ref_ptr<osg::Geode> OpenFrames::Model::_extras
protected

Any extra drawables which are not contained in the transform, but are still part of this frame. eg. ParticleSystems, etc...

◆ _group

osg::ref_ptr<osg::Group> OpenFrames::Model::_group
protected

The group will hold this frame's transform, as explained above

◆ _model

osg::ref_ptr<osg::Node> OpenFrames::Model::_model
protected

3D model, excluding ParticleSystems

◆ _modelXform

osg::ref_ptr<FrameTransform> OpenFrames::Model::_modelXform
protected

Transform that applies only to the model itself


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