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

A ReferenceFrame with a sphere at the origin. More...

#include <Sphere.hpp>

Inheritance diagram for OpenFrames::Sphere:
OpenFrames::ReferenceFrame OpenFrames::SkySphere

Public Member Functions

 Sphere (const std::string &name)
 
 Sphere (const std::string &name, const osg::Vec3 &color)
 
 Sphere (const std::string &name, const osg::Vec4 &color)
 
 Sphere (const std::string &name, float r, float g, float b, float a=1.0)
 
virtual void showContents (bool showContents)
 
virtual bool getContentsShown () const
 
void restoreTexCoords ()
 
void setRadius (const double &radius)
 
double getRadius () const
 
void setSpherePosition (const double &x, const double &y, const double &z)
 
void setSpherePosition (const osg::Vec3d &pos)
 
void getSpherePosition (double &x, double &y, double &z) const
 
void getSpherePosition (osg::Vec3d &pos) const
 
void setSphereAttitude (const osg::Quat &att)
 
void getSphereAttitude (osg::Quat &att) const
 
void setSphereScale (const double &sx, const double &sy, const double &sz)
 
void getSphereScale (double &sx, double &sy, double &sz) const
 
bool setTextureMap (const std::string &fname, unsigned int unit=0, bool force_reload=false)
 
bool setTexEnv (osg::StateAttribute *texenv, unsigned int unit)
 
bool setNightTextureMap (const std::string &fname, unsigned int unit=1, bool force_reload=false)
 
void setAutoLOD (bool lod)
 
virtual void setColor (const osg::Vec4 &color)
 
void setMaterial (osg::Material *mat)
 
osg::Material * getMaterial () const
 
virtual const osg::BoundingSphere & getBound () const
 
virtual void setColor (const osg::Vec4 &color)
 
virtual void setColor (float r, float g, float b, float a=1.0)
 
- 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 (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
 
virtual osg::Group * getGroup () 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)
 
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 repositionAxes ()
 

Protected Attributes

osg::ref_ptr< FrameTransform_sphereXform
 
osg::ref_ptr< osg::Geode > _geode
 
osg::ref_ptr< osg::ShapeDrawable > _sphereSD
 
- 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 ReferenceFrame with a sphere at the origin.

An OpenFrames Sphere is a ReferenceFrame with a 3D model of a sphere at its origin. The radius of the sphere is adjustable, and a texture can be mapped onto the sphere.

Member Function Documentation

◆ getBound()

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

Inherited from ReferenceFrame.

Reimplemented from OpenFrames::ReferenceFrame.

◆ restoreTexCoords()

void OpenFrames::Sphere::restoreTexCoords ( )

Needed because osg::ShapeDrawable only sets texture coordinates for unit0. This can be removed once the Sphere creates its own geometry. Not for use by end user.

◆ setAutoLOD()

void OpenFrames::Sphere::setAutoLOD ( bool  lod)

Have the sphere automatically adjust its detail level depending on how far it is from the current eye point.

◆ setColor()

virtual void OpenFrames::Sphere::setColor ( const osg::Vec4 &  color)
virtual

Inherited from ReferenceFrame Set the color of the sphere. Has no effect if a texture or material are applied to the sphere.

Reimplemented from OpenFrames::ReferenceFrame.

◆ setMaterial()

void OpenFrames::Sphere::setMaterial ( osg::Material *  mat)

Set the material used for sphere lighting. See osg::Material and OpenGL documentation for material parameters. This overrides color set by setColor(), and affects texture color.

◆ setNightTextureMap()

bool OpenFrames::Sphere::setNightTextureMap ( const std::string &  fname,
unsigned int  unit = 1,
bool  force_reload = false 
)

Convenience function to specify a night texture map. This is combined with the day texture map (assumed to be on previous texture unit) and shows on the dark side of the sphere.

◆ setRadius()

void OpenFrames::Sphere::setRadius ( const double &  radius)

Set the radius of the sphere, given wrt the origin of the sphere's reference frame

◆ setSphereAttitude()

void OpenFrames::Sphere::setSphereAttitude ( const osg::Quat &  att)
inline

Set/get the attitude of the sphere wrt the local frame. Useful for reorienting textures.

◆ setSpherePosition()

void OpenFrames::Sphere::setSpherePosition ( const double &  x,
const double &  y,
const double &  z 
)

Set/get the position of the sphere wrt the local frame.

◆ setSphereScale()

void OpenFrames::Sphere::setSphereScale ( const double &  sx,
const double &  sy,
const double &  sz 
)

Set/get the scale of the sphere wrt the pivot point. Useful for turning a sphere into an ellipsoid.

◆ setTexEnv()

bool OpenFrames::Sphere::setTexEnv ( osg::StateAttribute *  texenv,
unsigned int  unit 
)

Set the texture environment for the specified texture unit.

◆ setTextureMap()

bool OpenFrames::Sphere::setTextureMap ( const std::string &  fname,
unsigned int  unit = 0,
bool  force_reload = false 
)

Set the filename of the texture to map onto the sphere. Consult the osg documentation to see which image filetypes are supported.

Member Data Documentation

◆ _sphereXform

osg::ref_ptr<FrameTransform> OpenFrames::Sphere::_sphereXform
protected

Transform that applies only to the sphere itself


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