From 1ec410ecd725f5a3ccb2d2fc16f48730d9d9fe43 Mon Sep 17 00:00:00 2001 From: dan miller Date: Fri, 19 Oct 2007 05:22:23 +0000 Subject: trying to fix my screwup, please hold on --- .../Mac_CFMCarbon/mac_source/CommonPrefix.h | 6 - .../contrib/Mac_CFMCarbon/mac_source/DSPrefix.h | 6 - .../contrib/Mac_CFMCarbon/mac_source/DebugPrefix.h | 10 - .../Mac_CFMCarbon/mac_source/ExamplesPrefix.h | 13 - .../Mac_CFMCarbon/mac_source/ODETestPrefix.h | 13 - .../Mac_CFMCarbon/mac_source/ReleasePrefix.h | 6 - .../mac_source/drawstuff/src/mac_glut_carbon.cpp | 281 -------------------- .../Mac_CFMCarbon/mac_source/include/GL/gl.h | 2 - .../Mac_CFMCarbon/mac_source/include/GL/glu.h | 2 - .../Mac_CFMCarbon/mac_source/include/ode/config.h | 52 ---- .../mac_source/ode/test/test_stability1.cpp | 289 --------------------- .../mac_source/ode/test/test_stacktest.c | 197 -------------- 12 files changed, 877 deletions(-) delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/CommonPrefix.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DSPrefix.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DebugPrefix.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ExamplesPrefix.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ODETestPrefix.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ReleasePrefix.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/gl.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/glu.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/ode/config.h delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stability1.cpp delete mode 100644 libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stacktest.c (limited to 'libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source') diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/CommonPrefix.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/CommonPrefix.h deleted file mode 100644 index 5948b3e..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/CommonPrefix.h +++ /dev/null @@ -1,6 +0,0 @@ -#define TARGET_API_MAC_CARBON 1 -#define finite isfinite -#define dNODEBUG 1 - -// Comment out for single precision -#define PRECISION_DOUBLE 1 \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DSPrefix.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DSPrefix.h deleted file mode 100644 index 6122528..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DSPrefix.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef prefix_h -#define prefix_h - -#include "CommonPrefix.h" - -#endif // prefix_h \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DebugPrefix.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DebugPrefix.h deleted file mode 100644 index 0e328a9..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/DebugPrefix.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef prefix_h -#define prefix_h - -#include "CommonPrefix.h" - -#ifdef dNODEBUG -#undef dNODEBUG -#endif - -#endif // prefix_h \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ExamplesPrefix.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ExamplesPrefix.h deleted file mode 100644 index 1dedfc9..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ExamplesPrefix.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef prefix_h -#define prefix_h - -#include "CommonPrefix.h" - -// Hack to automatically call SIOUX's CLI interface for the test apps -#include -#include -int fmain (int argc, char **argv); -int main (int argc, char **argv) { argc = ccommand(&argv); return fmain(argc, argv); } -#define main(argc, argv) fmain(argc, argv) - -#endif // prefix_h \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ODETestPrefix.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ODETestPrefix.h deleted file mode 100644 index f8f5022..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ODETestPrefix.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef prefix_h -#define prefix_h - -#include "CommonPrefix.h" - -// Hack to automatically call SIOUX's CLI interface for the test apps -#include -#include -int fmain (); -int main (int argc, char **argv) { argc = ccommand(&argv); return fmain(); } -#define main() fmain() - -#endif // prefix_h \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ReleasePrefix.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ReleasePrefix.h deleted file mode 100644 index 6122528..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ReleasePrefix.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef prefix_h -#define prefix_h - -#include "CommonPrefix.h" - -#endif // prefix_h \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp deleted file mode 100644 index eb0b144..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/************************************************************************* - * * - * DrawStuff Library, Copyright (C) 2001 Russell L. Smith. * - * Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with this library (see the file LICENSE.TXT); if not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307 USA. * - * * - *************************************************************************/ - -// main window and event handling for Mac CFM Carbon - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include "internal.h" - - -//*************************************************************************** -// error handling for unix (works just fine with SIOUX) - -static void printMessage (char *msg1, char *msg2, va_list ap) -{ - fflush (stderr); - fflush (stdout); - fprintf (stderr,"\n%s: ",msg1); - vfprintf (stderr,msg2,ap); - fprintf (stderr,"\n"); - fflush (stderr); -} - -extern "C" void dsError (char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - printMessage ("Error",msg,ap); - exit (1); -} - - -extern "C" void dsDebug (char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - printMessage ("INTERNAL ERROR",msg,ap); - // *((char *)0) = 0; ... commit SEGVicide ? - abort(); -} - -extern "C" void dsPrint (char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - vprintf (msg,ap); -} - -//*************************************************************************** -// openGL window - -// window and openGL -static int width=0,height=0; // window size -static int last_key_pressed=0; // last key pressed in the window -static int pause=0; // 1 if in `pause' mode -static int singlestep=0; // 1 if single step key pressed -static int writeframes=0; // 1 if frame files to be written -static dsFunctions *gfn; -static int frame = 1; - -float getTime (void) -{ - UnsignedWide ms; - - Microseconds(&ms); - return ms.lo / 1000000.0; -} - - -static void captureFrame (int num) -{ -// TODO -} - -static void reshape(int w, int h) -{ - width = w; - height = h; -} - -static void draw(void) -{ - dsDrawFrame (width,height,gfn,pause && !singlestep); - singlestep = 0; - glutSwapBuffers(); - - if (pause==0 && writeframes) { - captureFrame (frame); - frame++; - } -} - -static void idle(void) -{ - static float lasttime=0; - float t; - - // Try to maintain a reasonable rate (good enough for testing anyway) - t = getTime(); - if (lasttime < t) { - lasttime = t+0.005; - draw(); - } -} - -static void key(unsigned char key, int x, int y) -{ - if (!glutGetModifiers()) { - - if (key >= ' ' && key <= 126 && gfn->command) gfn->command (key); - - // GLUT_ACTIVE_CTRL doesn't seem to be working, so we use Alt - } else if (glutGetModifiers()&GLUT_ACTIVE_ALT) { - - switch (key) { - case 't': case 'T': - dsSetTextures (dsGetTextures() ^ 1); - break; - case 's': case 'S': - dsSetShadows (dsGetShadows() ^ 1); - break; - case 'p': case 'P': - pause ^= 1; - singlestep = 0; - break; - case 'o': case 'O': - if (pause) singlestep = 1; - break; - case 'v': case 'V': { - float xyz[3],hpr[3]; - dsGetViewpoint (xyz,hpr); - printf ("Viewpoint = (%.4f,%.4f,%.4f,%.4f,%.4f,%.4f)\n", - xyz[0],xyz[1],xyz[2],hpr[0],hpr[1],hpr[2]); - break; - } - // No case 'X' - Quit works through the Mac system menu, or cmd-q - case 'w': case 'W': - writeframes ^= 1; - if (writeframes) printf ("Write frames not done yet!\n");// TODO - break; - } - } - - last_key_pressed = key; -} - -static int mx=0,my=0; // mouse position -static int mode = 0; // mouse button bits - -static void MouseDown(int button, int state, int x, int y) -{ - if(button == GLUT_LEFT_BUTTON) - { - if(state == GLUT_DOWN) - mode |= 1; - else if(state == GLUT_UP) - mode &= (~1); - } - else if (button == GLUT_MIDDLE_BUTTON) - { - if(state == GLUT_DOWN) - mode |= 3; - else if(state == GLUT_UP) - mode &= (~3); - } - else if (button == GLUT_RIGHT_BUTTON) - { - if(state == GLUT_DOWN) - mode |= 2; - else if(state == GLUT_UP) - mode &= (~2); - } - - mx = x; - my = y; -} - -static void MouseMove(int x, int y) -{ - dsMotion (mode, x - mx, y - my); - mx = x; - my = y; -} - -static void createMainWindow (int _width, int _height) -{ - // So GLUT doesn't complain - int argc = 0; - char **argv = NULL; - - // initialize variables - width = _width; - height = _height; - last_key_pressed = 0; - - if (width < 1 || height < 1) dsDebug (0,"bad window width or height"); - - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(_width, _height); - glutInitWindowPosition(100, 100); - glutCreateWindow("ODE Simulation"); - - glutKeyboardFunc(key); - glutMotionFunc(MouseMove); - glutMouseFunc(MouseDown); - glutReshapeFunc(reshape); - glutDisplayFunc(idle); - glutIdleFunc(idle); -} - -void dsPlatformSimLoop (int window_width, int window_height, dsFunctions *fn, - int initial_pause) -{ - SIOUXSettings.initializeTB = false; - SIOUXSettings.standalone = false; - SIOUXSettings.setupmenus = false; - SIOUXSettings.autocloseonquit = true; - SIOUXSettings.asktosaveonclose = false; - - gfn = fn; - pause = initial_pause; - - printf ( - "\n" - "Simulation test environment v%d.%02d\n" - " Option-P : pause / unpause (or say `-pause' on command line).\n" - " Option-O : single step when paused.\n" - " Option-T : toggle textures (or say `-notex' on command line).\n" - " Option-S : toggle shadows (or say `-noshadow' on command line).\n" - " Option-V : print current viewpoint coordinates (x,y,z,h,p,r).\n" - " Option-W : write frames to ppm files: frame/frameNNN.ppm\n" - "\n" - "Change the camera position by clicking + dragging in the window.\n" - " Left button - pan and tilt.\n" - " Right button - forward and sideways.\n" - " Left + Right button (or middle button) - sideways and up.\n" - "\n",DS_VERSION >> 8,DS_VERSION & 0xff); - - createMainWindow (window_width, window_height); - dsStartGraphics (window_width,window_height,fn); - - if (fn->start) fn->start(); - - glutMainLoop(); - - if (fn->stop) fn->stop(); - dsStopGraphics(); -} - -extern "C" void dsStop(){ }// GLUT/MSL hooks into the system to exit diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/gl.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/gl.h deleted file mode 100644 index 4acaeed..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/gl.h +++ /dev/null @@ -1,2 +0,0 @@ -// A little hackaround (Apple use / in the FILENAME, which doesn't work when following DOS paths) -#include \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/glu.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/glu.h deleted file mode 100644 index 5b4a791..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/GL/glu.h +++ /dev/null @@ -1,2 +0,0 @@ -// A little hackaround (Apple use / in the FILENAME, which doesn't work when following DOS paths) -#include \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/ode/config.h b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/ode/config.h deleted file mode 100644 index bb889f9..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/include/ode/config.h +++ /dev/null @@ -1,52 +0,0 @@ -/* This file has been manually hacked together for the Mac CFM Carbon build - Frank. */ - -#ifndef _ODE_CONFIG_H_ -#define _ODE_CONFIG_H_ - -/* standard system headers */ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* #define PENTIUM 1 -- not a pentium */ - -/* integer types (we assume int >= 32 bits) */ -typedef char int8; -typedef unsigned char uint8; -typedef int int32; -typedef unsigned int uint32; - -/* an integer type that we can safely cast a pointer to and from without loss of bits. */ -typedef unsigned int intP; - -#ifdef PRECISION_DOUBLE - - /*select the base floating point type*/ - #define dDOUBLE 1 - - /* the floating point infinity */ - #define dInfinity DBL_MAX - -#else - - /* select the base floating point type */ - #define dSINGLE 1 - - /* the floating point infinity */ - #define dInfinity FLT_MAX - -#endif - -#ifdef __cplusplus -} -#endif -#endif \ No newline at end of file diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stability1.cpp b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stability1.cpp deleted file mode 100644 index 79c066a..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stability1.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include -#include - -#ifdef _MSC_VER -#pragma warning(disable:4244 4305) // for VC++, no precision loss complaints -#endif - -// select correct drawing functions - -#ifdef dDOUBLE -#define dsDrawBox dsDrawBoxD -#define dsDrawSphere dsDrawSphereD -#define dsDrawCylinder dsDrawCylinderD -#define dsDrawCappedCylinder dsDrawCappedCylinderD -#endif - - -// some constants - -#define DENSITY (5.0) // density of all objects - -// dynamics and collision objects - -struct MyObject { - dBodyID body; // the body - dGeomID geom; // geometry representing this body -}; - -static dWorldID world; -static dSpaceID space; -static MyObject fallingObject; -static dGeomID box1, box2; -static dJointGroupID contactgroup; - - -// this is called by dSpaceCollide when two objects in space are -// potentially colliding. - -static void nearCallback (void *data, dGeomID o1, dGeomID o2) -{ - int i; - // if (o1->body && o2->body) return; - - // exit without doing anything if the two bodies are connected by a joint - dBodyID b1 = dGeomGetBody(o1); - dBodyID b2 = dGeomGetBody(o2); - if (b1 && b2 && dAreConnected (b1,b2)) return; - - dContact contact[4]; // up to 3 contacts per box - for (i=0; i<4; i++) { - contact[i].surface.mode = dContactBounce; //dContactMu2; - contact[i].surface.mu = dInfinity; - contact[i].surface.mu2 = 0; - contact[i].surface.bounce = 0.5; - contact[i].surface.bounce_vel = 0.1; - } - if (int numc = dCollide (o1,o2,4,&contact[0].geom,sizeof(dContact))) { - // dMatrix3 RI; - // dRSetIdentity (RI); - // const dReal ss[3] = {0.02,0.02,0.02}; - for (i=0; i= 'A' && c <= 'Z') return c - ('a'-'A'); - else return c; -} - - -// called when a key pressed - -static void command (int cmd) -{ - int i,k; - dReal sides[3]; - dMass m; - - cmd = locase (cmd); - if (cmd == 'b' || cmd == 's' || cmd == 'c') { - // Destroy the currently falling object and replace it by an instance of the requested type - if (fallingObject.body) { - dBodyDestroy (fallingObject.body); - dGeomDestroy (fallingObject.geom); - memset (&fallingObject, 0, sizeof(fallingObject)); - } - - fallingObject.body = dBodyCreate (world); - for (k=0; k<3; k++) sides[k] = dRandReal()*0.5+0.1; - - // Start out centered above the V-gap - dBodySetPosition (fallingObject.body, 0,0,5); - -#if 0 - dMatrix3 R; - dRFromAxisAndAngle (R,dRandReal()*2.0-1.0,dRandReal()*2.0-1.0, - dRandReal()*2.0-1.0,dRandReal()*10.0-5.0); - dBodySetRotation (fallingObject.body,R); - dBodySetData (fallingObject.body,(void*) i); -#endif - - if (cmd == 'b') { - dMassSetBox (&m,DENSITY,sides[0],sides[1],sides[2]); - fallingObject.geom = dCreateBox (space,sides[0],sides[1],sides[2]); - } - else if (cmd == 'c') { - sides[0] *= 0.5; - dMassSetCappedCylinder (&m,DENSITY,3,sides[0],sides[1]); - fallingObject.geom = dCreateCCylinder (space,sides[0],sides[1]); - } - else if (cmd == 's') { - sides[0] *= 0.5; - dMassSetSphere (&m,DENSITY,sides[0]); - fallingObject.geom = dCreateSphere (space,sides[0]); - } - - dGeomSetBody (fallingObject.geom,fallingObject.body); - - dBodySetMass (fallingObject.body,&m); - } -} - - -// draw a geom - -void drawGeom (dGeomID g, const dReal *pos, const dReal *R) -{ - if (!g) return; - if (!pos) pos = dGeomGetPosition (g); - if (!R) R = dGeomGetRotation (g); - - int type = dGeomGetClass (g); - if (type == dBoxClass) { - dVector3 sides; - dGeomBoxGetLengths (g,sides); - dsDrawBox (pos,R,sides); - } - else if (type == dSphereClass) { - dsDrawSphere (pos,R,dGeomSphereGetRadius (g)); - } - else if (type == dCCylinderClass) { - dReal radius,length; - dGeomCCylinderGetParams (g,&radius,&length); - dsDrawCappedCylinder (pos,R,length,radius); - } - /* - else if (type == dGeomTransformClass) { - dGeomID g2 = dGeomTransformGetGeom (g); - const dReal *pos2 = dGeomGetPosition (g2); - const dReal *R2 = dGeomGetRotation (g2); - dVector3 actual_pos; - dMatrix3 actual_R; - dMULTIPLY0_331 (actual_pos,R,pos2); - actual_pos[0] += pos[0]; - actual_pos[1] += pos[1]; - actual_pos[2] += pos[2]; - dMULTIPLY0_333 (actual_R,R,R2); - drawGeom (g2,actual_pos,actual_R); - } - */ -} - - -// simulation loop - -static void simLoop (int pause) -{ - dsSetColor (0,0,2); - dSpaceCollide (space,0,&nearCallback); - if (!pause) dWorldStep (world,0.0005); - - // remove all contact joints - dJointGroupEmpty (contactgroup); - - dsSetColor (1,1,0); - dsSetTexture (DS_WOOD); - - // draw the falling object - dsSetColor (1,0,0); - drawGeom (fallingObject.geom,0,0); - - // draw the constraining boxes - dsSetColor(0.8, 1, 0.8); - drawGeom (box1,0,0); - drawGeom (box2,0,0); -} - - -int main (int argc, char **argv) -{ - // setup pointers to drawstuff callback functions - dsFunctions fn; - fn.version = DS_VERSION; - fn.start = &start; - fn.step = &simLoop; - fn.command = &command; - fn.stop = 0; - fn.path_to_textures = "../../drawstuff/textures"; - if(argc==2) - { - fn.path_to_textures = argv[1]; - } - - // create world - - world = dWorldCreate(); - space = dHashSpaceCreate(); - contactgroup = dJointGroupCreate (0); - dWorldSetGravity (world,0,0,-0.5); - dWorldSetCFM (world,1e-5); - dCreatePlane (space,0,0,1,0); - memset (&fallingObject,0,sizeof(fallingObject)); - - // Create two flat boxes, just slightly off vertical and a bit apart for stuff to fall in between. - // Don't create bodies for these boxes -- they'll be immovable instead. - { - dReal sides[3]; - dMatrix3 R; - - sides[0] = 4; - sides[1] = 0.2; - sides[2] = 3; - - box1 = dCreateBox (space,sides[0],sides[1],sides[2]); - dGeomSetPosition (box1, 0, sides[1], sides[2]/2); - dRFromAxisAndAngle (R, 1, 0, 0, -0.1); - dGeomSetRotation (box1, R); - - box2 = dCreateBox (space,sides[0],sides[1],sides[2]); - dGeomSetPosition (box2, 0, -sides[1], sides[2]/2); - dRFromAxisAndAngle (R, 1, 0, 0, 0.1); - dGeomSetRotation (box2, R); - } - - // Pretend to drop a box to start - command('b'); - - // run simulation - dsSimulationLoop (argc,argv,640,480,&fn); - - dJointGroupDestroy (contactgroup); - dSpaceDestroy (space); - dWorldDestroy (world); - - return 0; -} diff --git a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stacktest.c b/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stacktest.c deleted file mode 100644 index e49fd73..0000000 --- a/libraries/ode-0.9/contrib/Mac_CFMCarbon/mac_source/ode/test/test_stacktest.c +++ /dev/null @@ -1,197 +0,0 @@ -#include -#include -#include "ode.h" - -#define NUMBODIES 80 - -#define USE_SPHERE 0 -#define USE_HELIX 1 -#define USE_TORQUE 1 -#define USE_WEIRD_MATRIX_OPS 0 - -#define CONTACTS 1 - -dWorldID aWorld; -dSpaceID aSpace; -float cycle = 0, fade; -dJointGroupID aContactGroup; -dBodyID bodies[NUMBODIES]; -dGeomID geoms[NUMBODIES]; -GLfloat colors[NUMBODIES][4]; -unsigned int contactsThisFrame; - -void kglTransformByODEGeom(dGeomID geom) { - const dReal *p = dGeomGetPosition(geom); - const dReal *R = dGeomGetRotation(geom); - GLdouble glm[16]; - - glm[0] = R[0]; glm[1] = R[4]; glm[2] = R[8]; glm[3] = 0; - glm[4] = R[1]; glm[5] = R[5]; glm[6] = R[9]; glm[7] = 0; - glm[8] = R[2]; glm[9] = R[6]; glm[10] = R[10];glm[11] = 0; - glm[12] = p[0]; glm[13] = p[1]; glm[14] = p[2]; glm[15] = 1; - - glMultMatrixd(glm); -} - -static void odeNearCallback(void *data, dGeomID g1, dGeomID g2) { - dBodyID b1 = dGeomGetBody(g1), - b2 = dGeomGetBody(g2); - dContact contact[CONTACTS]; - int contactsUsed, i; - - if (b1 && b2 && dAreConnected(b1, b2)) return; - - contactsUsed = dCollide(g1, g2, CONTACTS, &contact[0].geom, - sizeof(dContact)); - if (contactsUsed > CONTACTS) contactsUsed = CONTACTS; - - for (i = 0; i < contactsUsed; i++) { - contact[i].surface.mode = 0; - contact[i].surface.mu = 20.0; - - dJointAttach(dJointCreateContact(aWorld, aContactGroup, - &(contact[i])), b1, b2); - contactsThisFrame++; - } -} - -void myGlutResize(int w, int h) { - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0, (GLfloat)w / h, 1.0, 120.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0, -6, -20); -} - -void myGlutIdle(void) { - const float step = 1.0/120; - int i; - - cycle = fmod(cycle + step / 4, 1); - fade = fabs(cycle * 2 - 1); - - contactsThisFrame = 0; - dSpaceCollide(aSpace, NULL, &odeNearCallback); - //printf("%u\n", contactsThisFrame); - dWorldStep(aWorld, step); - dJointGroupEmpty(aContactGroup); - - for (i = 0; i < NUMBODIES; i++) { - const dReal *cvel = dBodyGetLinearVel(bodies[i]); - dBodyAddForce(bodies[i], - -cvel[0] * 0.5, - -cvel[1] * 0.5, - -cvel[2] * 0.5 - ); - } - - glutPostRedisplay(); -} - -void myGlutDisplay(void) { - int i; - - glClearColor(fade * 0.15, 0, 0, 1); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (USE_WEIRD_MATRIX_OPS) glPushMatrix(); - for (i = 0; i < NUMBODIES; i++) { - if (!USE_WEIRD_MATRIX_OPS) glPushMatrix(); - kglTransformByODEGeom(geoms[i]); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colors[i]); - glColor3f(fade * 1.5, 0, 0); -#if USE_SPHERE - glRotatef(90, 1, 0, 0); - glutSolidSphere(0.5, 9, 6); - glDisable(GL_LIGHTING); - glutWireSphere(0.5, 9, 6); -#else - glutSolidCube(1); - glDisable(GL_LIGHTING); - glutWireCube(1); -#endif - glEnable(GL_LIGHTING); - if (!USE_WEIRD_MATRIX_OPS) glPopMatrix(); - } - if (USE_WEIRD_MATRIX_OPS) glPopMatrix(); - - glutSwapBuffers(); -} - -int main(int argc, char **argv) { - printf("Initializing GLUT\n"); - - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize(400, 300); - glutInitWindowPosition(100, 100); - glutCreateWindow("ODE Crash Test"); - - glutDisplayFunc(myGlutDisplay); - glutReshapeFunc(myGlutResize); - glutIdleFunc(myGlutIdle); - - glPolygonOffset(1, 1); - glDepthFunc(GL_LEQUAL); - glEnable(GL_POLYGON_OFFSET_FILL); - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - myGlutResize(400, 300); - - printf("Creating ODE world\n"); - aWorld = dWorldCreate(); - aSpace = dHashSpaceCreate(); - aContactGroup = dJointGroupCreate(0); - dCreatePlane(aSpace, 0, 1, 0, 0); - dWorldSetGravity(aWorld, 0, -9.81, 0); - dWorldSetERP(aWorld, 0.4); - dWorldSetCFM(aWorld, 1e-10); - - printf("Creating objects\n"); - { - int i; - dMass mass; - - dMassSetBox(&mass, 1.0, 1, 1, 1); - - for (i = 0; i < NUMBODIES; i++) { - float fraction = (float)i / NUMBODIES; - - bodies[i] = dBodyCreate(aWorld); - dBodySetMass(bodies[i], &mass); -#if USE_SPHERE - geoms[i] = dCreateSphere(aSpace, 0.5); -#else - geoms[i] = dCreateBox(aSpace, 1, 1, 1); -#endif - dGeomSetBody(geoms[i], bodies[i]); - - if (USE_HELIX) { - float r = (i % 3 - 1) * (1.5+4*(1 - fraction)), - theta = (float)i / 4; - dBodySetPosition(bodies[i], - sin(theta) * r, - (float)i + 1, - cos(theta) * r - ); - } else { - dBodySetPosition(bodies[i], 0, (float)i * 2 + 1, 0); - } - if (USE_TORQUE) dBodyAddTorque(bodies[i], fraction*10, fraction*20, fraction*30); - - colors[i][0] = fraction; - colors[i][1] = 1 - fraction; - colors[i][2] = 1 - fabs(fraction * 2 - 1); - colors[i][3] = 1; - } - } - - printf("Starting simulation\n"); - glutMainLoop(); - - return 0; -} \ No newline at end of file -- cgit v1.1