version 3.3

VRS::Camera Class Reference

#include <vrs/camera.h>

Inheritance diagram for VRS::Camera:

VRS::MonoAttribute VRS::Attribute VRS::RenderObj VRS::SharedObj VRS::Visitable

List of all members.

Public Types

enum  Scope { SCENE, LOCAL }
enum  SizePolicy { NO_POLICY, SAME_SIZE, FIT_INSIDE, FIT_OUTSIDE }

Public Member Functions

 VRS_SERIALIZABLE_CLASS_ENUM (Scope)
 The camera scope.
 VRS_SERIALIZABLE_CLASS_ENUM (SizePolicy)
 Camera (Transform *projection=0, Transform *orientation=0, Scope=Camera::SCENE, SizePolicy=Camera::FIT_INSIDE)
 Camera (Vector from, Vector to, double angle, double nearPlane=0, double farPlane=0, Scope=Camera::SCENE, SizePolicy=Camera::FIT_INSIDE)
void setOrientation (Transform *tf)
 Set the transform object which specifies the orientation matrix.
TransformgetOrientation () const
 Get the transform object which specifies the orientation matrix.
void setProjection (Transform *tf)
 Set the transform object which specifies the projection matrix.
TransformgetProjection () const
 Get the transform object which specifies the projection matrix.
void setScope (Scope)
 Set the camera scope.
Scope getScope () const
 Get the camera scope.
void setSizePolicy (SizePolicy)
 Set the size policy.
SizePolicy getSizePolicy () const
 Get the size policy.
void setPixelCoordsTransform (bool)
bool getPixelCoordsTransform () const
 returns whether the pixel coords transform setting is enabled or disabled
void pushTransform (Transform *tf)
Iterator< SO< Transform > > * getTransform () const
 Gets an iterator of all additional transforms.
void popTransform ()
 Removes the last additional transform.
virtual SO< ViewInfoFactorynewViewInfoFactory () const
 VRS_TYPEINFO (Camera, MonoAttribute)
 VRS_SERIALIZABLE (Camera)

Static Public Member Functions

static SO< CameranewNormalizedDeviceCoordsCamera (double x1=-1.0, double x2=1.0, double y1=-1.0, double y2=1.0, double z1=-1.0, double z2=100.0)
static SO< CameranewNormalizedDeviceCoordsCamera (const Bounds &bbox)
 constructs a local camera with orthographic projection in Normalized Device Coordinates.
static SO< CameranewPixelCoordsCamera (double z1=-1.0, double z2=100.0)
 constructs a local camera with orthographic projection in Pixel Coordinates.


Detailed Description

VRS camera setting Specifies a Projection and an Orientation representing the properties of the Camera in the scene graph.

Member Enumeration Documentation

Enumerator:
SCENE 
LOCAL 

Enumerator:
NO_POLICY 
SAME_SIZE 
FIT_INSIDE 
FIT_OUTSIDE 


Constructor & Destructor Documentation

VRS::Camera::Camera ( Transform projection = 0,
Transform orientation = 0,
Scope  = Camera::SCENE,
SizePolicy  = Camera::FIT_INSIDE 
)

VRS::Camera::Camera ( Vector  from,
Vector  to,
double  angle,
double  nearPlane = 0,
double  farPlane = 0,
Scope  = Camera::SCENE,
SizePolicy  = Camera::FIT_INSIDE 
)

The camera is a monoattribute containing the necessary information for the camera specification in a scene graph. The first constructor expects two transformation attributes. The other constructor, provided for convenience, creates a perspective projection: The `from'-`to'-`angle' constructor will create a `LookAt' orientation with `from' and `to', and a `Perspective' projection. If `near' or `far' are 0 (i.e. the default), they will be replaced by 0.1*dist and 10*dist, with dist=|from-to|.
'Scope' specifies whether the camera is used for the whole scene graph or only locally. Only one scene camera attribute should be included in the scene graph, if more than one exist, the behaviour is undefined. Note that a scene camera respects transformations in object space, i.e., you can change the position of the camera like any other attribute.


Member Function Documentation

VRS::Camera::VRS_SERIALIZABLE_CLASS_ENUM ( Scope   ) 

The camera scope.

There are two different camera scopes:

  • A scene camera must be contained only once in the scene graph. It sets the transformation for the whole scene graph. A Scene camera is modified by the modelview transformation, so you can transform it with translations, rotations etc. (even with local cameras, though you probably do not want that!)
  • A local camera sets the camera in a subgraph. The projection and orientation matrix are applied directly.

VRS::Camera::VRS_SERIALIZABLE_CLASS_ENUM ( SizePolicy   ) 

