6 #ifndef OPENVDB_MATH_LEGACYFRUSTUM_HAS_BEEN_INCLUDED 7 #define OPENVDB_MATH_LEGACYFRUSTUM_HAS_BEEN_INCLUDED 29 LegacyFrustum(std::istream& is)
34 is.read(reinterpret_cast<char*>(&tmpMin),
sizeof(Vec3i::ValueType) * 3);
35 is.read(reinterpret_cast<char*>(&tmpMax),
sizeof(Vec3i::ValueType) * 3);
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),
54 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
55 is.read(reinterpret_cast<char*>(&mC2W),
56 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
57 is.read(reinterpret_cast<char*>(&tmpC2S),
58 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
59 is.read(reinterpret_cast<char*>(&tmpS2C),
60 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
61 is.read(reinterpret_cast<char*>(&tmpWorldToLocal),
62 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
63 is.read(reinterpret_cast<char*>(&mLocalToWorld),
64 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
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),
76 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
77 is.read(reinterpret_cast<char*>(&mXYUnitToLocal),
78 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
79 is.read(reinterpret_cast<char*>(&tmpXYLocalToUnit),
80 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
81 is.read(reinterpret_cast<char*>(&mZUnitToLocal),
82 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
83 is.read(reinterpret_cast<char*>(&tmpZLocalToUnit),
84 sizeof(Mat4d::value_type) * Mat4d::size * Mat4d::size);
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
Mat4< double > Mat4d
Definition: Mat4.h:1354
math::Vec3< Real > Vec3R
Definition: Types.h:72
double Real
Definition: Types.h:60
BBox< Coord > CoordBBox
Definition: NanoVDB.h:2535
Vec3< double > Vec3d
Definition: Vec3.h:664
Definition: Exceptions.h:13
T & z()
Definition: Vec3.h:87
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
Vec3< int32_t > Vec3i
Definition: Vec3.h:661
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212