Refactored osgText::Font so that it now supports both 2D and 3D glyphs.
Added TextNode.h and TextNode.cpp to examples/osgtext3D in prep for introducing the new node to osgText library
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
SET(TARGET_H
|
||||
GlyphGeometry.h
|
||||
TextNode.h
|
||||
)
|
||||
|
||||
SET(TARGET_SRC
|
||||
GlyphGeometry.cpp
|
||||
TextNode.cpp
|
||||
osgtext3D_orig.cpp
|
||||
osgtext3D_test.cpp
|
||||
osgtext3D.cpp
|
||||
|
||||
@@ -520,7 +520,7 @@ struct CollectTriangleIndicesFunctor
|
||||
};
|
||||
|
||||
|
||||
osg::Geometry* computeGlyphGeometry(osgText::Font3D::Glyph3D* glyph, float bevelThickness, float shellThickness)
|
||||
osg::Geometry* computeGlyphGeometry(osgText::Glyph3D* glyph, float bevelThickness, float shellThickness)
|
||||
{
|
||||
osg::Vec3Array* orig_vertices = glyph->getRawVertexArray();
|
||||
osg::Geometry::PrimitiveSetList& orig_primitives = glyph->getRawFacePrimitiveSetList();
|
||||
|
||||
@@ -42,7 +42,7 @@ class BevelProfile
|
||||
Vertices _vertices;
|
||||
};
|
||||
|
||||
extern osg::Geometry* computeGlyphGeometry(osgText::Font3D::Glyph3D* glyph, float bevelThickness, float shellThickness);
|
||||
extern osg::Geometry* computeGlyphGeometry(osgText::Glyph3D* glyph, float bevelThickness, float shellThickness);
|
||||
|
||||
extern osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, BevelProfile& profile, float width);
|
||||
|
||||
|
||||
289
examples/osgtext3D/TextNode.cpp
Normal file
289
examples/osgtext3D/TextNode.cpp
Normal file
@@ -0,0 +1,289 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include "TextNode.h"
|
||||
#include <osg/io_utils>
|
||||
|
||||
using namespace osgText;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bevel
|
||||
//
|
||||
Bevel::Bevel()
|
||||
{
|
||||
_thickness = 0.1f;
|
||||
flatBevel();
|
||||
}
|
||||
|
||||
Bevel::Bevel(const Bevel& bevel, const osg::CopyOp&):
|
||||
_thickness(bevel._thickness),
|
||||
_vertices(bevel._vertices)
|
||||
{
|
||||
}
|
||||
|
||||
void Bevel::flatBevel(float width)
|
||||
{
|
||||
_vertices.clear();
|
||||
|
||||
if (width>0.5f) width = 0.5f;
|
||||
|
||||
_vertices.push_back(osg::Vec2(0.0f,0.0f));
|
||||
|
||||
_vertices.push_back(osg::Vec2(width,1.0f));
|
||||
|
||||
if (width<0.5f) _vertices.push_back(osg::Vec2(1-width,1.0f));
|
||||
|
||||
_vertices.push_back(osg::Vec2(1.0f,0.0f));
|
||||
}
|
||||
|
||||
void Bevel::roundedBevel(float width, unsigned int numSteps)
|
||||
{
|
||||
_vertices.clear();
|
||||
|
||||
if (width>0.5f) width = 0.5f;
|
||||
|
||||
unsigned int i = 0;
|
||||
for(; i<=numSteps; ++i)
|
||||
{
|
||||
float angle = float(osg::PI)*0.5f*(float(i)/float(numSteps));
|
||||
_vertices.push_back( osg::Vec2((1.0f-cosf(angle))*width, sinf(angle)) );
|
||||
}
|
||||
|
||||
// start the second half one into the curve if the width is half way across
|
||||
i = width<0.5f ? 0 : 1;
|
||||
for(; i<=numSteps; ++i)
|
||||
{
|
||||
float angle = float(osg::PI)*0.5f*(float(numSteps-i)/float(numSteps));
|
||||
_vertices.push_back( osg::Vec2(1.0-(1.0f-cosf(angle))*width, sin(angle)) );
|
||||
}
|
||||
}
|
||||
|
||||
void Bevel::roundedBevel2(float width, unsigned int numSteps)
|
||||
{
|
||||
_vertices.clear();
|
||||
|
||||
if (width>0.5f) width = 0.5f;
|
||||
|
||||
float h = 0.1f;
|
||||
float r = 1.0f-h;
|
||||
|
||||
_vertices.push_back(osg::Vec2(0.0,0.0));
|
||||
|
||||
unsigned int i = 0;
|
||||
for(; i<=numSteps; ++i)
|
||||
{
|
||||
float angle = float(osg::PI)*0.5f*(float(i)/float(numSteps));
|
||||
_vertices.push_back( osg::Vec2((1.0f-cosf(angle))*width, h + sinf(angle)*r) );
|
||||
}
|
||||
|
||||
// start the second half one into the curve if the width is half way across
|
||||
i = width<0.5f ? 0 : 1;
|
||||
for(; i<=numSteps; ++i)
|
||||
{
|
||||
float angle = float(osg::PI)*0.5f*(float(numSteps-i)/float(numSteps));
|
||||
_vertices.push_back( osg::Vec2(1.0-(1.0f-cosf(angle))*width, h + sin(angle)*r) );
|
||||
}
|
||||
|
||||
_vertices.push_back(osg::Vec2(1.0,0.0));
|
||||
|
||||
}
|
||||
|
||||
void Bevel::print(std::ostream& fout)
|
||||
{
|
||||
OSG_NOTICE<<"print bevel"<<std::endl;
|
||||
for(Vertices::iterator itr = _vertices.begin();
|
||||
itr != _vertices.end();
|
||||
++itr)
|
||||
{
|
||||
OSG_NOTICE<<" "<<*itr<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Style
|
||||
//
|
||||
Style::Style():
|
||||
_widthRatio(1.0f),
|
||||
_thicknessRatio(0.0f),
|
||||
_outlineRatio(0.0f),
|
||||
_sampleDensity(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
Style::Style(const Style& style, const osg::CopyOp& copyop):
|
||||
osg::Object(style,copyop),
|
||||
_bevel(dynamic_cast<Bevel*>(copyop(style._bevel.get()))),
|
||||
_widthRatio(style._widthRatio),
|
||||
_thicknessRatio(style._thicknessRatio),
|
||||
_outlineRatio(style._outlineRatio),
|
||||
_sampleDensity(style._sampleDensity)
|
||||
{
|
||||
}
|
||||
|
||||
/// default Layout implementation used if no other is specified on TextNode
|
||||
osg::ref_ptr<Style>& Style::getDefaultStyle()
|
||||
{
|
||||
static OpenThreads::Mutex s_DefaultStyleMutex;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_DefaultStyleMutex);
|
||||
|
||||
static osg::ref_ptr<Style> s_defaultStyle = new Style;
|
||||
return s_defaultStyle;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Layout
|
||||
//
|
||||
Layout::Layout()
|
||||
{
|
||||
}
|
||||
|
||||
Layout::Layout(const Layout& layout, const osg::CopyOp& copyop):
|
||||
osg::Object(layout,copyop)
|
||||
{
|
||||
}
|
||||
|
||||
osg::ref_ptr<Layout>& Layout::getDefaultLayout()
|
||||
{
|
||||
static OpenThreads::Mutex s_DefaultLayoutMutex;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_DefaultLayoutMutex);
|
||||
|
||||
static osg::ref_ptr<Layout> s_defaultLayout = new Layout;
|
||||
return s_defaultLayout;
|
||||
}
|
||||
|
||||
void Layout::layout(TextNode& text) const
|
||||
{
|
||||
OSG_NOTICE<<"Layout::layout"<<std::endl;
|
||||
|
||||
Font* font = text.getActiveFont();
|
||||
Style* style = text.getActiveStyle();
|
||||
TextTechnique* technique = text.getTextTechnique();
|
||||
|
||||
if (!text.getTextTechnique())
|
||||
{
|
||||
OSG_NOTICE<<"Warning: no TextTechnique assigned to Layout"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
technique->start();
|
||||
technique->finish();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TextTechnique
|
||||
//
|
||||
TextTechnique::TextTechnique():
|
||||
_textNode(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TextTechnique::TextTechnique(const TextTechnique& technique, const osg::CopyOp& copyop):
|
||||
osg::Object(technique, copyop),
|
||||
_textNode(0)
|
||||
{
|
||||
}
|
||||
|
||||
osg::ref_ptr<TextTechnique>& TextTechnique::getDefaultTextTechinque()
|
||||
{
|
||||
static OpenThreads::Mutex s_DefaultTextTechniqueMutex;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_DefaultTextTechniqueMutex);
|
||||
|
||||
static osg::ref_ptr<TextTechnique> s_defaultTextTechnique = new TextTechnique;
|
||||
return s_defaultTextTechnique;
|
||||
}
|
||||
|
||||
void TextTechnique::start()
|
||||
{
|
||||
OSG_NOTICE<<"TextTechnique::start()"<<std::endl;
|
||||
}
|
||||
|
||||
void TextTechnique::addCharacter(const osg::Vec3& position, const osg::Vec3& size, Glyph* glyph, Style* style)
|
||||
{
|
||||
OSG_NOTICE<<"TextTechnique::addCharacter("<<position<<", "<<size<<", "<<glyph<<", "<<style<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void TextTechnique::finish()
|
||||
{
|
||||
OSG_NOTICE<<"TextTechnique::finish()"<<std::endl;
|
||||
}
|
||||
|
||||
void TextTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
OSG_NOTICE<<"TextTechnique::traverse()"<<std::endl;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TextNode
|
||||
//
|
||||
TextNode::TextNode()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TextNode::TextNode(const TextNode& text, const osg::CopyOp& copyop):
|
||||
osg::Group(text, copyop)
|
||||
{
|
||||
}
|
||||
|
||||
TextNode::~TextNode()
|
||||
{
|
||||
setTextTechnique(0);
|
||||
}
|
||||
|
||||
void TextNode::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_technique.valid())
|
||||
{
|
||||
_technique->traverse(nv);
|
||||
}
|
||||
else
|
||||
{
|
||||
Group::traverse(nv);
|
||||
}
|
||||
}
|
||||
|
||||
void TextNode::setTextTechnique(TextTechnique* technique)
|
||||
{
|
||||
if (_technique==technique) return;
|
||||
|
||||
if (TextTechnique::getDefaultTextTechinque()==technique)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: Attempt to assign DefaultTextTechnique() prototype to TextNode::setTextTechnique(..), assigning a clone() of it instead."<<std::endl;
|
||||
technique = new TextTechnique(*TextTechnique::getDefaultTextTechinque());
|
||||
}
|
||||
|
||||
if (_technique.valid()) _technique->setTextNode(0);
|
||||
|
||||
_technique = technique;
|
||||
|
||||
if (_technique.valid()) _technique->setTextNode(this);
|
||||
}
|
||||
|
||||
|
||||
void TextNode::update()
|
||||
{
|
||||
getActiveLayout()->layout(*this);
|
||||
}
|
||||
|
||||
void TextNode::setText(const std::string& str)
|
||||
{
|
||||
_string.set(str);
|
||||
}
|
||||
226
examples/osgtext3D/TextNode.h
Normal file
226
examples/osgtext3D/TextNode.h
Normal file
@@ -0,0 +1,226 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGTEXT_TEXTNODE
|
||||
#define OSGTEXT_TEXTNODE 1
|
||||
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/Quat>
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
#include <osgText/Font>
|
||||
#include <osgText/String>
|
||||
|
||||
namespace osgText {
|
||||
|
||||
// forward declare
|
||||
class TextNode;
|
||||
class Glyph;
|
||||
|
||||
class Bevel : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
Bevel();
|
||||
Bevel(const Bevel& bevel, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgText, Bevel)
|
||||
|
||||
void setBevelThickness(float thickness) { _thickness = thickness; }
|
||||
float getBevelThickness() const { return _thickness; }
|
||||
|
||||
void flatBevel(float width=0.25f);
|
||||
|
||||
void roundedBevel(float width=0.5f, unsigned int numSteps=10);
|
||||
|
||||
void roundedBevel2(float width=0.5f, unsigned int numSteps=10);
|
||||
|
||||
typedef std::vector<osg::Vec2> Vertices;
|
||||
|
||||
void setVertices(const Vertices& vertices) { _vertices = vertices; }
|
||||
Vertices& getVertices() { return _vertices; }
|
||||
const Vertices& getVertices() const { return _vertices; }
|
||||
|
||||
void print(std::ostream& fout);
|
||||
|
||||
protected:
|
||||
|
||||
float _thickness;
|
||||
Vertices _vertices;
|
||||
};
|
||||
|
||||
|
||||
class Style : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
Style();
|
||||
Style(const Style& style, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgText, Style)
|
||||
|
||||
/// default Layout implementation used if no other is specified on TextNode
|
||||
static osg::ref_ptr<Style>& getDefaultStyle();
|
||||
|
||||
/// NULL is no bevel
|
||||
void setBevel(Bevel* bevel) { _bevel = bevel; }
|
||||
const Bevel* getBevel() const { return _bevel.get(); }
|
||||
|
||||
|
||||
/// 1 is the default width of the text
|
||||
void setWidthRatio(float widthRatio) { _widthRatio = widthRatio; }
|
||||
float getWidthRatio() const { return _widthRatio; }
|
||||
|
||||
/// 0 is 2D text
|
||||
void setThicknessRatio(float thicknessRatio) { _thicknessRatio = thicknessRatio; }
|
||||
float getThicknessRatio() const { return _thicknessRatio; }
|
||||
|
||||
/// 0 is off
|
||||
void setOutlineRatio(float outlineRatio) { _outlineRatio = outlineRatio; }
|
||||
float getOutlineRatio() const { return _outlineRatio; }
|
||||
|
||||
/// 1.0 is default number of samples
|
||||
void setSampleDensity(float sd) { _sampleDensity = sd; }
|
||||
float getSampleDensity() const { return _sampleDensity; }
|
||||
|
||||
protected:
|
||||
|
||||
osg::ref_ptr<Bevel> _bevel;
|
||||
|
||||
float _widthRatio;
|
||||
float _thicknessRatio;
|
||||
float _outlineRatio;
|
||||
float _sampleDensity;
|
||||
};
|
||||
|
||||
class Layout : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
Layout();
|
||||
Layout(const Layout& layout, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgText,Layout)
|
||||
|
||||
/// default Layout implementation used if no other is specified on TextNode
|
||||
static osg::ref_ptr<Layout>& getDefaultLayout();
|
||||
|
||||
virtual void layout(TextNode& text) const;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
class TextTechnique : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
TextTechnique();
|
||||
TextTechnique(const TextTechnique& technique, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgText, TextTechnique)
|
||||
|
||||
TextNode* getTextNode() { return _textNode; }
|
||||
const TextNode* getTextNode() const { return _textNode; }
|
||||
|
||||
/// default TextTechnique implementation used if no other is specified on TextNode
|
||||
static osg::ref_ptr<TextTechnique>& getDefaultTextTechinque();
|
||||
|
||||
/// start building a new charater layout
|
||||
virtual void start();
|
||||
|
||||
/// called by Layout engine to place individual characters
|
||||
virtual void addCharacter(const osg::Vec3& position, const osg::Vec3& size, Glyph* glyph, Style* style);
|
||||
|
||||
/// finish building new charater layout
|
||||
virtual void finish();
|
||||
|
||||
/// provide traversal control
|
||||
virtual void traverse(osg::NodeVisitor& nv);
|
||||
|
||||
protected:
|
||||
|
||||
friend class TextNode;
|
||||
|
||||
void setTextNode(TextNode* textNode) { _textNode = textNode; }
|
||||
|
||||
TextNode* _textNode;
|
||||
};
|
||||
|
||||
class TextNode : public osg::Group
|
||||
{
|
||||
public:
|
||||
|
||||
TextNode();
|
||||
TextNode(const TextNode& text, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Node(osgText, TextNode)
|
||||
|
||||
virtual void traverse(osg::NodeVisitor& nv);
|
||||
|
||||
void setFont(Font* font) { _font = font; }
|
||||
Font* getFont() { return _font.get(); }
|
||||
const Font* getFont() const { return _font.get(); }
|
||||
Font* getActiveFont() { return _font.valid() ? _font.get() : Font::getDefaultFont().get(); }
|
||||
const Font* getActiveFont() const { return _font.valid() ? _font.get() : Font::getDefaultFont().get(); }
|
||||
|
||||
void setStyle(Style* style) { _style = style; }
|
||||
Style* getStyle() { return _style.get(); }
|
||||
const Style* getStyle() const { return _style.get(); }
|
||||
Style* getActiveStyle() { return _style.valid() ? _style.get() : Style::getDefaultStyle().get(); }
|
||||
const Style* getActiveStyle() const { return _style.valid() ? _style.get() : Style::getDefaultStyle().get(); }
|
||||
|
||||
void setLayout(Layout* layout) { _layout = layout; }
|
||||
Layout* getLayout() { return _layout.get(); }
|
||||
const Layout* getLayout() const { return _layout.get(); }
|
||||
const Layout* getActiveLayout() const { return _layout.valid() ? _layout.get() : Layout::getDefaultLayout().get(); }
|
||||
|
||||
void setTextTechnique(TextTechnique* technique);
|
||||
TextTechnique* getTextTechnique() { return _technique.get(); }
|
||||
const TextTechnique* getTextTechnique() const { return _technique.get(); }
|
||||
|
||||
void setText(const std::string& str);
|
||||
void setText(const String& str) { _string = str; }
|
||||
String& getText() { return _string; }
|
||||
const String& getText() const { return _string; }
|
||||
|
||||
void setPosition(const osg::Vec3d& position) { _position = position; }
|
||||
const osg::Vec3d& getPosition() const { return _position; }
|
||||
|
||||
void setRotation(const osg::Quat& rotation) { _rotation = rotation; }
|
||||
const osg::Quat& getRotation() const { return _rotation; }
|
||||
|
||||
void setCharacterSize(float characterSize) { _characterSize = characterSize; }
|
||||
float getCharacterSize() const { return _characterSize; }
|
||||
|
||||
/// force a regeneration of the rendering backend required to represent the text.
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TextNode();
|
||||
|
||||
osg::ref_ptr<Font> _font;
|
||||
osg::ref_ptr<Style> _style;
|
||||
osg::ref_ptr<Layout> _layout;
|
||||
osg::ref_ptr<TextTechnique> _technique;
|
||||
|
||||
String _string;
|
||||
osg::Vec3d _position;
|
||||
osg::Quat _rotation;
|
||||
float _characterSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -32,23 +32,13 @@
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include "GlyphGeometry.h"
|
||||
#include "TextNode.h"
|
||||
|
||||
extern int main_orig(int, char**);
|
||||
extern int main_test(int, char**);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main_experimental(osg::ArgumentParser& arguments)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
|
||||
if (arguments.read("--test"))
|
||||
{
|
||||
return main_test(argc,argv);
|
||||
}
|
||||
else if (arguments.read("--original") || arguments.read("--orig"))
|
||||
{
|
||||
return main_orig(argc,argv);
|
||||
}
|
||||
|
||||
std::string fontFile("arial.ttf");
|
||||
while(arguments.read("-f",fontFile)) {}
|
||||
|
||||
@@ -65,7 +55,7 @@ int main(int argc, char** argv)
|
||||
|
||||
while(arguments.read("-w",word)) {}
|
||||
|
||||
osg::ref_ptr<osgText::Font3D> font = osgText::readFont3DFile(fontFile);
|
||||
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(fontFile);
|
||||
if (!font) return 1;
|
||||
OSG_NOTICE<<"Read font "<<fontFile<<" font="<<font.get()<<std::endl;
|
||||
|
||||
@@ -110,7 +100,7 @@ int main(int argc, char** argv)
|
||||
|
||||
for(unsigned int i=0; i<word.size(); ++i)
|
||||
{
|
||||
osg::ref_ptr<osgText::Font3D::Glyph3D> glyph = font->getGlyph(word[i]);
|
||||
osg::ref_ptr<osgText::Glyph3D> glyph = font->getGlyph3D(word[i]);
|
||||
if (!glyph) return 1;
|
||||
|
||||
osg::ref_ptr<osg::PositionAttitudeTransform> transform = new osg::PositionAttitudeTransform;
|
||||
@@ -147,3 +137,42 @@ int main(int argc, char** argv)
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc, argv);
|
||||
|
||||
if (arguments.read("--test"))
|
||||
{
|
||||
return main_test(argc,argv);
|
||||
}
|
||||
else if (arguments.read("--original") || arguments.read("--orig"))
|
||||
{
|
||||
return main_orig(argc,argv);
|
||||
}
|
||||
else if (arguments.read("--exp"))
|
||||
{
|
||||
return main_experimental(arguments);
|
||||
}
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
std::string fontFile("arial.ttf");
|
||||
while(arguments.read("-f",fontFile)) {}
|
||||
|
||||
osg::ref_ptr<osgText::Font> font = osgText::readFontFile(fontFile);
|
||||
if (!font) return 1;
|
||||
OSG_NOTICE<<"Read font "<<fontFile<<" font="<<font.get()<<std::endl;
|
||||
|
||||
std::string word("This is a new test.");
|
||||
while (arguments.read("-w",word)) {}
|
||||
|
||||
osgText::TextNode* text = new osgText::TextNode;
|
||||
text->setText(word);
|
||||
text->setTextTechnique(new osgText::TextTechnique);
|
||||
text->update();
|
||||
|
||||
viewer.setSceneData(text);
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user