A Camera may maintain a matrix to keep an aspect-ratio of 1:1 regardless of the window-size. Several policies are available for the common case that the viewport is not squared: `NO_POLICY' will ignore the viewport dimensions. Therefore, the view will be distorted. `SAME_SIZE' will preserve the area of the view-volume, cutting-off something in one direction while adding some slack-area in the other. `FIT_INSIDE' will shrink the view-volume so that it fits entirely into the screen. This setting is the default. `FIT_OUTSIDE' will stretch the view-volume so that the window fits into it (well, you get the idea ...). The new view volume will have the same center as the old onw.
The SizePolicy is also applied for local cameras! You probably don't want any modification here, so you will likely use NO_POLICY for those.

static SO<Camera> VRS::Camera::newNormalizedDeviceCoordsCamera ( double  x1 = -1.0,
double  x2 = 1.0,
double  y1 = -1.0,
double  y2 = 1.0,
double  z1 = -1.0,
double  z2 = 100.0 
) [static]

static SO<Camera> VRS::Camera::newNormalizedDeviceCoordsCamera ( const Bounds bbox  )  [static]

constructs a local camera with orthographic projection in Normalized Device Coordinates.

Normalized coordinates are within the range [-1,1]x[-1,1]. That range is assigned to the canvas without taking into account the width/height relation ship, i.e., the left/bottom corner of the window has the coordinates (-1,-1), and the right/upper corner (1,1). It is guaranties that z-coordinates of zero are not clipped. newNormaliyedDeviceCoordsCamera() without parameters has the behaviour described above the parameters allow it to have coordinates in the range [x1,x2]x[y1,y2] z1 is the z coordinate of the lookfrom vector, z2 the z coordinate of the lookto vector, the nearplane is set to 0, the far plane is set to z2-z1, this means the visible scene will be everything in the volume [x1,x2]x[y1,y2]x[z1,z2] why are the default z values -1 and 100? because in the old version without parameters, the lookat used -1 and 0, the planes were at .1 and 100 (default of VRS::Ortho). i wanted nothing to disappear from scenes that used the old version.

static SO<Camera> VRS::Camera::newPixelCoordsCamera ( double  z1 = -1.0,
double  z2 = 100.0 
) [static]

constructs a local camera with orthographic projection in Pixel Coordinates.

Pixel coordinates are a one-to-one mapping of the canvas pixels to coordinates. You can access each pixel by its screen coordinates, i.e. from [0, 0] to [w-1, h-1], where w and h is the size of the canvas. The z-component is ignored. For z1 and z2 see comment for method newNormalizedDeviceCoordsCamera()!

void VRS::Camera::setOrientation ( Transform tf  ) 

Set the transform object which specifies the orientation matrix.

Transform * VRS::Camera::getOrientation (  )  const [inline]

Get the transform object which specifies the orientation matrix.

void VRS::Camera::setProjection ( Transform tf  ) 

Set the transform object which specifies the projection matrix.

Transform * VRS::Camera::getProjection (  )  const [inline]

Get the transform object which specifies the projection matrix.

void VRS::Camera::setScope ( Scope   ) 

Set the camera scope.

Camera::Scope VRS::Camera::getScope (  )  const [inline]

Get the camera scope.

void VRS::Camera::setSizePolicy ( SizePolicy   ) 

Set the size policy.

Camera::SizePolicy VRS::Camera::getSizePolicy (  )  const [inline]

Get the size policy.

void VRS::Camera::setPixelCoordsTransform ( bool   ) 

If set to true, the projection matrix will scaled by the inverse size of the canvas as first transformation. This can be used to setup a pixel coordinate system, where world-coordinates map to pixels 1:1.

bool VRS::Camera::getPixelCoordsTransform (  )  const [inline]

returns whether the pixel coords transform setting is enabled or disabled

void VRS::Camera::pushTransform ( Transform tf  ) 

Pushs an additional transformation for the camera. These transform objects are all applied _before_ the transformation defined by the projection object. The additional transformations can be used to adapt the view plane coordinates to the window settins or to implement view plane operators such as zooming, paning etc.

Iterator<SO<Transform> >* VRS::Camera::getTransform (  )  const

Gets an iterator of all additional transforms.

void VRS::Camera::popTransform (  ) 

Removes the last additional transform.

virtual SO<ViewInfoFactory> VRS::Camera::newViewInfoFactory (  )  const [virtual]

VRS::Camera::VRS_TYPEINFO ( Camera  ,
MonoAttribute   
)

VRS::Camera::VRS_SERIALIZABLE ( Camera   ) 


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

Generated on Fri May 18 06:00:18 2012 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact