ALBA
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
albaCameraTransform Class Reference

#include <albaCameraTransform.h>

Inheritance diagram for albaCameraTransform:
Inheritance graph
[legend]
Collaboration diagram for albaCameraTransform:
Collaboration graph
[legend]

Public Types

enum  AutoPositionModalities { ATTACH_TO_FOCAL_POINT , ATTACH_TO_CAMERA , ATTACH_TO_CLIPPING_PLANE }
 
enum  AutoFittingModalities {
  MAX_SCALE , MIN_SCALE , FIT_X , FIT_Y ,
  ANISOTROPIC , NUM_OF_MAPPINGS
}
 
enum  AutoScalingModalities { AUTO_FITTING , PRESERVE_SIZE }
 

Public Member Functions

 albaCameraTransform ()
 
virtual ~albaCameraTransform ()
 
 albaTypeMacro (albaCameraTransform, albaTransformBase)
 
void SetRenderer (vtkRenderer *ren)
 
vtkRenderer * GetRenderer ()
 
void SetBounds (albaOBB *bounds)
 
albaOBBGetBounds ()
 
void SetFollowPosition (int flag)
 
int GetFollowPosition ()
 
void FollowPositionOn ()
 
void FollowPositionOff ()
 
void SetFollowOrientation (int flag)
 
int GetFollowOrientation ()
 
void FollowOrientationOn ()
 
void FollowOrientationOff ()
 
void SetFollowScale (int flag)
 
int GetFollowScale ()
 
void FollowScaleOn ()
 
void FollowScaleOff ()
 
void SetPositionMode (int type)
 
int GetPositionMode ()
 
void SetPositionModeToAttachToFocalPoint ()
 
void SetPositionModeToAttachToCamera ()
 
void SetPositionModeToAttachToClippingPlane ()
 
void SetScalingMode (int mode)
 
int GetScalingMode ()
 
void SetScalingModeToAutoFitting ()
 
void SetScalingModeToPreserveSize ()
 
void SetFittingMode (int mode)
 
int GetFittingMode ()
 
virtual unsigned long GetMTime ()
 
virtual int DeepCopy (albaCameraTransform *trans)
 
void UpdatePoseMatrix (albaMatrix *matrix, albaMatrix *old_view_matrix, albaMatrix *new_view_matrix)
 
void AutoOrientation ()
 
void AutoPosition ()
 
void AutoFitting ()
 
void AutoFitting2 ()
 
void RecomputeAll ()
 
- Public Member Functions inherited from albaTransformBase
 albaTransformBase ()
 
 ~albaTransformBase ()
 
 albaTransformBase (const albaTransformBase &)
 
 albaAbstractTypeMacro (albaTransformBase, albaReferenceCounted)
 
virtual void Print (std::ostream &os, const int indent=0) const
 
virtual const albaMatrixGetMatrix ()
 
albaMatrixGetMatrixPointer ()
 
void TransformPoint (const float in[3], float out[3])
 
void TransformPoint (const double in[3], double out[3])
 
void TransformNormalAtPoint (const float point[3], const float in[3], float out[3])
 
void TransformNormalAtPoint (const double point[3], const double in[3], double out[3])
 
void TransformVectorAtPoint (const float point[3], const float in[3], float out[3])
 
void TransformVectorAtPoint (const double point[3], const double in[3], double out[3])
 
virtual void Update ()
 
void Modified ()
 
virtual void InternalTransformPoint (const double in[3], double out[3])
 
virtual void InternalTransformPoint (const float in[3], float out[3])
 
virtual unsigned long GetMTime ()
 
virtual unsigned long GetUpdateTime ()
 
void SetTimeStamp (albaTimeStamp t)
 
albaTimeStamp GetTimeStamp ()
 
- Public Member Functions inherited from albaReferenceCounted
 albaReferenceCounted ()
 
virtual ~albaReferenceCounted ()
 
 albaAbstractTypeMacro (albaReferenceCounted, albaObject)
 
virtual void Delete ()
 
void Register (void *obj)
 
virtual void UnRegister (void *obj)
 
int GetReferenceCount ()
 
void SetReferenceCount (int)
 
- Public Member Functions inherited from albaObject
 albaObject ()
 
virtual ~albaObject ()
 
virtual void Delete ()
 
virtual const char * GetTypeName () const
 
virtual bool IsA (const char *type_name) const
 
virtual bool IsA (const albaTypeID &type_id) const
 
virtual albaObjectNewObjectInstance () const =0
 
virtual const albaTypeIDGetTypeId () const
 
virtual void Print (std::ostream &os, const int indent=0) const
 
 albaObject (const albaObject &c)
 
