Added raw primitive and vertex data into the osgText::Font3D and FreeTypePlugin to aid development of new 3D text functionality.
Added new test for original 3D text support and new experimental code for exploring approaches to new 3D text support.
This commit is contained in:
@@ -308,7 +308,7 @@ FreeTypeFont3D::~FreeTypeFont3D()
|
||||
|
||||
osgText::Font3D::Glyph3D * FreeTypeFont3D::getGlyph(unsigned int charcode)
|
||||
{
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
||||
|
||||
//
|
||||
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
||||
@@ -359,6 +359,16 @@ osgText::Font3D::Glyph3D * FreeTypeFont3D::getGlyph(unsigned int charcode)
|
||||
|
||||
// ** create geometry for each part of the glyph
|
||||
osg::ref_ptr<osg::Geometry> frontGeo(new osg::Geometry);
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> rawVertices = new osg::Vec3Array(*(char3d._verts));
|
||||
osg::Geometry::PrimitiveSetList rawPrimitives;
|
||||
for(osg::Geometry::PrimitiveSetList::iterator itr = char3d.get()->getPrimitiveSetList().begin();
|
||||
itr != char3d.get()->getPrimitiveSetList().end();
|
||||
++itr)
|
||||
{
|
||||
rawPrimitives.push_back(dynamic_cast<osg::PrimitiveSet*>((*itr)->clone(osg::CopyOp::DEEP_COPY_ALL)));
|
||||
}
|
||||
|
||||
frontGeo->setVertexArray(char3d.get()->getVertexArray());
|
||||
frontGeo->setPrimitiveSetList(char3d.get()->getPrimitiveSetList());
|
||||
|
||||
@@ -458,6 +468,10 @@ osgText::Font3D::Glyph3D * FreeTypeFont3D::getGlyph(unsigned int charcode)
|
||||
// ** save vertices and PrimitiveSetList of each face in the Glyph3D PrimitiveSet face list
|
||||
osgText::Font3D::Glyph3D * glyph3D = new osgText::Font3D::Glyph3D(charcode);
|
||||
|
||||
// copy the raw primitive set list before we tessellate it.
|
||||
glyph3D->getRawFacePrimitiveSetList() = rawPrimitives;
|
||||
glyph3D->setRawVertexArray(rawVertices.get());
|
||||
|
||||
glyph3D->setVertexArray(dynamic_cast<osg::Vec3Array*>(frontGeo->getVertexArray()));
|
||||
glyph3D->setNormalArray(dynamic_cast<osg::Vec3Array*>(wallGeo->getNormalArray()));
|
||||
|
||||
@@ -494,6 +508,8 @@ osgText::Font3D::Glyph3D * FreeTypeFont3D::getGlyph(unsigned int charcode)
|
||||
|
||||
osg::Vec2 FreeTypeFont3D::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
||||
|
||||
if (!FT_HAS_KERNING(_face) || (kerningType == osgText::KERNING_NONE)) return osg::Vec2(0.0f,0.0f);
|
||||
|
||||
FT_Kerning_Mode mode = (kerningType==osgText::KERNING_DEFAULT) ? ft_kerning_default : ft_kerning_unfitted;
|
||||
|
||||
@@ -59,7 +59,24 @@ void Text3D::accept(osg::PrimitiveFunctor& pf) const
|
||||
LineRenderInfo::const_iterator it, end = itLine->end();
|
||||
for (it = itLine->begin(); it!=end; ++it)
|
||||
{
|
||||
pf.setVertexArray(it->_glyph->getVertexArray()->size(),&(it->_glyph->getVertexArray()->front()));
|
||||
osg::ref_ptr<osg::Vec3Array> vertices = it->_glyph->getVertexArray();
|
||||
|
||||
if (vertices->empty())
|
||||
continue; //skip over spaces
|
||||
|
||||
//pf.setVertexArray(it->_glyph->getVertexArray()->size(),&(it->_glyph->getVertexArray()->front()));
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// now apply matrix to the glyphs.
|
||||
osg::ref_ptr<osg::Vec3Array> transformedVertices = new osg::Vec3Array;
|
||||
osg::Matrix matrix = _autoTransformCache[0]._matrix;//osg::Matrix();
|
||||
matrix.postMultTranslate(matrix*it->_position);
|
||||
transformedVertices->reserve(vertices->size());
|
||||
for (osg::Vec3Array::iterator itr=vertices->begin(); itr!=vertices->end(); itr++)
|
||||
{
|
||||
transformedVertices->push_back((*itr)*matrix);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
pf.setVertexArray(transformedVertices->size(),&(transformedVertices->front()));
|
||||
|
||||
// ** render the front face of the glyph
|
||||
osg::Geometry::PrimitiveSetList & pslFront = it->_glyph->getFrontPrimitiveSetList();
|
||||
|
||||
Reference in New Issue
Block a user