6 #ifndef OPENVDB_MATH_LEGACYFRUSTUM_HAS_BEEN_INCLUDED
7 #define OPENVDB_MATH_LEGACYFRUSTUM_HAS_BEEN_INCLUDED
29 LegacyFrustum(std::istream& is)
37 Coord tmpMinCoord(tmpMin);
38 Coord tmpMaxCoord(tmpMax);
41 mExtents =
CoordBBox(tmpMinCoord, tmpMaxCoord);
45 Mat4d tmpW2C, tmpC2S, tmpS2C, tmpWorldToLocal;
46 Mat4d tmpS2U, tmpXYLocalToUnit, tmpZLocalToUnit;
53 is.read(reinterpret_cast<char*>(&tmpW2C),
55 is.read(reinterpret_cast<char*>(&mC2W),
57 is.read(reinterpret_cast<char*>(&tmpC2S),
59 is.read(reinterpret_cast<char*>(&tmpS2C),
61 is.read(reinterpret_cast<char*>(&tmpWorldToLocal),
63 is.read(reinterpret_cast<char*>(&mLocalToWorld),
66 is.read(reinterpret_cast<char*>(&tmpWindow[0]),
sizeof(
Real));
67 is.read(reinterpret_cast<char*>(&tmpWindow[1]),
sizeof(
Real));
68 is.read(reinterpret_cast<char*>(&tmpWindow[2]),
sizeof(
Real));
69 is.read(reinterpret_cast<char*>(&tmpWindow[3]),
sizeof(
Real));
70 is.read(reinterpret_cast<char*>(&tmpWindow[4]),
sizeof(
Real));
71 is.read(reinterpret_cast<char*>(&tmpWindow[5]),
sizeof(
Real));
73 is.read(reinterpret_cast<char*>(&tmpPadding),
sizeof(
Real));
75 is.read(reinterpret_cast<char*>(&tmpS2U),
77 is.read(reinterpret_cast<char*>(&mXYUnitToLocal),
79 is.read(reinterpret_cast<char*>(&tmpXYLocalToUnit),
81 is.read(reinterpret_cast<char*>(&mZUnitToLocal),
83 is.read(reinterpret_cast<char*>(&tmpZLocalToUnit),
87 mNearPlane = tmpWindow[4];
88 mFarPlane = tmpWindow[5];
92 mFrNearOrigin = unitToLocalFrustum(
Vec3R(0,0,0));
93 mFrFarOrigin = unitToLocalFrustum(
Vec3R(0,0,1));
95 Vec3d frNearXTip = unitToLocalFrustum(
Vec3R(1,0,0));
96 Vec3d frNearYTip = unitToLocalFrustum(
Vec3R(0,1,0));
97 mFrNearXBasis = frNearXTip - mFrNearOrigin;
98 mFrNearYBasis = frNearYTip - mFrNearOrigin;
100 Vec3R frFarXTip = unitToLocalFrustum(
Vec3R(1,0,1));
101 Vec3R frFarYTip = unitToLocalFrustum(
Vec3R(0,1,1));
102 mFrFarXBasis = frFarXTip - mFrFarOrigin;
103 mFrFarYBasis = frFarYTip - mFrFarOrigin;
108 const Mat4d& getCamXForm()
const {
return mC2W; }
110 double getDepth()
const {
return (mFarPlane - mNearPlane); }
111 double getTaper()
const {
113 return getNearPlaneWidth() / getFarPlaneWidth();
116 double getNearPlaneWidth()
const {
117 double nearPlaneWidth = (unitToWorld(
Vec3d(0,0,0)) - unitToWorld(
Vec3d(1,0,0))).
length();
118 return nearPlaneWidth;
121 double getFarPlaneWidth()
const {
122 double farPlaneWidth = (unitToWorld(
Vec3d(0,0,1)) - unitToWorld(
Vec3d(1,0,1))).
length();
123 return farPlaneWidth;
126 double getNearPlaneDist()
const {
return mNearPlane; }
128 const CoordBBox& getBBox()
const {
return mExtents; }
130 Vec3d unitToWorld(
const Vec3d& in)
const {
return mLocalToWorld.transform( unitToLocal(in) ); }
135 Vec3d unitToLocal(
const Vec3d& U)
const {
141 Vec3d nearLS = ( U[0] * mFrNearXBasis ) + ( U[1] * mFrNearYBasis ) + mFrNearOrigin;
142 Vec3d farLS = ( U[0] * mFrFarXBasis ) + ( U[1] * mFrFarYBasis ) + mFrFarOrigin;
145 return U[2] * farLS + ( 1.0 - U[2] ) * nearLS;
148 Vec3d unitToLocalFrustum(
const Vec3d& u)
const {
149 Vec3d fzu = mZUnitToLocal.transformH(u);
152 return mXYUnitToLocal.transformH(fu);
156 Mat4d mC2W, mLocalToWorld, mXYUnitToLocal, mZUnitToLocal;
158 Vec3d mFrNearXBasis, mFrNearYBasis, mFrFarXBasis, mFrFarYBasis;
159 Vec3d mFrNearOrigin, mFrFarOrigin;
160 double mNearPlane, mFarPlane;
171 #endif // OPENVDB_MATH_LEGACYFRUSTUM_HAS_BEEN_INCLUDED
double value_type
Data type held by the matrix.
GLuint GLsizei GLsizei * length
#define OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.