Field3D
|
Represents the mapping of a field by a perspective transform. More...
#include <FieldMapping.h>
Public Types | |
typedef FrustumFieldMapping | class_type |
typedef Curve< double > | FloatCurve |
Time-varying float. More... | |
typedef Curve< Imath::M44d > | MatrixCurve |
Time-varying matrix. More... | |
typedef boost::intrusive_ptr< FrustumFieldMapping > | Ptr |
Convenience typedef. More... | |
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... | |
![]() | |
typedef FieldMapping | class_type |
typedef boost::intrusive_ptr< FieldMapping > | Ptr |
![]() | |
typedef boost::intrusive_ptr< RefBase > | Ptr |
typedef boost::weak_ptr< RefBase > | WeakPtr |
Public Member Functions | |
const M44d | cameraToWorld () const |
Returns a reference to the camera to world space transform. More... | |
const MatrixCurve::SampleVec & | cameraToWorldSamples () const |
Returns a vector of all motion samples for camera to world transform. More... | |
double | farPlane () const |
Returns the far plane. More... | |
const FloatCurve::SampleVec & | farPlaneSamples () const |
Returns a vector of all motion samples for far plane. More... | |
double | nearPlane () const |
Returns the near plane. More... | |
const FloatCurve::SampleVec & | nearPlaneSamples () const |
Returns a vector of all motion samples for near plane. More... | |
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. More... | |
const M44d | screenToWorld () const |
Returns a reference to the screen to world space transform. More... | |
const MatrixCurve::SampleVec & | screenToWorldSamples () const |
Returns a vector of all motion samples for screen to world transform. More... | |
void | setTransforms (const M44d &ssToWs, const M44d &csToWs) |
Sets the screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these. More... | |
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. More... | |
void | setZDistribution (ZDistribution dist) |
Sets the z slice distribution. More... | |
ZDistribution | zDistribution () const |
Returns the z slice distribution. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
virtual std::string | className () const |
Returns the FieldMapping type name. Used when writing/reading from disk. More... | |
virtual bool | isIdentical (FieldMapping::Ptr other, double tolerance=0.0) const |
Whether the mapping is identical to another mapping. More... | |
virtual V3d | wsVoxelSize (int i, int j, int k) const |
Returns world-space size of a voxel at the specified coordinate. More... | |
virtual FieldMapping::Ptr | clone () const |
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it. More... | |
![]() | |
const V3d & | origin () const |
Returns the origin. More... | |
const V3d & | resolution () const |
Returns the resolution. More... | |
void | setExtents (const Box3i &extents) |
This sets the field extents information to use for defining the local coordinate space. More... | |
FieldMapping () | |
Constructor. More... | |
FieldMapping (const Box3i &extents) | |
Construct with known extents. More... | |
virtual | ~FieldMapping () |
Destructor. More... | |
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. More... | |
void | voxelToLocal (const V3d &vsP, V3d &lsP) const |
Inverse of localToVoxel. More... | |
![]() | |
void | ref () const |
Used by boost::intrusive_pointer. More... | |
size_t | refcnt () |
Used by boost::intrusive_pointer. More... | |
void | unref () const |
Used by boost::intrusive_pointer. More... | |
WeakPtr | weakPtr () const |
RefBase () | |
RefBase (const RefBase &) | |
Copy constructor. More... | |
RefBase & | operator= (const RefBase &) |
Assignment operator. More... | |
virtual | ~RefBase () |
Destructor. More... | |
virtual bool | checkRTTI (const char *typenameStr)=0 |
This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();. More... | |
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. More... | |
Static Public Member Functions | |
static const char * | staticClassType () |
![]() | |
static const char * | staticClassType () |
![]() | |
static const char * | staticClassType () |
Public Attributes | |
DEFINE_FIELD_RTTI_CONCRETE_CLASS | |
![]() | |
DEFINE_FIELD_RTTI_ABSTRACT_CLASS | |
Private Types | |
typedef FieldMapping | base |
Convenience typedef for referring to base class. More... | |
Private Member Functions | |
void | clearCurves () |
Clears all Curve data members. Used by setTransforms() to prepare for the first sample to be added. More... | |
void | computeVoxelSize () |
Updates the local to world transformation matrix. More... | |
void | getLocalToVoxelMatrix (M44d &result) |
Private Attributes | |
MatrixCurve | m_csToWsCurve |
Time-varying camera to world space transform. More... | |
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. More... | |
FloatCurve | m_farCurve |
Time-varying far plane. Computed from m_lpsToWsCurve. More... | |
MatrixCurve | m_lpsToWsCurve |
Time-varying local perspective to world space transform. Computed from m_ssToWsCurve. More... | |
FloatCurve | m_nearCurve |
Time-varying near plane. Computed from m_lpsToWsCurve. More... | |
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. More... | |
std::vector< V3d > | m_wsVoxelSize |
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency. More... | |
ZDistribution | m_zDistribution |
Slice distribution type. More... | |
Additional Inherited Members | |
![]() | |
V3d | m_origin |
The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min. More... | |
V3d | m_res |
The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1. More... | |
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.
Definition at line 564 of file FieldMapping.h.
typedef boost::intrusive_ptr<FrustumFieldMapping> FrustumFieldMapping::Ptr |
Convenience typedef.
Definition at line 571 of file FieldMapping.h.
Time-varying matrix.
Definition at line 573 of file FieldMapping.h.
typedef Curve<double> FrustumFieldMapping::FloatCurve |
Time-varying float.
Definition at line 575 of file FieldMapping.h.
Definition at line 592 of file FieldMapping.h.
|
private |
Convenience typedef for referring to base class.
Definition at line 745 of file FieldMapping.h.
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 585 of file FieldMapping.h.
FrustumFieldMapping::FrustumFieldMapping | ( | ) |
FrustumFieldMapping::FrustumFieldMapping | ( | const Box3i & | extents | ) |
Definition at line 433 of file FieldMapping.cpp.
References reset().
|
inlinestatic |
Definition at line 595 of file FieldMapping.h.
Referenced by className().
Sets the screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these.
ssToWs | See class documentation for definition. |
csToWs | See class documentation for definition. |
Definition at line 441 of file FieldMapping.cpp.
Referenced by reset().
Sets time-varying screenToWorld and cameraToWorld transforms. All other internal matrices will be updated based on these.
ssToWs | See class documentation for definition. |
csToWs | See class documentation for definition. |
Definition at line 448 of file FieldMapping.cpp.
References Curve< T >::addSample(), clearCurves(), computeVoxelSize(), m_csToWsCurve, m_defaultState, m_farCurve, m_lpsToWsCurve, m_nearCurve, and m_ssToWsCurve.
|
inline |
|
inline |
|
inline |
Returns a reference to the screen to world space transform.
Definition at line 634 of file FieldMapping.h.
|
inline |
Returns a reference to the camera to world space transform.
Definition at line 639 of file FieldMapping.h.
|
inline |
Returns a vector of all motion samples for screen to world transform.
Definition at line 643 of file FieldMapping.h.
|
inline |
Returns a vector of all motion samples for camera to world transform.
Definition at line 647 of file FieldMapping.h.
|
inline |
Returns a vector of all motion samples for near plane.
Definition at line 651 of file FieldMapping.h.
|
inline |
Returns a vector of all motion samples for far plane.
Definition at line 655 of file FieldMapping.h.
|
inline |
|
inline |
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 501 of file FieldMapping.cpp.
References clearCurves(), computeVoxelSize(), m_defaultState, and setTransforms().
Referenced by FrustumFieldMapping().
Transform from world space position into voxel space.
Implements FieldMapping.
Definition at line 550 of file FieldMapping.cpp.
Implements FieldMapping.
Definition at line 557 of file FieldMapping.cpp.
References FieldMapping::localToVoxel(), and worldToLocal().
Transform from voxel space position into world space.
Implements FieldMapping.
Definition at line 566 of file FieldMapping.cpp.
Referenced by computeVoxelSize().
Implements FieldMapping.
Definition at line 573 of file FieldMapping.cpp.
References localToWorld(), and FieldMapping::voxelToLocal().
Transform from world space position into local space.
Implements FieldMapping.
Definition at line 582 of file FieldMapping.cpp.
Referenced by worldToVoxel().
Implements FieldMapping.
Definition at line 589 of file FieldMapping.cpp.
References FIELD3D_LERPFACTOR, Curve< T >::linear(), m_csToWsCurve, m_farCurve, m_lpsToWsCurve, m_nearCurve, m_zDistribution, PerspectiveDistribution, and UniformDistribution.
Transform from local space position into world space.
Implements FieldMapping.
Definition at line 618 of file FieldMapping.cpp.
Referenced by FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectFrustumMapping(), and voxelToWorld().
Implements FieldMapping.
Definition at line 625 of file FieldMapping.cpp.
References FIELD3D_LERP, Curve< T >::linear(), m_csToWsCurve, m_farCurve, m_lpsToWsCurve, m_nearCurve, m_zDistribution, PerspectiveDistribution, and UniformDistribution.
|
virtual |
Implement this if the subclass needs to update itself when the resolution changes.
Reimplemented from FieldMapping.
Definition at line 543 of file FieldMapping.cpp.
References computeVoxelSize().
|
virtual |
Returns the FieldMapping type name. Used when writing/reading from disk.
Implements FieldMapping.
Definition at line 662 of file FieldMapping.cpp.
References staticClassType().
|
virtual |
Whether the mapping is identical to another mapping.
Implements FieldMapping.
Definition at line 669 of file FieldMapping.cpp.
References FIELD3D_NAMESPACE_OPEN::checkMatricesIdentical(), FIELD3D_NAMESPACE_OPEN::k_frustumMappingName(), m_csToWsCurve, m_lpsToWsCurve, m_zDistribution, and Curve< T >::samples().
|
virtual |
Returns world-space size of a voxel at the specified coordinate.
Implements FieldMapping.
Definition at line 728 of file FieldMapping.cpp.
References FieldMapping::m_origin, FieldMapping::m_res, m_wsVoxelSize, detail::max(), and detail::min().
Referenced by FieldGroup< BaseTypeList_T, Dims_T >::GetIntersections::intersectFrustumMapping().
|
virtual |
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement it.
Implements FieldMapping.
Definition at line 797 of file FieldMapping.cpp.
References FrustumFieldMapping().
|
private |
Updates the local to world transformation matrix.
Definition at line 737 of file FieldMapping.cpp.
References discToCont(), FieldMapping::m_origin, FieldMapping::m_res, m_wsVoxelSize, and voxelToWorld().
Referenced by extentsChanged(), reset(), and setTransforms().
|
private |
Definition at line 775 of file FieldMapping.cpp.
References FieldMapping::m_origin, and FieldMapping::m_res.
|
private |
Clears all Curve data members. Used by setTransforms() to prepare for the first sample to be added.
Definition at line 787 of file FieldMapping.cpp.
References Curve< T >::clear(), m_csToWsCurve, m_farCurve, m_lpsToWsCurve, and m_nearCurve.
Referenced by reset(), and setTransforms().
FrustumFieldMapping::DEFINE_FIELD_RTTI_CONCRETE_CLASS |
Definition at line 593 of file FieldMapping.h.
|
private |
Slice distribution type.
Definition at line 716 of file FieldMapping.h.
Referenced by isIdentical(), localToWorld(), and worldToLocal().
|
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 721 of file FieldMapping.h.
Referenced by setTransforms().
|
private |
Time-varying camera to world space transform.
Definition at line 723 of file FieldMapping.h.
Referenced by clearCurves(), isIdentical(), localToWorld(), setTransforms(), and worldToLocal().
|
private |
Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.
Definition at line 726 of file FieldMapping.h.
Referenced by clearCurves(), isIdentical(), localToWorld(), setTransforms(), and worldToLocal().
|
private |
Time-varying near plane. Computed from m_lpsToWsCurve.
Definition at line 728 of file FieldMapping.h.
Referenced by clearCurves(), localToWorld(), setTransforms(), and worldToLocal().
|
private |
Time-varying far plane. Computed from m_lpsToWsCurve.
Definition at line 730 of file FieldMapping.h.
Referenced by clearCurves(), localToWorld(), setTransforms(), and worldToLocal().
|
private |
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency.
Definition at line 734 of file FieldMapping.h.
Referenced by computeVoxelSize(), and wsVoxelSize().
|
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 740 of file FieldMapping.h.
Referenced by reset(), and setTransforms().