- Main Page
- Modules
- Data Structures
- Files

# drawstuff.h

    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 #ifdef __cplusplus
    00045 extern "C" {
    00046 #endif
    00047
    00048
    00049 #include <drawstuff/version.h>
    00050
    00051
    00052 /* texture numbers */
    00053 #define DS_NONE   0  /* uses the current color instead of a texture */
    00054 #define DS_WOOD   1
    00055
    00056
    00062 typedef struct dsFunctions {
    00063   int version;       /* put DS_VERSION here */
    00064   /* version 1 data */
    00065   void (*start)();      /* called before sim loop starts */
    00066   void (*step) (int pause);   /* called before every frame */
    00067   void (*command) (int cmd);  /* called if a command key is pressed */
    00068   void (*stop)();    /* called after sim loop exits */
    00069   /* version 2 data */
    00070   char *path_to_textures;  /* if nonzero, path to texture files */
    00071 } dsFunctions;
    00072
    00073
    00082 void dsSimulationLoop (int argc, char **argv,
    00083              int window_width, int window_height,
    00084              struct dsFunctions *fn);
    00085
    00092 void dsError (char *msg, ...);
    00093
    00100 void dsDebug (char *msg, ...);
    00101
    00107 void dsPrint (char *msg, ...);
    00108
    00117 void dsSetViewpoint (float xyz[3], float hpr[3]);
    00118
    00119
    00126 void dsGetViewpoint (float xyz[3], float hpr[3]);
    00127
    00136 void dsStop();
    00137
    00143 double dsElapsedTime();
    00144
    00155 void dsSetTexture (int texture_number);
    00156
    00164 void dsSetColor (float red, float green, float blue);
    00165
    00172 void dsSetColorAlpha (float red, float green, float blue, float alpha);
    00173
    00184 void dsDrawBox (const float pos[3], const float R[12], const float sides[3]);
    00185
    00193 void dsDrawSphere (const float pos[3], const float R[12], float radius);
    00194
    00205 void dsDrawTriangle (const float pos[3], const float R[12],
    00206            const float *v0, const float *v1, const float *v2, int solid);
    00207
    00212 void dsDrawCylinder (const float pos[3], const float R[12],
    00213            float length, float radius);
    00214
    00219 void dsDrawCapsule (const float pos[3], const float R[12],
    00220           float length, float radius);
    00221
    00226 void dsDrawLine (const float pos1[3], const float pos2[3]);
    00227
    00232 void dsDrawConvex(const float pos[3], const float R[12],
    00233         float *_planes,
    00234         unsigned int _planecount,
    00235         float *_points,
    00236         unsigned int _pointcount,
    00237         unsigned int *_polygons);
    00238
    00239  /* these drawing functions are identical to the ones above, except they take
    00240  * double arrays for `pos' and `R'.
    00241  */
    00242 void dsDrawBoxD (const double pos[3], const double R[12],
    00243        const double sides[3]);
    00244 void dsDrawSphereD (const double pos[3], const double R[12],
    00245           const float radius);
    00246 void dsDrawTriangleD (const double pos[3], const double R[12],
    00247             const double *v0, const double *v1, const double *v2, int solid);
    00248 void dsDrawCylinderD (const double pos[3], const double R[12],
    00249             float length, float radius);
    00250 void dsDrawCapsuleD (const double pos[3], const double R[12],
    00251            float length, float radius);
    00252 void dsDrawLineD (const double pos1[3], const double pos2[3]);
    00253 void dsDrawConvexD(const double pos[3], const double R[12],
    00254         double *_planes,
    00255         unsigned int _planecount,
    00256         double *_points,
    00257         unsigned int _pointcount,
    00258         unsigned int *_polygons);
    00259
    00267 void dsSetSphereQuality (int n);    /* default = 1 */
    00268 void dsSetCapsuleQuality (int n);      /* default = 3 */
    00269
    00270 // Backwards compatible API
    00271 #define dsDrawCappedCylinder dsDrawCapsule
    00272 #define dsDrawCappedCylinderD dsDrawCapsuleD
    00273 #define dsSetCappedCylinderQuality dsSetCapsuleQuality
    00274
    00275 /* closing bracket for extern "C" */
    00276 #ifdef __cplusplus
    00277 }
    00278 #endif
    00279
    00280 #endif
    00281