From 5cab53941f3a6f740cd34ca7d403a332d962fc5c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 19 Sep 2006 22:57:23 +0000 Subject: [PATCH] Further work on fade text. --- src/osgText/FadeText.cpp | 134 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 125 insertions(+), 9 deletions(-) diff --git a/src/osgText/FadeText.cpp b/src/osgText/FadeText.cpp index 9f5f3b7f0..78ad9cfb1 100644 --- a/src/osgText/FadeText.cpp +++ b/src/osgText/FadeText.cpp @@ -34,9 +34,9 @@ struct FadeTextData : public osg::Referenced float getNearestZ() const { float nearestZ = _vertices[0].z(); - if (nearestZ > _vertices[1].z()) nearestZ = _vertices[1].z(); - if (nearestZ > _vertices[2].z()) nearestZ = _vertices[2].z(); - if (nearestZ > _vertices[3].z()) nearestZ = _vertices[3].z(); + if (nearestZ < _vertices[1].z()) nearestZ = _vertices[1].z(); + if (nearestZ < _vertices[2].z()) nearestZ = _vertices[2].z(); + if (nearestZ < _vertices[3].z()) nearestZ = _vertices[3].z(); return nearestZ; } @@ -55,6 +55,14 @@ struct FadeTextPolytopeData : public FadeTextData, public osg::Polytope _referenceVertexList.push_back(_vertices[2]); _referenceVertexList.push_back(_vertices[3]); } + + void addEdgePlane(const osg::Vec3& corner, const osg::Vec3& edge) + { + osg::Vec3 normal( edge.y(), -edge.x(), 0.0f); + normal.normalize(); + + add(osg::Plane(normal, corner)); + } void buildPolytope() { @@ -62,7 +70,63 @@ struct FadeTextPolytopeData : public FadeTextData, public osg::Polytope osg::Vec3 edge12 = _vertices[2] - _vertices[1]; osg::Vec3 edge23 = _vertices[3] - _vertices[2]; osg::Vec3 edge30 = _vertices[0] - _vertices[3]; + osg::Vec3 normalFrontFace = edge01 ^ edge12; + bool needToFlip = normalFrontFace.z()>0.0f; + + normalFrontFace.normalize(); + add(osg::Plane(normalFrontFace, _vertices[0])); + + addEdgePlane(_vertices[0], edge01); + addEdgePlane(_vertices[1], edge12); + addEdgePlane(_vertices[2], edge23); + addEdgePlane(_vertices[3], edge30); + + + osg::notify(osg::NOTICE)<<" normalFrontFace = "<& vertices) + { + for(std::vector::const_iterator itr = vertices.begin(); + itr != vertices.end(); + ++itr) + { + osg::notify(osg::NOTICE)<<"testing "<<*itr<::const_iterator itr = vertices.begin(); + itr != vertices.end(); + ++itr) + { + if (osg::Polytope::contains(*itr)) + { + osg::notify(osg::NOTICE)<<"Does contain "<<*itr<second); + outer_ftpm.buildPolytope(); + + osg::notify(osg::NOTICE)<<"Outer z "<second); + + osg::notify(osg::NOTICE)<<"Inner z "<getProjectionMatrix())="<getProjectionMatrix()<