Open Dynamics Engine
|
00001 /************************************************************************* 00002 * * 00003 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * 00004 * All rights reserved. Email: russ@q12.org Web: www.q12.org * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of EITHER: * 00008 * (1) The GNU Lesser General Public License as published by the Free * 00009 * Software Foundation; either version 2.1 of the License, or (at * 00010 * your option) any later version. The text of the GNU Lesser * 00011 * General Public License is included with this library in the * 00012 * file LICENSE.TXT. * 00013 * (2) The BSD-style license that is included with this library in * 00014 * the file LICENSE-BSD.TXT. * 00015 * * 00016 * This library is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * 00019 * LICENSE.TXT and LICENSE-BSD.TXT for more details. * 00020 * * 00021 *************************************************************************/ 00022 00041 #ifndef __DRAWSTUFF_H__ 00042 #define __DRAWSTUFF_H__ 00043 00044 /* Define a DLL export symbol for those platforms that need it */ 00045 #if defined(ODE_PLATFORM_WINDOWS) 00046 #if defined(DS_DLL) 00047 #define DS_API __declspec(dllexport) 00048 #elif !defined(DS_LIB) 00049 #define DS_DLL_API __declspec(dllimport) 00050 #endif 00051 #endif 00052 00053 #if !defined(DS_API) 00054 #define DS_API 00055 #endif 00056 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 00062 #include <drawstuff/version.h> 00063 00064 00065 /* texture numbers */ 00066 enum DS_TEXTURE_NUMBER 00067 { 00068 DS_NONE = 0, /* uses the current color instead of a texture */ 00069 DS_WOOD, 00070 DS_CHECKERED, 00071 DS_GROUND, 00072 DS_SKY, 00073 }; 00074 00075 /* draw modes */ 00076 00077 #define DS_POLYFILL 0 00078 #define DS_WIREFRAME 1 00079 00085 typedef struct dsFunctions { 00086 int version; /* put DS_VERSION here */ 00087 /* version 1 data */ 00088 void (*start)(); /* called before sim loop starts */ 00089 void (*step) (int pause); /* called before every frame */ 00090 void (*command) (int cmd); /* called if a command key is pressed */ 00091 void (*stop)(); /* called after sim loop exits */ 00092 /* version 2 data */ 00093 const char *path_to_textures; /* if nonzero, path to texture files */ 00094 } dsFunctions; 00095 00096 00105 DS_API void dsSimulationLoop (int argc, char **argv, 00106 int window_width, int window_height, 00107 struct dsFunctions *fn); 00108 00115 DS_API void dsError (const char *msg, ...); 00116 00123 DS_API void dsDebug (const char *msg, ...); 00124 00130 DS_API void dsPrint (const char *msg, ...); 00131 00140 DS_API void dsSetViewpoint (float xyz[3], float hpr[3]); 00141 00142 00149 DS_API void dsGetViewpoint (float xyz[3], float hpr[3]); 00150 00159 DS_API void dsStop(); 00160 00166 DS_API double dsElapsedTime(); 00167 00178 DS_API void dsSetTexture (int texture_number); 00179 00187 DS_API void dsSetColor (float red, float green, float blue); 00188 00195 DS_API void dsSetColorAlpha (float red, float green, float blue, float alpha); 00196 00207 DS_API void dsDrawBox (const float pos[3], const float R[12], const float sides[3]); 00208 00216 DS_API void dsDrawSphere (const float pos[3], const float R[12], float radius); 00217 00228 DS_API void dsDrawTriangle (const float pos[3], const float R[12], 00229 const float *v0, const float *v1, const float *v2, int solid); 00230 00235 DS_API void dsDrawCylinder (const float pos[3], const float R[12], 00236 float length, float radius); 00237 00242 DS_API void dsDrawCapsule (const float pos[3], const float R[12], 00243 float length, float radius); 00244 00249 DS_API void dsDrawLine (const float pos1[3], const float pos2[3]); 00250 00255 DS_API void dsDrawConvex(const float pos[3], const float R[12], 00256 float *_planes, 00257 unsigned int _planecount, 00258 float *_points, 00259 unsigned int _pointcount, 00260 unsigned int *_polygons); 00261 00262 /* these drawing functions are identical to the ones above, except they take 00263 * double arrays for `pos' and `R'. 00264 */ 00265 DS_API void dsDrawBoxD (const double pos[3], const double R[12], 00266 const double sides[3]); 00267 DS_API void dsDrawSphereD (const double pos[3], const double R[12], 00268 const float radius); 00269 DS_API void dsDrawTriangleD (const double pos[3], const double R[12], 00270 const double *v0, const double *v1, const double *v2, int solid); 00271 DS_API void dsDrawCylinderD (const double pos[3], const double R[12], 00272 float length, float radius); 00273 DS_API void dsDrawCapsuleD (const double pos[3], const double R[12], 00274 float length, float radius); 00275 DS_API void dsDrawLineD (const double pos1[3], const double pos2[3]); 00276 DS_API void dsDrawConvexD(const double pos[3], const double R[12], 00277 double *_planes, 00278 unsigned int _planecount, 00279 double *_points, 00280 unsigned int _pointcount, 00281 unsigned int *_polygons); 00282 00290 DS_API void dsSetSphereQuality (int n); /* default = 1 */ 00291 DS_API void dsSetCapsuleQuality (int n); /* default = 3 */ 00292 00298 DS_API void dsSetDrawMode(int mode); 00299 00300 // Backwards compatible API 00301 #define dsDrawCappedCylinder dsDrawCapsule 00302 #define dsDrawCappedCylinderD dsDrawCapsuleD 00303 #define dsSetCappedCylinderQuality dsSetCapsuleQuality 00304 00305 /* closing bracket for extern "C" */ 00306 #ifdef __cplusplus 00307 } 00308 #endif 00309 00310 #endif 00311