8 #include "VsSimulator.h"
13 namespace Visualization
25 m_aryColor.Set(1, 1, 1, 1);
26 m_ptPosition.Set(10,10, 0);
27 m_strFont =
"fonts/Arial.ttf";
30 m_lpDisplayData = NULL;
31 m_lpUpdateData = NULL;
32 m_fltUpdateInterval = 1;
49 VsHudText::VsHudText(
float *aryColor, CStdFPoint &ptPosition, std::string strFont,
int iCharSize, std::string strText, std::string strDisplayTargetID, std::string strDisplayDataType, std::string strUpdateTargetID, std::string strUpdateDataType,
float fltUpdateInterval)
51 m_aryColor.Set(aryColor[0], aryColor[1], aryColor[2], aryColor[3]);
52 m_ptPosition = ptPosition;
54 m_iCharSize = iCharSize;
56 m_lpDisplayData = NULL;
57 m_lpUpdateData = NULL;
58 m_strDisplayTargetID = strDisplayTargetID;
59 m_strDisplayDataType = strDisplayDataType;
60 m_strUpdateTargetID = strUpdateTargetID;
61 m_strUpdateDataType = strUpdateDataType;
62 m_fltUpdateInterval = fltUpdateInterval;
77 HudText::Initialize(lpVoidProjection);
80 osg::Projection *lpProjection = (osg::Projection *) (lpVoidProjection);
82 THROW_PARAM_ERROR(Vs_Err_lHudProjectionNotDefined, Vs_Err_strHudProjectionNotDefined,
"ID",
m_strID);
84 m_osgText =
new osgText::Text;
85 m_osgText->setDataVariance(osg::Object::DYNAMIC);
86 m_osgText->setColor(osg::Vec4(m_aryColor[0], m_aryColor[1], m_aryColor[2], m_aryColor[3]));
87 m_osgText->setPosition(osg::Vec3(m_ptPosition.x, m_ptPosition.y, m_ptPosition.z));
88 m_osgText->setFont(m_strFont.c_str());
89 m_osgText->setCharacterSize(m_iCharSize);
90 m_osgText->setText(
"");
92 m_osgGeode =
new osg::Geode;
93 m_osgGeode->addDrawable(m_osgText.get());
94 lpProjection->addChild(m_osgGeode.get());
102 void VsHudText::Update()
106 if(m_osgText.valid() && m_lpDisplayData && m_lpUpdateData && (fabs(*m_lpUpdateData-m_fltPrevious) > 0.1) )
108 sprintf(str, m_strText.c_str(), *m_lpDisplayData);
109 m_osgText->setText(str);
110 m_fltPrevious = *m_lpUpdateData;
VsHudText()
Default constructor.
virtual ~VsHudText()
Destructor.
virtual void Initialize()
Initializes this object.
Declares the vortex heads-up display text class.
std::string m_strID
The unique Id for this object.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual void ResetSimulation()
Resets the simulation back to time 0.