AnimatLab  2
Test
VsHud.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "VsSimulator.h"
9 
10 namespace VortexAnimatSim
11 {
12  namespace Visualization
13  {
21 {
22 }
23 
31 {
32 
33 try
34 {
35 }
36 catch(...)
37 {Std_TraceMsg(0, "Caught Error in desctructor of VsHud\r\n", "", -1, false, true);}
38 }
39 
41 {
42  AnimatBase::Initialize();
43 
44  m_osgProjection = new osg::Projection;
45  m_osgProjection->setMatrix(osg::Matrix::ortho2D(0, 800, 0, 600));
46 
47  HudItem *lpItem = NULL;
48  int iCount = m_aryHudItems.GetSize();
49  for(int iIndex = 0; iIndex < iCount; iIndex++)
50  {
51  lpItem = m_aryHudItems[iIndex];
52  lpItem->Initialize(m_osgProjection.get());
53  }
54 
55  m_osgMT = new osg::MatrixTransform;
56  m_osgMT->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
57  m_osgMT->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
58  m_osgMT->getOrCreateStateSet()->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON);
59  m_osgMT->addChild(m_osgProjection.get());
60 
61  VsSimulator *lpVsSim = dynamic_cast<VsSimulator *>(m_lpSim);
62  if(!lpVsSim)
63  THROW_ERROR(Vs_Err_lUnableToConvertToVsSimulator, Vs_Err_strUnableToConvertToVsSimulator);
64 
65  lpVsSim->OSGRoot()->addChild(m_osgMT.get());
66 }
67 
68 void VsHud::Update()
69 {
70  HudItem *lpItem = NULL;
71  int iCount = m_aryHudItems.GetSize();
72  for(int iIndex = 0; iIndex < iCount; iIndex++)
73  {
74  lpItem = m_aryHudItems[iIndex];
75  lpItem->Update();
76  }
77 }
78 
79 
80  } // Visualization
81 } //VortexAnimatSim
virtual void Initialize()
Initializes this object.
Definition: VsHud.cpp:40
VsHud()
Default constructor.
Definition: VsHud.cpp:20
virtual ~VsHud()
Destructor.
Definition: VsHud.cpp:30
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.