-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCText.cpp
More file actions
57 lines (50 loc) · 1.45 KB
/
CText.cpp
File metadata and controls
57 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* CText.cpp
*
* Created on: Mar 7, 2011
* Author: enekochan
*/
#include "CText.h"
osg::Geode* CText::createTextGeode(std::string textString, float r, float g, float b, float a) {
osg::Geode* textGeode = new osg::Geode();
text = new osgText::Text();
text->setFont("/usr/share/fonts/truetype/ttf-japanese-gothic.ttf");
text->setCharacterSize(16.0f);
text->setPosition(osg::Vec3(4, 4, 0));
text->setAlignment(osgText::Text::LEFT_BASE_LINE);
text->setColor(osg::Vec4(r, g, b, a));
text->setText(textString);
textGeode->addDrawable(text);
return textGeode;
}
CText::CText(std::string textString) : osg::Group() {
this->addChild(createTextGeode(textString, 1.0f, 1.0f, 1.0f, 1.0f));
}
void CText::setText(std::string textString) {
/*
osg::Geode* geode = dynamic_cast<osg::Geode*>(this->getChild(0));
osgText::Text* text = dynamic_cast<osgText::Text*>(geode->getDrawable(0));
*/
text->setText(textString);
/*
this->removeChild(0, 1);
this->addChild(createTextGeode(textString, 1.0f, 0.0f, 0.0f, 1.0f));
*/
}
void CText::setColor(float r, float g, float b, float a) {
/*
osg::Geode* geode = dynamic_cast<osg::Geode*>(this->getChild(0));
osgText::Text* text = dynamic_cast<osgText::Text*>(geode->getDrawable(0));
*/
text->setColor(osg::Vec4(r, g, b, a));
/*
this->removeChild(0, 1);
this->addChild(createTextGeode(this->originalText, r, g, b, a));
*/
}
void CText::setPosition(osg::Vec3 pos) {
text->setPosition(pos);
}
CText::~CText()
{
}