Added osg::CoordinateSystemNode

This commit is contained in:
Robert Osfield
2004-04-29 22:16:50 +00:00
parent df0d0b0fe7
commit 36cd372847
5 changed files with 315 additions and 1 deletions

View File

@@ -0,0 +1,73 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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 <osg/CoordinateSystemNode>
using namespace osg;
CoordinateSystemNode::CoordinateSystemNode()
{
}
CoordinateSystemNode::CoordinateSystemNode(const std::string& WKT)
{
_WKT = WKT;
}
CoordinateSystemNode::CoordinateSystemNode(const CoordinateSystemNode& csn,const osg::CopyOp& copyop):
Group(csn,copyop)
{
_WKT = csn._WKT;
_ellipsoidModel = csn._ellipsoidModel;
}
CoordinateFrame CoordinateSystemNode::computeLocalCoordinateFrame(const Vec3& position) const
{
return computeLocalCoordinateFrame(position.x(), position.y(), position.z());
}
CoordinateFrame CoordinateSystemNode::computeLocalCoordinateFrame(double X, double Y, double Z) const
{
if (_ellipsoidModel.valid())
{
Matrixd localToWorld;
_ellipsoidModel->computeLocalToWorldTransformFromXYZ(X,Y,Z, localToWorld);
return localToWorld;
}
else
{
return Matrixd();
}
}
osg::Vec3 CoordinateSystemNode::computeLocalUpVector(const Vec3& position) const
{
return computeLocalUpVector(position.x(), position.y(), position.z());
}
osg::Vec3 CoordinateSystemNode::computeLocalUpVector(double X, double Y, double Z) const
{
if (_ellipsoidModel.valid())
{
return _ellipsoidModel->computeLocalUpVector(X,Y,Z);
}
else
{
return osg::Vec3(0.0f,0.0f,1.0f);
}
}

View File

@@ -1093,6 +1093,11 @@ void ClusterCullingCallback::computeFrom(const osg::Drawable* drawable)
TriangleFunctor<ComputeDeviationFunctor> cdf;
cdf.set(_controlPoint,_normal);
drawable->accept(cdf);
// osg::notify(osg::NOTICE)<<"ClusterCullingCallback::computeFrom() _controlPoint="<<_controlPoint<<std::endl;
// osg::notify(osg::NOTICE)<<" _normal="<<_normal<<std::endl;
// osg::notify(osg::NOTICE)<<" cdf._deviation="<<cdf._deviation<<std::endl;
if (_normal.length2()==0.0) _deviation = -1.0f;
else
@@ -1115,11 +1120,18 @@ void ClusterCullingCallback::set(const osg::Vec3& controlPoint, const osg::Vec3&
bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::State*) const
{
if (_deviation<=-1.0f) return false;
if (_deviation<=-1.0f)
{
// osg::notify(osg::NOTICE)<<"ClusterCullingCallback::cull() _deviation="<<_deviation<<std::endl;
return false;
}
osg::Vec3 eye_cp = nv->getEyePoint() - _controlPoint;
float deviation = (eye_cp * _normal)/eye_cp.length();
// osg::notify(osg::NOTICE)<<"ClusterCullingCallback::cull() _normal="<<_normal<<" _controlPointtest="<<_controlPoint<<" eye_cp="<<eye_cp<<std::endl;
// osg::notify(osg::NOTICE)<<" deviation="<<deviation<<" _deviation="<<_deviation<<" test="<<(deviation < _deviation)<<std::endl;
return deviation < _deviation;
}

View File

@@ -20,6 +20,7 @@ CXXFILES =\
CollectOccludersVisitor.cpp\
ConvexPlanarPolygon.cpp\
ConvexPlanarOccluder.cpp\
CoordinateSystemNode.cpp\
CopyOp.cpp\
CullFace.cpp\
CullingSet.cpp\