AnimatLab  2
Test
BlEllipsoid.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "BlOsgGeometry.h"
9 #include "BlJoint.h"
10 #include "BlRigidBody.h"
11 #include "BlEllipsoid.h"
12 #include "BlSimulator.h"
13 
14 namespace BulletAnimatSim
15 {
16  namespace Environment
17  {
18  namespace Bodies
19  {
20 
28 {
29  SetThisPointers();
30 }
31 
32 BlEllipsoid::~BlEllipsoid()
33 {
34  try
35  {
36  DeleteGraphics();
37  DeletePhysics(false);
38  }
39  catch(...)
40  {Std_TraceMsg(0, "Caught Error in desctructor of BlEllipsoid/\r\n", "", -1, false, true);}
41 }
42 
43 void BlEllipsoid::CreateGraphicsGeometry()
44 {
45  m_osgGeometry = CreateEllipsoidGeometry(m_iLatSegments, m_iLongSegments, m_fltMajorRadius, m_fltMinorRadius);
46 }
47 
48 void BlEllipsoid::CreatePhysicsGeometry()
49 {
50  if(IsCollisionObject())
51  {
52  DeleteCollisionGeometry();
53 
54  m_eBodyType = CONVEX_HULL_SHAPE_PROXYTYPE;
55  CalculateVolumeAndAreas();
56  m_btCollisionShape = OsgMeshToConvexHull(m_osgNode.get(), true, -1);
57  //m_bDisplayDebugCollisionGraphic = true;
58  }
59 }
60 
61 void BlEllipsoid::CalculateVolumeAndAreas()
62 {
65 
66  if(m_fltMass < 0)
67  {
68  float fltMass = m_fltVolume * m_fltDensity;
69  Mass(fltMass, false, false);
70  }
71 }
72 
74 {
75  CreateGeometry();
76 
77  BlRigidBody::CreateItem();
78  Ellipsoid::CreateParts();
79 }
80 
82 {
85 
86  Ellipsoid::CreateJoints();
87  BlRigidBody::Initialize();
88 }
89 
90  } //Bodies
91  } // Environment
92 } //BulletAnimatSim
virtual bool IsCollisionObject()
Query if this object is collision object.
Definition: RigidBody.cpp:468
float m_fltMinorRadius
The radius of the minor axis of the ellipsoid.
Definition: Ellipsoid.h:31
float m_fltMass
The mass of the object.
Definition: RigidBody.h:85
float m_fltMajorRadius
The radius of the major axis of the ellipsoid.
Definition: Ellipsoid.h:28
float m_fltVolume
The volume for the rigid body.
Definition: RigidBody.h:91
virtual void CreateParts()
Allows the rigid body to create its parts using the chosen physics engine.
Definition: BlEllipsoid.cpp:73
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual void CreateJoint()
Creates the joint.
Definition: Joint.cpp:602
virtual void CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
Definition: BlEllipsoid.cpp:81
float m_fltDensity
Uniform density for the rigid body.
Definition: RigidBody.h:79
int m_iLatSegments
The number of segments used to draw in the latitude direction.
Definition: Ellipsoid.h:34
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
Declares the vortex ellipsoid class.
int m_iLongSegments
The number of segments used to draw in the longtitude direction.
Definition: Ellipsoid.h:37