cpe::navigator_tool Class Reference

(Dirty) Container class for camera, mouse and fps manipulation More...

+ Collaboration diagram for cpe::navigator_tool:

Public Member Functions

 navigator_tool ()
 empty constructor More...
 
unsigned int & screen_size_x ()
 Window size x. More...
 
unsigned int screen_size_x () const
 Window size x. More...
 
unsigned int & screen_size_y ()
 Window size y. More...
 
unsigned int screen_size_y () const
 Window size y. More...
 
double & dist_cam ()
 zoom factor More...
 
float dist_cam () const
 zoom factor More...
 
void go_forward (float dL)
 move the camera forward by a distance dL More...
 
void go_right (float dL)
 move the camera to the right by a distance dL More...
 
void go_up (float dL)
 move the camera up by a distance dL More...
 
void trackball_rotate (const int &x, const int &y)
 camera rotation using on-screen coordinates More...
 
void trackball_zoom (const int &y)
 camera zoom using on-screen coordinates More...
 
int & x_previous ()
 previous position of the mouse in screen x-coordinate More...
 
const int & x_previous () const
 previous position of the mouse in screen x-coordinate More...
 
int & y_previous ()
 previous position of the mouse in screen y-coordinate More...
 
const int & y_previous () const
 previous position of the mouse in screen y-coordinate More...
 
bool & left_button ()
 is left button clicked More...
 
bool left_button () const
 is left button clicked More...
 
bool & right_button ()
 is right button clicked More...
 
bool right_button () const
 is right button clicked More...
 
std::vector< double > projection_param () const
 Projection camera parameters: left/top/znear/zfar/aspect. More...
 
matrix3 camera_orientation () const
 get the camera orientation (matrix of the quaternion) More...
 
vec3 camera_translation () const
 get the camera absolute translation More...
 
vec3 camera_position () const
 get the current position of the camera More...
 
void increase_frame_number ()
 increase the frame number by 1 More...
 
unsigned int time () const
 get the current elapsed time More...
 
unsigned int & time ()
 get the current elapsed time More...
 
double update_fps ()
 update the fps counter and set frame to 0 More...
 
double delta_time ()
 elapsed time since old_time record More...
 
double fps ()
 get the current fps More...
 
std::pair< vec3, vec3ray_world_space_cam1 (const int &x_screen, const int &y_screen) const
 give the (x,y) coordinate in screen space and return the center and the ray pointed in world space More...
 

Private Attributes

trackball track
 internal rotation quaternion controled using ArcBall More...
 
vec3 tr
 internal camera world space translation More...
 
double dist
 internal zoom magnitude (z-translation in local coordinate frame) More...
 
double fov
 internal camera FOV storage More...
 
double znear
 internal camera Znear storage More...
 
double zfar
 internal camera Zfar storage More...
 
unsigned int x_size
 internal storage of window width More...
 
unsigned int y_size
 internal storage of window height More...
 
int mouse_x_previous
 internal storage of previous clicked position of the mouse (x) More...
 
int mouse_y_previous
 internal storage of previous clicked position of the mouse (y) More...
 
bool is_left_button
 internal storage when left button is clicked More...
 
bool is_right_button
 internal storage when right button is clicked More...
 
double current_fps
 internal storage of current fps More...
 
unsigned int current_time
 internal storage of current time More...
 
unsigned int old_time
 internal storage of previously recorded time More...
 
unsigned int frame
 internal storage of current frame number More...
 

Detailed Description

(Dirty) Container class for camera, mouse and fps manipulation

The camera is controled using 3 parameters:

1/ zoom factor (dist) = translation along local z coordinate

2/ orientation (track) = rotation transformation in this second frame controlled by arcball

3/ translation (tr) = final translation in the global world space

Constructor & Destructor Documentation

cpe::navigator_tool::navigator_tool ( )

empty constructor

References dist, fov, zfar, and znear.

Member Function Documentation

matrix3 cpe::navigator_tool::camera_orientation ( ) const

