From 3c4180d9825175b7e37b6300d7f22d66ed0a6f04 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 19 Apr 2011 13:32:25 +0000 Subject: [PATCH] From Paul Martz, "To summarize the fix: OpenGL eye coords are negative outside Cartesian quadrant 1. As a result, the center of projection is eye coord (0,0), which (when used as st tex coords) looks up the lower left corner of the texture. However, in projective texturing, you usually want eye coord (0,0) to look up the center of the texture. Accomplishing this mapping requires not just a lookat and perspective transform, but also a translate and scale." --- examples/osgspotlight/osgspotlight.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/osgspotlight/osgspotlight.cpp b/examples/osgspotlight/osgspotlight.cpp index 2a2ed172e..0d973a807 100644 --- a/examples/osgspotlight/osgspotlight.cpp +++ b/examples/osgspotlight/osgspotlight.cpp @@ -121,7 +121,9 @@ osg::Node* createSpotLightNode(const osg::Vec3& position, const osg::Vec3& direc osg::TexGen* texgen = texgenNode->getTexGen(); texgen->setMode(osg::TexGen::EYE_LINEAR); texgen->setPlanesFromMatrix(osg::Matrixd::lookAt(position, position+direction, up)* - osg::Matrixd::perspective(angle,1.0,0.1,100)); + osg::Matrixd::perspective(angle,1.0,0.1,100)* + osg::Matrixd::translate(1.0,1.0,1.0)* + osg::Matrixd::scale(0.5,0.5,0.5)); group->addChild(texgenNode);