00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OPAL_DEFINES_H
00029 #define OPAL_DEFINES_H
00030
00031
00032
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
00105
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
00137
00138
00139
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
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
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
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;
00284 const Vec3r gravity(0, 0, 0);
00285 const real bounceThreshold = (real)1.0;
00286 const SolverAccuracyLevel solverAccuracy = SOLVER_ACCURACY_MEDIUM;
00287
00288
00289
00290
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
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
00408
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