The Vish Visualization Shell 0.3
Vish
Public Member Functions | Public Attributes | List of all members
Wizt::VCamera Struct Reference

The Camera object for OpenGL operations in VISH. More...

#include <ocean/shrimp/VCamera.hpp>

Public Member Functions

std::array< double, 16 > getModelViewMatrix () const
 Get an OpenGL-compatible model view matrix from the camera parameters, similar to calling glLookAt() .
 
std::array< double, 16 > getUntranslatedModelViewMatrix () const
 Same as untranslatedLookAt() .
 
void translate (std::array< double, 16 > &OpenGLMatrix) const
 Translate a given OpenGL matrix with the camera's observer location.
 
std::array< double, 16 > untranslatedLookAt () const
 
void untranslatedLookAt (double m[16]) const
 Compute a 3x3 matrix as subset of a 4x4 matrix containing rotations as defined by the current camera settings.
 
 VCamera ()
 Setup a default camera where the observer is located at (0,1,0), so at the y-axis, looking at the origin (0,0,0) with z-axis as up direction.
 
 VCamera (const point_t &Observer, const point_t &lookat=point_t(0, 0, 0), const bivector_t &UpVector=bivector_t(0, 0, 1), const double viewangle=45.0)
 Setup a camera with view parameters.
 
tvector3 viewdir () const
 The view direction.
 
 ~VCamera ()
 Destructor.
 

Public Attributes

point_t LookAt
 The point that is watched.
 
point_t Observer
 Location of the observer.
 
bivector_t Up
 The horizontal plane, a bi-vector, whose dual is the up-direction.
 
double ViewAngle
 Default view angle is 45 degrees, units are degrees.
 

Detailed Description

The Camera object for OpenGL operations in VISH.

Its functionality is based on geometric algebra.

Todo:
MOVE this class into eagle/Camera.hpp and merge this functionality with the current class defined there.
Examples
InteractivePoint.cpp.

Constructor & Destructor Documentation

◆ VCamera()

Wizt::VCamera::VCamera ( const point_t Observer,
const point_t lookat = point_t(0,0,0),
const bivector_t UpVector = bivector_t(0,0,1),
const double  viewangle = 45.0 
)

Setup a camera with view parameters.

Parameters
viewangleangle in degree, default is 45.0

Member Function Documentation

◆ getModelViewMatrix()

std::array< double, 16 > Wizt::VCamera::getModelViewMatrix ( ) const
inline

Get an OpenGL-compatible model view matrix from the camera parameters, similar to calling glLookAt() .

Note that model view matrices are numerically instable for large translations. In general it is better to separate translation and rotation. The rotation matrix can be retrieve via getUntranslatedModelViewMatrix()

  • which may include a minor translation component - and using Observer as the translation component.

This function here will calculate the combined 4x4 matrix (stored in column-major order as 1D array, as required by OpenGL).

Referenced by Wizt::View::computeModelViewMatrix().

◆ translate()

void Wizt::VCamera::translate ( std::array< double, 16 > &  OpenGLMatrix) const

Translate a given OpenGL matrix with the camera's observer location.

The function is intentionally void to emphasize that its argument will be modified by this call.

References Observer.

◆ untranslatedLookAt() [1/2]

std::array< double, 16 > Wizt::VCamera::untranslatedLookAt ( ) const
       Compute a 3x3 matrix as subset of a 4x4
       matrix containing rotations as defined by
       the current camera settings.
       This function is similar to
       http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml
       but does not include the translation by the
       Observer because the translation operation
       leads to severe numerical instabilities once
       coordinates become very large. If it is an
       option to translate object coordinates instead
       of the camera during the LookAt() call, then
       this is highly preferable. Otherwise, there
       needs to be a glTranslate( Observer ) call.

       This call is similar to calling gluLookAt
       (without translation) in the following manner:
::gluLookAt(Observer.x() , Observer.y() , Observer.z(),
LookAt .x() , LookAt .y() , LookAt .z(),
Up .yz(), Up .zx(), Up .xy() );
bivector_t Up
The horizontal plane, a bi-vector, whose dual is the up-direction.
Definition VCamera.hpp:38
point_t Observer
Location of the observer.
Definition VCamera.hpp:33
point_t LookAt
The point that is watched.
Definition VCamera.hpp:35

References LookAt, Eagle::norm(), Observer, and Up.

◆ untranslatedLookAt() [2/2]

void Wizt::VCamera::untranslatedLookAt ( double  m[16]) const

Compute a 3x3 matrix as subset of a 4x4 matrix containing rotations as defined by the current camera settings.

This function is similar to http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml but does not include the translation by the Observer because the translation operation leads to severe numerical instabilities once coordinates become very large. If it is an option to translate object coordinates instead of the camera during the LookAt() call, then this is highly preferable. Otherwise, there needs to be a glTranslate( Observer ) call.

References LookAt, Eagle::norm(), Observer, and Up.

Referenced by Wizt::View::computeModelViewMatrix().