#include <SofaGL.h>
OpenGL interface to a SofaScene. This is not a viewer, this is an object used by a viewer to display a Sofa scene and to pick objects in it. It contains a pointer to the Sofa scene. Several viewers can be connected to a single scene through such interfaces.
Picking returns a PickedPoint which describes a particle. It is up to the application to create the appropriate Interactor, which can then be inserted in the Sofa scene. This class provides the functions to attach/detach an interactor and move it.
Protected Attributes | |
SofaScene * | _sofaScene |
GLint | _viewport [4] |
GLdouble | _mvmatrix [16] |
GLdouble | _projmatrix [16] |
sofa::gl::DrawToolGL | _drawToolGL |
sofa::core::visual::VisualParams * | _vparams |
Picked_to_Interactor | _picked_to_interactor |
Interactor * | _drag |
The currently active interactor. More... | |
bool | _isPicking |
if we are doing OpenGL picking More... | |
GLint | pickX |
GLint | pickY |
GLuint | selectBuf [BUFSIZE] |
GLint | hits |
Public Member Functions | |
SofaGL (SofaScene *s) | |
void | draw () |
Draw the scene and stores the transformation matrices, for picking. This requires an OpenGL context. It is supposed to be used by the drawing method of a viewer, after setting the modelview matrix. More... | |
void | viewAll (SReal *xcam, SReal *ycam, SReal *zcam, SReal *xcen, SReal *ycen, SReal *zcen, SReal a, SReal *nearPlane, SReal *farPlane) |
Compute the parameters to pass to gluPerspective to make the whole scene visible. The new camera center is set on the line from the current camera center to the scene center, at the appropriate distance. More... | |
void | getSceneBBox (float *xmin, float *ymin, float *zmin, float *xmax, float *ymax, float *zmax) |
Compute the bounding box of the scene. More... | |
void | glPick (int x, int y) |
Try to pick a displayed thing along a ray, using OpenGL picking. The ray starts at the camera center and passes through point with coordinates x,y in image coordinates (origin on top left). In this experimental implementation, this function just prints something on the standard output. More... | |
void | getPickDirection (GLdouble *dx, GLdouble *dy, GLdouble *dz, int x, int y) |
getPickDirection Compute the direction of a button click, returned as a unit vector More... | |
Interaction | |
PickedPoint | pick (GLdouble ox, GLdouble oy, GLdouble oz, int x, int y) |
Try to pick a particle along a ray. The ray starts at the camera center and passes through point with coordinates x,y ox, oy, oz are the camera center in world coordinates. x,y in image coordinates (origin on top left). If a point is picked, the application may create an Interactor based on it. More... | |
void | attach (Interactor *) |
Insert an interactor in the scene Does not check if it is already there, so be careful not to insert the same twice. More... | |
Interactor * | getInteractor (const PickedPoint &picked) |
getInteractor More... | |
Interactor * | pickInteractor (GLdouble ox, GLdouble oy, GLdouble oz, int x, int y) |
Try to pick an Interactor along a ray. The ray starts at the camera center and passes through point with coordinates x,y ox, oy, oz are the camera center in world coordinates. x,y in image coordinates (origin on top left). More... | |
void | move (Interactor *, int x, int y) |
move the interactor according to the mouse pointer. x,y in image coordinates (origin on top left). More... | |
void | detach (Interactor *) |
Remove the interactor from the scene, without deleting it. More... | |
Protected Member Functions | |
void | draw (sofa::core::visual::VisualParams *) |
|
protected |
The currently active interactor.
|
protected |
|
protected |
if we are doing OpenGL picking
|
protected |
|
protected |
Currently available interactors, associated with picked points. The interactors are not necessarily being manipulated. Only one is typically manipulated at a given time.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
sofa::simplegui::SofaGL::SofaGL | ( | SofaScene * | s | ) |
s | The Sofa scene to interact with, the scene MUST already be opened ! |
void sofa::simplegui::SofaGL::attach | ( | Interactor * | interactor | ) |
Insert an interactor in the scene Does not check if it is already there, so be careful not to insert the same twice.
void sofa::simplegui::SofaGL::detach | ( | Interactor * | drag | ) |
Remove the interactor from the scene, without deleting it.
void sofa::simplegui::SofaGL::draw | ( | ) |
Draw the scene and stores the transformation matrices, for picking. This requires an OpenGL context. It is supposed to be used by the drawing method of a viewer, after setting the modelview matrix.
|
protected |
Interactor * sofa::simplegui::SofaGL::getInteractor | ( | const PickedPoint & | picked | ) |
void sofa::simplegui::SofaGL::getPickDirection | ( | GLdouble * | dx, |
GLdouble * | dy, | ||
GLdouble * | dz, | ||
int | x, | ||
int | y | ||
) |
getPickDirection Compute the direction of a button click, returned as a unit vector
dx | normalized direction |
dy | normalized direction |
dz | normalized direction |
x | x-coordinate of the click |
y | y-coordinate of the click (origin on top) |
void sofa::simplegui::SofaGL::getSceneBBox | ( | float * | xmin, |
float * | ymin, | ||
float * | zmin, | ||
float * | xmax, | ||
float * | ymax, | ||
float * | zmax | ||
) |
Compute the bounding box of the scene.
void sofa::simplegui::SofaGL::glPick | ( | int | x, |
int | y | ||
) |
Try to pick a displayed thing along a ray, using OpenGL picking. The ray starts at the camera center and passes through point with coordinates x,y in image coordinates (origin on top left). In this experimental implementation, this function just prints something on the standard output.
void sofa::simplegui::SofaGL::move | ( | Interactor * | interactor, |
int | x, | ||
int | y | ||
) |
move the interactor according to the mouse pointer. x,y in image coordinates (origin on top left).
PickedPoint sofa::simplegui::SofaGL::pick | ( | GLdouble | ox, |
GLdouble | oy, | ||
GLdouble | oz, | ||
int | x, | ||
int | y | ||
) |
Try to pick a particle along a ray. The ray starts at the camera center and passes through point with coordinates x,y ox, oy, oz are the camera center in world coordinates. x,y in image coordinates (origin on top left). If a point is picked, the application may create an Interactor based on it.
Interactor * sofa::simplegui::SofaGL::pickInteractor | ( | GLdouble | ox, |
GLdouble | oy, | ||
GLdouble | oz, | ||
int | x, | ||
int | y | ||
) |
Try to pick an Interactor along a ray. The ray starts at the camera center and passes through point with coordinates x,y ox, oy, oz are the camera center in world coordinates. x,y in image coordinates (origin on top left).
void sofa::simplegui::SofaGL::viewAll | ( | SReal * | xcam, |
SReal * | ycam, | ||
SReal * | zcam, | ||
SReal * | xcen, | ||
SReal * | ycen, | ||
SReal * | zcen, | ||
SReal | a, | ||
SReal * | nearPlane, | ||
SReal * | farPlane | ||
) |
Compute the parameters to pass to gluPerspective to make the whole scene visible. The new camera center is set on the line from the current camera center to the scene center, at the appropriate distance.
xcam | Camera center (input-output) |
ycam | Camera center (input-output) |
zcam | Camera center (input-output) |
xcen | Center of the scene (output) |
ycen | Center of the scene (output) |
zcen | Center of the scene (output) |
a | Camera vertical angle (input) |
near | Smaller than the nearest distance from the new camera center to the scene (output) |
far | Larger than the nearest distance from the new camera center to the scene (output) |