- Public Member Functions inherited from albaEventBroadcaster
 albaEventBroadcaster (void *owner=NULL)
 
virtual ~albaEventBroadcaster ()
 
 albaEventBroadcaster (const albaEventBroadcaster &c)
 
void AddObserver (albaObserver *obj)
 
void AddObserver (albaObserver &obj)
 
albaObserverCallbackAddObserverCallback (void(*f)(void *sender, albaID eid, void *clientdata, void *calldata))
 
bool RemoveObserver (albaObserver *obj)
 
void RemoveAllObservers ()
 
bool IsObserver (albaObserver *obj)
 
bool HasObservers ()
 
void GetObservers (std::vector< albaObserver * > &olist)
 
void InvokeEvent (albaEventBase &e)
 
void InvokeEvent (albaEventBase *e)
 
void InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
 
void SetChannel (albaID ch)
 
albaID GetChannel ()
 
virtual void SetListener (albaObserver *o)
 
- Public Member Functions inherited from albaEventSender
 albaEventSender ()
 
virtual void SetListener (albaObserver *o)
 
virtual albaObserverGetListener ()
 
virtual bool HasListener ()
 
virtual void InvokeEvent (albaEventBase &e)
 
virtual void InvokeEvent (albaEventBase *e)
 
virtual void InvokeEvent (void *sender, albaID id=ID_NO_EVENT, void *data=NULL)
 

Static Public Member Functions

static void AutoOrientation (albaMatrix *matrix, vtkRenderer *ren)
 
static void AutoPosition (albaMatrix *matrix, vtkRenderer *ren, int mode=ATTACH_TO_FOCAL_POINT)
 
static void AutoFitting (albaMatrix *matrix, albaOBB *tracked_bounds, vtkRenderer *ren, int mode=MIN_SCALE)
 
static void AutoFitting2 (albaMatrix *matrix, albaOBB *tracked_bounds, vtkRenderer *ren, int mode=ANISOTROPIC)
 
static void ComputeScaling (albaOBB *inBox, albaOBB *outBox, double *scale, int mode=MIN_SCALE)
 
- Static Public Member Functions inherited from albaObject
static const char * GetStaticTypeName ()
 
static bool IsStaticType (const char *type_name)
 
static bool IsStaticType (const albaTypeID &type_id)
 
static const albaTypeIDGetStaticTypeId ()
 
static albaObjectSafeDownCast (albaObject *o)
 

Protected Member Functions

virtual void InternalUpdate ()
 
virtual void InternalUpdate ()=0
 

Static Protected Member Functions

static void InternalProcessEvents (vtkObject *sender, unsigned long channel, void *clientdata, void *calldata)
 

Protected Attributes

vtkRenderer * m_Renderer
 
vtkCamera * m_Camera
 
int m_FollowPosition
 
int m_FollowOrientation
 
int m_FollowScale
 
int m_PositionMode
 
int m_ScalingMode
 
int m_FittingMode
 
albaOBBm_Bounds
 
float m_OldViewAngle
 
double m_OldDistance
 
albaMatrixm_OldViewMatrix
 
vtkCallbackCommand * m_EventRouter
 
- Protected Attributes inherited from albaTransformBase
albaAutoPointer< albaMatrixm_Matrix
 
albaMTime m_MTime
 
albaMTime m_UpdateTime
 
albaMutexLock m_UpdateMutex
 
albaTimeStamp m_TimeStamp
 
- Protected Attributes inherited from albaReferenceCounted
int m_ReferenceCount
 
- Protected Attributes inherited from albaObject
bool m_HeapFlag
 
- Protected Attributes inherited from albaEventBroadcaster
albaObserversList m_Observers
 
albaID m_Channel
 
- Protected Attributes inherited from albaEventSender
albaObserverm_Listener
 

Additional Inherited Members

- Protected Types inherited from albaEventBroadcaster
typedef std::list< albaObserver * > albaObserversList
 

Detailed Description

Implement transform between view coordinates to world coordinates.

albaCameraTransform is a class implementing transform between view coordinate system to world coordinate system. The renderer storing the coordinate system must be provided as input. This transforms maps points from the view coordinate system to a specified coordinate system. By default (TargetFrame=I) to the World coordinate system. In general the view coordinate system has the following spawning: X [-1,1] , where -1 is left frustum plane Y [-1,1] , where -1 is the bottom frustum plane Z [-1,1] , for Z there can be different mapping strategies:

  1. Z = 0 corresponds to the Camera position. Z = 1, depends on Y scale
  2. Z = 0 corresponds to the Focal point, Z = -1 and Z = 1 depends on Y Scale
  3. Z = -1 corresponds to the Near plane, Z = 1 to the Far plane

