AnimatLab  2
Test
OsgHud.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "OsgMovableItem.h"
9 #include "OsgBody.h"
10 #include "OsgRigidBody.h"
11 #include "OsgJoint.h"
12 #include "OsgOrganism.h"
13 #include "OsgStructure.h"
14 #include "OsgUserData.h"
15 #include "OsgUserDataVisitor.h"
16 
17 #include "OsgMouseSpring.h"
18 #include "OsgLight.h"
19 #include "OsgCameraManipulator.h"
20 #include "OsgDragger.h"
21 #include "OsgSimulator.h"
22 
23 namespace OsgAnimatSim
24 {
25  namespace Visualization
26  {
34 {
35 }
36 
44 {
45 
46 try
47 {
48 }
49 catch(...)
50 {Std_TraceMsg(0, "Caught Error in desctructor of OsgHud\r\n", "", -1, false, true);}
51 }
52 
54 {
55  AnimatBase::Initialize();
56 
57  m_osgProjection = new osg::Projection;
58  m_osgProjection->setMatrix(osg::Matrix::ortho2D(0, 800, 0, 600));
59 
60  HudItem *lpItem = NULL;
61  int iCount = m_aryHudItems.GetSize();
62  for(int iIndex = 0; iIndex < iCount; iIndex++)
63  {
64  lpItem = m_aryHudItems[iIndex];
65  lpItem->Initialize(m_osgProjection.get());
66  }
67 
68  m_osgMT = new osg::MatrixTransform;
69  m_osgMT->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
70  m_osgMT->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
71  m_osgMT->getOrCreateStateSet()->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON);
72  m_osgMT->addChild(m_osgProjection.get());
73 
74  OsgSimulator *lpVsSim = dynamic_cast<OsgSimulator *>(m_lpSim);
75  if(!lpVsSim)
76  THROW_ERROR(Osg_Err_lUnableToConvertToVsSimulator, Osg_Err_strUnableToConvertToVsSimulator);
77 
78  lpVsSim->OSGRoot()->addChild(m_osgMT.get());
79 }
80 
81 void OsgHud::Update()
82 {
83  HudItem *lpItem = NULL;
84  int iCount = m_aryHudItems.GetSize();
85  for(int iIndex = 0; iIndex < iCount; iIndex++)
86  {
87  lpItem = m_aryHudItems[iIndex];
88  lpItem->Update();
89  }
90 }
91 
92 
93  } // Visualization
94 } //OsgAnimatSim
Declares the vortex Light class.
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
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.
virtual void Initialize()
Initializes this object.
Definition: OsgHud.cpp:53
Declares the vortex organism class.
Declares the vortex structure class.
OsgHud()
Default constructor.
Definition: OsgHud.cpp:33
virtual ~OsgHud()
Destructor.
Definition: OsgHud.cpp:43