Field3D
FieldMapping.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------//
2 
3 /*
4  * Copyright (c) 2009 Sony Pictures Imageworks Inc
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution. Neither the name of Sony Pictures Imageworks nor the
18  * names of its contributors may be used to endorse or promote
19  * products derived from this software without specific prior written
20  * permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33  * OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 //----------------------------------------------------------------------------//
37 
44 //----------------------------------------------------------------------------//
45 
46 #ifndef _INCLUDED_Field3D_FieldMapping_H_
47 #define _INCLUDED_Field3D_FieldMapping_H_
48 
49 #include <vector>
50 #include <algorithm>
51 
52 #include "Curve.h"
53 #include "Exception.h"
54 #include "RefCount.h"
55 #include "Types.h"
56 
57 //----------------------------------------------------------------------------//
58 
59 #include "ns.h"
60 
62 
63 //----------------------------------------------------------------------------//
64 // FieldMapping
65 //----------------------------------------------------------------------------//
66 
84 //----------------------------------------------------------------------------//
85 
86 class FieldMapping : public RefBase
87 {
88  public:
89 
90  // Typedefs ------------------------------------------------------------------
91 
92  typedef boost::intrusive_ptr<FieldMapping> Ptr;
93 
94  // RTTI replacement ----------------------------------------------------------
95 
98 
99  static const char* classType()
100  {
101  return "FieldMapping";
102  }
103 
104  // Ctors, dtor ---------------------------------------------------------------
105 
108 
110  FieldMapping();
112  FieldMapping(const Box3i &extents);
114  virtual ~FieldMapping();
115 
117 
118  // Main methods --------------------------------------------------------------
119 
125  void setExtents(const Box3i &extents);
126 
128  const V3d& origin() const
129  { return m_origin; }
131  const V3d& resolution() const
132  { return m_res; }
133 
134  // To be implemented by subclasses -------------------------------------------
135 
138 
141  virtual Ptr clone() const = 0;
142 
144  virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const = 0;
145  virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) 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;
155 
157  virtual V3d wsVoxelSize(int i, int j, int k) const = 0;
158 
161  virtual void extentsChanged()
162  { /* Empty */ }
163 
165  virtual std::string className() const = 0;
166 
168  virtual bool isIdentical(FieldMapping::Ptr other,
169  double tolerance = 0.0) const = 0;
170 
172 
173  // Transform calls -----------------------------------------------------------
174 
177 
180  void localToVoxel(const V3d &lsP, V3d &vsP) const;
182  void voxelToLocal(const V3d &vsP, V3d &lsP) const;
183 
185 
186 protected:
187 
194 
195 private:
196 
197  // Typedefs ------------------------------------------------------------------
198 
200  typedef RefBase base;
201 
202 };
203 
204 //----------------------------------------------------------------------------//
205 // NullFieldMapping
206 //----------------------------------------------------------------------------//
207 
216 //----------------------------------------------------------------------------//
217 
219 {
220 public:
221 
222  // Typedefs ------------------------------------------------------------------
223 
225  typedef boost::intrusive_ptr<NullFieldMapping> Ptr;
226 
227  // RTTI replacement ----------------------------------------------------------
228 
231 
232  static const char* classType()
233  {
234  return "NullFieldMapping";
235  }
236 
237  // Ctors, dtor ---------------------------------------------------------------
238 
241 
243  : FieldMapping()
244  { /* Empty */ }
245  NullFieldMapping(const Box3i &extents)
246  : FieldMapping(extents)
247  { /* Empty */ }
248 
250 
251  // From FieldMapping ---------------------------------------------------------
252 
255 
256  virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
257  { localToVoxel(wsP, vsP); }
258  virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float /*time*/) const
259  { localToVoxel(wsP, vsP); }
260 
261  virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
262  { voxelToLocal(vsP, wsP); }
263  virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float /*time*/) const
264  { voxelToLocal(vsP, wsP); }
265 
266  virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
267  { lsP = wsP; }
268  virtual void worldToLocal(const V3d &wsP, V3d &lsP, float /*time*/) const
269  { lsP = wsP; }
270 
271  virtual void localToWorld(const V3d &lsP, V3d &wsP) const
272  { wsP = lsP; }
273  virtual void localToWorld(const V3d &lsP, V3d &wsP, float /*time*/) const
274  { wsP = lsP; }
275 
276  virtual std::string className() const;
277 
278  virtual bool isIdentical(FieldMapping::Ptr other,
279  double tolerance = 0.0) const;
280 
281  virtual V3d wsVoxelSize(int /*i*/, int /*j*/, int /*k*/) const
282  { return V3d(1.0 / m_res.x, 1.0 / m_res.y, 1.0 / m_res.z); }
283 
284  virtual FieldMapping::Ptr clone() const;
285 
287 
288 private:
289 
290  // Typedefs ------------------------------------------------------------------
291 
293  typedef FieldMapping base;
294 
295 };
296 
297 //----------------------------------------------------------------------------//
298 // MatrixFieldMapping
299 //----------------------------------------------------------------------------//
300 
314 //----------------------------------------------------------------------------//
315 
317 {
318 public:
319 
320  // Typedefs ------------------------------------------------------------------
321 
323  typedef boost::intrusive_ptr<MatrixFieldMapping> Ptr;
326 
327  // RTTI replacement ----------------------------------------------------------
328 
331 
332  static const char* classType ()
333  {
334  return "MatrixFieldMapping";
335  }
336 
337  // Ctors, dtor ---------------------------------------------------------------
338 
341 
343  MatrixFieldMapping(const Box3i &extents);
344 
346 
347  // Main methods --------------------------------------------------------------
348 
352  void setLocalToWorld(const M44d &lsToWs);
354  void setLocalToWorld(float t, const M44d &lsToWs);
355 
358  const M44d& localToWorld() const
359  { return m_lsToWs; }
360 
363  const M44d& worldToVoxel() const
364  { return m_wsToVs; }
365 
368  const M44d& voxelToWorld() const
369  { return m_vsToWs; }
370 
373  { return m_lsToWsCurve.samples(); }
374 
377  void makeIdentity();
378 
379  // From FieldMapping ---------------------------------------------------------
380 
383 
384  virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
385  { m_wsToVs.multVecMatrix(wsP, vsP); }
386  virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const
387  {
388  if (!m_isTimeVarying) {
389  m_wsToVs.multVecMatrix(wsP, vsP);
390  } else {
391  M44d wsToVs = m_vsToWsCurve.linear(time).inverse();
392  wsToVs.multVecMatrix(wsP, vsP);
393  }
394  }
395 
396  virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
397  { m_vsToWs.multVecMatrix(vsP, wsP); }
398  virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const
399  {
400  if (!m_isTimeVarying) {
401  m_vsToWs.multVecMatrix(vsP, wsP);
402  } else {
403  M44d vsToWs = m_vsToWsCurve.linear(time);
404  vsToWs.multVecMatrix(vsP, wsP);
405  }
406  }
407 
408  virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
409  { m_wsToLs.multVecMatrix(wsP, lsP); }
410  virtual void worldToLocal(const V3d &wsP, V3d &lsP,
411  float time) const
412  {
413  if (!m_isTimeVarying) {
414  m_wsToLs.multVecMatrix(wsP, lsP);
415  } else {
416  M44d wsToLs = m_lsToWsCurve.linear(time).inverse();
417  wsToLs.multVecMatrix(wsP, lsP);
418  }
419  }
420 
421  virtual void localToWorld(const V3d &lsP, V3d &wsP) const
422  { m_lsToWs.multVecMatrix(lsP, wsP); }
423  virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const
424  {
425  if (!m_isTimeVarying) {
426  m_lsToWs.multVecMatrix(lsP, wsP);
427  } else {
428  M44d lsToWs = m_lsToWsCurve.linear(time);
429  lsToWs.multVecMatrix(lsP, wsP);
430  }
431  }
432 
434  void worldToVoxelDir(const V3d &wsV, V3d &vsV) const
435  { m_wsToVs.multDirMatrix(wsV, vsV); }
436 
438  void voxelToWorldDir(const V3d &vsV, V3d &wsV) const
439  { m_vsToWs.multDirMatrix(vsV, wsV); }
440 
442  void worldToLocalDir(const V3d &wsV, V3d &lsV) const
443  { m_wsToLs.multDirMatrix(wsV, lsV); }
444 
446  void localToWorldDir(const V3d &lsV, V3d &wsV) const
447  { m_lsToWs.multDirMatrix(lsV, wsV); }
448 
449  virtual void extentsChanged();
450 
451  virtual std::string className() const;
452 
453  virtual bool isIdentical(FieldMapping::Ptr other,
454  double tolerance = 0.0) const;
455 
456  virtual V3d wsVoxelSize(int /*i*/, int /*j*/, int /*k*/) const
457  { return m_wsVoxelSize; }
458 
459  virtual FieldMapping::Ptr clone() const;
460 
462 
463 private:
464 
466  void updateTransform();
467 
469  void getLocalToVoxelMatrix(M44d &result);
470 
471  // Data members -------------------------------------------------------------
472 
485 
490 
494 
498 
499  // Typedefs ------------------------------------------------------------------
500 
502  typedef FieldMapping base;
503 };
504 
505 //----------------------------------------------------------------------------//
506 // FrustumFieldMapping
507 //----------------------------------------------------------------------------//
508 
534 //----------------------------------------------------------------------------//
535 
537 {
538 public:
539 
540  // Typedefs ------------------------------------------------------------------
541 
543  typedef boost::intrusive_ptr<FrustumFieldMapping> Ptr;
548 
549  // Exceptions ----------------------------------------------------------------
550 
552 
553  // Enums ---------------------------------------------------------------------
554 
555 
556  enum ZDistribution {
560  };
561 
562  // RTTI replacement ----------------------------------------------------------
563 
566 
567  static const char* classType ()
568  {
569  return "FrustumFieldMapping";
570  }
571 
572  // Ctors, dtor ---------------------------------------------------------------
573 
576 
578  FrustumFieldMapping(const Box3i &extents);
579 
581 
582  // Main methods --------------------------------------------------------------
583 
590  void setTransforms(const M44d &ssToWs, const M44d &csToWs);
595  void setTransforms(float t, const M44d &ssToWs, const M44d &csToWs);
596 
599  { m_zDistribution = dist; }
602  { return m_zDistribution; }
603 
606  const M44d screenToWorld() const
607  { return m_ssToWsCurve.linear(0.0); }
608 
611  const M44d cameraToWorld() const
612  { return m_csToWsCurve.linear(0.0); }
613 
616  { return m_ssToWsCurve.samples(); }
617 
620  { return m_csToWsCurve.samples(); }
621 
624  { return m_nearCurve.samples(); }
625 
628  { return m_farCurve.samples(); }
629 
631  double nearPlane() const
632  { return m_nearCurve.linear(0.0); }
633 
635  double farPlane() const
636  { return m_farCurve.linear(0.0); }
637 
641  void reset();
642 
643  // From FieldMapping ---------------------------------------------------------
644 
647 
648  virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const;
649  virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const;
650 
651  virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const;
652  virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const;
653 
654  virtual void worldToLocal(const V3d &wsP, V3d &lsP) const;
655  virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const;
656 
657  virtual void localToWorld(const V3d &lsP, V3d &wsP) const;
658  virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const;
659 
660  virtual void extentsChanged();
661 
662  virtual std::string className() const;
663 
664  virtual bool isIdentical(FieldMapping::Ptr other,
665  double tolerance = 0.0) const;
666 
667  virtual V3d wsVoxelSize(int i, int j, int k) const;
668 
669  virtual FieldMapping::Ptr clone() const;
670 
672 
673 private:
674 
676  void computeVoxelSize();
677 
679  void getLocalToVoxelMatrix(M44d &result);
680 
683  void clearCurves();
684 
685  // Data members -------------------------------------------------------------
686 
689 
703 
706  std::vector<V3d> m_wsVoxelSize;
707 
713 
714  // Typedefs ------------------------------------------------------------------
715 
718 
719 };
720 
721 //----------------------------------------------------------------------------//
722 
724 
725 //----------------------------------------------------------------------------//
726 
727 #endif // Include guard
Trivial class, world space is equal to local space, i.e. the field is contained in the unit cube [0...
Definition: FieldMapping.h:218
const MatrixCurve::SampleVec & cameraToWorldSamples() const
Returns a vector of all motion samples for camera to world transform.
Definition: FieldMapping.h:619
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
const M44d & voxelToWorld() const
Returns a reference to the voxel to world space transform.
Definition: FieldMapping.h:368
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
MatrixFieldMapping class_type
Definition: FieldMapping.h:329
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
Definition: FieldMapping.h:281
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
Definition: FieldMapping.h:408
Imath::M44d M44d
Definition: SpiMathLib.h:82
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.
Definition: FieldMapping.h:190
virtual FieldMapping::Ptr clone() const
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
FloatCurve m_farCurve
Time-varying far plane. Computed from m_lpsToWsCurve.
Definition: FieldMapping.h:702
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
Definition: FieldMapping.h:256
void clearCurves()
Clears all Curve data members. Used by setTransforms() to prepare for the first sample to be added...
M44d m_vsToWs
Voxel space to world space.
Definition: FieldMapping.h:481
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float) const
Definition: FieldMapping.h:258
virtual bool isIdentical(FieldMapping::Ptr other, double tolerance=0.0) const
Whether the mapping is identical to another mapping.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const =0
Transform from local space position into world space.
FieldMapping class_type
Definition: FieldMapping.h:96
MatrixCurve m_vsToWsCurve
Time-varying voxel to world space transform.
Definition: FieldMapping.h:489
const M44d & localToWorld() const
Returns a reference to the local to world transform.
Definition: FieldMapping.h:358
Contains base class for reference counting with Mutex.
FieldMapping()
Constructor.
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
Definition: FieldMapping.h:396
void setLocalToWorld(const M44d &lsToWs)
Sets the local to world transform. All other matrices will be updated based on this.
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
Definition: FieldMapping.h:421
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
Definition: FieldMapping.h:161
virtual V3d wsVoxelSize(int, int, int) const
Returns world-space size of a voxel at the specified coordinate.
Definition: FieldMapping.h:456
void getLocalToVoxelMatrix(M44d &result)
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
Base class for mapping between world-, local- and voxel coordinates.
Definition: FieldMapping.h:86
void setZDistribution(ZDistribution dist)
Sets the z slice distribution.
Definition: FieldMapping.h:598
void voxelToLocal(const V3d &vsP, V3d &lsP) const
Inverse of localToVoxel.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP, float time) const
Definition: FieldMapping.h:386
MatrixCurve m_lsToWsCurve
Time-varying local to world space transform.
Definition: FieldMapping.h:487
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float time) const
Definition: FieldMapping.h:398
M44d m_lsToWs
Local space to world space.
Definition: FieldMapping.h:475
void worldToVoxelDir(const V3d &wsV, V3d &vsV) const
Definition: FieldMapping.h:434
ZDistribution zDistribution() const
Returns the z slice distribution.
Definition: FieldMapping.h:601
V3d m_res
The integer voxel-space resolution of the underlying Field object. Is equal to field.extents.max - field.extents.min + 1.
Definition: FieldMapping.h:193
const V3d & resolution() const
Returns the resolution.
Definition: FieldMapping.h:131
RefBase base
Convenience typedef for referring to base class.
Definition: FieldMapping.h:200
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.
Definition: FieldMapping.h:635
virtual void voxelToWorld(const V3d &vsP, V3d &wsP, float) const
Definition: FieldMapping.h:263
virtual Ptr clone() const =0
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
virtual std::string className() const
Returns the FieldMapping type name. Used when writing/reading from disk.
void computeVoxelSize()
Updates the local to world transformation matrix.
NullFieldMapping class_type
Definition: FieldMapping.h:229
NullFieldMapping(const Box3i &extents)
Definition: FieldMapping.h:245
boost::intrusive_ptr< FieldMapping > Ptr
Definition: FieldMapping.h:92
static const char * classType()
Definition: FieldMapping.h:332
const FloatCurve::SampleVec & farPlaneSamples() const
Returns a vector of all motion samples for far plane.
Definition: FieldMapping.h:627
virtual void localToWorld(const V3d &lsP, V3d &wsP, float) const
Definition: FieldMapping.h:273
MatrixCurve m_lpsToWsCurve
Time-varying local perspective to world space transform. Computed from m_ssToWsCurve.
Definition: FieldMapping.h:698
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...
Definition: FieldMapping.h:706
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.
Definition: FieldMapping.h:293
virtual bool isIdentical(FieldMapping::Ptr other, double tolerance=0.0) const
Whether the mapping is identical to another mapping.
void reset()
Resets the transform. Makes a perspective transform at the origin, looking down the negative Z axis w...
void voxelToWorldDir(const V3d &vsV, V3d &wsV) const
Definition: FieldMapping.h:438
boost::intrusive_ptr< NullFieldMapping > Ptr
Convenience typedef.
Definition: FieldMapping.h:225
static const char * classType()
Definition: FieldMapping.h:567
virtual bool isIdentical(FieldMapping::Ptr other, double tolerance=0.0) const
Whether the mapping is identical to another mapping.
virtual void worldToVoxel(const V3d &wsP, V3d &vsP) const
Transform from world space position into voxel space.
Definition: FieldMapping.h:384
bool m_defaultState
Boolean to tell us if the mapping is in its &#39;default&#39; state. This is needed because the class has a d...
Definition: FieldMapping.h:712
Imath::V3d V3d
Definition: SpiMathLib.h:74
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.
Definition: FieldMapping.h:693
static const char * classType()
Definition: FieldMapping.h:99
virtual ~FieldMapping()
Destructor.
void localToWorldDir(const V3d &lsV, V3d &wsV) const
Definition: FieldMapping.h:446
const SampleVec & samples() const
Returns a const reference to the samples in the curve.
Definition: Curve.h:103
const MatrixCurve::SampleVec & localToWorldSamples() const
Returns a vector of all motion samples for local to world transform.
Definition: FieldMapping.h:372
Contains the Curve class which is used to interpolate attributes in time.
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
virtual FieldMapping::Ptr clone() const
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float time) const
Definition: FieldMapping.h:410
virtual void worldToLocal(const V3d &wsP, V3d &lsP, float) const
Definition: FieldMapping.h:268
virtual void localToWorld(const V3d &lsP, V3d &wsP) const
Transform from local space position into world space.
Definition: FieldMapping.h:271
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
virtual void localToWorld(const V3d &lsP, V3d &wsP, float time) const
Definition: FieldMapping.h:423
virtual void extentsChanged()
Implement this if the subclass needs to update itself when the resolution changes.
const M44d screenToWorld() const
Returns a reference to the screen to world space transform.
Definition: FieldMapping.h:606
Curve< double > FloatCurve
Time-varying float.
Definition: FieldMapping.h:547
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
Definition: Exception.h:107
FloatCurve m_nearCurve
Time-varying near plane. Computed from m_lpsToWsCurve.
Definition: FieldMapping.h:700
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
Definition: FieldMapping.h:97
const M44d & worldToVoxel() const
Returns a reference to the world to voxel space transform.
Definition: FieldMapping.h:363
FrustumFieldMapping class_type
Definition: FieldMapping.h:564
T linear(const float t) const
Linearly interpolates a value from the curve.
Definition: Curve.h:199
void getLocalToVoxelMatrix(M44d &result)
virtual V3d wsVoxelSize(int i, int j, int k) const
Returns world-space size of a voxel at the specified coordinate.
const MatrixCurve::SampleVec & screenToWorldSamples() const
Returns a vector of all motion samples for screen to world transform.
Definition: FieldMapping.h:615
const V3d & origin() const
Returns the origin.
Definition: FieldMapping.h:128
Represents the mapping of a field by a perspective transform.
Definition: FieldMapping.h:536
void setTransforms(const M44d &ssToWs, const M44d &csToWs)
Sets the screenToWorld and cameraToWorld transforms. All other internal matrices will be updated base...
MatrixCurve m_csToWsCurve
Time-varying camera to world space transform.
Definition: FieldMapping.h:695
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
Definition: FieldMapping.h:325
bool m_isTimeVarying
Stores whether the curve has more than one time sample.
Definition: FieldMapping.h:493
void makeIdentity()
Sets the transform to identity. This makes it functionally equivalent to a NullFieldMapping.
ZDistribution
Enumerates the Z slice distribution. .f3d files will store values as an int, so be very careful not t...
Definition: FieldMapping.h:557
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const
Transform from voxel space position into world space.
Definition: FieldMapping.h:261
FieldMapping base
Convenience typedef for referring to base class.
Definition: FieldMapping.h:717
FieldMapping base
Convenience typedef for referring to base class.
Definition: FieldMapping.h:502
void updateTransform()
Updates the local to world transformation matrix.
void worldToLocalDir(const V3d &wsV, V3d &lsV) const
Definition: FieldMapping.h:442
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
Definition: Curve.h:85
ZDistribution m_zDistribution
Slice distribution type.
Definition: FieldMapping.h:688
virtual void voxelToWorld(const V3d &vsP, V3d &wsP) const =0
Transform from voxel space position into world space.
virtual std::string className() const
Returns the FieldMapping type name. Used when writing/reading from disk.
V3d m_wsVoxelSize
Precomputed world-space voxel size. Calculations may assume orthogonal transformation for efficiency...
Definition: FieldMapping.h:497
Contains Exception base class.
Represents the mapping of a field by a matrix transform.
Definition: FieldMapping.h:316
virtual FieldMapping::Ptr clone() const
Returns a pointer to a copy of the mapping, pure virtual so ensure derived classes properly implement...
double nearPlane() const
Returns the near plane.
Definition: FieldMapping.h:631
boost::intrusive_ptr< MatrixFieldMapping > Ptr
Convenience typedef.
Definition: FieldMapping.h:323
const FloatCurve::SampleVec & nearPlaneSamples() const
Returns a vector of all motion samples for near plane.
Definition: FieldMapping.h:623
M44d m_wsToLs
World space to local space.
Definition: FieldMapping.h:478
boost::intrusive_ptr< FrustumFieldMapping > Ptr
Convenience typedef.
Definition: FieldMapping.h:543
virtual void worldToLocal(const V3d &wsP, V3d &lsP) const
Transform from world space position into local space.
Definition: FieldMapping.h:266
M44d m_wsToVs
World space to voxel space.
Definition: FieldMapping.h:484
const M44d cameraToWorld() const
Returns a reference to the camera to world space transform.
Definition: FieldMapping.h:611
Curve< Imath::M44d > MatrixCurve
Time-varying matrix.
Definition: FieldMapping.h:545
virtual std::string className() const
Returns the FieldMapping type name. Used when writing/reading from disk.
void setExtents(const Box3i &extents)
This sets the field extents information to use for defining the local coordinate space.
#define FIELD3D_NAMESPACE_OPEN
Definition: ns.h:56
static const char * classType()
Definition: FieldMapping.h:232