You can enable single features:

With orientation enabled the transform will always try to take the input matrix and rotate it such that it points to the camera (supposed 0,0,0 means orientated toward the camera). The original orientation is cumulated. With position enabled the transform will try to translate the matrix to be in the same position when the camera moves. 0,0,0 means in the focus point.

See also
albaTransform
Todo:
:
  • implement issuing of MATRIX_UPDATE (to be done in albaTranformBase)

Definition at line 64 of file albaCameraTransform.h.

Member Enumeration Documentation

◆ AutoPositionModalities

Enumerator
ATTACH_TO_FOCAL_POINT 

Follow the focal point.

ATTACH_TO_CAMERA 

Follow the camera position.

ATTACH_TO_CLIPPING_PLANE 

Follow the neat clipping plane.

Definition at line 72 of file albaCameraTransform.h.

◆ AutoFittingModalities

Enumerator
MAX_SCALE 

Select the maximum scale among X/Y (i.e. fit the minimum size)

MIN_SCALE 

Select the minimum scale X/Y (i.e. fit the maximum size)

FIT_X 

Always fit the X axis.

FIT_Y 

Always fit the Y axis.

ANISOTROPIC 

set XYZ scales to fit exactly

NUM_OF_MAPPINGS 

Definition at line 79 of file albaCameraTransform.h.

◆ AutoScalingModalities

Enumerator
AUTO_FITTING 

scale the bounds to fit the camera frustum

PRESERVE_SIZE 

scale the bounds to appear at constant size (use with ATTACH_TO_CAMERA)

Definition at line 89 of file albaCameraTransform.h.

Constructor & Destructor Documentation

◆ albaCameraTransform()

albaCameraTransform::albaCameraTransform ( )

◆ ~albaCameraTransform()

virtual albaCameraTransform::~albaCameraTransform ( )
virtual

Member Function Documentation

◆ albaTypeMacro()

albaCameraTransform::albaTypeMacro ( albaCameraTransform  ,
albaTransformBase   
)

◆ SetRenderer()

void albaCameraTransform::SetRenderer ( vtkRenderer *  ren)

Set the renderer used as input for this transform.

◆ GetRenderer()

vtkRenderer * albaCameraTransform::GetRenderer ( )
inline

Return the renderer used as input for this transform.

Definition at line 99 of file albaCameraTransform.h.

◆ SetBounds()

void albaCameraTransform::SetBounds ( albaOBB bounds)
inline

Set the bounds of the object that should follow the camera.

This is necessary to allow the the right scaling.

Definition at line 104 of file albaCameraTransform.h.

◆ GetBounds()

albaOBB * albaCameraTransform::GetBounds ( )
inline

Definition at line 105 of file albaCameraTransform.h.

◆ SetFollowPosition()

void albaCameraTransform::SetFollowPosition ( int  flag)
inline

Enable/Disable following of the camera position.

Definition at line 108 of file albaCameraTransform.h.

References albaTransformBase::Modified().

Here is the call graph for this function:

◆ GetFollowPosition()

int albaCameraTransform::GetFollowPosition ( )
inline

Definition at line 109 of file albaCameraTransform.h.

◆ FollowPositionOn()

void albaCameraTransform::FollowPositionOn ( )
inline

Definition at line 110 of file albaCameraTransform.h.

◆ FollowPositionOff()

void albaCameraTransform::FollowPositionOff ( )
inline

Definition at line 111 of file albaCameraTransform.h.

◆ SetFollowOrientation()

void albaCameraTransform::SetFollowOrientation ( int  flag)
inline

Enable/Disable following of the camera orientation.

Definition at line 114 of file albaCameraTransform.h.

References albaTransformBase::Modified().

Here is the call graph for this function:

◆ GetFollowOrientation()

int albaCameraTransform::GetFollowOrientation ( )
inline

Definition at line 115 of file albaCameraTransform.h.

◆ FollowOrientationOn()

void albaCameraTransform::FollowOrientationOn ( )
inline

Definition at line 116 of file albaCameraTransform.h.

◆ FollowOrientationOff()

void albaCameraTransform::FollowOrientationOff ( )
inline

Definition at line 117 of file albaCameraTransform.h.

◆ SetFollowScale()

void albaCameraTransform::SetFollowScale ( int  flag)
inline

Enable/Disable following of the camera scaling.

Definition at line 120 of file albaCameraTransform.h.

References albaTransformBase::Modified().

Here is the call graph for this function:

◆ GetFollowScale()

int albaCameraTransform::GetFollowScale ( )
inline

Definition at line 121 of file albaCameraTransform.h.

