![]() |
Computational Embodied Neuroscience Simulator
1.1
3D simulation library
|
A C++ wrapper for OpenGL. More...
#include <cens_graphics.h>
Classes | |
struct | CENSCamera |
parameters of a camera More... | |
struct | CENSLight |
Light settings of the scene. More... | |
Public Member Functions | |
CENSGraphics () | |
~CENSGraphics () | |
virtual void | initCENSGraphics (int argc, char **argv) |
virtual void | loop () |
virtual void | stepToStepLoop () |
virtual void | step (int ts) |
virtual void | display () |
virtual bool | isIdle () |
virtual void | quit () |
virtual void | keyboard (unsigned char key, int x, int y) |
void | initCamera (CENSCamera &camera, CENSLight light) |
void | focusCamera (int camera_index) |
void | updateCamera (int camera_index) |
const CENSPixelMap & | getCameraPixelMap (int camera_index) |
void | saveCameraPixelMap (int camera_index, int t, const char *type="jpg") |
void | drawLine (const Vector3f &v1, const Vector3f &v2, const Vector3f color) |
void | drawPlane (const Vector3f &orig, const Vector3f &vec0, const Vector3f &vec1) |
void | drawBox (const Vector3f &orig, const Matrix3f &rotMat, const Vector3f &halfExtent) |
void | drawSphere (const Vector3f &orig, const Matrix3f &rot, float radius) |
void | drawConvex (const Vector3f &orig, const Matrix3f &rot, const std::vector< Vector3f > &vtx, const unsigned int *idx, int nvtxs, int nidxs, int ntrns) |
void | drawAxis (const Vector3f &origin, const Matrix3f &rotation, float length) |
void | drawVector (const Vector3f &v) |
void | drawTriangle (const Vector3f &v1, const Vector3f &v2, const Vector3f &v3, const Vector3f n) |
void | stepLeft () |
void | stepRight () |
void | stepFront () |
void | stepBack () |
void | zoomIn () |
void | zoomOut () |
void | toggleStop () |
void | toggleTexture () |
void | toggleAxis () |
void | toggleObjectAxes () |
void | toggleJointAxes () |
void | toggleCameraAxis () |
Protected Member Functions | |
void | beginRendering () |
void | endRendering () |
void | initTextures () |
void | initTexture (const GLubyte *source=0, int width=0, int height=0) |
Protected Attributes | |
int | m_grTimestep |
int | m_grArgc |
char ** | m_grArgv |
Vector3f | m_grEnvColor |
Vector3f | m_grGroundColor |
Vector3f | m_grObjectColor |
Vector3f | m_grBoxColor |
Vector3f | m_grCapsuleColor |
Vector3f | m_grSphereColor |
Vector3f | m_grSoftColor |
Vector3f | m_grCompoundColor |
bool | m_grTextureEnabled |
bool | m_grTextureInitialized |
bool | m_grHide |
CENSLight | m_grLight |
bool | m_grAxisEnabled |
bool | m_grSimEnabled |
bool | m_grCameraAxisEnabled |
bool | m_grObjectAxesEnabled |
bool | m_grJointAxesEnabled |
CENSCamera | m_grViewCamera |
int | m_grEyeCameraNumber |
std::vector< CENSCamera * > | m_grEyeCameras |
std::vector< CENSCamera * > | m_grCameras |
std::vector< CENSGraphicsShape * > | m_grShapes |
CENSParameterManager | m_grParameterManager |
A C++ wrapper for OpenGL.
It allows to use graphics easily, encapsulating low-level particulars. It uses the Glut interface to OpenGL. General parameters can be changed by modifing the "graphics_parameters" file that is created the first time the application is called. An object of this class must be passed to the CENSGraphics::cens_graphics pointer so that all callbacks can be linked and used in the right way:
#include "cens_graphics.h" ... CENSGraphics mygraph(...); cens_graphics = &mygraph;
Definition at line 77 of file cens_graphics.h.
|
inline |
Definition at line 86 of file cens_graphics.h.
cens::CENSGraphics::~CENSGraphics | ( | ) |
Definition at line 65 of file cens_graphics.cpp.
|
protected |
Begin a rendering session.
Definition at line 293 of file cens_graphics.cpp.
|
virtual |
Rendering of all objects
Reimplemented in cens::CENSEngine.
Definition at line 238 of file cens_graphics.cpp.
Referenced by cens::glutDisplayCallback().
void cens::CENSGraphics::drawAxis | ( | const Vector3f & | origin, |
const Matrix3f & | rotation, | ||
float | length | ||
) |
Draw XYZ axes.
origin | origin. |
rotation | rotation. |
length | length of each axis. |
Definition at line 904 of file cens_graphics.cpp.
Referenced by cens::CENSEngine::display().
void cens::CENSGraphics::drawBox | ( | const Vector3f & | orig, |
const Matrix3f & | rotMat, | ||
const Vector3f & | halfExtent | ||
) |
Draw a box.
orig | origin. |
rotMat | transformation. |
halfExtent | half extents with margin. |
Definition at line 630 of file cens_graphics.cpp.
void cens::CENSGraphics::drawConvex | ( | const Vector3f & | orig, |
const Matrix3f & | rot, | ||
const std::vector< Vector3f > & | vtx, | ||
const unsigned int * | idx, | ||
int | nvtxs, | ||
int | nidxs, | ||
int | ntrns | ||
) |
Draw a cens convex object.
orig | origin. |
rot | rotation. |
vtx | list of triangular vertexes. |
idx | list of indices of triangular vertexes. |
nvtxs | number of triangular vertexes. |
nidxs | number indices of triangular vertexes. |
ntrns | number indices of triangles. |
Definition at line 841 of file cens_graphics.cpp.
void cens::CENSGraphics::drawLine | ( | const Vector3f & | v1, |
const Vector3f & | v2, | ||
const Vector3f | color | ||
) |
Draw a line
Definition at line 787 of file cens_graphics.cpp.
Referenced by cens::CENSEngine::display().
void cens::CENSGraphics::drawPlane | ( | const Vector3f & | orig, |
const Vector3f & | vec0, | ||
const Vector3f & | vec1 | ||
) |
Draw a plane or half-empty space. Three perpendicular versors are given as parameters, indicating the sense of the empty space.
orig | a versor indicating the direction of the empty part of the space. |
vec0 | the second versor, perpendicular to orig. |
vec1 | the third versor, perpendicular to both orig and vec0. |
Definition at line 599 of file cens_graphics.cpp.
void cens::CENSGraphics::drawSphere | ( | const Vector3f & | orig, |
const Matrix3f & | rot, | ||
float | radius | ||
) |
Draw a sphere.
orig | origin. |
rot | rotation. |
radius | radius. |
Definition at line 730 of file cens_graphics.cpp.
void cens::CENSGraphics::drawTriangle | ( | const Vector3f & | v1, |
const Vector3f & | v2, | ||
const Vector3f & | v3, | ||
const Vector3f | n | ||
) |
Draw a triangle.
v1 | first vertex. |
v2 | second vertex. |
v3 | third vertex. |
n | normal. |
Definition at line 810 of file cens_graphics.cpp.
|
inline |
|
protected |
End a rendering session.
Definition at line 302 of file cens_graphics.cpp.
void cens::CENSGraphics::focusCamera | ( | int | camera_index | ) |
Update camera viewpoint.
Definition at line 471 of file cens_graphics.cpp.
References cens::CENSGraphics::CENSCamera::m_cHandle.
Referenced by cens::CENSEngine::init().
const CENSPixelMap & cens::CENSGraphics::getCameraPixelMap | ( | int | camera_index | ) |
get CENSCamera pixels
Definition at line 526 of file cens_graphics.cpp.
References cens::CENSPixelMap::getBlob(), cens::CENSGraphics::CENSCamera::m_cHandle, cens::CENSGraphics::CENSCamera::m_cPixmap, cens::CENSGraphics::CENSCamera::m_cScreenHeight, and cens::CENSGraphics::CENSCamera::m_cScreenWidth.
void cens::CENSGraphics::initCamera | ( | CENSCamera & | camera, |
CENSLight | light | ||
) |
Init camera viewpoint.
Definition at line 380 of file cens_graphics.cpp.
References cens::glutDisplayCallback(), cens::CENSGraphics::CENSCamera::initPixels(), cens::CENSGraphics::CENSCamera::m_cFar, cens::CENSGraphics::CENSCamera::m_cFoV, cens::CENSGraphics::CENSCamera::m_cHandle, cens::CENSGraphics::CENSCamera::m_cNear, cens::CENSGraphics::CENSCamera::m_cRatio, cens::CENSGraphics::CENSCamera::m_cScreenHeight, cens::CENSGraphics::CENSCamera::m_cScreenTitle, cens::CENSGraphics::CENSCamera::m_cScreenWidth, cens::CENSGraphics::CENSCamera::m_cScreenXGap, cens::CENSGraphics::CENSCamera::m_cScreenYGap, cens::CENSGraphics::CENSLight::m_lAmbient, cens::CENSGraphics::CENSLight::m_lDiffuse, cens::CENSGraphics::CENSLight::m_lPosition0, cens::CENSGraphics::CENSLight::m_lPosition1, and cens::CENSGraphics::CENSLight::m_lSpecular.
Referenced by cens::CENSEngine::attachCamera().
|
virtual |
Initialize cens_graphics.
Parameters from file
Definition at line 73 of file cens_graphics.cpp.
References cens::glutKeyboardCallback(), and cens::glutTimerCallback().
Referenced by cens::CENSEngine::init().
|
protected |
Initialize texturing without graphics_shape objects.
Definition at line 319 of file cens_graphics.cpp.
|
protected |
Initialize texturing.
Definition at line 309 of file cens_graphics.cpp.
Referenced by cens::CENSEngine::init().
|
virtual |
Stop screen visualization.
Definition at line 245 of file cens_graphics.cpp.
|
virtual |
Process keyboard shortcuts.
Definition at line 259 of file cens_graphics.cpp.
Referenced by cens::glutKeyboardCallback().
|
virtual |
Calls the cens_graphics loop function.
Definition at line 212 of file cens_graphics.cpp.
Referenced by cens::CENSEngine::run().
|
virtual |
Exit simulation.
Definition at line 252 of file cens_graphics.cpp.
void cens::CENSGraphics::saveCameraPixelMap | ( | int | camera_index, |
int | t, | ||
const char * | type = "jpg" |
||
) |
save CENSCamera pixels
Definition at line 554 of file cens_graphics.cpp.
References cens::CENSPixelMap::getBlob(), cens::CENSGraphics::CENSCamera::m_cHandle, cens::CENSGraphics::CENSCamera::m_cPixmap, cens::CENSGraphics::CENSCamera::m_cScreenHeight, and cens::CENSGraphics::CENSCamera::m_cScreenWidth.
|
virtual |
One step of cens_graphics rendering.
ts | time-step. A timer recalls the cens_graphics step function every ts time. |
Reimplemented in cens::CENSSerializedEngine, and cens::CENSEngine.
Definition at line 224 of file cens_graphics.cpp.
Referenced by cens::glutTimerCallback(), and cens::CENSEngine::step().
void cens::CENSGraphics::stepBack | ( | ) |
Go down.
Definition at line 961 of file cens_graphics.cpp.
void cens::CENSGraphics::stepFront | ( | ) |
Go up.
Definition at line 955 of file cens_graphics.cpp.
void cens::CENSGraphics::stepLeft | ( | ) |
Turn to the left.
Definition at line 941 of file cens_graphics.cpp.
void cens::CENSGraphics::stepRight | ( | ) |
Turn to the right.
Definition at line 948 of file cens_graphics.cpp.
|
virtual |
Calls the cens_graphics loppevent function
Definition at line 217 of file cens_graphics.cpp.
Referenced by cens::CENSEngine::stepRun().
void cens::CENSGraphics::toggleAxis | ( | ) |
Toggle axis.
Definition at line 1013 of file cens_graphics.cpp.
void cens::CENSGraphics::toggleCameraAxis | ( | ) |
Toggle camera axis.
Definition at line 1046 of file cens_graphics.cpp.
void cens::CENSGraphics::toggleJointAxes | ( | ) |
Toggle joint axes.
Definition at line 1035 of file cens_graphics.cpp.
void cens::CENSGraphics::toggleObjectAxes | ( | ) |
Toggle object axes.
Definition at line 1024 of file cens_graphics.cpp.
void cens::CENSGraphics::toggleStop | ( | ) |
Stop/restart the simulation.
Definition at line 1056 of file cens_graphics.cpp.
void cens::CENSGraphics::toggleTexture | ( | ) |
Toggle texture.
Definition at line 982 of file cens_graphics.cpp.
void cens::CENSGraphics::updateCamera | ( | int | camera_index | ) |
Update camera viewpoint.
Definition at line 483 of file cens_graphics.cpp.
References cens::CENSGraphics::CENSCamera::m_cAngle, cens::CENSGraphics::CENSCamera::m_cDistance, cens::CENSGraphics::CENSCamera::m_cHeight, cens::CENSGraphics::CENSCamera::m_cOrigin, cens::CENSGraphics::CENSCamera::m_cTarget, and cens::CENSGraphics::CENSCamera::m_cUp.
void cens::CENSGraphics::zoomIn | ( | ) |
Zoom in.
Definition at line 969 of file cens_graphics.cpp.
void cens::CENSGraphics::zoomOut | ( | ) |
Zoom out.
Definition at line 975 of file cens_graphics.cpp.
|
protected |
program number of arguments
Definition at line 397 of file cens_graphics.h.
|
protected |
list of arguments
Definition at line 399 of file cens_graphics.h.
|
protected |
axis-enabled flag
Definition at line 429 of file cens_graphics.h.
Referenced by cens::CENSEngine::display().
|
protected |
default box color
Definition at line 408 of file cens_graphics.h.
Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().
|
protected |
camera-axis-enabled flag
Definition at line 433 of file cens_graphics.h.
Referenced by cens::CENSEngine::display().
|
protected |
vector of all cameras
Definition at line 446 of file cens_graphics.h.
Referenced by cens::CENSEngine::init().
|
protected |
default capsule color
Definition at line 410 of file cens_graphics.h.
Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().
|
protected |
default compound color
Definition at line 416 of file cens_graphics.h.
|
protected |
environment color
Definition at line 402 of file cens_graphics.h.
|
protected |
number of supplementar cameras
Definition at line 442 of file cens_graphics.h.
|
protected |
vector of supplementar cameras
Definition at line 444 of file cens_graphics.h.
Referenced by cens::CENSEngine::attachCamera(), cens::CENSEngine::display(), and cens::CENSEngine::syncAttachedCamera().
|
protected |
default ground color
Definition at line 404 of file cens_graphics.h.
|
protected |
hiding-cens_graphics flag
Definition at line 424 of file cens_graphics.h.
|
protected |
axis-enabled flag
Definition at line 437 of file cens_graphics.h.
Referenced by cens::CENSEngine::display().
|
protected |
light parameters structure
Definition at line 426 of file cens_graphics.h.
Referenced by cens::CENSEngine::attachCamera().
|
protected |
object-axes-enabled flag
Definition at line 435 of file cens_graphics.h.
Referenced by cens::CENSEngine::display().
|
protected |
default object color
Definition at line 406 of file cens_graphics.h.
|
protected |
Parameter manager
Definition at line 451 of file cens_graphics.h.
|
protected |
vector of graphic shape objects
Definition at line 448 of file cens_graphics.h.
Referenced by cens::CENSEngine::display(), cens::CENSEngine::localCreateRigidBody(), cens::CENSEngine::localCreateSoftBody(), cens::CENSEngine::localImportRigidBody(), and cens::CENSEngine::localLinkSoftBody().
|
protected |
simulation-enabled flag
Definition at line 431 of file cens_graphics.h.
Referenced by cens::CENSEngine::step().
|
protected |
default soft color
Definition at line 414 of file cens_graphics.h.
Referenced by cens::CENSEngine::localCreateSoftBody(), and cens::CENSEngine::localLinkSoftBody().
|
protected |
default sphere color
Definition at line 412 of file cens_graphics.h.
Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().
|
protected |
texture-enabled flag
Definition at line 419 of file cens_graphics.h.
|
protected |
texture-initialized flag
Definition at line 421 of file cens_graphics.h.
|
protected |
m_grTimestep of the graphic simulation
Definition at line 395 of file cens_graphics.h.
|
protected |
main camera
Definition at line 440 of file cens_graphics.h.
Referenced by cens::CENSEngine::attachCamera().