10#include <osg/ShapeDrawable>
13#include <osg/PositionAttitudeTransform>
16#include <a_utils/a_utils.h>
86 osg::ref_ptr<osg::Switch> m_pSelectionSwitch;
87 osg::ref_ptr<osg::Geode> m_pSelectionGeode;
88 osg::ref_ptr<osg::ShapeDrawable> m_pSelectionDrawable;
89 osg::ref_ptr<osg::Box> m_pSelectionBox;
127 osg::Geode* pGeode =
new osg::Geode;
133 m_pDrawable->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
136 m_pSelectionSwitch =
new osg::Switch;
137 m_pSelectionGeode =
new osg::Geode;
138 m_pSelectionDrawable =
new osg::ShapeDrawable;
139 m_pSelectionDrawable->setColor(osg::Vec4(0.0f, 1.0f, 0.0f, 0.4f));
140 m_pSelectionBox =
new osg::Box;
141 m_pSelectionDrawable->setShape(m_pSelectionBox);
143 m_pSelectionGeode->addDrawable(m_pSelectionDrawable);
144 m_pSelectionGeode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
145 m_pSelectionGeode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
147 m_pSelectionSwitch->addChild(m_pSelectionGeode);
148 m_pSelectionSwitch->setAllChildrenOff();
155 m_pHistoryGeom->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
156 m_pHistoryGeom->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::OFF);
157 osg::Geode* pHistoryGeode =
new osg::Geode;
166 addChild(pHistoryGeode);
169 m_pMotionArray =
new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP);
171 m_pMotionGeom->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
172 m_pMotionGeom->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::OFF);
173 osg::Geode* pMotionGeode =
new osg::Geode;
183 addChild(pMotionGeode);
245 virtual tResult
SetHistory(tBool bEnabled, tUInt32 nCount = 0)
279 virtual tResult
SetPosition(tFloat64 fPosX, tFloat64 fPosY, tFloat64 fPosZ)
322 virtual tResult
SetRotation(tFloat64 fRotX, tFloat64 fRotY, tFloat64 fRotZ)
325 osg::Quat(fRotX, osg::Vec3(1, 0, 0), fRotY, osg::Vec3(0, 1, 0), fRotZ, osg::Vec3(0, 0, 1)));
343 virtual tResult
SetSize(tFloat64 fSizeX, tFloat64 fSizeY, tFloat64 fSizeZ)
346 auto oNewDimensions = osg::Vec3d(fSizeX / 2.0, fSizeY / 2.0, fSizeZ / 2.0);
347 if (oNewDimensions !=
m_pBox->getHalfLengths())
349 m_pBox->setHalfLengths(oNewDimensions);
369 return m_pBox->getHalfLengths() * 2;
378 virtual tResult
SetColor(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue, tFloat64 fAlpha)
381 osg::Vec4 oColor(fRed, fGreen, fBlue, fAlpha);
389 m_pDrawable->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
390 m_pDrawable->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
394 m_pDrawable->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::OFF);
395 m_pDrawable->getOrCreateStateSet()->setRenderingHint(osg::StateSet::DEFAULT_BIN);
410 virtual tResult
SetMotion(tFloat64 fMotionX, tFloat64 fMotionY, tFloat64 fMotionZ)
443 m_pSelectionSwitch->setValue(0, bSelected);
466 osg::Vec3 vSize =
m_pBox->getHalfLengths();
467 vSize += osg::Vec3(0.1f, 0.1f, 0.1f);
468 m_pSelectionBox->setHalfLengths(vSize);
469 m_pSelectionDrawable->dirtyDisplayList();
478using endor::cBaseObject;
cBaseObject(tUInt32 nId)
Constructor.
tBool IsUpdated()
Returns whether or not this object has been updated since the last Reset call.
virtual tResult SetHistory(tBool bEnabled, tUInt32 nCount=0)
Enables or disable the history trail of this object.
osg::Vec3d GetMotion()
Returns the current motion vector.
tResult Reset()
Resets the updated property to false.
virtual tResult SetRotation(tFloat64 fRotX, tFloat64 fRotY, tFloat64 fRotZ)
Sets the rotation (attitude) of the object.
osg::ref_ptr< osg::ShapeDrawable > m_pDrawable
The drawable for the box.
tBool m_bUpdated
Whether or not this object has been updated.
virtual tResult SetMotionVector(tBool bEnabled)
Enables or disables the motion vector.
virtual ~cBaseObject()
Destructor.
tBool m_bSelected
Whether or not this object is selected.
virtual tResult SetMotion(tFloat64 fMotionX, tFloat64 fMotionY, tFloat64 fMotionZ)
Sets the motion vector of the object.
osg::ref_ptr< osg::Vec3Array > m_pMotionVector
The start and end point of the motion vector.
osg::ref_ptr< osg::DrawArrays > m_pMotionArray
This will do the actual drawing of the motion vector.
osg::Vec3d GetRotation()
Returns the current rotation.
virtual tBool IsSelected()
Returns the selected property of the object.
osg::ref_ptr< osg::Geometry > m_pHistoryGeom
Geometry object used for rendering the history trail.
tUInt32 GetId()
Returns the id of the object.
osg::Vec3d GetSize()
Returns the current size.
osg::ref_ptr< osg::Vec3Array > m_pPositionHistory
This will store old positions for drawing the history trail.
osg::ref_ptr< osg::DrawArrays > m_pHistoryArray
This will do the actual drawing of the history trail.
tResult Update()
Base Implementation sets the updated property to true.
osg::Vec3d m_vPos
The current position of the object.
virtual tResult SetSelected(tBool bSelected)
Gives the object a chance to change its appearance when being selected or unselected.
virtual tResult SetSize(tFloat64 fSizeX, tFloat64 fSizeY, tFloat64 fSizeZ)
Sets the dimensions of the object.
virtual tResult SetColor(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue, tFloat64 fAlpha)
Sets the color of the object.
cBaseObject(tUInt32 nId)
Constructor.
virtual tResult UpdateSelection()
Used to update the selection sphere.
osg::ref_ptr< osg::PositionAttitudeTransform > m_pTransform
The transform that applies the translation and rotation to the box.
virtual tResult SetPosition(tFloat64 fPosX, tFloat64 fPosY, tFloat64 fPosZ)
Sets the position of the object.
tBool m_bHistory
Whether or not to show the history trail.
osg::Vec3d GetPosition()
Returns the current position.
osg::ref_ptr< osg::Geometry > m_pMotionGeom
Geometry object used for rendering the motion vector.
tBool m_bMotionVector
Whether or not to show the motion vector.
osg::ref_ptr< osg::Vec4Array > m_pColorArray
The color array used for drawing the history trail and the motion vector.
osg::ref_ptr< osg::Box > m_pBox
The box that represents the object.
tUInt32 m_nHistorySize
The maximum amount of positions in the m_pPositionHistory array.
Namespace for functionality provided by the Mixin Library.
Namespace for functionality provided by the Display Toolbox.