Field3D
FrustumFieldMapping Class Reference

Represents the mapping of a field by a perspective transform. More...

#include <FieldMapping.h>

Inheritance diagram for FrustumFieldMapping:
FieldMapping RefBase

Public Types

typedef FrustumFieldMapping class_type
typedef Curve< double > FloatCurve
 Time-varying float.
typedef Curve< Imath::M44dMatrixCurve
 Time-varying matrix.
typedef boost::intrusive_ptr
< FrustumFieldMapping
Ptr
 Convenience typedef.
enum  ZDistribution { PerspectiveDistribution, UniformDistribution }
 Enumerates the Z slice distribution. .f3d files will store values as an int, so be very careful not to change the order of these. More...
- Public Types inherited from FieldMapping
typedef FieldMapping class_type
typedef boost::intrusive_ptr
< FieldMapping
Ptr
- Public Types inherited from RefBase
typedef boost::intrusive_ptr
< RefBase
Ptr

Public Member Functions

const M44d cameraToWorld () const
 Returns a reference to the camera to world space transform.
const MatrixCurve::SampleVeccameraToWorldSamples () const
 Returns a vector of all motion samples for camera to world transform.
double farPlane () const
 Returns the far plane.
const FloatCurve::SampleVecfarPlaneSamples () const
 Returns a vector of all motion samples for far plane.
double nearPlane () const
 Returns the near plane.
const FloatCurve::SampleVecnearPlaneSamples () const
 Returns a vector of all motion samples for near plane.
void reset ()
 Resets the transform. Makes a perspective transform at the origin, looking down the negative Z axis with a 45 degree FOV and square projection.
const M44d screenToWorld () const
 Returns a reference to the screen to world space transform.
const MatrixCurve::SampleVecscreenToWorldSamples () const
 Returns a vector of all motion samples for screen to world transform.
void setTransforms (const M44d &ssToWs, const M44d &csToWs)
 Sets the screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these.
void setTransforms (float t, const M44d &ssToWs, const M44d &csToWs)
 Sets time-varying screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these.
void setZDistribution (ZDistribution dist)
 Sets the z slice distribution.
ZDistribution zDistribution () const
 Returns the z slice distribution.
Constructors & destructor
 FrustumFieldMapping ()
 FrustumFieldMapping (const Box3i &extents)
From FieldMapping
virtual void worldToVoxel (const V3d &wsP, V3d &vsP) const
 Transform from world space position into voxel space.
virtual void worldToVoxel (const V3d &wsP, V3d &vsP, float time) const
virtual void voxelToWorld (const V3d &vsP, V3d &wsP) const
 Transform from voxel space position into world space.
virtual void voxelToWorld (const V3d &vsP, V3d &wsP, float time) const
virtual void worldToLocal (const V3d &wsP, V3d &lsP) const
 Transform from world space position into local space.
virtual void worldToLocal (const V3d &wsP, V3d &lsP, float time) const
virtual void localToWorld (const V3d &lsP, V3d &wsP) const
 Transform from local space position into world space.
virtual void localToWorld (const V3d &lsP, V3d &wsP, float time) const
virtual void extentsChanged ()
 Implement this if the subclass needs to update itself when the resolution changes.
virtual std::string className () const
 Returns the FieldMapping type name. Used when writing/reading from disk.
virtual bool isIdentical (FieldMapping::Ptr other, double tolerance=0.0) const
 Whether the mapping is identical to another mapping.
virtual V3d wsVoxelSize (int i, int j, int k) const
 Returns world-space size of a voxel at the specified coordinate.
virtual FieldMapping::Ptr clone () const
 Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it.
- Public Member Functions inherited from FieldMapping
const V3dorigin () const
 Returns the origin.
const V3dresolution () const
 Returns the resolution.
void setExtents (const Box3i &extents)
 This sets the field extents information to use for defining the local coordinate space.
 FieldMapping ()
 Constructor.
 FieldMapping (const Box3i &extents)
 Construct with known extents.
