AnimatLab  2
Test
VsConstraintFriction.cpp
1 // VsConstraintFriction.cpp: implementation of the VsConstraintFriction class.
2 //
4 
5 #include "StdAfx.h"
6 #include "VsConstraintFriction.h"
7 #include "VsMovableItem.h"
8 #include "VsBody.h"
9 #include "VsJoint.h"
10 #include "VsMotorizedJoint.h"
11 #include "VsRigidBody.h"
12 #include "VsStructure.h"
13 #include "VsSimulator.h"
14 #include "VsOsgUserData.h"
15 #include "VsOsgUserDataVisitor.h"
16 #include "VsDragger.h"
17 #include "VsSimulator.h"
18 
19 namespace VortexAnimatSim
20 {
21  namespace Environment
22  {
23 
25 // Construction/Destruction
27 
28 VsConstraintFriction::VsConstraintFriction()
29 {
30 }
31 
32 VsConstraintFriction::~VsConstraintFriction()
33 {
34 }
35 
37 {
38  ConstraintFriction::Initialize();
39 
40  SetFrictionProperties();
41 }
42 
43 void VsConstraintFriction::SetFrictionProperties()
44 {
45  if(m_lpSim && m_lpNode)
46  {
47  VsJoint *lpJoint = dynamic_cast<VsJoint *>(m_lpNode);
48  if(lpJoint)
49  {
50  Vx::VxConstraint *vxConstraint = lpJoint->Constraint();
51 
52  if(vxConstraint)
53  {
54  VxConstraintFriction *vxCFriction = vxConstraint->getCoordinateFriction(0);
55 
56  if(vxCFriction)
57  {
58  vxCFriction->setEnabled(m_bEnabled);
59  vxCFriction->setCoefficient(m_fltCoefficient);
60  vxCFriction->setMaxForce(m_fltMaxForce);
61  vxCFriction->setProportional(m_bProportional);
62  vxCFriction->setStaticFrictionScale(m_fltStaticFrictionScale);
63  }
64  }
65 
66  }
67  }
68 }
69 
70  } // Visualization
71 } //VortexAnimatSim
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
A common class for all joint data specific to vortex.
Definition: VsJoint.h:32
float m_fltStaticFrictionScale
The scale ration of static to dynamic friction.
virtual void Initialize()
Initializes this object.
Node * m_lpNode
The pointer to this items parent Node. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:52
float m_fltCoefficient
The friction coefficient for this constraint.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
bool m_bProportional
Tells if the friction force should be scaled based on the force applied to the joint.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
Definition: AnimatBase.h:40
float m_fltMaxForce
The maximum force for this constraint.
Declares the vortex structure class.