◆ FollowScaleOn()

void albaCameraTransform::FollowScaleOn ( )
inline

Definition at line 122 of file albaCameraTransform.h.

◆ FollowScaleOff()

void albaCameraTransform::FollowScaleOff ( )
inline

Definition at line 123 of file albaCameraTransform.h.

◆ SetPositionMode()

void albaCameraTransform::SetPositionMode ( int  type)
inline

Set the modality to fit the Z coordinate.

See class comment.

Definition at line 126 of file albaCameraTransform.h.

References albaTransformBase::Modified().

Here is the call graph for this function:

◆ GetPositionMode()

int albaCameraTransform::GetPositionMode ( )
inline

Definition at line 127 of file albaCameraTransform.h.

◆ SetPositionModeToAttachToFocalPoint()

void albaCameraTransform::SetPositionModeToAttachToFocalPoint ( )
inline

Definition at line 128 of file albaCameraTransform.h.

◆ SetPositionModeToAttachToCamera()

void albaCameraTransform::SetPositionModeToAttachToCamera ( )
inline

Definition at line 129 of file albaCameraTransform.h.

◆ SetPositionModeToAttachToClippingPlane()

void albaCameraTransform::SetPositionModeToAttachToClippingPlane ( )
inline

Definition at line 130 of file albaCameraTransform.h.

◆ SetScalingMode()

void albaCameraTransform::SetScalingMode ( int  mode)
inline

Set which kind of scaling should be applied to the transform.

Definition at line 133 of file albaCameraTransform.h.

◆ GetScalingMode()

int albaCameraTransform::GetScalingMode ( )
inline

Definition at line 134 of file albaCameraTransform.h.

◆ SetScalingModeToAutoFitting()

void albaCameraTransform::SetScalingModeToAutoFitting ( )

Set scaling mode to AUTO_FITTING: the transform try to fit the given m_Bounds (see SetBounds() ) to the view frustum.

Fitting can occur in different ways (see SetFittingMode() ). Notice the m_Bounds can be any size, the transform will provide the right scaling.

◆ SetScalingModeToPreserveSize()

void albaCameraTransform::SetScalingModeToPreserveSize ( )

(not yet implemented) Set scaling mode to PRESERVE_SIZE.

This should scale the 3D object to keep display size fixed with respect to the view port. In this case the m_Bounds (see SetBounds() ) should be expressed in normalized coordinates, where X and Y represent view port coords, and Z... yet to be defined :-) .

◆ SetFittingMode()

void albaCameraTransform::SetFittingMode ( int  mode)
inline

set which kind of AutoFitting strategy should be used

Definition at line 152 of file albaCameraTransform.h.

References albaTransformBase::Modified().

Here is the call graph for this function:

◆ GetFittingMode()

int albaCameraTransform::GetFittingMode ( )
inline

Definition at line 153 of file albaCameraTransform.h.

◆ GetMTime()

virtual unsigned long albaCameraTransform::GetMTime ( )
virtual

Get the MTime: this is the bit of magic that makes everything work.

This MTime takes in consideration also the camera's MTime

Reimplemented from albaTransformBase.

◆ DeepCopy()

virtual int albaCameraTransform::DeepCopy ( albaCameraTransform trans)
virtual

◆ UpdatePoseMatrix()

void albaCameraTransform::UpdatePoseMatrix ( albaMatrix matrix,
albaMatrix old_view_matrix,
albaMatrix new_view_matrix 
)

Change the given matrix to follow camera movements.

◆ AutoOrientation() [1/2]

static void albaCameraTransform::AutoOrientation ( albaMatrix matrix,
vtkRenderer *  ren 
)
static

change matrix orientation to create a transform making points to be oriented according to camera orientation.

Translation is left unchanged while scale is reset to 1. The input matrix posiiton is used to compute the direction, in case call AutoPosition() before of this.

◆ AutoOrientation() [2/2]

void albaCameraTransform::AutoOrientation ( )
inline

Definition at line 170 of file albaCameraTransform.h.

References AutoOrientation().

Referenced by AutoOrientation().

Here is the call graph for this function:

◆ AutoPosition() [1/2]

static void albaCameraTransform::AutoPosition ( albaMatrix matrix,
vtkRenderer *  ren,
int  mode = ATTACH_TO_FOCAL_POINT 
)
static

change matrix translation to create a transform making points to be centered into the camera's focal point.

Orientation and scale are left unchanged

◆ AutoPosition() [2/2]

void albaCameraTransform::AutoPosition ( )
inline

Definition at line 176 of file albaCameraTransform.h.

References AutoPosition().

Referenced by AutoPosition().