virtual ~FieldMapping ()
 Destructor.
void localToVoxel (const V3d &lsP, V3d &vsP) const
 Transform from local space to voxel space. This is just a multiplication by the resolution of the Field that we're mapping.
void voxelToLocal (const V3d &vsP, V3d &lsP) const
 Inverse of localToVoxel.
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer.
size_t refcnt ()
 Used by boost::intrusive_pointer.
void unref () const
 Used by boost::intrusive_pointer.
 RefBase ()
 RefBase (const RefBase &)
 Copy constructor.
RefBaseoperator= (const RefBase &)
 Assignment operator.
virtual ~RefBase ()
 Destructor.
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.
bool matchRTTI (const char *typenameStr)
 Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones.

Static Public Member Functions

static const char * classType ()

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS
- Public Attributes inherited from FieldMapping
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS

Private Types

typedef FieldMapping base
 Convenience typedef for referring to base class.

Private Member Functions

void clearCurves ()
 Clears all Curve data members. Used by setTransforms() to prepare for the first sample to be added.
void computeVoxelSize ()
 Updates the local to world transformation matrix.
void getLocalToVoxelMatrix (M44d &result)

Private Attributes

MatrixCurve m_csToWsCurve
 Time-varying camera to world space transform.
bool m_defaultState
 Boolean to tell us if the mapping is in its 'default' state. This is needed because the class has a default configuration where there is a single sample in all the curves. Once a new transform is set through setTransforms(), the default samples must be cleared.
FloatCurve m_farCurve
 Time-varying far plane. Computed from m_lpsToWsCurve.
MatrixCurve m_lpsToWsCurve
 Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.
FloatCurve m_nearCurve
 Time-varying near plane. Computed from m_lpsToWsCurve.
MatrixCurve m_ssToWsCurve
 Time-varying local perspective to world space transform This is not used in calculations, but rather as the public interface to the class.
std::vector< V3dm_wsVoxelSize
 Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.
ZDistribution m_zDistribution
 Slice distribution type.

Additional Inherited Members

- Protected Attributes inherited from FieldMapping
V3d m_origin
 The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min.
V3d m_res
 The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1.

Detailed Description

Represents the mapping of a field by a perspective transform.

Refer to using_mappings for examples of how to use this in your code.

Frustum mappings can use two approaches in determining the distribution of "Z slices". By transforming from world space into screen space and using the Z component in perspective space, the slices in Z will be distributed in world space accordingly. It is also possible to use a uniform distribution of Z slices by specifying a near and far clip plane and normalizing the camera-space Z distance between those.

Note
Screen space is defined left-handed as [-1.0,1.0] in all three dimensions
Camera space is defined right-handed with the camera looking down negative Z.
Todo:
Define local perspective space
Note
Regarding time-varying matrices. If setTransforms() is called, an underlying Curve object is created with just one sample at time=0.0.

Definition at line 536 of file FieldMapping.h.

Member Typedef Documentation

typedef boost::intrusive_ptr<FrustumFieldMapping> FrustumFieldMapping::Ptr

Convenience typedef.

Definition at line 543 of file FieldMapping.h.

Time-varying matrix.

Definition at line 545 of file FieldMapping.h.

Time-varying float.

Definition at line 547 of file FieldMapping.h.

Convenience typedef for referring to base class.

Definition at line 717 of file FieldMapping.h.

Member Enumeration Documentation

Enumerates the Z slice distribution. .f3d files will store values as an int, so be very careful not to change the order of these.

Enumerator:
PerspectiveDistribution 
UniformDistribution 

Definition at line 557 of file FieldMapping.h.

Constructor & Destructor Documentation

FrustumFieldMapping::FrustumFieldMapping ( )

Definition at line 366 of file FieldMapping.cpp.

References reset().

Referenced by clone().

FrustumFieldMapping::FrustumFieldMapping ( const Box3i extents)

