Open Dynamics Engine
Classes | Functions

DrawStuff

Classes

struct  dsFunctions
 Set of functions to be used as callbacks by the simulation loop. More...

Functions

DS_API void dsSimulationLoop (int argc, char **argv, int window_width, int window_height, struct dsFunctions *fn)
 Does the complete simulation.This function starts running the simulation, and only exits when the simulation is done. Function pointers should be provided for the callbacks.
DS_API void dsError (const char *msg,...)
 exit with error message.This function displays an error message then exit.
DS_API void dsDebug (const char *msg,...)
 exit with error message and core dump.this functions tries to dump core or start the debugger.
DS_API void dsPrint (const char *msg,...)
 print log message
DS_API void dsSetViewpoint (float xyz[3], float hpr[3])
 Sets the viewpoint.
DS_API void dsGetViewpoint (float xyz[3], float hpr[3])
 Gets the viewpoint.
DS_API void dsStop ()
 Stop the simulation loop.Calling this from within dsSimulationLoop() will cause it to exit and return to the caller. it is the same as if the user used the exit command. using this outside the loop will have no effect.
DS_API double dsElapsedTime ()
 Get the elapsed time (on wall-clock)It returns the nr of seconds since the last call to this function.
DS_API void dsSetTexture (int texture_number)
 Toggle the rendering of textures.It changes the way objects are drawn. these changes will apply to all further dsDrawXXX() functions.
DS_API void dsSetColor (float red, float green, float blue)
 Set the color with which geometry is drawn.
DS_API void dsSetColorAlpha (float red, float green, float blue, float alpha)
 Set the color and transparency with which geometry is drawn.
DS_API void dsDrawBox (const float pos[3], const float R[12], const float sides[3])
 Draw a box.
DS_API void dsDrawSphere (const float pos[3], const float R[12], float radius)
 Draw a sphere.
DS_API void dsDrawTriangle (const float pos[3], const float R[12], const float *v0, const float *v1, const float *v2, int solid)
 Draw a triangle.
DS_API void dsDrawCylinder (const float pos[3], const float R[12], float length, float radius)
 Draw a z-aligned cylinder.
DS_API void dsDrawCapsule (const float pos[3], const float R[12], float length, float radius)
 Draw a z-aligned capsule.
DS_API void dsDrawLine (const float pos1[3], const float pos2[3])
 Draw a line.
DS_API void dsDrawConvex (const float pos[3], const float R[12], float *_planes, unsigned int _planecount, float *_points, unsigned int _pointcount, unsigned int *_polygons)
 Draw a convex shape.
DS_API void dsSetSphereQuality (int n)
 Set the quality with which curved objects are rendered.Higher numbers are higher quality, but slower to draw. This must be set before the first objects are drawn to be effective. Default sphere quality is 1, default capsule quality is 3.
DS_API void dsSetDrawMode (int mode)
 Set Drawmode 0=Polygon Fill,1=Wireframe). Use the DS_POLYFILL and DS_WIREFRAME macros.

Detailed Description

DrawStuff is a library for rendering simple 3D objects in a virtual environment, for the purposes of demonstrating the features of ODE. It is provided for demonstration purposes and is not intended for production use.

Notes

In the virtual world, the z axis is "up" and z=0 is the floor.

The user is able to click+drag in the main window to move the camera: left button - pan and tilt. right button - forward and sideways. left + right button (or middle button) - sideways and up.


Function Documentation

DS_API void dsDebug ( const char *  msg,
  ... 
)

exit with error message and core dump.this functions tries to dump core or start the debugger.

Parameters:
msgformat strin, like printf, without the newline character.

Referenced by dsSimulationLoop().

DS_API void dsDrawBox ( const float  pos[3],
const float  R[12],
const float  sides[3] 
)

Draw a box.

Parameters:
posis the x,y,z of the center of the object.
Ris a 3x3 rotation matrix for the object, stored by row like this: [ R11 R12 R13 0 ] [ R21 R22 R23 0 ] [ R31 R32 R33 0 ]
sides[]is an array of x,y,z side lengths.

References dsError().

DS_API void dsDrawSphere ( const float  pos[3],
const float  R[12],
float  radius 
)

Draw a sphere.

Parameters:
posPosition of center.
Rorientation.
radius

References dsError().

DS_API void dsDrawTriangle ( const float  pos[3],
const float  R[12],
const float *  v0,
const float *  v1,
const float *  v2,
int  solid 
)

Draw a triangle.

Parameters:
posPosition of center
Rorientation
v0first vertex
v1second
v2third vertex
solidset to 0 for wireframe

References dsError().

DS_API void dsError ( const char *  msg,
  ... 
)

exit with error message.This function displays an error message then exit.

Parameters:
msgformat strin, like printf, without the newline character.

Referenced by dsDrawBox(), dsDrawCapsule(), dsDrawConvex(), dsDrawCylinder(), dsDrawSphere(), dsDrawTriangle(), dsGetViewpoint(), dsSetColor(), dsSetColorAlpha(), dsSetTexture(), dsSetViewpoint(), and dsSimulationLoop().

DS_API void dsGetViewpoint ( float  xyz[3],
float  hpr[3] 
)

Gets the viewpoint.

Parameters:
xyzposition
hprheading,pitch,roll.

References dsError().

DS_API void dsPrint ( const char *  msg,
  ... 
)

print log message

Parameters:
msgformat string, like printf, without the
.
DS_API void dsSetColor ( float  red,
float  green,
float  blue 
)

Set the color with which geometry is drawn.

Parameters:
redRed component from 0 to 1
greenGreen component from 0 to 1
blueBlue component from 0 to 1

References dsError().

DS_API void dsSetColorAlpha ( float  red,
float  green,
float  blue,
float  alpha 
)

Set the color and transparency with which geometry is drawn.

Parameters:
alphaNote that alpha transparency is a misnomer: it is alpha opacity. 1.0 means fully opaque, and 0.0 means fully transparent.

References dsError().

DS_API void dsSetTexture ( int  texture_number)

Toggle the rendering of textures.It changes the way objects are drawn. these changes will apply to all further dsDrawXXX() functions.

Parameters:
thetexture number must be a DS_xxx texture constant. The current texture is colored according to the current color. At the start of each frame, the texture is reset to none and the color is reset to white.

References dsError().

DS_API void dsSetViewpoint ( float  xyz[3],
float  hpr[3] 
)

Sets the viewpoint.

Parameters:
xyzcamera position.
hprcontains heading, pitch and roll numbers in degrees. heading=0 points along the x axis, pitch=0 is looking towards the horizon, and roll 0 is "unrotated".

References dsError().

DS_API void dsSimulationLoop ( int  argc,
char **  argv,
int  window_width,
int  window_height,
struct dsFunctions fn 
)

Does the complete simulation.This function starts running the simulation, and only exits when the simulation is done. Function pointers should be provided for the callbacks.

Parameters:
argvsupports flags like '-notex' '-noshadow' '-pause'
fnCallback functions.

References dsDebug(), and dsError().