Here is the call graph for this function:

◆ AutoFitting() [1/2]

static void albaCameraTransform::AutoFitting ( albaMatrix matrix,
albaOBB tracked_bounds,
vtkRenderer *  ren,
int  mode = MIN_SCALE 
)
static

Change matrix scale to create a transform making two boxes to fit.Translation and Orientation are left unchanged.

Fitting can occur according to different modalities.

See also
ComputeScaling()

◆ AutoFitting() [2/2]

void albaCameraTransform::AutoFitting ( )
inline

Definition at line 183 of file albaCameraTransform.h.

References AutoFitting().

Referenced by AutoFitting().

Here is the call graph for this function:

◆ AutoFitting2() [1/2]

static void albaCameraTransform::AutoFitting2 ( albaMatrix matrix,
albaOBB tracked_bounds,
vtkRenderer *  ren,
int  mode = ANISOTROPIC 
)
static

Change matrix scale to create a transform making two boxes to fit.

Translation and Orientation are left unchanged. This specific algrothim is thought to be used with AutoPosition() and ATTACH_TO_FOCAL_POINT mode. Fitting can occur according to different modalities.

See also
ComputeScaling()

◆ AutoFitting2() [2/2]

void albaCameraTransform::AutoFitting2 ( )
inline

Definition at line 191 of file albaCameraTransform.h.

References AutoFitting2().

Referenced by AutoFitting2().

Here is the call graph for this function:

◆ ComputeScaling()

static void albaCameraTransform::ComputeScaling ( albaOBB inBox,
albaOBB outBox,
double *  scale,
int  mode = MIN_SCALE 
)
static

Compute scale between two boxes according to given modality:

  • 0 select isotropic min scale
  • 1 select isotropic max scale
  • 2 select anisotropic scale (do not keep aspect ratio)
  • 3 fit Y
  • 4 fit X

◆ RecomputeAll()

void albaCameraTransform::RecomputeAll ( )

◆ InternalUpdate()

virtual void albaCameraTransform::InternalUpdate ( )
protectedvirtual

Updates the internal matrix.

Implements albaTransformBase.

◆ InternalProcessEvents()

static void albaCameraTransform::InternalProcessEvents ( vtkObject *  sender,
unsigned long  channel,
void *  clientdata,
void *  calldata 
)
staticprotected

Member Data Documentation

◆ m_Renderer

vtkRenderer* albaCameraTransform::m_Renderer
protected

This stores the renderer used as input.

Definition at line 210 of file albaCameraTransform.h.

◆ m_Camera

vtkCamera* albaCameraTransform::m_Camera
protected

this is to find if the render's active camera is changed

Definition at line 211 of file albaCameraTransform.h.

◆ m_FollowPosition

int albaCameraTransform::m_FollowPosition
protected

Flag for enabling the translation according to camera position.

Definition at line 212 of file albaCameraTransform.h.

◆ m_FollowOrientation

int albaCameraTransform::m_FollowOrientation
protected

Flag for enabling the re-orientation according to camera position.

Definition at line 213 of file albaCameraTransform.h.

◆ m_FollowScale

int albaCameraTransform::m_FollowScale
protected

Flag for enabling the scaling according to camera frustum.

Definition at line 214 of file albaCameraTransform.h.

◆ m_PositionMode

int albaCameraTransform::m_PositionMode
protected

Modality defining the rule to set the position with respect to the camera.

Definition at line 215 of file albaCameraTransform.h.

◆ m_ScalingMode

int albaCameraTransform::m_ScalingMode
protected

Kind of scaling policy (.

See also
AutoScalingModalities)

Definition at line 216 of file albaCameraTransform.h.

◆ m_FittingMode

int albaCameraTransform::m_FittingMode
protected

Kind of scaling used to fit the view frustum.

Definition at line 217 of file albaCameraTransform.h.

◆ m_Bounds

albaOBB* albaCameraTransform::m_Bounds
protected

m_Bounds of the object that should follow the camera

Definition at line 219 of file albaCameraTransform.h.

◆ m_OldViewAngle

float albaCameraTransform::m_OldViewAngle
protected

Definition at line 221 of file albaCameraTransform.h.

◆ m_OldDistance

double albaCameraTransform::m_OldDistance
protected

Definition at line 222 of file albaCameraTransform.h.

◆ m_OldViewMatrix

albaMatrix* albaCameraTransform::m_OldViewMatrix
protected

Definition at line 223 of file albaCameraTransform.h.

◆ m_EventRouter

vtkCallbackCommand* albaCameraTransform::m_EventRouter
protected

Definition at line 225 of file albaCameraTransform.h.


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