Definition at line 376 of file FieldMapping.cpp.

References reset().

: FieldMapping(extents)
{
reset();
}

Member Function Documentation

static const char* FrustumFieldMapping::classType ( )
inlinestatic

Reimplemented from FieldMapping.

Definition at line 567 of file FieldMapping.h.

Referenced by className().

{
return "FrustumFieldMapping";
}
void FrustumFieldMapping::setTransforms ( const M44d ssToWs,
const M44d csToWs 
)

Sets the screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these.

Note
This resets the transform Curve instances to contain just one sample at time=0.0
Parameters
ssToWsSee class documentation for definition.
csToWsSee class documentation for definition.

Definition at line 384 of file FieldMapping.cpp.

Referenced by reset().

{
setTransforms(0.0, ssToWs, csToWs);
}
void FrustumFieldMapping::setTransforms ( float  t,
const M44d ssToWs,
const M44d csToWs 
)

Sets time-varying screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these.

Parameters
ssToWsSee class documentation for definition.
csToWsSee class documentation for definition.

Definition at line 391 of file FieldMapping.cpp.

References Curve< T >::addSample(), clearCurves(), computeVoxelSize(), m_csToWsCurve, m_defaultState, m_farCurve, m_lpsToWsCurve, m_nearCurve, and m_ssToWsCurve.

{
m_defaultState = false;
}
// Construct local-to-world transform from ssToWs
M44d lsToSs, scale, translation;
scale.setScale(V3d(2.0, 2.0, 1.0));
translation.setTranslation(V3d(-1.0, -1.0, 0.0));
lsToSs = scale * translation;
M44d lpsToWs = lsToSs * ssToWs;
// Add samples to Curves
// Compute near and far planes ---
// Because the frustum may be skewed we can't just measure distance from
// the apex of the frustum to the world-space center point of the frustum.
// Instead, we transform into camera space and measure z depth there.
V3d lsNearP(0.5, 0.5, 0.0), lsFarP(0.5, 0.5, 1.0);
V3d wsNearP, wsFarP, csNearP, csFarP;
lpsToWs.multVecMatrix(lsNearP, wsNearP);
lpsToWs.multVecMatrix(lsFarP, wsFarP);
M44d wsToCs = csToWs.inverse();
wsToCs.multVecMatrix(wsNearP, csNearP);
wsToCs.multVecMatrix(wsFarP, csFarP);
double near = -csNearP.z;
double far = -csFarP.z;
// Catch NaN here
if (isnan(near) || isnan(far)) {
throw BadPerspectiveMatrix("FrustumFieldMapping::setTransforms "
"received bad screen-to-world matrix");
}
}
void FrustumFieldMapping::setZDistribution ( ZDistribution  dist)
inline

Sets the z slice distribution.

Definition at line 598 of file FieldMapping.h.

References m_zDistribution.

{ m_zDistribution = dist; }
ZDistribution FrustumFieldMapping::zDistribution ( ) const
inline

Returns the z slice distribution.

Definition at line 601 of file FieldMapping.h.

References m_zDistribution.

{ return m_zDistribution; }
const M44d FrustumFieldMapping::screenToWorld ( ) const
inline

Returns a reference to the screen to world space transform.

Note
This assumes the query to be at time=0.0

Definition at line 606 of file FieldMapping.h.

References Curve< T >::linear(), and m_ssToWsCurve.

{ return m_ssToWsCurve.linear(0.0); }
const M44d FrustumFieldMapping::cameraToWorld ( ) const
inline

Returns a reference to the camera to world space transform.

Note
This assumes the query to be at time=0.0

Definition at line 611 of file FieldMapping.h.

References Curve< T >::linear(), and m_csToWsCurve.

{ return m_csToWsCurve.linear(0.0); }
const MatrixCurve::SampleVec& FrustumFieldMapping::screenToWorldSamples ( ) const
inline

Returns a vector of all motion samples for screen to world transform.

Definition at line 615 of file FieldMapping.h.

