Open Dynamics Engine
drawstuff.h
1 /*************************************************************************
2  * *
3  * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
4  * All rights reserved. Email: russ@q12.org Web: www.q12.org *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of EITHER: *
8  * (1) The GNU Lesser General Public License as published by the Free *
9  * Software Foundation; either version 2.1 of the License, or (at *
10  * your option) any later version. The text of the GNU Lesser *
11  * General Public License is included with this library in the *
12  * file LICENSE.TXT. *
13  * (2) The BSD-style license that is included with this library in *
14  * the file LICENSE-BSD.TXT. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19  * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
20  * *
21  *************************************************************************/
22 
41 #ifndef __DRAWSTUFF_H__
42 #define __DRAWSTUFF_H__
43 
44 /* Define a DLL export symbol for those platforms that need it */
45 #if defined(ODE_PLATFORM_WINDOWS)
46  #if defined(DS_DLL)
47  #define DS_API __declspec(dllexport)
48  #elif !defined(DS_LIB)
49  #define DS_DLL_API __declspec(dllimport)
50  #endif
51 #endif
52 
53 #if !defined(DS_API)
54  #define DS_API
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
62 #include <drawstuff/version.h>
63 
64 
65 /* texture numbers */
66  enum DS_TEXTURE_NUMBER
67  {
68  DS_NONE = 0, /* uses the current color instead of a texture */
69  DS_WOOD,
70  DS_CHECKERED,
71  DS_GROUND,
72  DS_SKY
73  };
74 
75 /* draw modes */
76 
77 #define DS_POLYFILL 0
78 #define DS_WIREFRAME 1
79 
85 typedef struct dsFunctions {
86  int version; /* put DS_VERSION here */
87  /* version 1 data */
88  void (*start)(); /* called before sim loop starts */
89  void (*step) (int pause); /* called before every frame */
90  void (*command) (int cmd); /* called if a command key is pressed */
91  void (*stop)(); /* called after sim loop exits */
92  /* version 2 data */
93  const char *path_to_textures; /* if nonzero, path to texture files */
94 } dsFunctions;
95 
96 
105 DS_API void dsSimulationLoop (int argc, char **argv,
106  int window_width, int window_height,
107  struct dsFunctions *fn);
108 
115 DS_API void dsError (const char *msg, ...);
116 
123 DS_API void dsDebug (const char *msg, ...);
124 
130 DS_API void dsPrint (const char *msg, ...);
131 
140 DS_API void dsSetViewpoint (float xyz[3], float hpr[3]);
141 
142 
149 DS_API void dsGetViewpoint (float xyz[3], float hpr[3]);
150 
159 DS_API void dsStop();
160 
166 DS_API double dsElapsedTime();
167 
178 DS_API void dsSetTexture (int texture_number);
179 
187 DS_API void dsSetColor (float red, float green, float blue);
188 
195 DS_API void dsSetColorAlpha (float red, float green, float blue, float alpha);
196 
207 DS_API void dsDrawBox (const float pos[3], const float R[12], const float sides[3]);
208 
216 DS_API void dsDrawSphere (const float pos[3], const float R[12], float radius);
217 
228 DS_API void dsDrawTriangle (const float pos[3], const float R[12],
229  const float *v0, const float *v1, const float *v2, int solid);
230 
235 DS_API void dsDrawCylinder (const float pos[3], const float R[12],
236  float length, float radius);
237 
242 DS_API void dsDrawCapsule (const float pos[3], const float R[12],
243  float length, float radius);
244 
249 DS_API void dsDrawLine (const float pos1[3], const float pos2[3]);
250 
255 DS_API void dsDrawConvex(const float pos[3], const float R[12],
256  float *_planes,
257  unsigned int _planecount,
258  float *_points,
259  unsigned int _pointcount,
260  unsigned int *_polygons);
261 
262  /* these drawing functions are identical to the ones above, except they take
263  * double arrays for `pos' and `R'.
264  */
265 DS_API void dsDrawBoxD (const double pos[3], const double R[12],
266  const double sides[3]);
267 DS_API void dsDrawSphereD (const double pos[3], const double R[12],
268  const float radius);
269 DS_API void dsDrawTriangleD (const double pos[3], const double R[12],
270  const double *v0, const double *v1, const double *v2, int solid);
271 DS_API void dsDrawCylinderD (const double pos[3], const double R[12],
272  float length, float radius);
273 DS_API void dsDrawCapsuleD (const double pos[3], const double R[12],
274  float length, float radius);
275 DS_API void dsDrawLineD (const double pos1[3], const double pos2[3]);
276 DS_API void dsDrawConvexD(const double pos[3], const double R[12],
277  double *_planes,
278  unsigned int _planecount,
279  double *_points,
280  unsigned int _pointcount,
281  unsigned int *_polygons);
282 
290 DS_API void dsSetSphereQuality (int n); /* default = 1 */
291 DS_API void dsSetCapsuleQuality (int n); /* default = 3 */
292 
298 DS_API void dsSetDrawMode(int mode);
299 
300 /* Backwards compatible API */
301 #define dsDrawCappedCylinder dsDrawCapsule
302 #define dsDrawCappedCylinderD dsDrawCapsuleD
303 #define dsSetCappedCylinderQuality dsSetCapsuleQuality
304 
305 /* closing bracket for extern "C" */
306 #ifdef __cplusplus
307 }
308 #endif
309 
310 #endif
311 
DS_API void dsDrawSphere(const float pos[3], const float R[12], float radius)
Draw a sphere.
Definition: drawstuff.cpp:1405
DS_API void dsPrint(const char *msg,...)
print log message
Definition: osx.cpp:97
DS_API void dsDrawCylinder(const float pos[3], const float R[12], float length, float radius)
Draw a z-aligned cylinder.
Definition: drawstuff.cpp:1454
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.
Definition: drawstuff.cpp:1381
DS_API void dsError(const char *msg,...)
exit with error message.This function displays an error message then exit.
Definition: osx.cpp:77
DS_API void dsSetViewpoint(float xyz[3], float hpr[3])
Sets the viewpoint.
Definition: drawstuff.cpp:1299
DS_API void dsDrawCapsule(const float pos[3], const float R[12], float length, float radius)
Draw a z-aligned capsule.
Definition: drawstuff.cpp:1476
DS_API void dsDrawLine(const float pos1[3], const float pos2[3])
Draw a line.
Definition: drawstuff.cpp:1510
DS_API void dsGetViewpoint(float xyz[3], float hpr[3])
Gets the viewpoint.
Definition: drawstuff.cpp:1316
DS_API void dsDrawBox(const float pos[3], const float R[12], const float sides[3])
Draw a box.
Definition: drawstuff.cpp:1360
DS_API void dsSetDrawMode(int mode)
Set Drawmode 0=Polygon Fill,1=Wireframe). Use the DS_POLYFILL and DS_WIREFRAME macros.
Definition: drawstuff.cpp:1632
DS_API void dsSetColor(float red, float green, float blue)
Set the color with which geometry is drawn.
Definition: drawstuff.cpp:1339
DS_API void dsSetTexture(int texture_number)
Toggle the rendering of textures.It changes the way objects are drawn. these changes will apply to al...
Definition: drawstuff.cpp:1332
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 sim...
Definition: drawstuff.cpp:1270
DS_API void dsDebug(const char *msg,...)
exit with error message and core dump.this functions tries to dump core or start the debugger...
Definition: osx.cpp:87
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.
Definition: drawstuff.cpp:1621
DS_API double dsElapsedTime()
Get the elapsed time (on wall-clock)It returns the nr of seconds since the last call to this function...
Definition: osx.cpp:127
Set of functions to be used as callbacks by the simulation loop.
Definition: drawstuff.h:85
DS_API void dsSetColorAlpha(float red, float green, float blue, float alpha)
Set the color and transparency with which geometry is drawn.
Definition: drawstuff.cpp:1349
DS_API void dsStop()
Stop the simulation loop.Calling this from within dsSimulationLoop() will cause it to exit and return...
Definition: osx.cpp:123
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.
Definition: drawstuff.cpp:1441