get the camera orientation (matrix of the quaternion)

References cpe::quaternion::conjugated(), cpe::quaternion::matrix(), cpe::trackball::quat(), and track.

Referenced by camera_position(), glwidget::draw_orientation(), glwidget::draw_pointer(), glwidget::paintGL(), and ray_world_space_cam1().

+ Here is the call graph for this function:

vec3 cpe::navigator_tool::camera_position ( ) const

get the current position of the camera

References camera_orientation(), dist_cam(), tr, and cpe::matrix3::transposed().

Referenced by ray_world_space_cam1().

+ Here is the call graph for this function:

vec3 cpe::navigator_tool::camera_translation ( ) const

get the camera absolute translation

References tr.

Referenced by glwidget::paintGL().

double cpe::navigator_tool::delta_time ( )

elapsed time since old_time record

References current_time, and old_time.

Referenced by glwidget::draw_decorating_info().

double & cpe::navigator_tool::dist_cam ( )
float cpe::navigator_tool::dist_cam ( ) const

zoom factor

References dist.

double cpe::navigator_tool::fps ( )

get the current fps

References current_fps.

Referenced by glwidget::draw_fps().

void cpe::navigator_tool::go_forward ( float  dL)

move the camera forward by a distance dL

References cpe::trackball::quat(), cpe::quaternion::rotate(), tr, and track.

Referenced by glwidget::keyPressEvent(), and glwidget::mouseMoveEvent().

+ Here is the call graph for this function:

void cpe::navigator_tool::go_right ( float  dL)

move the camera to the right by a distance dL

References cpe::trackball::quat(), cpe::quaternion::rotate(), tr, and track.

Referenced by glwidget::keyPressEvent(), and glwidget::mouseMoveEvent().

+ Here is the call graph for this function:

void cpe::navigator_tool::go_up ( float  dL)

move the camera up by a distance dL

References cpe::trackball::quat(), cpe::quaternion::rotate(), tr, and track.

Referenced by glwidget::keyPressEvent(), and glwidget::mouseMoveEvent().

+ Here is the call graph for this function:

void cpe::navigator_tool::increase_frame_number ( )

increase the frame number by 1

References frame.

Referenced by glwidget::draw_decorating_info().

bool & cpe::navigator_tool::left_button ( )

is left button clicked

References is_left_button.

bool cpe::navigator_tool::left_button ( ) const

is left button clicked

References is_left_button.

std::vector< double > cpe::navigator_tool::projection_param ( ) const

Projection camera parameters: left/top/znear/zfar/aspect.

for use: glFrustum(left, -left, top, -top, znear, zfar); with double aspect=static_cast<double>(navigator.x_screen_size_1)/static_cast<double>(navigator.y_screen_size_1); double fov=45.0*PI/180.0; double near=0.1; double top=tan(fov*0.5)*near; double bottom=-top; double left=aspect*bottom; double right=-left;

References fov, x_size, y_size, zfar, and znear.

Referenced by glwidget::paintGL(), and ray_world_space_cam1().

std::pair< vec3, vec3 > cpe::navigator_tool::ray_world_space_cam1 ( const int &  x_screen,
const int &  y_screen 
) const

give the (x,y) coordinate in screen space and return the center and the ray pointed in world space

Returns
center,ray

References camera_orientation(), camera_position(), projection_param(), screen_size_x(), screen_size_y(), cpe::matrix3::transposed(), and znear.

+ Here is the call graph for this function:

bool & cpe::navigator_tool::right_button ( )

is right button clicked

References is_right_button.

bool cpe::navigator_tool::right_button ( ) const

is right button clicked

References is_right_button.

unsigned int & cpe::navigator_tool::screen_size_x ( )
unsigned int cpe::navigator_tool::screen_size_x ( ) const

Window size x.

References x_size.

unsigned int & cpe::navigator_tool::screen_size_y ( )
unsigned int cpe::navigator_tool::screen_size_y ( ) const

Window size y.

References y_size.