References m_ssToWsCurve, and Curve< T >::samples().

{ return m_ssToWsCurve.samples(); }
const MatrixCurve::SampleVec& FrustumFieldMapping::cameraToWorldSamples ( ) const
inline

Returns a vector of all motion samples for camera to world transform.

Definition at line 619 of file FieldMapping.h.

References m_csToWsCurve, and Curve< T >::samples().

{ return m_csToWsCurve.samples(); }
const FloatCurve::SampleVec& FrustumFieldMapping::nearPlaneSamples ( ) const
inline

Returns a vector of all motion samples for near plane.

Definition at line 623 of file FieldMapping.h.

References m_nearCurve, and Curve< T >::samples().

{ return m_nearCurve.samples(); }
const FloatCurve::SampleVec& FrustumFieldMapping::farPlaneSamples ( ) const
inline

Returns a vector of all motion samples for far plane.

Definition at line 627 of file FieldMapping.h.

References m_farCurve, and Curve< T >::samples().

{ return m_farCurve.samples(); }
double FrustumFieldMapping::nearPlane ( ) const
inline

Returns the near plane.

Definition at line 631 of file FieldMapping.h.

References Curve< T >::linear(), and m_nearCurve.

{ return m_nearCurve.linear(0.0); }
double FrustumFieldMapping::farPlane ( ) const
inline

Returns the far plane.

Definition at line 635 of file FieldMapping.h.

References Curve< T >::linear(), and m_farCurve.

{ return m_farCurve.linear(0.0); }
void FrustumFieldMapping::reset ( )

Resets the transform. Makes a perspective transform at the origin, looking down the negative Z axis with a 45 degree FOV and square projection.

Definition at line 444 of file FieldMapping.cpp.

References clearCurves(), computeVoxelSize(), m_defaultState, and setTransforms().

Referenced by FrustumFieldMapping().

{
// Default camera to world ---
M44d csToWs;
csToWs.makeIdentity();
// Default screen to world ---
double near = 1;
double far = 2;
double fovRadians = 45.0 * M_PI / 180.0;
double invTan = 1.0 / std::tan(fovRadians / 2.0);
double imageAspectRatio = 1.0;
M44d perspective(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, (far) / (far - near), 1,
0, 0, (- far * near) / (far - near), 0);
M44d fov;
fov.setScale(V3d(invTan / imageAspectRatio, invTan, 1.0));
M44d flipZ;
flipZ.setScale(V3d(1.0, 1.0, -1.0));
M44d csToSs = flipZ * perspective * fov;
M44d standardSsToWs = csToSs.inverse() * csToWs;
// Set default state ---
setTransforms(standardSsToWs, csToWs);
}
void FrustumFieldMapping::worldToVoxel ( const V3d wsP,
V3d vsP 
) const
virtual

Transform from world space position into voxel space.

Implements FieldMapping.

Definition at line 493 of file FieldMapping.cpp.

{
worldToVoxel(wsP, vsP, 0.0);
}
void FrustumFieldMapping::worldToVoxel ( const V3d wsP,
V3d vsP,
float  time 
) const
virtual

Implements FieldMapping.

Definition at line 500 of file FieldMapping.cpp.

References FieldMapping::localToVoxel(), and worldToLocal().

{
V3d lsP;
worldToLocal(wsP, lsP, time);
localToVoxel(lsP, vsP);
}
void FrustumFieldMapping::voxelToWorld ( const V3d vsP,
V3d wsP 
) const
virtual

Transform from voxel space position into world space.

Implements FieldMapping.

Definition at line 509 of file FieldMapping.cpp.

Referenced by computeVoxelSize().

{
voxelToWorld(vsP, wsP, 0.0);
}
void FrustumFieldMapping::voxelToWorld ( const V3d vsP,
V3d wsP,
float  time 
) const
virtual

Implements FieldMapping.

Definition at line 516 of file FieldMapping.cpp.

