Further work on new 3D text support
This commit is contained in:
@@ -407,93 +407,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BevelProfile
|
||||
//
|
||||
BevelProfile::BevelProfile()
|
||||
{
|
||||
flatBevel();
|
||||
}
|
||||
|
||||
void BevelProfile::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 BevelProfile::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 BevelProfile::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 BevelProfile::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;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// computeGlyphGeometry
|
||||
@@ -601,7 +514,7 @@ osg::Geometry* computeGlyphGeometry(osgText::Glyph3D* glyph, float bevelThicknes
|
||||
//
|
||||
// computeTextGeometry
|
||||
//
|
||||
osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, BevelProfile& profile, float width)
|
||||
osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, const osgText::Bevel& profile, float width)
|
||||
{
|
||||
osg::Vec3Array* orig_vertices = dynamic_cast<osg::Vec3Array*>(glyphGeometry->getVertexArray());
|
||||
if (!orig_vertices)
|
||||
@@ -698,7 +611,7 @@ osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, BevelProfile& p
|
||||
|
||||
unsigned int no_vertices_on_boundary = bevel->size()/2;
|
||||
|
||||
osgText::BevelProfile::Vertices& profileVertices = profile.getVertices();
|
||||
const osgText::Bevel::Vertices& profileVertices = profile.getVertices();
|
||||
unsigned int no_vertices_on_bevel = profileVertices.size();
|
||||
|
||||
Indices bevelIndices;
|
||||
@@ -781,7 +694,7 @@ osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, BevelProfile& p
|
||||
//
|
||||
// computeShellGeometry
|
||||
//
|
||||
osg::Geometry* computeShellGeometry(osg::Geometry* glyphGeometry, BevelProfile& profile, float width)
|
||||
osg::Geometry* computeShellGeometry(osg::Geometry* glyphGeometry, const osgText::Bevel& profile, float width)
|
||||
{
|
||||
osg::Vec3Array* orig_vertices = dynamic_cast<osg::Vec3Array*>(glyphGeometry->getVertexArray());
|
||||
if (!orig_vertices)
|
||||
@@ -924,7 +837,7 @@ osg::Geometry* computeShellGeometry(osg::Geometry* glyphGeometry, BevelProfile&
|
||||
|
||||
unsigned int no_vertices_on_boundary = bevel->size()/2;
|
||||
|
||||
osgText::BevelProfile::Vertices& profileVertices = profile.getVertices();
|
||||
const osgText::Bevel::Vertices& profileVertices = profile.getVertices();
|
||||
unsigned int no_vertices_on_bevel = profileVertices.size();
|
||||
|
||||
Indices bevelIndices;
|
||||
|
||||
Reference in New Issue
Block a user