#include <manipworld.h>
Manipulate the world, mouse translations and rotations are screen-axis aligned This object handles the modelview matrix, in your display function use:
void display() { glClear(GL_COLOR_BUFFER_BIT | // erase last image on buffer GL_DEPTH_BUFFER_BIT); // erase last z buffer glPushMatrix(); manip.loadIdentityMatrix(); // ... draw objects ... glPopMatrix(); }
Rotate with:
void mouse_motion(int x, int y) { manip.rotateXAxis(y - last_y); manip.rotateYAxis(x - last_x); }
To pick an object (also look into the Pick class):
void mouse_click(int x, int y) { float pos[3]; if( ManipWorld::pick(x, window_height-y, pos[0], pos[1], pos[2]) ) // ... object picked at position -pos- ... }
Note that the mouse coordinate origin is on the lower left corner of the viewport
Public Member Functions | |
| ManipWorld () | |
| ~ManipWorld () | |
| void | init () |
| void | translateAxis (float dx, float dy, float dz) |
| void | translate (float dx, float dy, float dz) |
| void | zoom (float zoom) |
| void | rotateXAxis (float delta) |
| void | rotateYAxis (float delta) |
| void | rotateZAxis (float delta) |
| void | rotateX (float delta) |
| void | rotateY (float delta) |
| void | rotateZ (float delta) |
| void | loadModelViewMatrix () const |
| void | loadInverseModelViewMatrix () const |
| void | saveModelViewMatrix () |
| void | getModelViewMatrix (float m[]) const |
| void | setModelViewMatrix (const float m[]) |
Static Public Member Functions | |
| static bool | pick (int mouse_x, int mouse_y, float &x, float &y, float &z) |
| Tools::ManipWorld::ManipWorld | ( | ) |
| Tools::ManipWorld::~ManipWorld | ( | ) |
| void Tools::ManipWorld::init | ( | ) |
Use identity matrix
| void Tools::ManipWorld::translateAxis | ( | float | dx, | |
| float | dy, | |||
| float | dz | |||
| ) |
translate camera (screen aligned translations)
| dx,dy | translate object parallel to the screen | |
| dz | move object in and outside the screen |
| void Tools::ManipWorld::translate | ( | float | dx, | |
| float | dy, | |||
| float | dz | |||
| ) |
translate camera (world aligned translations)
| dx,dy,dz | translate object in world distance |
| void Tools::ManipWorld::zoom | ( | float | zoom | ) |
camera zoom
| void Tools::ManipWorld::rotateXAxis | ( | float | delta | ) |
Rotate verticaly, around the screen X axis
| void Tools::ManipWorld::rotateYAxis | ( | float | delta | ) |
Rotate horizontaly, around the screen Y axis
| void Tools::ManipWorld::rotateZAxis | ( | float | delta | ) |
Tilt camera, around the screen Z axis
| void Tools::ManipWorld::rotateX | ( | float | delta | ) |
Rotate around the world X axis
| void Tools::ManipWorld::rotateY | ( | float | delta | ) |
Rotate around the world Y axis
| void Tools::ManipWorld::rotateZ | ( | float | delta | ) |
Rotate around the world Z axis
| void Tools::ManipWorld::loadModelViewMatrix | ( | ) | const |
Load modelview matrix this actually rotate and translate the world
| void Tools::ManipWorld::loadInverseModelViewMatrix | ( | ) | const |
Load inverse of the modelview matrix it can be used to undo a manipulation
| void Tools::ManipWorld::saveModelViewMatrix | ( | ) |
Save the actual modelview matrix if the modelview if modified externally, this method will copy it to this manipulator
| void Tools::ManipWorld::getModelViewMatrix | ( | float | m[] | ) | const |
Get modelview matrix
| void Tools::ManipWorld::setModelViewMatrix | ( | const float | m[] | ) |
Set modelview matrix
| static bool Tools::ManipWorld::pick | ( | int | mouse_x, | |
| int | mouse_y, | |||
| float & | x, | |||
| float & | y, | |||
| float & | z | |||
| ) | [static] |
1.5.5