References localToWorld(), and FieldMapping::voxelToLocal().

{
V3d lsP;
voxelToLocal(vsP, lsP);
localToWorld(lsP, wsP, time);
}
void FrustumFieldMapping::worldToLocal ( const V3d wsP,
V3d lsP 
) const
virtual

Transform from world space position into local space.

Implements FieldMapping.

Definition at line 525 of file FieldMapping.cpp.

Referenced by worldToVoxel().

{
worldToLocal(wsP, lsP, 0.0);
}
void FrustumFieldMapping::worldToLocal ( const V3d wsP,
V3d lsP,
float  time 
) const
virtual

Implements FieldMapping.

Definition at line 532 of file FieldMapping.cpp.

References FIELD3D_LERPFACTOR, Curve< T >::linear(), m_csToWsCurve, m_farCurve, m_lpsToWsCurve, m_nearCurve, m_zDistribution, PerspectiveDistribution, and UniformDistribution.

{
switch (m_zDistribution) {
{
// First transform to local perspective space
V3d lpsP;
m_lpsToWsCurve.linear(time).inverse().multVecMatrix(wsP, lpsP);
// Also transform to camera space
V3d csP;
m_csToWsCurve.linear(time).inverse().multVecMatrix(wsP, csP);
// Interpolate near and far plane at current time
double near = m_nearCurve.linear(time);
double far = m_farCurve.linear(time);
// Use perspective-space X/Y and normalized depth for Z.
lsP = V3d(lpsP.x, lpsP.y, FIELD3D_LERPFACTOR(-csP.z, near, far));
break;
}
default:
{
m_lpsToWsCurve.linear(time).inverse().multVecMatrix(wsP, lsP);
break;
}
}
}
void FrustumFieldMapping::localToWorld ( const V3d lsP,
V3d wsP 
) const
virtual

Transform from local space position into world space.

Implements FieldMapping.

Definition at line 561 of file FieldMapping.cpp.

Referenced by voxelToWorld().

{
localToWorld(lsP, wsP, 0.0);
}
void FrustumFieldMapping::localToWorld ( const V3d lsP,
V3d wsP,
float  time 
) const
virtual

Implements FieldMapping.

Definition at line 568 of file FieldMapping.cpp.

References FIELD3D_LERP, Curve< T >::linear(), m_csToWsCurve, m_farCurve, m_lpsToWsCurve, m_nearCurve, m_zDistribution, PerspectiveDistribution, and UniformDistribution.

{
switch (m_zDistribution) {
{
// Interpolate near and far plane at current time
double near = m_nearCurve.linear(time);
double far = m_farCurve.linear(time);
// In this case, local space is -not- equal to local perspective space
// Determine distance from camera
double wsDepthFromCam = FIELD3D_LERP(near, far, lsP.z);
// Transform point right in front of camera, X units away into world space
V3d lpsCenterP, wsCenterP, csCenterP(0.0, 0.0, -wsDepthFromCam);
m_csToWsCurve.linear(time).multVecMatrix(csCenterP, wsCenterP);
// Transform center point into screen space so we know what depth
// (in screen space) the voxel would live at -if- it were in local
// perspective space.
m_lpsToWsCurve.linear(time).inverse().multVecMatrix(wsCenterP, lpsCenterP);
// Now we create a local perspective coordinate that can be transformed
// using m_lpsToWsCurve
V3d lpsP(lsP.x, lsP.y, lpsCenterP.z);
// Now we can use m_lpsToWsCurve to transform the actual voxel location
m_lpsToWsCurve.linear(time).multVecMatrix(lpsP, wsP);
break;
}
default:
{
// In this case, local space and local perspective space are the same.
m_lpsToWsCurve.linear(time).multVecMatrix(lsP, wsP);
break;
}
}
}
void FrustumFieldMapping::extentsChanged ( )
virtual

Implement this if the subclass needs to update itself when the resolution changes.

Reimplemented from FieldMapping.

