On 1/19/2011 10:24 AM, Jean-Sébastien Guay wrote:
Hi Paul,
So my original code must have been flawed.
Just curious, trying to get to the bottom of this in case it's important... The
code you first posted used Plane::asVec4(), and your new code doesn't. Could it
be that p.asVec4() != v? i.e. there would be a bug in Plane::asVec4()?
The asVec4() function seems straightforward:
Vec4_type asVec4() const { return Vec4(_fv[0],_fv[1],_fv[2],_fv[3]); }
I see in the code I posted earlier that the matrix is names "l2w" rather than
"w2l", so I think it's more likely that I forget to invert the matrix for the
Vec4 transform, which the Plane transform does automatically.
My project code is still transforming using Plane, so the real test would be to
go back and rewrite that code to (again) use Vec4. I'll try to get to that
today, but have a few other high-priority issues I need to deal with...
-Paul
{
osg::Vec4 v( 1.0, 0.0, 0.0, 1.0 );
osg::Matrix m( osg::Matrix::translate( 3., 5., 0. ) );
osg::Plane p( v );
p.transform( m ); // multiply by inverse transpose
osg::notify( osg::NOTICE ) << p << std::endl;
osg::Matrix mInv = osg::Matrix::inverse( m );
osg::Vec4 vPrime = mInv * v; // multiply by inverse transpose
osg::notify( osg::NOTICE ) << vPrime << std::endl;
osg::Vec4 vPrime2 = mInv * p.asVec4(); // multiply by inverse transpose
osg::notify( osg::NOTICE ) << vPrime2 << std::endl;
assert(v == p.asVec4());
assert(vPrime == vPrime2);
}
J-S
--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org