diff --git a/examples/osgtext3D/osgtext3D.cpp b/examples/osgtext3D/osgtext3D.cpp index 4dfcf3692..7abbd5ba3 100644 --- a/examples/osgtext3D/osgtext3D.cpp +++ b/examples/osgtext3D/osgtext3D.cpp @@ -31,8 +31,24 @@ extern int main_orig(int, char**); extern int main_test(int, char**); + +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.0) + { + OSG_NOTICE<<"computeRayIntersectionPoint()< 0.0f) + { + // OSG_NOTICE<<" computeBisectorNormal(a=["<0.0 && thickness < minThickness) + { + minThickness = thickness; + minThickness_i = i; + } + } + + return minThickness_i != _segments.size(); + } + + void removeAllSegmentsBelowThickness(float targetThickness) + { + OSG_NOTICE<<"removeAllSegmentsBelowThickness("<0.001) + { + OSG_NOTICE<<" WARNING 1 bisector disagree "<0.0) bisector = -bisector; - OSG_NOTICE<<" bisector normal "<0.001) + { + OSG_NOTICE<<" WARNING 2 bisector disagree "<(orig_geometry->getVertexArray()); + osg::Geometry::PrimitiveSetList& orig_primitives = orig_geometry->getPrimitiveSetList(); + + for(osg::Geometry::PrimitiveSetList::iterator itr = orig_primitives.begin(); + itr != orig_primitives.end(); + ++itr) + { + osg::DrawArrays* drawArray = dynamic_cast(itr->get()); + if (drawArray && drawArray->getMode()==GL_POLYGON) + { + Boundary boundary(orig_vertices, drawArray->getFirst(), drawArray->getCount()); + boundary.computeAllThickness(); + + boundary.removeAllSegmentsBelowThickness(thickness); + } + } + return 0; +} + + int main(int argc, char** argv) { osg::ArgumentParser arguments(&argc, argv); @@ -297,6 +456,9 @@ int main(int argc, char** argv) bool useTessellator = false; while(arguments.read("-t") || arguments.read("--tessellate")) { useTessellator = true; } + float thickness = 5.0; + while(arguments.read("--thickness",thickness)) {} + osg::ref_ptr group = new osg::Group; osg::Vec3 position; @@ -324,11 +486,13 @@ int main(int argc, char** argv) geometry->setColorArray(colours); geometry->setColorBinding(osg::Geometry::BIND_OVERALL); - computeBoundaryAngles(geometry); + // computeBoundaryAngles(geometry); osg::Geometry* bevel = computeBevelEdge(geometry); geode->addDrawable(bevel); + computeThickness(geometry, thickness); + if (useTessellator) { osgUtil::Tessellator ts;