From 63ea6ae9792c6b46fe7ec7a26ed1da0206edad00 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 26 Jul 2010 11:06:45 +0000 Subject: [PATCH] Clean up boudnary code --- examples/osgtext3D/osgtext3D.cpp | 378 +++++++------------------------ 1 file changed, 76 insertions(+), 302 deletions(-) diff --git a/examples/osgtext3D/osgtext3D.cpp b/examples/osgtext3D/osgtext3D.cpp index 13745a228..1c1267b94 100644 --- a/examples/osgtext3D/osgtext3D.cpp +++ b/examples/osgtext3D/osgtext3D.cpp @@ -32,99 +32,6 @@ 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.0f) + { + // OSG_NOTICE<<" computeBisectorNormal(a=["<(geometry->getVertexArray()); - osg::Geometry::PrimitiveSetList& primitives = geometry->getPrimitiveSetList(); - for(osg::Geometry::PrimitiveSetList::iterator itr = primitives.begin(); - itr != primitives.end(); - ++itr) - { - osg::DrawArrays* drawArray = dynamic_cast(itr->get()); - if (drawArray && drawArray->getMode()==GL_POLYGON) - { - computeBoundaryAngles(*vertices, drawArray->getFirst(), drawArray->getCount()); - } - } -} - -osg::Vec3 computeNewVertexPosition(osg::Vec3& v1, osg::Vec3& v2, osg::Vec3& v3) -{ - double angle = computeAngle(v1,v2,v3); - osg::Vec3 v21(v2-v1); - osg::Vec3 v32(v3-v2); - float length_21 = v21.normalize(); - float length_32 = v32.normalize(); - - float t = 5.0; - if (length_21==0.0) - { - OSG_NOTICE<<"length_21=="<0.001) - { - OSG_NOTICE<<" WARNING 1 bisector disagree "<0.0) bisector = -bisector; - - if ((computeBisectorNormal(v1,v2,v2,v3)-bisector).length2()>0.001) - { - OSG_NOTICE<<" WARNING 2 bisector disagree "<(orig_geometry->getVertexArray()); - osg::Geometry::PrimitiveSetList& orig_primitives = orig_geometry->getPrimitiveSetList(); - - osg::Geometry* new_geometry = new osg::Geometry; - osg::Vec3Array* new_vertices = new osg::Vec3Array(*orig_vertices); - osg::Geometry::PrimitiveSetList& new_primitives = new_geometry->getPrimitiveSetList(); - new_geometry->setVertexArray(new_vertices); - osg::Vec4Array* new_colours = new osg::Vec4Array; - new_colours->push_back(osg::Vec4(1.0,0.0,0.0,1.0)); - new_geometry->setColorArray(new_colours); - new_geometry->setColorBinding(osg::Geometry::BIND_OVERALL); - - 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) - { - osg::DrawArrays* new_drawArray = computeBevelEdge(*orig_vertices, drawArray->getFirst(), drawArray->getCount(), *new_vertices); - removeLoops(*new_vertices, new_drawArray->getFirst(), new_drawArray->getCount()); - new_primitives.push_back(new_drawArray); - } - } - return new_geometry; -} - osg::Geometry* computeThickness(osg::Geometry* orig_geometry, float thickness) { // OSG_NOTICE<<"computeThickness("<setColorArray(colours); geometry->setColorBinding(osg::Geometry::BIND_OVERALL); - osg::Geometry* bevel = 0; - if (useOldBoundaryCalc) - { - bevel = computeBevelEdge(geometry); - } - else - { - bevel = computeThickness(geometry, thickness); - } + osg::Geometry* bevel = computeThickness(geometry, thickness); if (bevel) geode->addDrawable(bevel);