3 #include "OsgMovableItem.h"
5 #include "OsgRigidBody.h"
7 #include "OsgHingeLimit.h"
9 #include "OsgUserData.h"
10 #include "OsgUserDataVisitor.h"
11 #include "OsgDragger.h"
20 OsgHingeLimit::OsgHingeLimit()
24 OsgHingeLimit::~OsgHingeLimit()
28 void OsgHingeLimit::LimitAlpha(
float fltA)
30 if(m_osgFlapMat.valid() && m_osgFlapSS.valid())
32 m_osgFlapMat->setAlpha(osg::Material::FRONT_AND_BACK, fltA);
35 m_osgFlapSS->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
37 m_osgFlapSS->setRenderingHint(osg::StateSet::OPAQUE_BIN);
41 void OsgHingeLimit::SetLimitPos(
float fltHeight)
43 float fltLimitPos = m_lpThisLimit->LimitPos();
44 CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0);
47 if(m_osgFlapRotateMT.valid() && m_osgFlapTranslateMT.valid())
50 vPos.Set(0, 0, 0); vRot.Set(0, 0, -fltLimitPos);
51 m_osgFlapRotateMT->setMatrix(SetupMatrix(vPos, vRot));
53 vPos.Set((fltHeight/2)*sin(-fltLimitPos), -(fltHeight/2)*cos(-fltLimitPos), 0); vRot.Set(0, 0, 0);
54 m_osgFlapTranslateMT->setMatrix(SetupMatrix(vPos, vRot));
58 void OsgHingeLimit::DeleteLimitGraphics()
60 m_osgFlapRotateMT.release();
62 m_osgFlapMat.release();
63 m_osgFlapSS.release();
66 void OsgHingeLimit::SetupLimitGraphics(
float fltFlapWidth,
float fltCylinderHeight)
68 float fltLimitPos = m_lpThisLimit->LimitPos();
69 CStdColor *vColor = m_lpThisLimit->Color();
72 m_osgFlap = CreateBoxGeometry(fltFlapWidth, (fltCylinderHeight/2),
73 fltCylinderHeight, fltFlapWidth,
74 (fltCylinderHeight/2), fltCylinderHeight);
75 osg::ref_ptr<osg::Geode> osgFlap =
new osg::Geode;
76 osgFlap->addDrawable(m_osgFlap.get());
78 CStdFPoint vPos(0, 0, 0), vRot(0, 0, 0);
81 vPos.Set(0, 0, 0); vRot.Set(0, 0, -fltLimitPos);
82 m_osgFlapRotateMT =
new osg::MatrixTransform();
83 m_osgFlapRotateMT->setMatrix(SetupMatrix(vPos, vRot));
84 m_osgFlapRotateMT->addChild(osgFlap.get());
86 vPos.Set((fltCylinderHeight/2)*sin(-fltLimitPos), -(fltCylinderHeight/2)*cos(-fltLimitPos), 0);
88 m_osgFlapTranslateMT =
new osg::MatrixTransform();
89 m_osgFlapTranslateMT->setMatrix(SetupMatrix(vPos, vRot));
90 m_osgFlapTranslateMT->addChild(m_osgFlapRotateMT.get());
93 if(!m_osgFlapMat.valid())
94 m_osgFlapMat =
new osg::Material();
97 m_osgFlapSS = m_osgFlapTranslateMT->getOrCreateStateSet();
100 m_osgFlapMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.1, 0.1, 0.1, 1));
101 m_osgFlapMat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(vColor->r(), vColor->g(), vColor->b(), vColor->a()));
102 m_osgFlapMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25, 0.25, 0.25, 1));
103 m_osgFlapMat->setShininess(osg::Material::FRONT_AND_BACK, 64);
104 m_osgFlapSS->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
107 m_osgFlapSS->setAttribute(m_osgFlapMat.get(), osg::StateAttribute::ON);
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
Declares the vortex structure class.