3 #include "OsgMovableItem.h"
5 #include "OsgRigidBody.h"
7 #include "OsgDragger.h"
8 #include "OsgTranslateAxisDragger.h"
10 #include "OsgUserData.h"
11 #include "OsgSimulator.h"
15 namespace Visualization
18 OsgTranslateAxisDragger::OsgTranslateAxisDragger(
bool bAllowTranslateX,
bool bAllowTranslateY,
bool bAllowTranslateZ)
22 _xDragger =
new osgManipulator::Translate1DDragger(osg::Vec3(0.0,0.0,0.0), osg::Vec3(0.0,0.0,1.0));
23 addChild(_xDragger.get());
24 addDragger(_xDragger.get());
29 _yDragger =
new osgManipulator::Translate1DDragger(osg::Vec3(0.0,0.0,0.0), osg::Vec3(0.0,0.0,1.0));
30 addChild(_yDragger.get());
31 addDragger(_yDragger.get());
36 _zDragger =
new osgManipulator::Translate1DDragger(osg::Vec3(0.0,0.0,0.0), osg::Vec3(0.0,0.0,1.0));
37 addChild(_zDragger.get());
38 addDragger(_zDragger.get());
41 setParentDragger(getParentDragger());
44 OsgTranslateAxisDragger::~OsgTranslateAxisDragger(
void)
51 if(!_xDragger.valid() && !_xDragger.valid() && !_xDragger.valid())
54 float fltLength = 1.0f;
57 osg::Geode* lineGeode =
new osg::Geode;
59 osg::Geometry* geometry =
new osg::Geometry();
61 osg::Vec3Array* vertices =
new osg::Vec3Array(2);
62 (*vertices)[0] = osg::Vec3(0.0f,0.0f,0.0f);
63 (*vertices)[1] = osg::Vec3(0.0f,0.0f,fltLength);
65 geometry->setVertexArray(vertices);
66 geometry->addPrimitiveSet(
new osg::DrawArrays(osg::PrimitiveSet::LINES,0,2));
68 lineGeode->addDrawable(geometry);
73 osg::LineWidth* linewidth =
new osg::LineWidth();
74 linewidth->setWidth(7.0f);
75 lineGeode->getOrCreateStateSet()->setAttributeAndModes(linewidth, osg::StateAttribute::ON);
76 lineGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
80 osg::Geode* geode =
new osg::Geode;
84 osg::Cone* cone =
new osg::Cone (osg::Vec3(0.0f, 0.0f, 1.0f), 0.06f, 0.30f);
85 geode->addDrawable(
new osg::ShapeDrawable(cone));
90 osg::Cylinder* cylinder =
new osg::Cylinder (osg::Vec3(0.0f,0.0f,0.5f), 0.03f, fltLength);
91 osg::Drawable* geometry =
new osg::ShapeDrawable(cylinder);
92 osgManipulator::setDrawableToAlwaysCull(*geometry);
93 geode->addDrawable(geometry);
99 _xDragger->addChild(lineGeode);
100 _xDragger->addChild(geode);
103 osg::Quat rotation; rotation.makeRotate(osg::Vec3(0.0f, 0.0f, 1.0f), osg::Vec3(1.0f, 0.0f, 0.0f));
104 _xDragger->setMatrix(osg::Matrix(rotation));
107 _xDragger->setColor(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
110 if(_yDragger.valid())
112 _yDragger->addChild(lineGeode);
113 _yDragger->addChild(geode);
116 osg::Quat rotation; rotation.makeRotate(osg::Vec3(0.0f, 0.0f, 1.0f), osg::Vec3(0.0f, 1.0f, 0.0f));
117 _yDragger->setMatrix(osg::Matrix(rotation));
120 _yDragger->setColor(osg::Vec4(0.0f,1.0f,0.0f,1.0f));
123 if(_zDragger.valid())
125 _zDragger->addChild(lineGeode);
126 _zDragger->addChild(geode);
129 _zDragger->setColor(osg::Vec4(0.0f,0.0f,1.0f,1.0f));
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
void setupDefaultGeometry()
Declares the vortex structure class.