46 #ifndef _INCLUDED_Field3D_FieldMapping_H_ 47 #define _INCLUDED_Field3D_FieldMapping_H_ 92 typedef boost::intrusive_ptr<FieldMapping>
Ptr;
101 return "FieldMapping";
141 virtual Ptr
clone()
const = 0;
165 virtual std::string
className()
const = 0;
169 double tolerance = 0.0)
const = 0;
225 typedef boost::intrusive_ptr<NullFieldMapping>
Ptr;
234 return "NullFieldMapping";
279 double tolerance = 0.0)
const;
323 typedef boost::intrusive_ptr<MatrixFieldMapping>
Ptr;
334 return "MatrixFieldMapping";
352 void setLocalToWorld(
const M44d &lsToWs);
354 void setLocalToWorld(
float t,
const M44d &lsToWs);
373 {
return m_lsToWsCurve.samples(); }
385 { m_wsToVs.multVecMatrix(wsP, vsP); }
388 if (!m_isTimeVarying) {
389 m_wsToVs.multVecMatrix(wsP, vsP);
391 M44d wsToVs = m_vsToWsCurve.linear(time).inverse();
392 wsToVs.multVecMatrix(wsP, vsP);
397 { m_vsToWs.multVecMatrix(vsP, wsP); }
400 if (!m_isTimeVarying) {
401 m_vsToWs.multVecMatrix(vsP, wsP);
403 M44d vsToWs = m_vsToWsCurve.linear(time);
404 vsToWs.multVecMatrix(vsP, wsP);
409 { m_wsToLs.multVecMatrix(wsP, lsP); }
413 if (!m_isTimeVarying) {
414 m_wsToLs.multVecMatrix(wsP, lsP);
416 M44d wsToLs = m_lsToWsCurve.linear(time).inverse();
417 wsToLs.multVecMatrix(wsP, lsP);
422 { m_lsToWs.multVecMatrix(lsP, wsP); }
425 if (!m_isTimeVarying) {
426 m_lsToWs.multVecMatrix(lsP, wsP);
428 M44d lsToWs = m_lsToWsCurve.linear(time);
429 lsToWs.multVecMatrix(lsP, wsP);
435 { m_wsToVs.multDirMatrix(wsV, vsV); }
439 { m_vsToWs.multDirMatrix(vsV, wsV); }
443 { m_wsToLs.multDirMatrix(wsV, lsV); }
447 { m_lsToWs.multDirMatrix(lsV, wsV); }
454 double tolerance = 0.0)
const;
457 {
return m_wsVoxelSize; }
466 void updateTransform();
469 void getLocalToVoxelMatrix(
M44d &result);
543 typedef boost::intrusive_ptr<FrustumFieldMapping>
Ptr;
569 return "FrustumFieldMapping";
590 void setTransforms(
const M44d &ssToWs,
const M44d &csToWs);
595 void setTransforms(
float t,
const M44d &ssToWs,
const M44d &csToWs);
599 { m_zDistribution = dist; }
602 {
return m_zDistribution; }
607 {
return m_ssToWsCurve.linear(0.0); }
612 {
return m_csToWsCurve.linear(0.0); }
616 {
return m_ssToWsCurve.samples(); }
620 {
return m_csToWsCurve.samples(); }
624 {
return m_nearCurve.samples(); }
628 {
return m_farCurve.samples(); }
632 {
return m_nearCurve.linear(0.0); }
636 {
return m_farCurve.linear(0.0); }
665 double tolerance = 0.0)
const;
676 void computeVoxelSize();
679 void getLocalToVoxelMatrix(
M44d &result);
727 #endif // Include guard const MatrixCurve::SampleVec & screenToWorldSamples() const
Returns a vector of all motion samples for screen to world transform.
Trivial class, world space is equal to local space, i.e. the field is contained in the unit cube [0...
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float) const
#define FIELD3D_NAMESPACE_HEADER_CLOSE
ZDistribution zDistribution() const
Returns the z slice distribution.
MatrixFieldMapping class_type
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.
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
FloatCurve m_farCurve
Time-varying far plane. Computed from m_lpsToWsCurve.
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
M44d m_vsToWs
Voxel space to world space.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const =0
Transform from local space position into world space.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const
Contains base class for reference counting with Mutex.
FieldMapping()
Constructor.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float) const
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
Base class for mapping between world-, local- and voxel coordinates.
void setZDistribution(ZDistribution dist)
Sets the z slice distribution.
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
double farPlane() const
Returns the far plane.
M44d m_lsToWs
Local space to world space.
double nearPlane() const
Returns the near plane.
const V3d & resolution() const
Returns the resolution.
V3d m_res
The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1.
RefBase base
Convenience typedef for referring to base class.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
const V3d & origin() const
Returns the origin.
void voxelToWorldDir(const V3d &vsV, V3d &wsV) const
void worldToVoxelDir(const V3d &wsV, V3d &vsV) const
virtual Ptr clone() const =0
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
void localToWorldDir(const V3d &lsV, V3d &wsV) const
NullFieldMapping class_type
NullFieldMapping(const Box3i &extents)
boost::intrusive_ptr< FieldMapping > Ptr
const M44d cameraToWorld() const
Returns a reference to the camera to world space transform.
static const char * classType()
const FloatCurve::SampleVec & nearPlaneSamples() const
Returns a vector of all motion samples for near plane.
const M44d & voxelToWorld() const
Returns a reference to the voxel to world space transform.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) 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.
const MatrixCurve::SampleVec & cameraToWorldSamples() const
Returns a vector of all motion samples for camera to world transform.
FieldMapping base
Convenience typedef for referring to base class.
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
boost::intrusive_ptr< NullFieldMapping > Ptr
Convenience typedef.
static const char * classType()
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float) const
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.
static const char * classType()
virtual ~FieldMapping()
Destructor.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float) const
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const
Contains the Curve class which is used to interpolate attributes in time.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
DEFINE_FIELD_RTTI_CONCRETE_CLASS
const MatrixCurve::SampleVec & localToWorldSamples() const
Returns a vector of all motion samples for local to world transform.
Curve< double > FloatCurve
Time-varying float.
const M44d screenToWorld() const
Returns a reference to the screen to world space transform.
#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.
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...
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
FrustumFieldMapping class_type
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
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
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...
FieldMapping base
Convenience typedef for referring to base class.
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
FieldMapping base
Convenience typedef for referring to base class.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
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.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const =0
Transform from voxel space position into world space.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency...
const M44d & localToWorld() const
Returns a reference to the local to world transform.
Contains Exception base class.
Represents the mapping of a field by a matrix transform.
const M44d & worldToVoxel() const
Returns a reference to the world to voxel space transform.
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
void voxelToLocal(const V3d &vsP, V3d &lsP) const
Inverse of localToVoxel.
M44d m_wsToLs
World space to local space.
boost::intrusive_ptr< FrustumFieldMapping > Ptr
Convenience typedef.
M44d m_wsToVs
World space to voxel space.
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
const FloatCurve::SampleVec & farPlaneSamples() const
Returns a vector of all motion samples for far plane.
void setExtents(const Box3i &extents)
This sets the field extents information to use for defining the local coordinate space.
static const char * classType()