lib-game-delta3d-sdk-examples-testGameActorComponents-textlabelcomponent.h / h
A game actor component that attaches a text billboard to the actor. The text can be made to blink on and off periodically.
returns: the color as a vec4 */ osg::Vec4 GetColor() const { return mColor; }
parameter: color The color as 4 bytes */ void SetColor(int color) { double a = ((color & 0xff000000) >> 24) / 256.; double r = ((color & 0x00ff0000) >> 16) / 256.; double g = ((color & 0x0000ff00) >> 8) / 256.; double b = ((color & 0x000000ff) >> 0) / 256.; mColor.set(r, g, b, a); Create(); }
parameter: color The color as a vec4 */ void SetColor(const osg::Vec4& color) { mColor = color; Create(); }
returns: the height of the symbol above 0 */ float GetHeight() const { return mPosition->getPosition()[2]; }
parameter: h the height of the symbol above 0 */ void SetHeight(float h) { mPosition->setPosition(osg::Vec3(0, 0, h)); } should the text label be shown?bool IsEnabled() const { return mShow; } should the text label be shown?void SetEnabled(bool show) { mShow = show; if(show) { Create(); } else { Reset(); } } set the text to be displayedvoid SetText(const std::string& text) { mText = text; Create(); } get the text to be displayedstd::string GetText() const { return mText; } apply a red border around textvoid SetHighlighted(bool); set font size
parameter: s size in metersvoid SetFontSize(float s) { mFontSize = s; Create(); } get font size in metersfloat GetFontSize() const { return mFontSize; } is the text currently flashing?bool IsFlashing() const { return mIsFlashing; } toggle flashingvoid SetFlashing(bool b); react to game tick messagesvirtual void OnTickLocal(const dtGame::TickMessage& tickMessage); set the interval in seconds at that the text should blinkvoid SetFlashInterval(float v) { mFlashInterval = v; } get the interval in seconds at that the text should blinkfloat GetFlashInterval() const { return mFlashInterval; } add actor component properties to game actor for configuring in STAGEvirtual void BuildPropertyMap(); protected: ~TextLabelComponent(); private: Clear geometryvoid Reset(); Create geometry according to propertiesvoid Create(); // text size in meters float mFontSize; // the OSG text geometry dtCore::RefPtr<osgText::Text> mTextGeometry; Color of the text osg::Vec4 mColor; // symbol geometry dtCore::RefPtr<osg::Group> mGroup; dtCore::RefPtr<osg::Geode> mGeode; dtCore::RefPtr<osg::PositionAttitudeTransform> mPosition; // currently flasing? bool mIsFlashing; // visible? bool mShow; // the text to display std::string mText; // flash at this interval float mFlashInterval; };
[]readme course(s) prefaceI 1 2II 3 4III 5 6 7IV 8 9 10V 11 12 afterthought(s)appendix reference(s) example(s)resource(s) _![]()
(C) Æliens 04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.