/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 "GlyphGeometry.h" #include #include #include #include #include #include namespace osgText { ///////////////////////////////////////////////////////////////////////////////////////// // // Boundary // class Boundary { public: typedef std::pair Segment; typedef std::vector Segments; osg::ref_ptr _vertices; osg::ref_ptr _elements; Segments _segments; Boundary(const osg::Vec3Array* vertices, const osg::PrimitiveSet* primitiveSet) { const osg::DrawArrays* drawArrays = dynamic_cast(primitiveSet); if (drawArrays) { set(vertices, drawArrays->getFirst(), drawArrays->getCount()); } else { const osg::DrawElementsUShort* elements = dynamic_cast(primitiveSet); if (elements) set(vertices, elements); } } void set(const osg::Vec3Array* vertices, unsigned int start, unsigned int count) { osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::POLYGON); for(unsigned int i=start; ipush_back(i); } set(vertices, elements); } void set(const osg::Vec3Array* vertices, const osg::DrawElementsUShort* elements) { _vertices = vertices; _elements = elements; _segments.clear(); if (elements->empty()) return; _segments.reserve(elements->size()-1); for(unsigned int i=0; isize()-1; ++i) { _segments.push_back(Segment((*elements)[i],(*elements)[i+1])); } } osg::Vec3 computeRayIntersectionPoint(const osg::Vec3& a, const osg::Vec3& an, const osg::Vec3& c, const osg::Vec3& cn) { float denominator = ( cn.x() * an.y() - cn.y() * an.x()); if (denominator==0.0f) { //OSG_NOTICE<<"computeRayIntersectionPoint()< 0.0f) { // OSG_NOTICE<<" computeBisectorNormal(a=["< maxThickness) { maxThickness = thickness; maxThickness_i = i; } } return maxThickness_i != _segments.size(); } void removeAllSegmentsAboveThickness(float targetThickness) { // OSG_NOTICE<<"removeAllSegmentsBelowThickness("<reserve(new_vertices->size() + _segments.size()+1 + _elements->size()); // create vertices unsigned int previous_second = _segments[0].second; osg::Vec3 newPoint = computeBisectorPoint(0, targetThickness); unsigned int first = new_vertices->size(); new_vertices->push_back(newPoint); unsigned int start = (*_elements)[0]; unsigned int count = _elements->size(); if (_segments[0].first != start) { //OSG_NOTICE<<"We have pruned from the start"<push_back(first); } } else { face->push_back(first); } for(unsigned int i=1; i<_segments.size(); ++i) { newPoint = computeBisectorPoint(i, targetThickness); unsigned int vi = new_vertices->size(); new_vertices->push_back(newPoint); if (previous_second != _segments[i].first) { //OSG_NOTICE<<"Gap in boundary"<push_back(vi); } } else { face->push_back(vi); } previous_second = _segments[i].second; } // fill the end of the polygon with repititions of the first index in the polygon to ensure // that the orignal and new boundary polygons have the same number and pairing of indices. // This ensures that the bevel can be created coherently. while(face->size() < count) { face->push_back(first); } if (requireFace) { // add face primitive set for polygon geometry->addPrimitiveSet(face.get()); } osg::DrawElementsUShort* bevel = new osg::DrawElementsUShort(GL_QUAD_STRIP); bevel->setName("bevel"); bevel->reserve(count*2); for(unsigned int i=0; isize(); new_vertices->push_back((*_vertices)[(*_elements)[i]]); bevel->push_back(vi); bevel->push_back((*face)[i]); } geometry->addPrimitiveSet(bevel); } void newAddBoundaryToGeometry(osg::Geometry* geometry, float targetThickness, const std::string& faceName, const std::string& bevelName) { if (_segments.empty()) return; unsigned int start = (*_elements)[0]; unsigned int count = _elements->size(); if (geometry->getVertexArray()==0) geometry->setVertexArray(new osg::Vec3Array(*_vertices)); osg::Vec3Array* new_vertices = dynamic_cast(geometry->getVertexArray()); // allocate the primitive set to store the face geometry osg::ref_ptr face = new osg::DrawElementsUShort(GL_POLYGON); face->setName(faceName); // reserve enough space in the vertex array to accomodate the vertices associated with the segments new_vertices->reserve(new_vertices->size() + _segments.size()+1 + count); // create vertices unsigned int previous_second = _segments[0].second; osg::Vec3 newPoint = computeBisectorPoint(0, targetThickness); unsigned int first = new_vertices->size(); new_vertices->push_back(newPoint); if (_segments[0].first != start) { //OSG_NOTICE<<"We have pruned from the start"<push_back(first); } } else { face->push_back(first); } for(unsigned int i=1; i<_segments.size(); ++i) { newPoint = computeBisectorPoint(i, targetThickness); unsigned int vi = new_vertices->size(); new_vertices->push_back(newPoint); if (previous_second != _segments[i].first) { //OSG_NOTICE<<"Gap in boundary"<push_back(vi); } } else { face->push_back(vi); } previous_second = _segments[i].second; } // fill the end of the polygon with repititions of the first index in the polygon to ensure // that the orignal and new boundary polygons have the same number and pairing of indices. // This ensures that the bevel can be created coherently. while(face->size() < count) { face->push_back(first); } if (!faceName.empty()) { // add face primitive set for polygon geometry->addPrimitiveSet(face.get()); } osg::DrawElementsUShort* bevel = new osg::DrawElementsUShort(GL_QUAD_STRIP); bevel->setName(bevelName); bevel->reserve(count*2); for(unsigned int i=0; ipush_back((*_elements)[i]); bevel->push_back((*face)[i]); } geometry->addPrimitiveSet(bevel); } }; ///////////////////////////////////////////////////////////////////////////////////////// // // computeGlyphGeometry // struct CollectTriangleIndicesFunctor { CollectTriangleIndicesFunctor() {} typedef std::vector Indices; Indices _indices; void operator() (unsigned int p1, unsigned int p2, unsigned int p3) { if (p1==p2 || p2==p3 || p1==p3) { return; } _indices.push_back(p1); _indices.push_back(p3); _indices.push_back(p2); } }; OSGTEXT_EXPORT osg::Geometry* computeGlyphGeometry(const osgText::Glyph3D* glyph, float bevelThickness, float shellThickness) { const osg::Vec3Array* orig_vertices = glyph->getRawVertexArray(); const osg::Geometry::PrimitiveSetList& orig_primitives = glyph->getRawFacePrimitiveSetList(); osg::ref_ptr new_geometry = new osg::Geometry; for(osg::Geometry::PrimitiveSetList::const_iterator itr = orig_primitives.begin(); itr != orig_primitives.end(); ++itr) { if ((*itr)->getMode()==GL_POLYGON) { Boundary boundaryInner(orig_vertices, itr->get()); boundaryInner.removeAllSegmentsBelowThickness(bevelThickness); boundaryInner.newAddBoundaryToGeometry(new_geometry.get(), bevelThickness, "face", "bevel"); Boundary boundaryOuter(orig_vertices, itr->get()); boundaryOuter.removeAllSegmentsAboveThickness(-shellThickness); boundaryOuter.newAddBoundaryToGeometry(new_geometry.get(), -shellThickness, "", "shell"); } } osg::Vec3Array* vertices = dynamic_cast(new_geometry->getVertexArray()); // need to tessellate the inner boundary { osg::ref_ptr face_geometry = new osg::Geometry; face_geometry->setVertexArray(vertices); osg::CopyOp copyop(osg::CopyOp::DEEP_COPY_ALL); osg::Geometry::PrimitiveSetList primitiveSets; for(osg::Geometry::PrimitiveSetList::iterator itr = new_geometry->getPrimitiveSetList().begin(); itr != new_geometry->getPrimitiveSetList().end(); ++itr) { osg::PrimitiveSet* prim = itr->get(); if (prim->getName()=="face") face_geometry->addPrimitiveSet(copyop(itr->get())); else primitiveSets.push_back(prim); } osgUtil::Tessellator ts; ts.setWindingType(osgUtil::Tessellator::TESS_WINDING_POSITIVE); ts.setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY); ts.retessellatePolygons(*face_geometry); osg::TriangleIndexFunctor ctif; face_geometry->accept(ctif); CollectTriangleIndicesFunctor::Indices& indices = ctif._indices; // remove the previous primitive sets new_geometry->getPrimitiveSetList().clear(); // create a front face using triangle indices osg::DrawElementsUShort* front_face = new osg::DrawElementsUShort(GL_TRIANGLES); front_face->setName("face"); new_geometry->addPrimitiveSet(front_face); for(unsigned int i=0; ipush_back(indices[i]); } for(osg::Geometry::PrimitiveSetList::iterator itr = primitiveSets.begin(); itr != primitiveSets.end(); ++itr) { osg::PrimitiveSet* prim = itr->get(); if (prim->getName()!="face") new_geometry->addPrimitiveSet(prim); } } return new_geometry.release(); } ///////////////////////////////////////////////////////////////////////////////////////// // // computeTextGeometry // OSGTEXT_EXPORT osg::Geometry* computeTextGeometry(const osgText::Glyph3D* glyph, float width) { const osg::Vec3Array* orig_vertices = glyph->getRawVertexArray(); const osg::Geometry::PrimitiveSetList& orig_primitives = glyph->getRawFacePrimitiveSetList(); osg::ref_ptr text_geometry = new osg::Geometry; osg::ref_ptr vertices = new osg::Vec3Array((*orig_vertices)); text_geometry->setVertexArray(vertices.get()); text_geometry->setPrimitiveSetList(orig_primitives); osgUtil::Tessellator ts; ts.setWindingType(osgUtil::Tessellator::TESS_WINDING_POSITIVE); ts.setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY); ts.retessellatePolygons(*text_geometry); osg::TriangleIndexFunctor ctif; text_geometry->accept(ctif); CollectTriangleIndicesFunctor::Indices& indices = ctif._indices; // remove the previous primitive sets text_geometry->getPrimitiveSetList().clear(); if (indices.empty()) return 0; // create a front face using triangle indices osg::DrawElementsUShort* frontFace = new osg::DrawElementsUShort(GL_TRIANGLES); frontFace->setName("front"); text_geometry->addPrimitiveSet(frontFace); for(unsigned int i=0; ipush_back(indices[i]); } typedef std::vector Indices; const unsigned int NULL_VALUE = UINT_MAX; Indices back_indices; back_indices.resize(vertices->size(), NULL_VALUE); osg::Vec3 forward(0,0,-width); // build up the vertices primitives for the back face, and record the indices // for later use, and to ensure sharing of vertices in the face primitive set // the order of the triangle indices are flipped to make sure that the triangles are back face osg::DrawElementsUShort* backFace = new osg::DrawElementsUShort(GL_TRIANGLES); backFace->setName("back"); text_geometry->addPrimitiveSet(backFace); for(unsigned int i=0; isize(); vertices->push_back((*vertices)[p1]+forward); } if (back_indices[p2]==NULL_VALUE) { back_indices[p2] = vertices->size(); vertices->push_back((*vertices)[p2]+forward); } if (back_indices[p3]==NULL_VALUE) { back_indices[p3] = vertices->size(); vertices->push_back((*vertices)[p3]+forward); } backFace->push_back(back_indices[p1]); backFace->push_back(back_indices[p3]); backFace->push_back(back_indices[p2]); } unsigned int orig_size = orig_vertices->size(); Indices frontedge_indices, backedge_indices; frontedge_indices.resize(orig_size, NULL_VALUE); backedge_indices.resize(orig_size, NULL_VALUE); for(osg::Geometry::PrimitiveSetList::const_iterator itr = orig_primitives.begin(); itr != orig_primitives.end(); ++itr) { osg::DrawElementsUShort* edging = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP); edging->setName("wall"); text_geometry->addPrimitiveSet(edging); osg::DrawElementsUShort* elements = dynamic_cast(itr->get()); if (elements) { for(unsigned int i=0; isize(); ++i) { unsigned int ei = (*elements)[i]; if (frontedge_indices[ei]==NULL_VALUE) { frontedge_indices[ei] = vertices->size(); vertices->push_back((*orig_vertices)[ei]); } if (backedge_indices[ei]==NULL_VALUE) { backedge_indices[ei] = vertices->size(); vertices->push_back((*orig_vertices)[ei]+forward); } edging->push_back(backedge_indices[ei]); edging->push_back(frontedge_indices[ei]); } } } return text_geometry.release(); } ///////////////////////////////////////////////////////////////////////////////////////// // // computeTextGeometry // OSGTEXT_EXPORT osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, const osgText::Bevel& profile, float width) { osg::Vec3Array* orig_vertices = dynamic_cast(glyphGeometry->getVertexArray()); if (!orig_vertices) { OSG_INFO<<"computeTextGeometry(..): No vertices on glyphGeometry."< text_geometry = new osg::Geometry; osg::ref_ptr vertices = new osg::Vec3Array; text_geometry->setVertexArray(vertices.get()); typedef std::vector Indices; const unsigned int NULL_VALUE = UINT_MAX; Indices front_indices, back_indices; front_indices.resize(orig_vertices->size(), NULL_VALUE); back_indices.resize(orig_vertices->size(), NULL_VALUE); osg::DrawElementsUShort* face = 0; osg::Geometry::PrimitiveSetList bevelPrimitiveSets; osg::Vec3 forward(0,0,-width); // collect bevels and face primitive sets for(osg::Geometry::PrimitiveSetList::iterator itr = glyphGeometry->getPrimitiveSetList().begin(); itr != glyphGeometry->getPrimitiveSetList().end(); ++itr) { osg::PrimitiveSet* prim = itr->get(); if (prim->getName()=="face") face = dynamic_cast(prim); else if (prim->getName()=="bevel") bevelPrimitiveSets.push_back(prim); } // if we don't have a face we can't create any 3d text if (!face) return 0; // face doesn't have enough vertices on it to represent a polygon. if (face->size()<3) { OSG_NOTICE<<"Face does not have enough elements to be able to represent a polygon, face->size() = "<size()<setName("front"); text_geometry->addPrimitiveSet(frontFace); for(unsigned int i=0; isize();) { unsigned int pi = (*face)[i++]; if (front_indices[pi]==NULL_VALUE) { front_indices[pi] = vertices->size(); vertices->push_back((*orig_vertices)[pi]); } frontFace->push_back(front_indices[pi]); } // build up the vertices primitives for the back face, and record the indices // for later use, and to ensure sharing of vertices in the face primitive set // the order of the triangle indices are flipped to make sure that the triangles are back face osg::DrawElementsUShort* backFace = new osg::DrawElementsUShort(GL_TRIANGLES); backFace->setName("back"); text_geometry->addPrimitiveSet(backFace); for(unsigned int i=0; isize()-2;) { unsigned int p1 = (*face)[i++]; unsigned int p2 = (*face)[i++]; unsigned int p3 = (*face)[i++]; if (back_indices[p1]==NULL_VALUE) { back_indices[p1] = vertices->size(); vertices->push_back((*orig_vertices)[p1]+forward); } if (back_indices[p2]==NULL_VALUE) { back_indices[p2] = vertices->size(); vertices->push_back((*orig_vertices)[p2]+forward); } if (back_indices[p3]==NULL_VALUE) { back_indices[p3] = vertices->size(); vertices->push_back((*orig_vertices)[p3]+forward); } backFace->push_back(back_indices[p1]); backFace->push_back(back_indices[p3]); backFace->push_back(back_indices[p2]); } bool shareVerticesWithFaces = true; // now build up the bevel for(osg::Geometry::PrimitiveSetList::iterator itr = bevelPrimitiveSets.begin(); itr != bevelPrimitiveSets.end(); ++itr) { osg::DrawElementsUShort* bevel = dynamic_cast(itr->get()); if (!bevel) continue; unsigned int no_vertices_on_boundary = bevel->size()/2; const osgText::Bevel::Vertices& profileVertices = profile.getVertices(); unsigned int no_vertices_on_bevel = profileVertices.size(); Indices bevelIndices; bevelIndices.resize(no_vertices_on_boundary*no_vertices_on_bevel, NULL_VALUE); // populate vertices for(unsigned int i=0; isize(); vertices->push_back(base_vertex); } bevelIndices[i*no_vertices_on_bevel + 0] = front_indices[basei]; for(unsigned int j=1; jsize(); vertices->push_back(pos); } if (back_indices[basei]==NULL_VALUE) { back_indices[basei] = vertices->size(); vertices->push_back(base_vertex + forward); } bevelIndices[i*no_vertices_on_bevel + no_vertices_on_bevel-1] = back_indices[basei]; } else { for(unsigned int j=0; jsize(); vertices->push_back(pos); } } } osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(GL_TRIANGLES); elements->setName("wall"); unsigned int base, next; for(unsigned int i = 0; i< no_vertices_on_boundary-1; ++i) { for(unsigned int j=0; jpush_back(bevelIndices[base]); elements->push_back(bevelIndices[next]); elements->push_back(bevelIndices[base+1]); elements->push_back(bevelIndices[base+1]); elements->push_back(bevelIndices[next]); elements->push_back(bevelIndices[next+1]); } } text_geometry->addPrimitiveSet(elements); } return text_geometry.release(); } ///////////////////////////////////////////////////////////////////////////////////////// // // computeShellGeometry // OSGTEXT_EXPORT osg::Geometry* computeShellGeometry(osg::Geometry* glyphGeometry, const osgText::Bevel& profile, float width) { osg::Vec3Array* orig_vertices = dynamic_cast(glyphGeometry->getVertexArray()); if (!orig_vertices) { OSG_NOTICE<<"computeTextGeometry(..): No vertices on glyphGeometry."< text_geometry = new osg::Geometry; osg::ref_ptr vertices = new osg::Vec3Array; text_geometry->setVertexArray(vertices.get()); typedef std::vector Indices; const unsigned int NULL_VALUE = UINT_MAX; Indices front_indices, back_indices; front_indices.resize(orig_vertices->size(), NULL_VALUE); back_indices.resize(orig_vertices->size(), NULL_VALUE); osg::DrawElementsUShort* face = 0; osg::Geometry::PrimitiveSetList bevelPrimitiveSets; osg::Geometry::PrimitiveSetList shellPrimitiveSets; osg::Vec3 frontOffset(0,0,width); osg::Vec3 backOffset(0,0,-2.0*width); osg::Vec3 forward(backOffset-frontOffset); // collect bevels and face primitive sets for(osg::Geometry::PrimitiveSetList::iterator itr = glyphGeometry->getPrimitiveSetList().begin(); itr != glyphGeometry->getPrimitiveSetList().end(); ++itr) { osg::PrimitiveSet* prim = itr->get(); if (prim->getName()=="face") face = dynamic_cast(prim); else if (prim->getName()=="bevel") bevelPrimitiveSets.push_back(prim); else if (prim->getName()=="shell") shellPrimitiveSets.push_back(prim); } // if we don't have a face we can't create any 3d text if (!face) return 0; // build up the vertices primitives for the front face, and record the indices // for later use, and to ensure sharing of vertices in the face primitive set // the order of the triangle indices are flipped to make sure that the triangles are back face osg::DrawElementsUShort* frontFace = new osg::DrawElementsUShort(GL_TRIANGLES); text_geometry->addPrimitiveSet(frontFace); for(unsigned int i=0; isize()-2;) { unsigned int p1 = (*face)[i++]; unsigned int p2 = (*face)[i++]; unsigned int p3 = (*face)[i++]; if (front_indices[p1]==NULL_VALUE) { front_indices[p1] = vertices->size(); vertices->push_back((*orig_vertices)[p1]+frontOffset); } if (front_indices[p2]==NULL_VALUE) { front_indices[p2] = vertices->size(); vertices->push_back((*orig_vertices)[p2]+frontOffset); } if (front_indices[p3]==NULL_VALUE) { front_indices[p3] = vertices->size(); vertices->push_back((*orig_vertices)[p3]+frontOffset); } frontFace->push_back(front_indices[p1]); frontFace->push_back(front_indices[p3]); frontFace->push_back(front_indices[p2]); } // build up the vertices primitives for the back face, and record the indices // for later use, and to ensure sharing of vertices in the face primitive set osg::DrawElementsUShort* backFace = new osg::DrawElementsUShort(GL_TRIANGLES); text_geometry->addPrimitiveSet(backFace); for(unsigned int i=0; isize();) { unsigned int pi = (*face)[i++]; if (back_indices[pi]==NULL_VALUE) { back_indices[pi] = vertices->size(); vertices->push_back((*orig_vertices)[pi]+backOffset); } backFace->push_back(back_indices[pi]); } for(osg::Geometry::PrimitiveSetList::iterator itr = bevelPrimitiveSets.begin(); itr != bevelPrimitiveSets.end(); ++itr) { osg::DrawElementsUShort* strip = dynamic_cast(itr->get()); if (!strip) continue; osg::CopyOp copyop(osg::CopyOp::DEEP_COPY_ALL); osg::DrawElementsUShort* front_strip = dynamic_cast(copyop(strip)); text_geometry->addPrimitiveSet(front_strip); for(unsigned int i=0; isize(); ++i) { unsigned short& pi = (*front_strip)[i]; if (front_indices[pi]==NULL_VALUE) { front_indices[pi] = vertices->size(); vertices->push_back((*orig_vertices)[pi]+frontOffset); } pi = front_indices[pi]; } for(unsigned int i=0; isize()-1;) { unsigned short& p1 = (*front_strip)[i++]; unsigned short& p2 = (*front_strip)[i++]; std::swap(p1,p2); } osg::DrawElementsUShort* back_strip = dynamic_cast(copyop(strip)); text_geometry->addPrimitiveSet(back_strip); for(unsigned int i=0; isize(); ++i) { unsigned short& pi = (*back_strip)[i]; if (back_indices[pi]==NULL_VALUE) { back_indices[pi] = vertices->size(); vertices->push_back((*orig_vertices)[pi]+backOffset); } pi = back_indices[pi]; } } // now build up the shell for(osg::Geometry::PrimitiveSetList::iterator itr = shellPrimitiveSets.begin(); itr != shellPrimitiveSets.end(); ++itr) { osg::DrawElementsUShort* bevel = dynamic_cast(itr->get()); if (!bevel) continue; unsigned int no_vertices_on_boundary = bevel->size()/2; const osgText::Bevel::Vertices& profileVertices = profile.getVertices(); unsigned int no_vertices_on_bevel = profileVertices.size(); Indices bevelIndices; bevelIndices.resize(no_vertices_on_boundary*no_vertices_on_bevel, NULL_VALUE); // populate vertices for(unsigned int i=0; isize(); vertices->push_back(base_vertex); } bevelIndices[i*no_vertices_on_bevel + 0] = front_indices[basei]; for(unsigned int j=1; jsize(); vertices->push_back(pos); } if (back_indices[basei]==NULL_VALUE) { back_indices[basei] = vertices->size(); vertices->push_back(base_vertex + forward); } bevelIndices[i*no_vertices_on_bevel + no_vertices_on_bevel-1] = back_indices[basei]; } osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(GL_TRIANGLES); unsigned int base, next; for(unsigned int i = 0; i< no_vertices_on_boundary-1; ++i) { for(unsigned int j=0; jpush_back(bevelIndices[base]); elements->push_back(bevelIndices[base+1]); elements->push_back(bevelIndices[next]); elements->push_back(bevelIndices[base+1]); elements->push_back(bevelIndices[next+1]); elements->push_back(bevelIndices[next]); } } text_geometry->addPrimitiveSet(elements); } #if 1 osg::Vec4Array* new_colours = new osg::Vec4Array; new_colours->push_back(osg::Vec4(1.0,1.0,1.0,0.2)); text_geometry->setColorArray(new_colours); text_geometry->setColorBinding(osg::Geometry::BIND_OVERALL); osg::StateSet* stateset = text_geometry->getOrCreateStateSet(); stateset->setMode(GL_BLEND, osg::StateAttribute::ON); stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); stateset->setAttributeAndModes(new osg::CullFace, osg::StateAttribute::ON); //stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); stateset->setRenderBinDetails(11, "SORT_FRONT_TO_BACK"); #endif return text_geometry.release(); } }