Definition at line 486 of file FieldMapping.cpp.

References computeVoxelSize().

std::string FrustumFieldMapping::className ( ) const
virtual

Returns the FieldMapping type name. Used when writing/reading from disk.

Implements FieldMapping.

Definition at line 605 of file FieldMapping.cpp.

References classType().

{
return std::string(classType());
}
bool FrustumFieldMapping::isIdentical ( FieldMapping::Ptr  other,
double  tolerance = 0.0 
) const
virtual

Whether the mapping is identical to another mapping.

Implements FieldMapping.

Definition at line 612 of file FieldMapping.cpp.

References FIELD3D_NAMESPACE_OPEN::checkMatricesIdentical(), FIELD3D_NAMESPACE_OPEN::k_frustumMappingName(), m_csToWsCurve, m_lpsToWsCurve, m_zDistribution, and Curve< T >::samples().

{
if (other->className() != k_frustumMappingName) {
return false;
} else {
FIELD_DYNAMIC_CAST<FrustumFieldMapping>(other);
if (fm) {
const SampleVec lpsToWs1 = m_lpsToWsCurve.samples();
const SampleVec lpsToWs2 = fm->m_lpsToWsCurve.samples();
const SampleVec csToWs1 = m_csToWsCurve.samples();
const SampleVec csToWs2 = fm->m_csToWsCurve.samples();
size_t numSamples = lpsToWs1.size();
// Check that slice distributions match
if (m_zDistribution != fm->m_zDistribution) {
return false;
}
// First check if time sample counts differ
// lpsToWs and csToWs are guaranteed to have same sample count.
if (lpsToWs1.size() != lpsToWs2.size()) {
return false;
}
// Then check if all time samples match, then check localToWorld
// and voxelToWorld matrices
for (size_t i = 0; i < numSamples; ++i) {
if (lpsToWs1[i].first != lpsToWs2[i].first) {
return false;
}
if (!checkMatricesIdentical(lpsToWs1[i].second, lpsToWs2[i].second,
tolerance)) {
return false;
}
if (!checkMatricesIdentical(csToWs1[i].second, csToWs2[i].second,
tolerance)) {
return false;
}
}
return true;
} else {
return false;
}
}
return false;
}
V3d FrustumFieldMapping::wsVoxelSize ( int  i,
int  j,
int  k 
) const
virtual

Returns world-space size of a voxel at the specified coordinate.

Implements FieldMapping.

Definition at line 671 of file FieldMapping.cpp.

References FieldMapping::m_origin, FieldMapping::m_res, and m_wsVoxelSize.

{
k = std::min(std::max(k, static_cast<int>(m_origin.z)),
static_cast<int>(m_origin.z + m_res.z - 1));
return m_wsVoxelSize[k - static_cast<int>(m_origin.z)];
}
FieldMapping::Ptr FrustumFieldMapping::clone ( ) const
virtual

Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it.

Implements FieldMapping.

Definition at line 740 of file FieldMapping.cpp.

References FrustumFieldMapping().

{
return Ptr(new FrustumFieldMapping(*this));
}
void FrustumFieldMapping::computeVoxelSize ( )
private

Updates the local to world transformation matrix.

Definition at line 680 of file FieldMapping.cpp.

References discToCont(), FieldMapping::m_origin, FieldMapping::m_res, m_wsVoxelSize, and voxelToWorld().

Referenced by extentsChanged(), reset(), and setTransforms().

