[osg-users] Why are the two osg::Polytope results different when using the transform method?
mirr...@gmail.com
mirro187 at gmail.com
Sat Mar 13 03:34:39 PST 2021
win10&osg3.6.4
//
osg::Matrixd proj = osg::Matrixd::identity();
proj.makePerspective(60, frustumAspectWidth/frustumAspectHeight,
frustumNear, frustumFar);
//
const double mynear = proj(3, 2) / (proj(2, 2) - 1.0);
const double myfar = proj(3, 2) / (1.0 + proj(2, 2));
//
const double nLeft = mynear * (proj(2, 0) - 1.0) / proj(0, 0);
const double nRight = mynear * (1.0 + proj(2, 0)) / proj(0, 0);
const double nTop = mynear * (1.0 + proj(2, 1)) / proj(1, 1);
const double nBottom = mynear * (proj(2, 1) - 1.0) / proj(1, 1);
const double fLeft = myfar * (proj(2, 0) - 1.0) / proj(0, 0);
const double fRight = myfar * (1.0 + proj(2, 0)) / proj(0, 0);
const double fTop = myfar * (1.0 + proj(2, 1)) / proj(1, 1);
const double fBottom = myfar * (proj(2, 1) - 1.0) / proj(1, 1);
//
osg::Matrixd ViewM = _view->getCamera()->getInverseViewMatrix();
{
osg::Polytope viewFrstumPoly;
osg::Vec3d pt[9];
pt[1] = osg::Vec3d(nLeft, nBottom, -mynear)*ViewM ;
pt[2] = osg::Vec3d(nRight, nBottom, -mynear)*ViewM ;
pt[3] = osg::Vec3d(nRight, nTop, -mynear)*ViewM ;
viewFrstumPoly.add(osg::Plane(pt[1],pt[2],pt[3]));
}
{
osg::Polytope viewFrstumPoly2;
osg::Vec3d pt[9];
pt[1] = osg::Vec3d(nLeft, nBottom, -mynear);
pt[2] = osg::Vec3d(nRight, nBottom, -mynear) ;
pt[3] = osg::Vec3d(nRight, nTop, -mynear);
viewFrstumPoly2.add(osg::Plane(pt[1],pt[2],pt[3]));
viewFrstumPoly2 .transform(ViewM);
}
--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/605b9691-4e64-4083-8229-fe6a94203bben%40googlegroups.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20210313/7127bcd5/attachment.html>
More information about the osg-users
mailing list