Added osg::CoordinateSystemNode
This commit is contained in:
73
src/osg/CoordinateSystemNode.cpp
Normal file
73
src/osg/CoordinateSystemNode.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ CXXFILES =\
|
||||
CollectOccludersVisitor.cpp\
|
||||
ConvexPlanarPolygon.cpp\
|
||||
ConvexPlanarOccluder.cpp\
|
||||
CoordinateSystemNode.cpp\
|
||||
CopyOp.cpp\
|
||||
CullFace.cpp\
|
||||
CullingSet.cpp\
|
||||
|
||||
Reference in New Issue
Block a user