Fixed a bug in the drive manipulator which was due to it using the local
coords of the intersection point with the scene rather than the world coord value for that point. The code now uses osgUtil::Hit::getWorldIntersectionPoint() method for getting the world coords. Added support for getWorldIntersectionPoint to Viewer.cpp. Put and #ifdef around the setting of the default display list visitor so it nolonger sets in under IRIX. This is a world around to the IR graphics imbending lighting info into display lists, if the display lists are created before state is set up it produces lighting artifacts such as flickering. Remove the the default display list init visitor removes these problems, display lists are then built on the fly and drawables a drawn for the first time.
This commit is contained in:
parent
a08fc47313
commit
d9398af300
@ -1053,14 +1053,14 @@ void Viewer::keyboard(unsigned char key, int x, int y)
|
|||||||
hitr!=hitList.end();
|
hitr!=hitList.end();
|
||||||
++hitr)
|
++hitr)
|
||||||
{
|
{
|
||||||
osg::Vec3 ip = hitr->_intersectPoint;
|
osg::Vec3 ip = hitr->getLocalIntersectPoint();
|
||||||
osg::Vec3 in = hitr->_intersectNormal;
|
osg::Vec3 in = hitr->getLocalIntersectNormal();
|
||||||
osg::Geode* geode = hitr->_geode.get();
|
osg::Geode* geode = hitr->_geode.get();
|
||||||
osg::notify(osg::NOTICE) << " Itersection Point ("<<ip<<") Normal ("<<in<<")"<< std::endl;
|
osg::notify(osg::NOTICE) << " Itersection Point ("<<ip<<") Normal ("<<in<<")"<< std::endl;
|
||||||
if (hitr->_matrix.valid())
|
if (hitr->_matrix.valid())
|
||||||
{
|
{
|
||||||
osg::Vec3 ipEye = ip*(*(hitr->_matrix));
|
osg::Vec3 ipEye = hitr->getWorldIntersectPoint();
|
||||||
osg::Vec3 inEye = (in+ip)*(*(hitr->_matrix))-ipEye;
|
osg::Vec3 inEye = hitr->getWorldIntersectNormal();
|
||||||
inEye.normalize();
|
inEye.normalize();
|
||||||
if (geode) osg::notify(osg::NOTICE) << "Geode '"<<geode->getName()<< std::endl;
|
if (geode) osg::notify(osg::NOTICE) << "Geode '"<<geode->getName()<< std::endl;
|
||||||
osg::notify(osg::NOTICE) << " Eye Itersection Point ("<<ipEye<<") Normal ("<<inEye<<")"<< std::endl;
|
osg::notify(osg::NOTICE) << " Eye Itersection Point ("<<ipEye<<") Normal ("<<inEye<<")"<< std::endl;
|
||||||
|
@ -72,8 +72,8 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
if (!hitList.empty())
|
if (!hitList.empty())
|
||||||
{
|
{
|
||||||
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
osg::Vec3 np = hitList.front()._intersectNormal;
|
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
|
||||||
|
|
||||||
osg::Vec3 uv;
|
osg::Vec3 uv;
|
||||||
if (np.z()>0.0f) uv = np;
|
if (np.z()>0.0f) uv = np;
|
||||||
@ -111,8 +111,8 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
if (!hitList.empty())
|
if (!hitList.empty())
|
||||||
{
|
{
|
||||||
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
osg::Vec3 np = hitList.front()._intersectNormal;
|
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
|
||||||
|
|
||||||
osg::Vec3 uv;
|
osg::Vec3 uv;
|
||||||
if (np.z()>0.0f) uv = np;
|
if (np.z()>0.0f) uv = np;
|
||||||
@ -187,8 +187,8 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
if (!hitList.empty())
|
if (!hitList.empty())
|
||||||
{
|
{
|
||||||
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
osg::Vec3 np = hitList.front()._intersectNormal;
|
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
|
||||||
|
|
||||||
osg::Vec3 uv;
|
osg::Vec3 uv;
|
||||||
if (np.z()>0.0f) uv = np;
|
if (np.z()>0.0f) uv = np;
|
||||||
@ -226,8 +226,8 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
if (!hitList.empty())
|
if (!hitList.empty())
|
||||||
{
|
{
|
||||||
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
osg::Vec3 np = hitList.front()._intersectNormal;
|
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
|
||||||
|
|
||||||
osg::Vec3 uv;
|
osg::Vec3 uv;
|
||||||
if (np.z()>0.0f) uv = np;
|
if (np.z()>0.0f) uv = np;
|
||||||
@ -464,7 +464,7 @@ bool DriveManipulator::calcMovement()
|
|||||||
if (!hitList.empty())
|
if (!hitList.empty())
|
||||||
{
|
{
|
||||||
// notify(INFO) << "Hit obstruction"<< std::endl;
|
// notify(INFO) << "Hit obstruction"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
distanceToMove = (ip-ep).length()-_buffer;
|
distanceToMove = (ip-ep).length()-_buffer;
|
||||||
_velocity = 0.0f;
|
_velocity = 0.0f;
|
||||||
}
|
}
|
||||||
@ -489,8 +489,8 @@ bool DriveManipulator::calcMovement()
|
|||||||
if (!hitList.empty())
|
if (!hitList.empty())
|
||||||
{
|
{
|
||||||
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
// notify(INFO) << "Hit terrain ok"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
osg::Vec3 np = hitList.front()._intersectNormal;
|
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
|
||||||
|
|
||||||
if (uv*np>0.0f) uv = np;
|
if (uv*np>0.0f) uv = np;
|
||||||
else uv = -np;
|
else uv = -np;
|
||||||
@ -528,8 +528,8 @@ bool DriveManipulator::calcMovement()
|
|||||||
{
|
{
|
||||||
|
|
||||||
notify(INFO) << "Hit terrain on decent ok"<< std::endl;
|
notify(INFO) << "Hit terrain on decent ok"<< std::endl;
|
||||||
osg::Vec3 ip = hitList.front()._intersectPoint;
|
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
|
||||||
osg::Vec3 np = hitList.front()._intersectNormal;
|
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
|
||||||
|
|
||||||
if (uv*np>0.0f) uv = np;
|
if (uv*np>0.0f) uv = np;
|
||||||
else uv = -np;
|
else uv = -np;
|
||||||
|
@ -61,9 +61,15 @@ void SceneView::setDefaults()
|
|||||||
_renderStage = new RenderStage;
|
_renderStage = new RenderStage;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __sgi
|
||||||
|
// sgi's IR graphics has a problem with lighting and display lists, as it seems to store
|
||||||
|
// lighting state with the display list, and the display list visitor doesn't currently apply
|
||||||
|
// state before creating display lists. So will disable the init visitor default, this won't
|
||||||
|
// affect functionality since the display lists will be created as and when needed.
|
||||||
DisplayListVisitor* dlv = new DisplayListVisitor();
|
DisplayListVisitor* dlv = new DisplayListVisitor();
|
||||||
dlv->setState(_state.get());
|
dlv->setState(_state.get());
|
||||||
_initVisitor = dlv;
|
_initVisitor = dlv;
|
||||||
|
#endif
|
||||||
|
|
||||||
_appVisitor = new AppVisitor;
|
_appVisitor = new AppVisitor;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user