SOFA plugin: SofaSimpleGUI  master
Open source framework for multi-physics simuation
sofa::simplegui::Camera Class Reference

#include <Camera.h>

The Camera class implements a simple viewpoint transformation, and its update using the mouse. Currently only one displacement mode is implemented, and it is not extensively tested. More...

Detailed Description

The Camera class implements a simple viewpoint transformation, and its update using the mouse. Currently only one displacement mode is implemented, and it is not extensively tested.

Author
Francois Faure, 2014

Protected Attributes

Transform transform
 Viewing transform: world wrt camera, i.e. inverse of the camera pose. More...
 
float fovy
 
float ratio
 
float znear
 
float zfar
 
int tb_ancienX
 
int tb_ancienY
 
int tb_tournerXY
 
int tb_translaterXY
 
int tb_bougerZ
 

Public Member Functions

 Camera ()
 
void setlookAt (float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
 
void lookAt ()
 Apply the viewing transform, typically just after glLoadIdentity() in the draw function. More...
 
void viewAll (float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
 
void perspective (float fovy, float ratio, float znear, float zfar)
 
void setPerspective (float fovy, float ratio, float znear, float zfar)
 
void perspective ()
 Apply the projection matrix defined in setPerspective, typically in the reshape function. More...
 
bool handleMouseButton (int button, int state, int x, int y)
 Set the camera displacement modes and return true. More...
 
bool handleMouseMotion (int x, int y)
 Displace the camera based on the mouse motion and return true. More...
 
Vec3 eye () const
 Center of the camera in world coordinates. More...
 
const TransformgetTransform () const
 Viewing matrix. More...
 

Attribute details

◆ fovy

float sofa::simplegui::Camera::fovy
protected

◆ ratio

float sofa::simplegui::Camera::ratio
protected

◆ tb_ancienX

int sofa::simplegui::Camera::tb_ancienX
protected

◆ tb_ancienY

int sofa::simplegui::Camera::tb_ancienY
protected

◆ tb_bougerZ

int sofa::simplegui::Camera::tb_bougerZ
protected

◆ tb_tournerXY

int sofa::simplegui::Camera::tb_tournerXY
protected

◆ tb_translaterXY

int sofa::simplegui::Camera::tb_translaterXY
protected

◆ transform

Transform sofa::simplegui::Camera::transform
protected

Viewing transform: world wrt camera, i.e. inverse of the camera pose.

◆ zfar

float sofa::simplegui::Camera::zfar
protected

◆ znear

float sofa::simplegui::Camera::znear
protected

Constructor details

◆ Camera()

sofa::simplegui::Camera::Camera ( )

Function details

◆ eye()

Camera::Vec3 sofa::simplegui::Camera::eye ( ) const

Center of the camera in world coordinates.

◆ getTransform()

const Transform& sofa::simplegui::Camera::getTransform ( ) const
inline

Viewing matrix.

◆ handleMouseButton()

bool sofa::simplegui::Camera::handleMouseButton ( int  button,
int  state,
int  x,
int  y 
)

Set the camera displacement modes and return true.

◆ handleMouseMotion()

bool sofa::simplegui::Camera::handleMouseMotion ( int  x,
int  y 
)

Displace the camera based on the mouse motion and return true.

◆ lookAt()

void sofa::simplegui::Camera::lookAt ( )

Apply the viewing transform, typically just after glLoadIdentity() in the draw function.

◆ perspective() [1/2]

void sofa::simplegui::Camera::perspective ( )

Apply the projection matrix defined in setPerspective, typically in the reshape function.

◆ perspective() [2/2]

void sofa::simplegui::Camera::perspective ( float  fovy,
float  ratio,
float  znear,
float  zfar 
)

Equivalent of gluPerspective. Alternatively, the definition and the application of the projection matrix can be done separately using other functions.

See also
void setPerspective( float fovy, float ratio, float znear, float zfar )
void perspective()

◆ setlookAt()

void sofa::simplegui::Camera::setlookAt ( float  eyeX,
float  eyeY,
float  eyeZ,
float  targetX,
float  targetY,
float  targetZ,
float  upX,
float  upY,
float  upZ 
)

Set the view point. Parameters correspond to gluLookAt. Note that this just sets the parameters. The actual viewing transform is applied in void lookAt() .

◆ setPerspective()

void sofa::simplegui::Camera::setPerspective ( float  fovy,
float  ratio,
float  znear,
float  zfar 
)

Set the projection matrix, without applying it. Parameters correspond to gluPerspective. Note that this just sets the parameters. The actual projection transform is applied in void perspective() .

◆ viewAll()

void sofa::simplegui::Camera::viewAll ( float  xmin,
float  ymin,
float  zmin,
float  xmax,
float  ymax,
float  zmax 
)

Enum details

◆ anonymous enum

anonymous enum
Enumerator
ButtonLeft 
ButtonMiddle 
ButtonRight 

◆ anonymous enum

anonymous enum
Enumerator
ButtonDown 
ButtonUp