3 #include "VsMovableItem.h"
6 #include "VsMotorizedJoint.h"
7 #include "VsRigidBody.h"
8 #include "VsHingeLimit.h"
10 #include "VsSimulator.h"
11 #include "VsOsgUserData.h"
12 #include "VsOsgUserDataVisitor.h"
13 #include "VsDragger.h"
22 VsHingeLimit::VsHingeLimit()
27 VsHingeLimit::~VsHingeLimit()
31 void VsHingeLimit::HingeRef(Vx::VxHinge *vxHinge)
40 if(m_osgFlapMat.valid() && m_osgFlapSS.valid())
42 m_osgFlapMat->setAlpha(osg::Material::FRONT_AND_BACK, fltA);
45 m_osgFlapSS->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
47 m_osgFlapSS->setRenderingHint(osg::StateSet::OPAQUE_BIN);
54 CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0);
56 Hinge *lpHinge =
dynamic_cast<Hinge *
>(
m_lpJoint);
59 if(m_osgFlapRotateMT.valid() && m_osgFlapTranslateMT.valid() && lpHinge)
62 float fltHeight = lpHinge->CylinderHeight();
65 m_osgFlapRotateMT->setMatrix(SetupMatrix(vPos, vRot));
68 m_osgFlapTranslateMT->setMatrix(SetupMatrix(vPos, vRot));
88 m_osgFlapRotateMT.release();
90 m_osgFlapMat.release();
91 m_osgFlapSS.release();
97 Hinge *lpHinge =
dynamic_cast<Hinge *
>(
m_lpJoint);
102 m_osgFlap = CreateBoxGeometry(lpHinge->FlapWidth(), (lpHinge->CylinderHeight()/2),
103 lpHinge->CylinderHeight(), lpHinge->FlapWidth(),
104 (lpHinge->CylinderHeight()/2), lpHinge->CylinderHeight());
105 osg::ref_ptr<osg::Geode> osgFlap =
new osg::Geode;
106 osgFlap->addDrawable(m_osgFlap.get());
108 CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0);
112 m_osgFlapRotateMT =
new osg::MatrixTransform();
113 m_osgFlapRotateMT->setMatrix(SetupMatrix(vPos, vRot));
114 m_osgFlapRotateMT->addChild(osgFlap.get());
118 m_osgFlapTranslateMT =
new osg::MatrixTransform();
119 m_osgFlapTranslateMT->setMatrix(SetupMatrix(vPos, vRot));
120 m_osgFlapTranslateMT->addChild(m_osgFlapRotateMT.get());
123 if(!m_osgFlapMat.valid())
124 m_osgFlapMat =
new osg::Material();
127 m_osgFlapSS = m_osgFlapTranslateMT->getOrCreateStateSet();
130 m_osgFlapMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.1, 0.1, 0.1, 1));
132 m_osgFlapMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25, 0.25, 0.25, 1));
133 m_osgFlapMat->setShininess(osg::Material::FRONT_AND_BACK, 64);
134 m_osgFlapSS->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
137 m_osgFlapSS->setAttribute(m_osgFlapMat.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...
virtual void DeleteGraphics()
Deletes up the graphics for the constraint.
float m_fltRestitution
The restitution coefficient for the constraint.
virtual void SetLimitPos()
Sets the limit position using the current value set within the object.
virtual float Alpha()
Gets the alpha value.
Joint * m_lpJoint
Pointer to parent joint.
float m_fltDamping
The damping for the constraint.
virtual void SetupGraphics()
Sets 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 SetLimitValues()
Sets the limit values of the joint in the child object.
CStdColor m_vColor
The color used to display the limit.
Declares the vortex structure class.