3 #include "VsMovableItem.h"
6 #include "VsMotorizedJoint.h"
7 #include "VsRigidBody.h"
8 #include "VsPrismaticLimit.h"
10 #include "VsSimulator.h"
11 #include "VsOsgUserData.h"
12 #include "VsOsgUserDataVisitor.h"
13 #include "VsDragger.h"
22 VsPrismaticLimit::VsPrismaticLimit()
27 VsPrismaticLimit::~VsPrismaticLimit()
31 void VsPrismaticLimit::PrismaticRef(Vx::VxPrismatic *vxPrismatic)
33 m_vxPrismatic = vxPrismatic;
40 if(m_osgBoxMat.valid() && m_osgBoxSS.valid())
42 m_osgBoxMat->setAlpha(osg::Material::FRONT_AND_BACK, fltA);
45 m_osgBoxSS->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
47 m_osgBoxSS->setRenderingHint(osg::StateSet::OPAQUE_BIN);
50 if(m_osgCylinderMat.valid() && m_osgCylinderSS.valid())
52 m_osgCylinderMat->setAlpha(osg::Material::FRONT_AND_BACK, fltA);
55 m_osgCylinderSS->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
57 m_osgCylinderSS->setRenderingHint(osg::StateSet::OPAQUE_BIN);
61 osg::Geometry *VsPrismaticLimit::BoxGeometry() {
return m_osgBox.get();}
63 osg::MatrixTransform *VsPrismaticLimit::BoxMT() {
return m_osgBoxMT.get();}
65 osg::Material *VsPrismaticLimit::BoxMat() {
return m_osgBoxMat.get();}
67 osg::StateSet *VsPrismaticLimit::BoxSS() {
return m_osgBoxSS.get();}
69 osg::Geometry *VsPrismaticLimit::CylinderGeometry() {
return m_osgCylinder.get();}
71 osg::MatrixTransform *VsPrismaticLimit::CylinderMT() {
return m_osgCylinderMT.get();}
73 osg::Material *VsPrismaticLimit::CylinderMat() {
return m_osgCylinderMat.get();}
75 osg::StateSet *VsPrismaticLimit::CylinderSS() {
return m_osgCylinderSS.get();}
79 CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0);
81 Prismatic *lpPrismatic =
dynamic_cast<Prismatic *
>(
m_lpJoint);
84 if(m_osgBoxMT.valid() && lpPrismatic)
87 m_osgBoxMT->setMatrix(SetupMatrix(vPos, vRot));
91 if(m_osgCylinderMT.valid() && m_osgCylinder.valid() && m_osgCylinderGeode.valid() && lpPrismatic)
94 if(m_osgCylinderGeode->containsDrawable(m_osgCylinder.get()))
95 m_osgCylinderGeode->removeDrawable(m_osgCylinder.get());
96 m_osgCylinder.release();
100 m_osgCylinderGeode->addDrawable(m_osgCylinder.get());
103 m_osgCylinderMT->setMatrix(SetupMatrix(vPos, vRot));
124 m_osgBoxMT.release();
125 m_osgBoxMat.release();
126 m_osgBoxSS.release();
127 m_osgCylinder.release();
128 m_osgCylinderGeode.release();
129 m_osgCylinderMT.release();
130 m_osgCylinderMat.release();
131 m_osgCylinderSS.release();
137 Prismatic *lpPrismatic =
dynamic_cast<Prismatic *
>(
m_lpJoint);
142 m_osgBox = CreateBoxGeometry(lpPrismatic->BoxSize(), lpPrismatic->BoxSize(),
143 lpPrismatic->BoxSize(), lpPrismatic->BoxSize(),
144 lpPrismatic->BoxSize(), lpPrismatic->BoxSize());
145 osg::ref_ptr<osg::Geode> osgBox =
new osg::Geode;
146 osgBox->addDrawable(m_osgBox.get());
148 CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0);
153 m_osgBoxMT =
new osg::MatrixTransform();
154 m_osgBoxMT->setMatrix(SetupMatrix(vPos, vRot));
155 m_osgBoxMT->addChild(osgBox.get());
158 if(!m_osgBoxMat.valid())
159 m_osgBoxMat =
new osg::Material();
162 m_osgBoxSS = m_osgBoxMT->getOrCreateStateSet();
165 m_osgBoxMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.1, 0.1, 0.1, 1));
167 m_osgBoxMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25, 0.25, 0.25, 1));
168 m_osgBoxMat->setShininess(osg::Material::FRONT_AND_BACK, 64);
169 m_osgBoxSS->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
172 m_osgBoxSS->setAttribute(m_osgBoxMat.get(), osg::StateAttribute::ON);
181 m_osgCylinderGeode =
new osg::Geode;
182 m_osgCylinderGeode->addDrawable(m_osgCylinder.get());
184 CStdFPoint vPos(0, 0, (-
m_fltLimitPos/2)), vRot(VX_PI/2, 0, 0);
185 m_osgCylinderMT =
new osg::MatrixTransform();
186 m_osgCylinderMT->setMatrix(SetupMatrix(vPos, vRot));
187 m_osgCylinderMT->addChild(m_osgCylinderGeode.get());
190 if(!m_osgCylinderMat.valid())
191 m_osgCylinderMat =
new osg::Material();
194 m_osgCylinderSS = m_osgCylinderMT->getOrCreateStateSet();
197 m_osgCylinderMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.1, 0.1, 0.1, 1));
200 m_osgCylinderMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25, 0.25, 0.25, 1));
201 m_osgCylinderMat->setShininess(osg::Material::FRONT_AND_BACK, 64);
202 m_osgCylinderSS->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
205 m_osgCylinderSS->setAttribute(m_osgCylinderMat.get(), osg::StateAttribute::ON);
float m_fltLimitPos
The limit position for the constraint. This can be in radians or meters depending on the type of join...
float m_fltRestitution
The restitution coefficient for the constraint.
virtual float Alpha()
Gets the alpha value.
osg::Geometry * CreateConeGeometry(float height, float topradius, float botradius, int sides, bool doSide, bool doTop, bool doBottom)
Joint * m_lpJoint
Pointer to parent joint.
virtual void SetupGraphics()
Sets up the graphics for the constraint.
float m_fltDamping
The damping for the constraint.
virtual void SetLimitValues()
Sets the limit values of the joint in the child object.
virtual void DeleteGraphics()
Deletes up the graphics for the constraint.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
float m_fltStiffness
The stiffness of the constraint.
bool m_bIsLowerLimit
If true then this is the lower limit of a pair of ConstraintLimits, else it is the upper limit...
virtual void SetLimitPos()
Sets the limit position using the current value set within the object.
CStdColor m_vColor
The color used to display the limit.
Declares the vortex structure class.