46 #ifndef _INCLUDED_Field3D_FieldMapping_H_ 47 #define _INCLUDED_Field3D_FieldMapping_H_ 92 typedef boost::intrusive_ptr<FieldMapping>
Ptr;
101 return "FieldMapping";
125 void setExtents(
const Box3i &extents);
141 virtual Ptr clone()
const = 0;
147 virtual void voxelToWorld(
const V3d &vsP,
V3d &wsP)
const = 0;
148 virtual void voxelToWorld(
const V3d &vsP,
V3d &wsP,
float time)
const = 0;
150 virtual void worldToLocal(
const V3d &wsP,
V3d &lsP)
const = 0;
151 virtual void worldToLocal(
const V3d &wsP,
V3d &lsP,
float time)
const = 0;
153 virtual void localToWorld(
const V3d &lsP,
V3d &wsP)
const = 0;
154 virtual void localToWorld(
const V3d &lsP,
V3d &wsP,
float time)
const = 0;
157 virtual V3d wsVoxelSize(
int i,
int j,
int k)
const = 0;
165 virtual std::string className()
const = 0;
169 double tolerance = 0.0)
const = 0;
180 void localToVoxel(
const V3d &lsP,
V3d &vsP)
const;
182 void voxelToLocal(
const V3d &vsP,
V3d &lsP)
const;
212 const Box3d &wsBounds,
236 typedef boost::intrusive_ptr<NullFieldMapping>
Ptr;
245 return "NullFieldMapping";
290 double tolerance = 0.0)
const;
293 {
return V3d(1.0 / m_res.x, 1.0 / m_res.y, 1.0 / m_res.z); }
334 typedef boost::intrusive_ptr<MatrixFieldMapping>
Ptr;
345 return "MatrixFieldMapping";
363 void setLocalToWorld(
const M44d &lsToWs);
365 void setLocalToWorld(
float t,
const M44d &lsToWs);
384 {
return m_lsToWsCurve.samples(); }
396 { m_wsToVs.multVecMatrix(wsP, vsP); }
399 if (!m_isTimeVarying) {
400 m_wsToVs.multVecMatrix(wsP, vsP);
402 M44d wsToVs = m_vsToWsCurve.linear(time).inverse();
403 wsToVs.multVecMatrix(wsP, vsP);
408 { m_vsToWs.multVecMatrix(vsP, wsP); }
411 if (!m_isTimeVarying) {
412 m_vsToWs.multVecMatrix(vsP, wsP);
414 M44d vsToWs = m_vsToWsCurve.linear(time);
415 vsToWs.multVecMatrix(vsP, wsP);
420 { m_wsToLs.multVecMatrix(wsP, lsP); }
424 if (!m_isTimeVarying) {
425 m_wsToLs.multVecMatrix(wsP, lsP);
427 M44d wsToLs = m_lsToWsCurve.linear(time).inverse();
428 wsToLs.multVecMatrix(wsP, lsP);
433 { m_lsToWs.multVecMatrix(lsP, wsP); }
436 if (!m_isTimeVarying) {
437 m_lsToWs.multVecMatrix(lsP, wsP);
439 M44d lsToWs = m_lsToWsCurve.linear(time);
440 lsToWs.multVecMatrix(lsP, wsP);
446 { m_wsToVs.multDirMatrix(wsV, vsV); }
450 { m_vsToWs.multDirMatrix(vsV, wsV); }
454 { m_wsToLs.multDirMatrix(wsV, lsV); }
458 { m_lsToWs.multDirMatrix(lsV, wsV); }
465 double tolerance = 0.0)
const;
468 {
return m_wsVoxelSize; }
477 void updateTransform();
480 void getLocalToVoxelMatrix(
M44d &result);
554 typedef boost::intrusive_ptr<FrustumFieldMapping>
Ptr;
580 return "FrustumFieldMapping";
601 void setTransforms(
const M44d &ssToWs,
const M44d &csToWs);
606 void setTransforms(
float t,
const M44d &ssToWs,
const M44d &csToWs);
610 { m_zDistribution = dist; }
613 {
return m_zDistribution; }
618 {
return m_ssToWsCurve.linear(0.0); }
623 {
return m_csToWsCurve.linear(0.0); }
627 {
return m_ssToWsCurve.samples(); }
631 {
return m_csToWsCurve.samples(); }
635 {
return m_nearCurve.samples(); }
639 {
return m_farCurve.samples(); }
643 {
return m_nearCurve.linear(0.0); }
647 {
return m_farCurve.linear(0.0); }
676 double tolerance = 0.0)
const;
687 void computeVoxelSize();
690 void getLocalToVoxelMatrix(
M44d &result);
738 #endif // Include guard Trivial class, world space is equal to local space, i.e. the field is contained in the unit cube [0...
const MatrixCurve::SampleVec & cameraToWorldSamples() const
Returns a vector of all motion samples for camera to world transform.
#define FIELD3D_NAMESPACE_HEADER_CLOSE
const M44d & voxelToWorld() const
Returns a reference to the voxel to world space transform.
MatrixFieldMapping class_type
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
Contains typedefs for the commonly used types in Field3D.
V3d m_origin
The integer voxel-space origin of the underlying Field object. Is equal to field.extents.min.
FloatCurve m_farCurve
Time-varying far plane. Computed from m_lpsToWsCurve.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
M44d m_vsToWs
Voxel space to world space.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float) const
static const char * staticClassType()
virtual void localToWorld(const V3d &lsP, V3d &wsP) const =0
Transform from local space position into world space.
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
const M44d & localToWorld() const
Returns a reference to the local to world transform.
Contains base class for reference counting with Mutex.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
Base class for mapping between world-, local- and voxel coordinates.
void setZDistribution(ZDistribution dist)
Sets the z slice distribution.
void voxelToLocal(const V3d &vsP, V3d &lsP) const
Inverse of localToVoxel.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const
void worldToVoxel(const Field3D::FieldMapping *mapping, const Box3d &wsBounds, Box3d &vsBounds)
Computes a voxel space bounds given a bounding box in world space. This is done by transforming each ...
M44d m_lsToWs
Local space to world space.
void worldToVoxelDir(const V3d &wsV, V3d &vsV) const
ZDistribution zDistribution() const
Returns the z slice distribution.
V3d m_res
The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1.
const V3d & resolution() const
Returns the resolution.
static const char * staticClassType()
RefBase base
Convenience typedef for referring to base class.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
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 Fie...
double farPlane() const
Returns the far plane.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float) const
virtual Ptr clone() const =0
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
NullFieldMapping class_type
NullFieldMapping(const Box3i &extents)
boost::intrusive_ptr< FieldMapping > Ptr
const FloatCurve::SampleVec & farPlaneSamples() const
Returns a vector of all motion samples for far plane.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float) const
MatrixCurve m_lpsToWsCurve
Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.
virtual V3d wsVoxelSize(int i, int j, int k) const =0
Returns world-space size of a voxel at the specified coordinate.
std::vector< V3d > m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency...
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const =0
Transform from world space position into voxel space.
virtual bool isIdentical(FieldMapping::Ptr other, double tolerance=0.0) const =0
Whether the mapping is identical to another mapping.
FieldMapping base
Convenience typedef for referring to base class.
void voxelToWorldDir(const V3d &vsV, V3d &wsV) const
boost::intrusive_ptr< NullFieldMapping > Ptr
Convenience typedef.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
bool m_defaultState
Boolean to tell us if the mapping is in its 'default' state. This is needed because the class has a d...
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.
void localToWorldDir(const V3d &lsV, V3d &wsV) const
const MatrixCurve::SampleVec & localToWorldSamples() const
Returns a vector of all motion samples for local to world transform.
Contains the Curve class which is used to interpolate attributes in time.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float) 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
const M44d screenToWorld() const
Returns a reference to the screen to world space transform.
static const char * staticClassType()
Curve< double > FloatCurve
Time-varying float.
bool isIdentical(typename Field< Data_T >::Ptr a, typename Field< Data_T >::Ptr b)
Checks whether the span and data in two different fields are identical.
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
FloatCurve m_nearCurve
Time-varying near plane. Computed from m_lpsToWsCurve.
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
const M44d & worldToVoxel() const
Returns a reference to the world to voxel space transform.
FrustumFieldMapping class_type
const MatrixCurve::SampleVec & screenToWorldSamples() const
Returns a vector of all motion samples for screen to world transform.
const V3d & origin() const
Returns the origin.
Represents the mapping of a field by a perspective transform.
MatrixCurve m_csToWsCurve
Time-varying camera to world space transform.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
ZDistribution
Enumerates the Z slice distribution. .f3d files will store values as an int, so be very careful not t...
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
FieldMapping base
Convenience typedef for referring to base class.
FieldMapping base
Convenience typedef for referring to base class.
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
virtual std::string className() const =0
Returns the FieldMapping type name. Used when writing/reading from disk.
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const =0
Transform from world space position into local space.
std::vector< Sample > SampleVec
ZDistribution m_zDistribution
Slice distribution type.
static const char * staticClassType()
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const =0
Transform from voxel space position into world space.
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency...
Contains Exception base class.
Represents the mapping of a field by a matrix transform.
double nearPlane() const
Returns the near plane.
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
const FloatCurve::SampleVec & nearPlaneSamples() const
Returns a vector of all motion samples for near plane.
M44d m_wsToLs
World space to local space.
boost::intrusive_ptr< FrustumFieldMapping > Ptr
Convenience typedef.
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
M44d m_wsToVs
World space to voxel space.
const M44d cameraToWorld() const
Returns a reference to the camera to world space transform.
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.