Computational Embodied Neuroscience Simulator  1.1
3D simulation library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cens::CENSGraphics Class Reference

A C++ wrapper for OpenGL. More...

#include <cens_graphics.h>

Inheritance diagram for cens::CENSGraphics:
Inheritance graph
[legend]
Collaboration diagram for cens::CENSGraphics:
Collaboration graph
[legend]

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 CENSPixelMapgetCameraPixelMap (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
 

Detailed Description

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.

Constructor & Destructor Documentation

cens::CENSGraphics::CENSGraphics ( )
inline

Definition at line 86 of file cens_graphics.h.

cens::CENSGraphics::~CENSGraphics ( )

Definition at line 65 of file cens_graphics.cpp.

Member Function Documentation

void cens::CENSGraphics::beginRendering ( )
protected

Begin a rendering session.

Definition at line 293 of file cens_graphics.cpp.

void cens::CENSGraphics::display ( )
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.

Parameters
originorigin.
rotationrotation.
lengthlength 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.

Parameters
origorigin.
rotMattransformation.
halfExtenthalf 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.

Parameters
origorigin.
rotrotation.
vtxlist of triangular vertexes.
idxlist of indices of triangular vertexes.
nvtxsnumber of triangular vertexes.
nidxsnumber indices of triangular vertexes.
ntrnsnumber 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.

Parameters
origa versor indicating the direction of the empty part of the space.
vec0the second versor, perpendicular to orig.
vec1the 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.

Parameters
origorigin.
rotrotation.
radiusradius.

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.

Parameters
v1first vertex.
v2second vertex.
v3third vertex.
nnormal.

Definition at line 810 of file cens_graphics.cpp.

void cens::CENSGraphics::drawVector ( const Vector3f &  v)
inline

Draw a vertex.

Parameters
vvertex.

Definition at line 361 of file cens_graphics.h.

void cens::CENSGraphics::endRendering ( )
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)
void cens::CENSGraphics::initCamera ( CENSCamera camera,
CENSLight  light 
)
void cens::CENSGraphics::initCENSGraphics ( int  argc,
char **  argv 
)
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().

void cens::CENSGraphics::initTexture ( const GLubyte *  source = 0,
int  width = 0,
int  height = 0 
)
protected

Initialize texturing without graphics_shape objects.

Definition at line 319 of file cens_graphics.cpp.

void cens::CENSGraphics::initTextures ( )
protected

Initialize texturing.

Definition at line 309 of file cens_graphics.cpp.

Referenced by cens::CENSEngine::init().

bool cens::CENSGraphics::isIdle ( )
virtual

Stop screen visualization.

Definition at line 245 of file cens_graphics.cpp.

void cens::CENSGraphics::keyboard ( unsigned char  key,
int  x,
int  y 
)
virtual

Process keyboard shortcuts.

Definition at line 259 of file cens_graphics.cpp.

Referenced by cens::glutKeyboardCallback().

void cens::CENSGraphics::loop ( )
virtual

Calls the cens_graphics loop function.

Definition at line 212 of file cens_graphics.cpp.

Referenced by cens::CENSEngine::run().

void cens::CENSGraphics::quit ( )
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" 
)
void cens::CENSGraphics::step ( int  ts)
virtual

One step of cens_graphics rendering.

Parameters
tstime-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.

void cens::CENSGraphics::stepToStepLoop ( )
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)
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.

Member Data Documentation

int cens::CENSGraphics::m_grArgc
protected

program number of arguments

Definition at line 397 of file cens_graphics.h.

char** cens::CENSGraphics::m_grArgv
protected

list of arguments

Definition at line 399 of file cens_graphics.h.

bool cens::CENSGraphics::m_grAxisEnabled
protected

axis-enabled flag

Definition at line 429 of file cens_graphics.h.

Referenced by cens::CENSEngine::display().

Vector3f cens::CENSGraphics::m_grBoxColor
protected

default box color

Definition at line 408 of file cens_graphics.h.

Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().

bool cens::CENSGraphics::m_grCameraAxisEnabled
protected

camera-axis-enabled flag

Definition at line 433 of file cens_graphics.h.

Referenced by cens::CENSEngine::display().

std::vector< CENSCamera *> cens::CENSGraphics::m_grCameras
protected

vector of all cameras

Definition at line 446 of file cens_graphics.h.

Referenced by cens::CENSEngine::init().

Vector3f cens::CENSGraphics::m_grCapsuleColor
protected

default capsule color

Definition at line 410 of file cens_graphics.h.

Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().

Vector3f cens::CENSGraphics::m_grCompoundColor
protected

default compound color

Definition at line 416 of file cens_graphics.h.

Vector3f cens::CENSGraphics::m_grEnvColor
protected

environment color

Definition at line 402 of file cens_graphics.h.

int cens::CENSGraphics::m_grEyeCameraNumber
protected

number of supplementar cameras

Definition at line 442 of file cens_graphics.h.

std::vector< CENSCamera *> cens::CENSGraphics::m_grEyeCameras
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().

Vector3f cens::CENSGraphics::m_grGroundColor
protected

default ground color

Definition at line 404 of file cens_graphics.h.

bool cens::CENSGraphics::m_grHide
protected

hiding-cens_graphics flag

Definition at line 424 of file cens_graphics.h.

bool cens::CENSGraphics::m_grJointAxesEnabled
protected

axis-enabled flag

Definition at line 437 of file cens_graphics.h.

Referenced by cens::CENSEngine::display().

CENSLight cens::CENSGraphics::m_grLight
protected

light parameters structure

Definition at line 426 of file cens_graphics.h.

Referenced by cens::CENSEngine::attachCamera().

bool cens::CENSGraphics::m_grObjectAxesEnabled
protected

object-axes-enabled flag

Definition at line 435 of file cens_graphics.h.

Referenced by cens::CENSEngine::display().

Vector3f cens::CENSGraphics::m_grObjectColor
protected

default object color

Definition at line 406 of file cens_graphics.h.

CENSParameterManager cens::CENSGraphics::m_grParameterManager
protected

Parameter manager

Definition at line 451 of file cens_graphics.h.

std::vector< CENSGraphicsShape *> cens::CENSGraphics::m_grShapes
protected
bool cens::CENSGraphics::m_grSimEnabled
protected

simulation-enabled flag

Definition at line 431 of file cens_graphics.h.

Referenced by cens::CENSEngine::step().

Vector3f cens::CENSGraphics::m_grSoftColor
protected

default soft color

Definition at line 414 of file cens_graphics.h.

Referenced by cens::CENSEngine::localCreateSoftBody(), and cens::CENSEngine::localLinkSoftBody().

Vector3f cens::CENSGraphics::m_grSphereColor
protected

default sphere color

Definition at line 412 of file cens_graphics.h.

Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().

bool cens::CENSGraphics::m_grTextureEnabled
protected

texture-enabled flag

Definition at line 419 of file cens_graphics.h.

bool cens::CENSGraphics::m_grTextureInitialized
protected

texture-initialized flag

Definition at line 421 of file cens_graphics.h.

int cens::CENSGraphics::m_grTimestep
protected

m_grTimestep of the graphic simulation

Definition at line 395 of file cens_graphics.h.

CENSCamera cens::CENSGraphics::m_grViewCamera
protected

main camera

Definition at line 440 of file cens_graphics.h.

Referenced by cens::CENSEngine::attachCamera().


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