{
// Precompute the voxel size ---
m_wsVoxelSize.resize(static_cast<int>(m_res.z),V3d(0.0));
int i = m_origin.x + m_res.x / 2;
int j = m_origin.y + m_res.y / 2;
// Do all z slices except last
int zMin = static_cast<int>(m_origin.z);
int zMax = static_cast<int>(m_origin.z + m_res.z - 1);
for (int k = zMin, idx = 0; k < zMax; ++k, ++idx) {
V3d wsP, wsPx, wsPy, wsPz;
V3d vsP = discToCont(V3i(i, j, k));
V3d vsPx = discToCont(V3i(i + 1, j, k));
V3d vsPy = discToCont(V3i(i, j + 1, k));
V3d vsPz = discToCont(V3i(i, j, k + 1));
voxelToWorld(vsP, wsP);
voxelToWorld(vsPx, wsPx);
voxelToWorld(vsPy, wsPy);
voxelToWorld(vsPz, wsPz);
m_wsVoxelSize[idx] = V3d((wsPx - wsP).length(),
(wsPy - wsP).length(),
(wsPz - wsP).length());
}
// Duplicate last value since there are no further slices to differentiate
// against
if (m_res.z >= 2) {
}
}
void FrustumFieldMapping::getLocalToVoxelMatrix ( M44d result)
private
Todo:
Unit test this

Definition at line 718 of file FieldMapping.cpp.

References FieldMapping::m_origin, and FieldMapping::m_res.

{
// Local to voxel is a scale by the resolution of the field, offset
// to the origin of the extents
M44d scaling, translation;
scaling.setScale(m_res);
translation.setTranslation(m_origin);
result = scaling * translation;
}
void FrustumFieldMapping::clearCurves ( )
private

Clears all Curve data members. Used by setTransforms() to prepare for the first sample to be added.

Definition at line 730 of file FieldMapping.cpp.

References Curve< T >::clear(), m_csToWsCurve, m_farCurve, m_lpsToWsCurve, and m_nearCurve.

Referenced by reset(), and setTransforms().

Member Data Documentation

FrustumFieldMapping::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 565 of file FieldMapping.h.

ZDistribution FrustumFieldMapping::m_zDistribution
private

Slice distribution type.

Definition at line 688 of file FieldMapping.h.

Referenced by isIdentical(), localToWorld(), setZDistribution(), worldToLocal(), and zDistribution().

MatrixCurve FrustumFieldMapping::m_ssToWsCurve
private

Time-varying local perspective to world space transform This is not used in calculations, but rather as the public interface to the class.

Definition at line 693 of file FieldMapping.h.

Referenced by screenToWorld(), screenToWorldSamples(), and setTransforms().

MatrixCurve FrustumFieldMapping::m_csToWsCurve
private

Time-varying camera to world space transform.

Definition at line 695 of file FieldMapping.h.

Referenced by cameraToWorld(), cameraToWorldSamples(), clearCurves(), isIdentical(), localToWorld(), setTransforms(), and worldToLocal().

MatrixCurve FrustumFieldMapping::m_lpsToWsCurve
private

Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.

Definition at line 698 of file FieldMapping.h.

Referenced by clearCurves(), isIdentical(), localToWorld(), setTransforms(), and worldToLocal().

FloatCurve FrustumFieldMapping::m_nearCurve
private

Time-varying near plane. Computed from m_lpsToWsCurve.

Definition at line 700 of file FieldMapping.h.

Referenced by clearCurves(), localToWorld(), nearPlane(), nearPlaneSamples(), setTransforms(), and worldToLocal().

FloatCurve FrustumFieldMapping::m_farCurve
private

Time-varying far plane. Computed from m_lpsToWsCurve.

Definition at line 702 of file FieldMapping.h.

Referenced by clearCurves(), farPlane(), farPlaneSamples(), localToWorld(), setTransforms(), and worldToLocal().

std::vector<V3d> FrustumFieldMapping::m_wsVoxelSize
private

Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.

Definition at line 706 of file FieldMapping.h.

Referenced by computeVoxelSize(), and wsVoxelSize().

bool FrustumFieldMapping::m_defaultState
private

Boolean to tell us if the mapping is in its 'default' state. This is needed because the class has a default configuration where there is a single sample in all the curves. Once a new transform is set through setTransforms(), the default samples must be cleared.

Definition at line 712 of file FieldMapping.h.

Referenced by reset(), and setTransforms().


The documentation for this class was generated from the following files: