Defines.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Physics Abstraction Layer                                        *
00004  * Copyright (C) 2004-2005                                               *
00005  * Alan Fischer  alan.fischer@gmail.com                                  *
00006  * Andres Reinot  andres@reinot.com                                      *
00007  * Tyler Streeter  tylerstreeter@gmail.com                               *
00008  * All rights reserved.                                                  *
00009  * Web: opal.sourceforge.net                                             *
00010  *                                                                       *
00011  * This library is free software; you can redistribute it and/or         *
00012  * modify it under the terms of EITHER:                                  *
00013  *   (1) The GNU Lesser General Public License as published by the Free  *
00014  *       Software Foundation; either version 2.1 of the License, or (at  *
00015  *       your option) any later version. The text of the GNU Lesser      *
00016  *       General Public License is included with this library in the     *
00017  *       file license-LGPL.txt.                                          *
00018  *   (2) The BSD-style license that is included with this library in     *
00019  *       the file license-BSD.txt.                                       *
00020  *                                                                       *
00021  * This library is distributed in the hope that it will be useful,       *
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024  * license-LGPL.txt and license-BSD.txt for more details.                *
00025  *                                                                       *
00026  *************************************************************************/
00027 
00028 #ifndef OPAL_DEFINES_H
00029 #define OPAL_DEFINES_H
00030 
00031 // Put this here for now.  They seem to nail all the really annoying and
00032 // useless VC6 warning: 4786, Debug info too long
00033 #if defined(WIN32) || defined(_WIN32)
00034         #pragma warning(disable:4786)
00035 #endif
00036 
00037 #include <iostream>
00038 #include <vector>
00039 #include <map>
00040 #include <string>
00041 #include <assert.h>
00042 #include "OpalMath.h"
00043 #include "Portability.h"
00044 #include "Logger.h"
00045 #include "Vec3r.h"
00046 #include "Point3r.h"
00047 
00049 namespace opal
00050 {
00051         class Solid;
00052         class Joint;
00053 
00056         enum ForceType
00057         {
00060                 LOCAL_FORCE,
00061 
00064                 GLOBAL_FORCE,
00065 
00068                 LOCAL_TORQUE,
00069 
00072                 GLOBAL_TORQUE,
00073 
00077                 LOCAL_FORCE_AT_LOCAL_POS,
00078 
00082                 LOCAL_FORCE_AT_GLOBAL_POS,
00083 
00087                 GLOBAL_FORCE_AT_LOCAL_POS,
00088 
00092                 GLOBAL_FORCE_AT_GLOBAL_POS
00093         };
00094 
00097         struct Force
00098         {
00099                 Force()
00100                 {
00101                         type = LOCAL_FORCE;
00102                         duration = 0;
00103                         singleStep = false;
00104                         // "vec" is initialized in its own constructor.
00105                         // "pos" is initialized in its own constructor.
00106                 }
00107 
00109                 ForceType type;
00110 
00114                 real duration;
00115 
00119                 bool singleStep;
00120 
00123                 Vec3r vec;
00124 
00127                 Point3r pos;
00128         };
00129 
00132         struct Material
00133         {
00134                 Material(real h, real f, real b, real d)
00135                 {
00136                         //assert(h >= 0.0 && h <= 1.0);
00137                         //assert(f >= 0.0 && f <= 1.0);
00138                         //assert(b >= 0.0 && b <= 1.0);
00139                         //assert(d >= 0.0);
00140 
00141                         hardness = h;
00142                         friction = f;
00143                         bounciness = b;
00144                         density = d;
00145                 }
00146 
00147                 Material()
00148                 {
00149                         hardness = (real)0.5;
00150                         friction = (real)0.5;
00151                         bounciness = (real)0.5;
00152                         density = (real)0.5;
00153                 }
00154 
00157                 real hardness;
00158 
00160                 real friction;
00161 
00167                 real bounciness;
00168 
00171                 real density;
00172         };
00173 
00177         enum SolverAccuracyLevel
00178         {
00179                 SOLVER_ACCURACY_VERY_LOW,
00180                 SOLVER_ACCURACY_LOW,
00181                 SOLVER_ACCURACY_MEDIUM,
00182                 SOLVER_ACCURACY_HIGH,
00183                 SOLVER_ACCURACY_VERY_HIGH
00184         };
00185 
00188         enum JointBreakMode
00189         {
00191                 UNBREAKABLE_MODE,
00192 
00194                 THRESHOLD_MODE,
00195 
00197                 ACCUMULATED_MODE
00198         };
00199 
00201         enum JointType
00202         {
00207                 HINGE_JOINT,
00208 
00213                 UNIVERSAL_JOINT,
00214 
00219                 BALL_JOINT,
00220 
00225                 SLIDER_JOINT,
00226 
00231                 WHEEL_JOINT,
00232 
00237                 FIXED_JOINT
00238         };
00239 
00241         namespace globals
00242         {
00245                 const unsigned int maxMaxContacts = 128;
00246 
00247                 // Pre-defined material settings
00248                 const real metalHardness = (real)1.0;
00249                 const real metalFriction = (real)0.7;
00250                 const real metalBounciness = (real)0.05;
00251                 const real metalDensity = (real)1.0;
00252 
00253                 //NOTE: Max and mix friction settings result in faster calculations.
00254                 const real woodHardness = (real)0.8;
00255                 const real woodFriction = (real)1.0;
00256                 const real woodBounciness = (real)0.15;
00257                 const real woodDensity = (real)0.2;
00258 
00259                 const real rubberHardness = 0;
00260                 const real rubberFriction = (real)1.0;
00261                 const real rubberBounciness = (real)1.0;
00262                 const real rubberDensity = (real)0.4;
00263 
00264                 const real iceHardness = (real)1.0;
00265                 const real iceFriction = 0;
00266                 const real iceBounciness = (real)0.05;
00267                 const real iceDensity = (real)0.25;
00268 
00269                 // Global materials
00270                 const Material metalMaterial(metalHardness, metalFriction,
00271                         metalBounciness, metalDensity);
00272                 const Material woodMaterial(woodHardness, woodFriction,
00273                         woodBounciness, woodDensity);
00274                 const Material rubberMaterial(rubberHardness, rubberFriction,
00275                         rubberBounciness, rubberDensity);
00276                 const Material iceMaterial(iceHardness, iceFriction,
00277                         iceBounciness, iceDensity);
00278         }
00279 
00281         namespace defaults
00282         {
00283                 const real stepSize = (real)0.0167; // ~60 Hz physics update rate.
00284                 const Vec3r gravity(0, 0, 0);
00285                 const real bounceThreshold = (real)1.0;
00286                 const SolverAccuracyLevel solverAccuracy = SOLVER_ACCURACY_MEDIUM;
00287                 //const bool allowPartialFrames=true;
00288                 //const int maxStepsPerFrame=10;
00289                 //const real maxLinearVel = (real)10000.0;
00290                 //const real maxAngularVel = (real)1000.0;
00291                 const bool staticSleepingContactsEnabled = false;
00292                 const real maxCorrectingVel=(real)40.0;
00293                 const int maxContacts=(int)24;
00294 
00296                 const unsigned long int contactGroupFlags = 0xFFFFFFFF;
00297 
00299                 namespace solid
00300                 {
00301                         const bool enabled = true;
00302                         const bool sleeping = true;
00303                         const real sleepiness = (real)0.5;
00304                         const bool isStatic = false;
00305                         const real linearDamping = (real)0.15;
00306                         const real angularDamping = (real)0.15;
00307                 }
00308 
00310                 namespace shape
00311                 {
00312                         const Material material = globals::woodMaterial;
00313                         const unsigned int contactGroup = 0;
00314                         const Vec3r boxDimensions = Vec3r(1, 1, 1);
00315                         const real sphereRadius = 1;
00316                         const real capsuleRadius = 1;
00317                         const real capsuleLength = 1;
00318                         const real planeABCD[4] = {0, 1, 0, 0};
00319                 }
00320 
00322                 namespace joint
00323                 {
00324                         const JointType type = HINGE_JOINT;
00325                         const bool enabled = true;
00326                         const real lowLimit = 0;
00327                         const real highLimit = 0;
00328                         const real limitHardness = (real)0.5;
00329                         const real limitBounciness = (real)0.5;
00330                         const Vec3r axis0Direction = Vec3r(1, 0, 0);
00331                         const Vec3r axis1Direction = Vec3r(0, 1, 0);
00332                         const Vec3r axis2Direction = Vec3r(0, 0, 1);
00333                         const bool limitsEnabled = false;
00334 
00335                         const Point3r anchor = Point3r(0, 0, 0);
00336                         const JointBreakMode breakMode = UNBREAKABLE_MODE;
00337                         const real breakThresh = (real)100.0;
00338                         const real accumThresh = (real)1000.0;
00339                         const bool contactsEnabled = false;
00340                 }
00341 
00343                 namespace motor
00344                 {
00345                         const bool enabled = true;
00346 
00348                         namespace attractor
00349                         {
00350                                 const real strength = (real)1.0;
00351                                 const real exponent = (real)1.0;
00352                         }
00353 
00355                         namespace geared
00356                         {
00357                                 const real maxTorque = (real)10.0;
00358                                 const real maxVelocity = (real)10.0;
00359                         }
00360 
00362                         namespace servo
00363                         {
00364                                 const real maxTorque = (real)10.0;
00365                                 const real restoreSpeed = (real)1.0;
00366                         }
00367 
00369                         namespace spring
00370                         {
00371                                 const real linearKd = (real)0.1;
00372                                 const real linearKs = (real)1.0;
00373                                 const real angularKd = (real)0.1;
00374                                 const real angularKs = (real)1.0;
00375                                 const Vec3r desiredForward = Vec3r(0, 0, -1);
00376                                 const Vec3r desiredUp = Vec3r(0, 1, 0);
00377                                 const Vec3r desiredRight = Vec3r(1, 0, 0);
00378                         }
00379                 }
00380 
00382                 namespace sensor
00383                 {
00384                         const bool enabled = true;
00385 
00387                         namespace incline
00388                         {
00389                                 const Vec3r axis = Vec3r(1, 0, 0);
00390                         }
00391                 }
00392 
00394                 namespace ode
00395                 {
00396                         // ODE-specific defaults
00397                         const real autoDisableLinearMin=0;
00398                         const real autoDisableLinearMax=(real)0.2;
00399                         const real autoDisableAngularMin=0;
00400                         const real autoDisableAngularMax=(real)0.2;
00401                         const int autoDisableStepsMin=(int)1;
00402                         const int autoDisableStepsMax=(int)60;
00403                         const real autoDisableTimeMin=0;
00404                         const real autoDisableTimeMax=(real)0.4;
00405                         const real minMassRatio=(real)0.001;
00406 
00407                         //note: max and min mass ratios must be the inverse of each other
00408                         //const real maxMassRatio=(real)1000.0;
00409                         const real minERP=(real)0.1;
00410                         const real maxERP=(real)0.9;
00411                         const real globalCFM=(real)1e-5;
00412                         const real jointFudgeFactor=(real)0.1;
00413                         const real maxFriction=(real)1000.0;
00414                         const real surfaceLayer=(real)0.001;
00415                         const int maxRaycastContacts=10;
00416                 }
00417         }
00418 }
00419 
00420 #endif

Generated on Tue May 16 17:49:50 2006 for OPAL by  doxygen 1.4.6-NO