unsigned int cpe::navigator_tool::time ( ) const

get the current elapsed time

References current_time.

Referenced by glwidget::draw_decorating_info().

unsigned int & cpe::navigator_tool::time ( )

get the current elapsed time

References current_time.

void cpe::navigator_tool::trackball_rotate ( const int &  x,
const int &  y 
)

camera rotation using on-screen coordinates

References cpe::trackball::apply_rotation(), mouse_x_previous, mouse_y_previous, cpe::trackball::set_2d_coords(), track, x_size, and y_size.

Referenced by glwidget::mouseMoveEvent().

+ Here is the call graph for this function:

void cpe::navigator_tool::trackball_zoom ( const int &  y)

camera zoom using on-screen coordinates

References dist, and mouse_y_previous.

Referenced by glwidget::mouseMoveEvent().

double cpe::navigator_tool::update_fps ( )

update the fps counter and set frame to 0

References current_fps, current_time, frame, and old_time.

Referenced by glwidget::draw_decorating_info().

int & cpe::navigator_tool::x_previous ( )

previous position of the mouse in screen x-coordinate

References mouse_x_previous.

Referenced by glwidget::mouseMoveEvent(), and glwidget::mousePressEvent().

const int & cpe::navigator_tool::x_previous ( ) const

previous position of the mouse in screen x-coordinate

References mouse_x_previous.

int & cpe::navigator_tool::y_previous ( )

previous position of the mouse in screen y-coordinate

References mouse_y_previous.

Referenced by glwidget::mouseMoveEvent(), and glwidget::mousePressEvent().

const int & cpe::navigator_tool::y_previous ( ) const

previous position of the mouse in screen y-coordinate

References mouse_y_previous.

Member Data Documentation

double cpe::navigator_tool::current_fps
private

internal storage of current fps

Referenced by fps(), and update_fps().

unsigned int cpe::navigator_tool::current_time
private

internal storage of current time

Referenced by delta_time(), time(), and update_fps().

double cpe::navigator_tool::dist
private

internal zoom magnitude (z-translation in local coordinate frame)

Referenced by dist_cam(), navigator_tool(), and trackball_zoom().

double cpe::navigator_tool::fov
private

internal camera FOV storage

Referenced by navigator_tool(), and projection_param().

unsigned int cpe::navigator_tool::frame
private

internal storage of current frame number

Referenced by increase_frame_number(), and update_fps().

bool cpe::navigator_tool::is_left_button
private

internal storage when left button is clicked

Referenced by left_button().

bool cpe::navigator_tool::is_right_button
private

internal storage when right button is clicked

Referenced by right_button().

int cpe::navigator_tool::mouse_x_previous
private

internal storage of previous clicked position of the mouse (x)

Referenced by trackball_rotate(), and x_previous().

int cpe::navigator_tool::mouse_y_previous
private

internal storage of previous clicked position of the mouse (y)

Referenced by trackball_rotate(), trackball_zoom(), and y_previous().

unsigned int cpe::navigator_tool::old_time
private

internal storage of previously recorded time

Referenced by delta_time(), and update_fps().

vec3 cpe::navigator_tool::tr
private

internal camera world space translation

Referenced by camera_position(), camera_translation(), go_forward(), go_right(), and go_up().

trackball cpe::navigator_tool::track
private

internal rotation quaternion controled using ArcBall

Referenced by camera_orientation(), go_forward(), go_right(), go_up(), and trackball_rotate().

unsigned int cpe::navigator_tool::x_size
private

internal storage of window width

Referenced by projection_param(), screen_size_x(), and trackball_rotate().

unsigned int cpe::navigator_tool::y_size
private

internal storage of window height

Referenced by projection_param(), screen_size_y(), and trackball_rotate().

double cpe::navigator_tool::zfar
private

internal camera Zfar storage

Referenced by navigator_tool(), and projection_param().

double cpe::navigator_tool::znear
private

internal camera Znear storage

Referenced by navigator_tool(), projection_param(), and ray_world_space_cam1().


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