From fd6808e7656673f126f02717cb3bd278ea1bf2bc Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Mon, 29 Jan 2007 21:30:34 +0000 Subject: [PATCH] first pass at integrating ODE v0.7 --- panda/metalibs/pandaode/Sources.pp | 26 ++ panda/metalibs/pandaode/pandaode.cxx | 26 ++ panda/metalibs/pandaode/pandaode.h | 13 + panda/src/ode/Sources.pp | 115 +++++++++ panda/src/ode/config_ode.cxx | 115 +++++++++ panda/src/ode/config_ode.h | 37 +++ panda/src/ode/odeAMotorJoint.I | 82 +++++++ panda/src/ode/odeAMotorJoint.cxx | 36 +++ panda/src/ode/odeAMotorJoint.h | 57 +++++ panda/src/ode/odeBallJoint.I | 37 +++ panda/src/ode/odeBallJoint.cxx | 36 +++ panda/src/ode/odeBallJoint.h | 48 ++++ panda/src/ode/odeBody.I | 306 ++++++++++++++++++++++++ panda/src/ode/odeBody.cxx | 60 +++++ panda/src/ode/odeBody.h | 142 +++++++++++ panda/src/ode/odeBoxGeom.I | 35 +++ panda/src/ode/odeBoxGeom.cxx | 36 +++ panda/src/ode/odeBoxGeom.h | 66 +++++ panda/src/ode/odeCappedCylinderGeom.I | 46 ++++ panda/src/ode/odeCappedCylinderGeom.cxx | 36 +++ panda/src/ode/odeCappedCylinderGeom.h | 68 ++++++ panda/src/ode/odeContact.I | 54 +++++ panda/src/ode/odeContact.cxx | 41 ++++ panda/src/ode/odeContact.h | 77 ++++++ panda/src/ode/odeContactGeom.I | 87 +++++++ panda/src/ode/odeContactGeom.cxx | 84 +++++++ panda/src/ode/odeContactGeom.h | 85 +++++++ panda/src/ode/odeContactJoint.I | 17 ++ panda/src/ode/odeContactJoint.cxx | 36 +++ panda/src/ode/odeContactJoint.h | 43 ++++ panda/src/ode/odeConvexGeom.I | 23 ++ panda/src/ode/odeConvexGeom.cxx | 36 +++ panda/src/ode/odeConvexGeom.h | 63 +++++ panda/src/ode/odeCylinderGeom.I | 41 ++++ panda/src/ode/odeCylinderGeom.cxx | 36 +++ panda/src/ode/odeCylinderGeom.h | 67 ++++++ panda/src/ode/odeFixedJoint.I | 22 ++ panda/src/ode/odeFixedJoint.cxx | 36 +++ panda/src/ode/odeFixedJoint.h | 44 ++++ panda/src/ode/odeGeom.I | 190 +++++++++++++++ panda/src/ode/odeGeom.cxx | 60 +++++ panda/src/ode/odeGeom.h | 107 +++++++++ panda/src/ode/odeHashSpace.I | 36 +++ panda/src/ode/odeHashSpace.cxx | 37 +++ panda/src/ode/odeHashSpace.h | 65 +++++ panda/src/ode/odeHeightFieldGeom.h | 68 ++++++ panda/src/ode/odeHinge2Joint.I | 83 +++++++ panda/src/ode/odeHinge2Joint.cxx | 36 +++ panda/src/ode/odeHinge2Joint.h | 57 +++++ panda/src/ode/odeHingeJoint.I | 73 ++++++ panda/src/ode/odeHingeJoint.cxx | 36 +++ panda/src/ode/odeHingeJoint.h | 54 +++++ panda/src/ode/odeJoint.I | 47 ++++ panda/src/ode/odeJoint.cxx | 89 +++++++ panda/src/ode/odeJoint.h | 88 +++++++ panda/src/ode/odeJointGroup.I | 28 +++ panda/src/ode/odeJointGroup.cxx | 36 +++ panda/src/ode/odeJointGroup.h | 67 ++++++ panda/src/ode/odeLMotorJoint.I | 49 ++++ panda/src/ode/odeLMotorJoint.cxx | 36 +++ panda/src/ode/odeLMotorJoint.h | 49 ++++ panda/src/ode/odeMass.I | 130 ++++++++++ panda/src/ode/odeMass.cxx | 67 ++++++ panda/src/ode/odeMass.h | 96 ++++++++ panda/src/ode/odeNullJoint.I | 17 ++ panda/src/ode/odeNullJoint.cxx | 36 +++ panda/src/ode/odeNullJoint.h | 41 ++++ panda/src/ode/odePlane2dJoint.I | 32 +++ panda/src/ode/odePlane2dJoint.cxx | 36 +++ panda/src/ode/odePlane2dJoint.h | 45 ++++ panda/src/ode/odePlaneGeom.I | 34 +++ panda/src/ode/odePlaneGeom.cxx | 36 +++ panda/src/ode/odePlaneGeom.h | 65 +++++ panda/src/ode/odeQuadTreeSpace.I | 18 ++ panda/src/ode/odeQuadTreeSpace.cxx | 61 +++++ panda/src/ode/odeQuadTreeSpace.h | 65 +++++ panda/src/ode/odeRayGeom.I | 88 +++++++ panda/src/ode/odeRayGeom.cxx | 36 +++ panda/src/ode/odeRayGeom.h | 74 ++++++ panda/src/ode/odeSimpleSpace.I | 17 ++ panda/src/ode/odeSimpleSpace.cxx | 37 +++ panda/src/ode/odeSimpleSpace.h | 60 +++++ panda/src/ode/odeSliderJoint.I | 57 +++++ panda/src/ode/odeSliderJoint.cxx | 36 +++ panda/src/ode/odeSliderJoint.h | 51 ++++ panda/src/ode/odeSpace.I | 86 +++++++ panda/src/ode/odeSpace.cxx | 93 +++++++ panda/src/ode/odeSpace.h | 97 ++++++++ panda/src/ode/odeSphereGeom.I | 33 +++ panda/src/ode/odeSphereGeom.cxx | 42 ++++ panda/src/ode/odeSphereGeom.h | 66 +++++ panda/src/ode/odeSurfaceParameters.I | 130 ++++++++++ panda/src/ode/odeSurfaceParameters.cxx | 84 +++++++ panda/src/ode/odeSurfaceParameters.h | 127 ++++++++++ panda/src/ode/odeTriMeshData.I | 88 +++++++ panda/src/ode/odeTriMeshData.cxx | 236 ++++++++++++++++++ panda/src/ode/odeTriMeshData.h | 123 ++++++++++ panda/src/ode/odeTriMeshGeom.I | 71 ++++++ panda/src/ode/odeTriMeshGeom.cxx | 63 +++++ panda/src/ode/odeTriMeshGeom.h | 85 +++++++ panda/src/ode/odeUniversalJoint.I | 87 +++++++ panda/src/ode/odeUniversalJoint.cxx | 36 +++ panda/src/ode/odeUniversalJoint.h | 58 +++++ panda/src/ode/odeUtil.cxx | 60 +++++ panda/src/ode/odeUtil.h | 51 ++++ panda/src/ode/odeWorld.I | 186 ++++++++++++++ panda/src/ode/odeWorld.cxx | 45 ++++ panda/src/ode/odeWorld.h | 103 ++++++++ panda/src/ode/pode_composite1.cxx | 14 ++ panda/src/ode/pode_composite2.cxx | 13 + panda/src/ode/pode_composite3.cxx | 12 + panda/src/pandabase/pandasymbols.h | 11 + 112 files changed, 7041 insertions(+) create mode 100755 panda/metalibs/pandaode/Sources.pp create mode 100755 panda/metalibs/pandaode/pandaode.cxx create mode 100755 panda/metalibs/pandaode/pandaode.h create mode 100755 panda/src/ode/Sources.pp create mode 100755 panda/src/ode/config_ode.cxx create mode 100755 panda/src/ode/config_ode.h create mode 100755 panda/src/ode/odeAMotorJoint.I create mode 100644 panda/src/ode/odeAMotorJoint.cxx create mode 100644 panda/src/ode/odeAMotorJoint.h create mode 100755 panda/src/ode/odeBallJoint.I create mode 100755 panda/src/ode/odeBallJoint.cxx create mode 100644 panda/src/ode/odeBallJoint.h create mode 100755 panda/src/ode/odeBody.I create mode 100755 panda/src/ode/odeBody.cxx create mode 100755 panda/src/ode/odeBody.h create mode 100755 panda/src/ode/odeBoxGeom.I create mode 100644 panda/src/ode/odeBoxGeom.cxx create mode 100644 panda/src/ode/odeBoxGeom.h create mode 100755 panda/src/ode/odeCappedCylinderGeom.I create mode 100755 panda/src/ode/odeCappedCylinderGeom.cxx create mode 100755 panda/src/ode/odeCappedCylinderGeom.h create mode 100755 panda/src/ode/odeContact.I create mode 100755 panda/src/ode/odeContact.cxx create mode 100755 panda/src/ode/odeContact.h create mode 100755 panda/src/ode/odeContactGeom.I create mode 100755 panda/src/ode/odeContactGeom.cxx create mode 100755 panda/src/ode/odeContactGeom.h create mode 100755 panda/src/ode/odeContactJoint.I create mode 100755 panda/src/ode/odeContactJoint.cxx create mode 100644 panda/src/ode/odeContactJoint.h create mode 100755 panda/src/ode/odeConvexGeom.I create mode 100644 panda/src/ode/odeConvexGeom.cxx create mode 100755 panda/src/ode/odeConvexGeom.h create mode 100755 panda/src/ode/odeCylinderGeom.I create mode 100644 panda/src/ode/odeCylinderGeom.cxx create mode 100755 panda/src/ode/odeCylinderGeom.h create mode 100755 panda/src/ode/odeFixedJoint.I create mode 100644 panda/src/ode/odeFixedJoint.cxx create mode 100644 panda/src/ode/odeFixedJoint.h create mode 100755 panda/src/ode/odeGeom.I create mode 100755 panda/src/ode/odeGeom.cxx create mode 100755 panda/src/ode/odeGeom.h create mode 100755 panda/src/ode/odeHashSpace.I create mode 100755 panda/src/ode/odeHashSpace.cxx create mode 100755 panda/src/ode/odeHashSpace.h create mode 100644 panda/src/ode/odeHeightFieldGeom.h create mode 100755 panda/src/ode/odeHinge2Joint.I create mode 100644 panda/src/ode/odeHinge2Joint.cxx create mode 100644 panda/src/ode/odeHinge2Joint.h create mode 100755 panda/src/ode/odeHingeJoint.I create mode 100644 panda/src/ode/odeHingeJoint.cxx create mode 100755 panda/src/ode/odeHingeJoint.h create mode 100755 panda/src/ode/odeJoint.I create mode 100755 panda/src/ode/odeJoint.cxx create mode 100755 panda/src/ode/odeJoint.h create mode 100755 panda/src/ode/odeJointGroup.I create mode 100755 panda/src/ode/odeJointGroup.cxx create mode 100755 panda/src/ode/odeJointGroup.h create mode 100755 panda/src/ode/odeLMotorJoint.I create mode 100644 panda/src/ode/odeLMotorJoint.cxx create mode 100755 panda/src/ode/odeLMotorJoint.h create mode 100755 panda/src/ode/odeMass.I create mode 100755 panda/src/ode/odeMass.cxx create mode 100755 panda/src/ode/odeMass.h create mode 100755 panda/src/ode/odeNullJoint.I create mode 100644 panda/src/ode/odeNullJoint.cxx create mode 100755 panda/src/ode/odeNullJoint.h create mode 100755 panda/src/ode/odePlane2dJoint.I create mode 100644 panda/src/ode/odePlane2dJoint.cxx create mode 100755 panda/src/ode/odePlane2dJoint.h create mode 100755 panda/src/ode/odePlaneGeom.I create mode 100644 panda/src/ode/odePlaneGeom.cxx create mode 100755 panda/src/ode/odePlaneGeom.h create mode 100755 panda/src/ode/odeQuadTreeSpace.I create mode 100755 panda/src/ode/odeQuadTreeSpace.cxx create mode 100755 panda/src/ode/odeQuadTreeSpace.h create mode 100755 panda/src/ode/odeRayGeom.I create mode 100644 panda/src/ode/odeRayGeom.cxx create mode 100755 panda/src/ode/odeRayGeom.h create mode 100755 panda/src/ode/odeSimpleSpace.I create mode 100755 panda/src/ode/odeSimpleSpace.cxx create mode 100755 panda/src/ode/odeSimpleSpace.h create mode 100755 panda/src/ode/odeSliderJoint.I create mode 100644 panda/src/ode/odeSliderJoint.cxx create mode 100755 panda/src/ode/odeSliderJoint.h create mode 100755 panda/src/ode/odeSpace.I create mode 100755 panda/src/ode/odeSpace.cxx create mode 100755 panda/src/ode/odeSpace.h create mode 100755 panda/src/ode/odeSphereGeom.I create mode 100755 panda/src/ode/odeSphereGeom.cxx create mode 100755 panda/src/ode/odeSphereGeom.h create mode 100755 panda/src/ode/odeSurfaceParameters.I create mode 100755 panda/src/ode/odeSurfaceParameters.cxx create mode 100755 panda/src/ode/odeSurfaceParameters.h create mode 100755 panda/src/ode/odeTriMeshData.I create mode 100755 panda/src/ode/odeTriMeshData.cxx create mode 100755 panda/src/ode/odeTriMeshData.h create mode 100755 panda/src/ode/odeTriMeshGeom.I create mode 100755 panda/src/ode/odeTriMeshGeom.cxx create mode 100755 panda/src/ode/odeTriMeshGeom.h create mode 100755 panda/src/ode/odeUniversalJoint.I create mode 100644 panda/src/ode/odeUniversalJoint.cxx create mode 100644 panda/src/ode/odeUniversalJoint.h create mode 100755 panda/src/ode/odeUtil.cxx create mode 100755 panda/src/ode/odeUtil.h create mode 100755 panda/src/ode/odeWorld.I create mode 100755 panda/src/ode/odeWorld.cxx create mode 100755 panda/src/ode/odeWorld.h create mode 100755 panda/src/ode/pode_composite1.cxx create mode 100755 panda/src/ode/pode_composite2.cxx create mode 100755 panda/src/ode/pode_composite3.cxx diff --git a/panda/metalibs/pandaode/Sources.pp b/panda/metalibs/pandaode/Sources.pp new file mode 100755 index 0000000000..565a0dcfd0 --- /dev/null +++ b/panda/metalibs/pandaode/Sources.pp @@ -0,0 +1,26 @@ +// DIR_TYPE "metalib" indicates we are building a shared library that +// consists mostly of references to other shared libraries. Under +// Windows, this directly produces a DLL (as opposed to the regular +// src libraries, which don't produce anything but a pile of OBJ files +// under Windows). + +#define DIR_TYPE metalib +#define BUILD_DIRECTORY $[HAVE_ODE] +#define BUILDING_DLL BUILDING_PANDAODE + +#define COMPONENT_LIBS \ + pode + +#define LOCAL_LIBS pgraph +#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ + dtoolutil:c dtoolbase:c dtool:m prc:c + + +#begin metalib_target +#define TARGET pandaode + + #define SOURCES pandaode.cxx pandaode.h + #define INSTALL_HEADERS pandaode.h + +#end metalib_target + diff --git a/panda/metalibs/pandaode/pandaode.cxx b/panda/metalibs/pandaode/pandaode.cxx new file mode 100755 index 0000000000..10b8f5eb77 --- /dev/null +++ b/panda/metalibs/pandaode/pandaode.cxx @@ -0,0 +1,26 @@ +// Filename: pandaode.cxx +// Created by: drose (16May00) +// +//////////////////////////////////////////////////////////////////// + +#include "pandaode.h" +#include "config_ode.h" + +// By including checkPandaVersion.h, we guarantee that runtime +// attempts to load libpandaode.so/.dll will fail if they +// inadvertently link with the wrong version of libdtool.so/.dll. + +#include "checkPandaVersion.h" + +//////////////////////////////////////////////////////////////////// +// Function: init_libpandaode +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpandaode() { + init_libode(); +} diff --git a/panda/metalibs/pandaode/pandaode.h b/panda/metalibs/pandaode/pandaode.h new file mode 100755 index 0000000000..ceb0eb2d6d --- /dev/null +++ b/panda/metalibs/pandaode/pandaode.h @@ -0,0 +1,13 @@ +// Filename: pandaode.h +// Created by: drose (2Jan01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDAODE_H +#define PANDAODE_H + +#include "pandabase.h" + +EXPCL_PANDAODE void init_libpandaode(); + +#endif diff --git a/panda/src/ode/Sources.pp b/panda/src/ode/Sources.pp new file mode 100755 index 0000000000..34d31d8da0 --- /dev/null +++ b/panda/src/ode/Sources.pp @@ -0,0 +1,115 @@ +#define BUILD_DIRECTORY $[HAVE_ODE] +#define BUILDING_DLL BUILDING_PANDAODE + +#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ + dtoolutil:c dtoolbase:c dtool:m prc:c + +#begin lib_target + #define TARGET pode + #define LOCAL_LIBS \ + pgraph physics + + #define USE_PACKAGES ode + + #define COMBINED_SOURCES $[TARGET]_composite1.cxx \ + $[TARGET]_composite2.cxx $[TARGET]_composite3.cxx + + #define SOURCES \ + config_ode.h \ + odeWorld.I odeWorld.h \ + odeMass.I odeMass.h \ + odeBody.I odeBody.h \ + odeJointGroup.I odeJointGroup.h \ + odeJoint.I odeJoint.h \ + odeUtil.h \ + odeSpace.I odeSpace.h \ + odeGeom.I odeGeom.h \ + odeSurfaceParameters.I odeSurfaceParameters.h \ + odeContactGeom.I odeContactGeom.h \ + odeContact.I odeContact.h \ + odeAMotorJoint.I odeAMotorJoint.h \ + odeBallJoint.I odeBallJoint.h \ + odeContactJoint.I odeContactJoint.h \ + odeFixedJoint.I odeFixedJoint.h \ + odeHingeJoint.I odeHingeJoint.h \ + odeHinge2Joint.I odeHinge2Joint.h \ + odeLMotorJoint.I odeLMotorJoint.h \ + odeNullJoint.I odeNullJoint.h \ + odePlane2dJoint.I odePlane2dJoint.h \ + odeSliderJoint.I odeSliderJoint.h \ + odeUniversalJoint.I odeUniversalJoint.h \ + odeSimpleSpace.I odeSimpleSpace.h \ + odeHashSpace.I odeHashSpace.h \ + odeQuadTreeSpace.I odeQuadTreeSpace.h \ + odeSphereGeom.I odeSphereGeom.h \ + odeBoxGeom.I odeBoxGeom.h \ + odePlaneGeom.I odePlaneGeom.h \ + odeCappedCylinderGeom.I odeCappedCylinderGeom.h \ + odeCylinderGeom.I odeCylinderGeom.h \ + odeRayGeom.I odeRayGeom.h \ + odeTriMeshData.I odeTriMeshData.h \ + odeTriMeshGeom.I odeTriMeshGeom.h + + #define INCLUDED_SOURCES \ + config_ode.cxx \ + odeWorld.cxx odeMass.cxx odeBody.cxx \ + odeJointGroup.cxx odeJoint.cxx \ + odeUtil.cxx \ + odeSpace.cxx \ + odeGeom.cxx \ + odeSurfaceParameters.cxx \ + odeContactGeom.cxx odeContact.cxx \ + odeAMotorJoint.cxx odeBallJoint.cxx \ + odeContactJoint.cxx odeFixedJoint.cxx \ + odeHingeJoint.cxx odeHinge2Joint.cxx \ + odeLMotorJoint.cxx odeNullJoint.cxx \ + odePlane2dJoint.cxx odeSliderJoint.cxx \ + odeUniversalJoint.cxx \ + odeSimpleSpace.cxx \ + odeHashSpace.cxx odeQuadTreeSpace.cxx \ + odeSphereGeom.cxx odeBoxGeom.cxx \ + odePlaneGeom.cxx odeCappedCylinderGeom.cxx \ + odeCylinderGeom.cxx odeRayGeom.cxx \ + odeTriMeshData.cxx odeTriMeshGeom.cxx + + + #define INSTALL_HEADERS \ + config_ode.h \ + odeWorld.I odeWorld.h \ + odeMass.I odeMass.h \ + odeBody.I odeBody.h \ + odeJointGroup.I odeJointGroup.h \ + odeJoint.I odeJoint.h \ + odeUtil.h \ + odeSpace.I odeSpace.h \ + odeGeom.I odeGeom.h \ + odeSurfaceParameters.I odeSurfaceParameters.h \ + odeContactGeom.I odeContactGeom.h \ + odeContact.I odeContact.h \ + odeAMotorJoint.I odeAMotorJoint.h \ + odeBallJoint.I odeBallJoint.h \ + odeContactJoint.I odeContactJoint.h \ + odeFixedJoint.I odeFixedJoint.h \ + odeHingeJoint.I odeHingeJoint.h \ + odeHinge2Joint.I odeHinge2Joint.h \ + odeLMotorJoint.I odeLMotorJoint.h \ + odeNullJoint.I odeNullJoint.h \ + odePlane2dJoint.I odePlane2dJoint.h \ + odeSliderJoint.I odeSliderJoint.h \ + odeUniversalJoint.I odeUniversalJoint.h \ + odeSimpleSpace.I odeSimpleSpace.h \ + odeHashSpace.I odeHashSpace.h \ + odeQuadTreeSpace.I odeQuadTreeSpace.h \ + odeSphereGeom.I odeSphereGeom.h \ + odeBoxGeom.I odeBoxGeom.h \ + odePlaneGeom.I odePlaneGeom.h \ + odeCappedCylinderGeom.I odeCappedCylinderGeom.h \ + odeCylinderGeom.I odeCylinderGeom.h \ + odeRayGeom.I odeRayGeom.h \ + odeTriMeshData.I odeTriMeshData.h \ + odeTriMeshGeom.I odeTriMeshGeom.h + + #define IGATESCAN all + +#end lib_target + diff --git a/panda/src/ode/config_ode.cxx b/panda/src/ode/config_ode.cxx new file mode 100755 index 0000000000..85e4d4a9df --- /dev/null +++ b/panda/src/ode/config_ode.cxx @@ -0,0 +1,115 @@ +// Filename: config_effects.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeWorld.h" +#include "odeMass.h" +#include "odeBody.h" +#include "odeJointGroup.h" +#include "odeJoint.h" +#include "odeSpace.h" +#include "odeGeom.h" +#include "odeSurfaceParameters.h" +#include "odeContactGeom.h" +#include "odeContact.h" +#include "odeAMotorJoint.h" +#include "odeBallJoint.h" +#include "odeContactJoint.h" +#include "odeFixedJoint.h" +#include "odeHingeJoint.h" +#include "odeHinge2Joint.h" +#include "odeLMotorJoint.h" +#include "odeNullJoint.h" +#include "odePlane2dJoint.h" +#include "odeSliderJoint.h" +#include "odeUniversalJoint.h" +#include "odeSimpleSpace.h" +#include "odeHashSpace.h" +#include "odeQuadTreeSpace.h" +#include "odeSphereGeom.h" +#include "odeBoxGeom.h" +#include "odePlaneGeom.h" +#include "odeCappedCylinderGeom.h" +#include "odeCylinderGeom.h" +#include "odeRayGeom.h" +#include "odeTriMeshData.h" +#include "odeTriMeshGeom.h" +#include "dconfig.h" + +Configure(config_ode); +NotifyCategoryDef(ode, ""); +NotifyCategoryDef(odeworld, ""); +NotifyCategoryDef(odebody, ""); +NotifyCategoryDef(odejoint, ""); +NotifyCategoryDef(odespace, ""); +NotifyCategoryDef(odegeom, ""); +NotifyCategoryDef(odetrimeshdata, ""); + +ConfigureFn(config_ode) { + init_libode(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libode +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libode() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + + OdeWorld::init_type(); + OdeMass::init_type(); + OdeBody::init_type(); + OdeJointGroup::init_type(); + OdeJoint::init_type(); + OdeSpace::init_type(); + OdeGeom::init_type(); + OdeSurfaceParameters::init_type(); + OdeContactGeom::init_type(); + OdeContact::init_type(); + OdeAMotorJoint::init_type(); + OdeBallJoint::init_type(); + OdeContactJoint::init_type(); + OdeFixedJoint::init_type(); + OdeHingeJoint::init_type(); + OdeHinge2Joint::init_type(); + OdeLMotorJoint::init_type(); + OdeNullJoint::init_type(); + OdePlane2dJoint::init_type(); + OdeSliderJoint::init_type(); + OdeUniversalJoint::init_type(); + OdeSimpleSpace::init_type(); + OdeHashSpace::init_type(); + OdeQuadTreeSpace::init_type(); + OdeSphereGeom::init_type(); + OdeBoxGeom::init_type(); + OdePlaneGeom::init_type(); + OdeCappedCylinderGeom::init_type(); + OdeCylinderGeom::init_type(); + OdeRayGeom::init_type(); + OdeTriMeshData::init_type(); + OdeTriMeshGeom::init_type(); +} diff --git a/panda/src/ode/config_ode.h b/panda/src/ode/config_ode.h new file mode 100755 index 0000000000..b1fdb61004 --- /dev/null +++ b/panda/src/ode/config_ode.h @@ -0,0 +1,37 @@ +// Filename: config_effects.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef CONFIG_ODE_H +#define CONFIG_ODE_H + +#include "pandabase.h" +#include "notifyCategoryProxy.h" + +#include "dconfig.h" + +NotifyCategoryDecl(ode, EXPCL_PANDAODE, EXPTP_PANDAODE); +NotifyCategoryDecl(odeworld, EXPCL_PANDAODE, EXPTP_PANDAODE); +NotifyCategoryDecl(odebody, EXPCL_PANDAODE, EXPTP_PANDAODE); +NotifyCategoryDecl(odejoint, EXPCL_PANDAODE, EXPTP_PANDAODE); +NotifyCategoryDecl(odespace, EXPCL_PANDAODE, EXPTP_PANDAODE); +NotifyCategoryDecl(odegeom, EXPCL_PANDAODE, EXPTP_PANDAODE); +NotifyCategoryDecl(odetrimeshdata, EXPCL_PANDAODE, EXPTP_PANDAODE); + +extern EXPCL_PANDAODE void init_libode(); + +#endif /* CONFIG_ODE_H */ diff --git a/panda/src/ode/odeAMotorJoint.I b/panda/src/ode/odeAMotorJoint.I new file mode 100755 index 0000000000..0a4157c4a8 --- /dev/null +++ b/panda/src/ode/odeAMotorJoint.I @@ -0,0 +1,82 @@ +// Filename: odeAMotorJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeAMotorJoint:: +set_a_motor_num_axes(int num) { + dJointSetAMotorNumAxes(_id, num); +} + +INLINE void OdeAMotorJoint:: +set_a_motor_axis(int anum, int rel, dReal x, dReal y, dReal z) { + dJointSetAMotorAxis(_id, anum, rel, x, y, z); +} + +INLINE void OdeAMotorJoint:: +set_a_motor_angle(int anum, dReal angle) { + dJointSetAMotorAngle(_id, anum, angle); +} + +INLINE void OdeAMotorJoint:: +set_a_motor_param(int parameter, dReal value) { + dJointSetAMotorParam(_id, parameter, value); +} + +INLINE void OdeAMotorJoint:: +set_a_motor_mode(int mode) { + dJointSetAMotorMode(_id, mode); +} + +INLINE void OdeAMotorJoint:: +add_a_motor_torques(dReal torque1, dReal torque2, dReal torque3) { + dJointAddAMotorTorques(_id, torque1, torque2, torque3); +} + +INLINE int OdeAMotorJoint:: +get_a_motor_num_axes() const { + return dJointGetAMotorNumAxes(_id); +} + +INLINE void OdeAMotorJoint:: +get_a_motor_axis(int anum, dVector3 result) const { + return dJointGetAMotorAxis(_id, anum, result); +} + +INLINE int OdeAMotorJoint:: +get_a_motor_axis_rel(int anum) const { + return dJointGetAMotorAxisRel(_id, anum); +} + +INLINE dReal OdeAMotorJoint:: +get_a_motor_angle(int anum) const { + return dJointGetAMotorAngle(_id, anum); +} + +INLINE dReal OdeAMotorJoint:: +get_a_motor_angle_rate(int anum) const { + return dJointGetAMotorAngleRate(_id, anum); +} + +INLINE dReal OdeAMotorJoint:: +get_a_motor_param(int parameter) const { + return dJointGetAMotorParam(_id, parameter); +} + +INLINE int OdeAMotorJoint:: +get_a_motor_mode() const { + return dJointGetAMotorMode(_id); +} diff --git a/panda/src/ode/odeAMotorJoint.cxx b/panda/src/ode/odeAMotorJoint.cxx new file mode 100644 index 0000000000..574d8bf9a6 --- /dev/null +++ b/panda/src/ode/odeAMotorJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeAMotorJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeAMotorJoint.h" + +TypeHandle OdeAMotorJoint::_type_handle; + +OdeAMotorJoint:: +OdeAMotorJoint(OdeWorld &world) : + OdeJoint(dJointCreateAMotor(world.get_id(), 0)) { +} + +OdeAMotorJoint:: +OdeAMotorJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateAMotor(world.get_id(), joint_group.get_id())) { +} + +OdeAMotorJoint:: +~OdeAMotorJoint() { +} diff --git a/panda/src/ode/odeAMotorJoint.h b/panda/src/ode/odeAMotorJoint.h new file mode 100644 index 0000000000..296b7762c5 --- /dev/null +++ b/panda/src/ode/odeAMotorJoint.h @@ -0,0 +1,57 @@ +#ifndef ODEAMOTORJOINT_H +#define ODEAMOTORJOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeAMotorJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeAMotorJoint : public OdeJoint { +PUBLISHED: + OdeAMotorJoint(OdeWorld &world); + OdeAMotorJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeAMotorJoint(); + + INLINE void set_a_motor_num_axes(int num); + INLINE void set_a_motor_axis(int anum, int rel, dReal x, dReal y, dReal z); + INLINE void set_a_motor_angle(int anum, dReal angle); + INLINE void set_a_motor_param(int parameter, dReal value); + INLINE void set_a_motor_mode(int mode); + INLINE void add_a_motor_torques(dReal torque1, dReal torque2, dReal torque3); + + INLINE int get_a_motor_num_axes() const; + INLINE void get_a_motor_axis(int anum, dVector3 result) const; + INLINE int get_a_motor_axis_rel(int anum) const; + INLINE dReal get_a_motor_angle(int anum) const; + INLINE dReal get_a_motor_angle_rate(int anum) const; + INLINE dReal get_a_motor_param(int parameter) const; + INLINE int get_a_motor_mode() const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeAMotorJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeAMotorJoint.I" + +#endif diff --git a/panda/src/ode/odeBallJoint.I b/panda/src/ode/odeBallJoint.I new file mode 100755 index 0000000000..2996275d5b --- /dev/null +++ b/panda/src/ode/odeBallJoint.I @@ -0,0 +1,37 @@ +// Filename: odeBallJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeBallJoint:: +set_ball_anchor(dReal x, dReal y, dReal z) { + dJointSetBallAnchor(_id, x, y, z); +} + +INLINE void OdeBallJoint:: +set_ball_anchor2(dReal x, dReal y, dReal z) { + dJointSetBallAnchor2(_id, x, y, z); +} + +INLINE void OdeBallJoint:: +get_ball_anchor(dVector3 result) const { + return dJointGetBallAnchor(_id, result); +} + +INLINE void OdeBallJoint:: +get_ball_anchor2(dVector3 result) const { + return dJointGetBallAnchor2(_id, result); +} diff --git a/panda/src/ode/odeBallJoint.cxx b/panda/src/ode/odeBallJoint.cxx new file mode 100755 index 0000000000..326389dadc --- /dev/null +++ b/panda/src/ode/odeBallJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeBallJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeBallJoint.h" + +TypeHandle OdeBallJoint::_type_handle; + +OdeBallJoint:: +OdeBallJoint(OdeWorld &world) : + OdeJoint(dJointCreateBall(world.get_id(), 0)) { +} + +OdeBallJoint:: +OdeBallJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateBall(world.get_id(), joint_group.get_id())) { +} + +OdeBallJoint:: +~OdeBallJoint() { +} diff --git a/panda/src/ode/odeBallJoint.h b/panda/src/ode/odeBallJoint.h new file mode 100644 index 0000000000..59e61b6111 --- /dev/null +++ b/panda/src/ode/odeBallJoint.h @@ -0,0 +1,48 @@ +#ifndef ODEBALLJOINT_H +#define ODEBALLJOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeBallJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeBallJoint : public OdeJoint { +PUBLISHED: + OdeBallJoint(OdeWorld &world); + OdeBallJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeBallJoint(); + + INLINE void set_ball_anchor(dReal x, dReal y, dReal z); + INLINE void set_ball_anchor2(dReal x, dReal y, dReal z); + + INLINE void get_ball_anchor(dVector3 result) const; + INLINE void get_ball_anchor2(dVector3 result) const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeBallJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeBallJoint.I" + +#endif diff --git a/panda/src/ode/odeBody.I b/panda/src/ode/odeBody.I new file mode 100755 index 0000000000..76dc5088d5 --- /dev/null +++ b/panda/src/ode/odeBody.I @@ -0,0 +1,306 @@ +// Filename: odeBody.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE dBodyID OdeBody:: +get_id() const { + return _id; +} + +INLINE dReal OdeBody:: +get_auto_disable_linear_threshold() const { + return dBodyGetAutoDisableLinearThreshold(_id); +} + +INLINE void OdeBody:: +set_auto_disable_linear_threshold(dReal linear_threshold) { + dBodySetAutoDisableLinearThreshold(_id, linear_threshold); +} + +INLINE dReal OdeBody:: +get_auto_disable_angular_threshold() const { + return dBodyGetAutoDisableAngularThreshold(_id); +} + +INLINE void OdeBody:: +set_auto_disable_angular_threshold(dReal angular_threshold) { + dBodySetAutoDisableAngularThreshold(_id, angular_threshold); +} + +INLINE int OdeBody:: +get_auto_disable_steps() const { + return dBodyGetAutoDisableSteps(_id); +} + +INLINE void OdeBody:: +set_auto_disable_steps(int steps) { + dBodySetAutoDisableSteps(_id, steps); +} + +INLINE dReal OdeBody:: +get_auto_disable_time() const { + return dBodyGetAutoDisableTime(_id); +} + +INLINE void OdeBody:: +set_auto_disable_time(dReal time) { + dBodySetAutoDisableTime(_id, time); +} + +INLINE int OdeBody:: +get_auto_disable_flag() const { + return dBodyGetAutoDisableFlag(_id); +} + +INLINE void OdeBody:: +set_auto_disable_flag(int do_auto_disable) { + dBodySetAutoDisableFlag(_id, do_auto_disable); +} + +INLINE void OdeBody:: +set_auto_disable_defaults() { + dBodySetAutoDisableDefaults(_id); +} + +INLINE void OdeBody:: +set_data(void *data) { + dBodySetData(_id, data); +} + +INLINE void* OdeBody:: +get_data() const { + return dBodyGetData(_id); +} + +INLINE void OdeBody:: +set_position(dReal x, dReal y, dReal z) { + dBodySetPosition(_id, x, y, z); +} + +INLINE void OdeBody:: +set_rotation(const LMatrix3f r) { + dMatrix3 mat3 = {r._m.data[0], r._m.data[1], r._m.data[2], 0, + r._m.data[3], r._m.data[4], r._m.data[5], 0, + r._m.data[6], r._m.data[7], r._m.data[8], 0}; + + dBodySetRotation(_id, mat3); +} + +INLINE void OdeBody:: +set_quaternion(const LQuaternionf q) { + dQuaternion quat = {q._v.data[0], + q._v.data[1], + q._v.data[2], + q._v.data[3]}; + dBodySetQuaternion(_id, quat); +} + +INLINE void OdeBody:: +set_linear_vel(dReal x, dReal y, dReal z) { + dBodySetLinearVel(_id, x, y, z); +} + +INLINE void OdeBody:: +set_angular_vel(dReal x, dReal y, dReal z) { + dBodySetAngularVel(_id, x, y, z); +} + +INLINE LVecBase3f OdeBody:: +get_position() const { + const dReal *res = dBodyGetPosition(_id); + return LVecBase3f(res[0], res[1], res[2]); +} + +INLINE LVecBase3f OdeBody:: +get_rotation() const { + const dReal *res = dBodyGetRotation(_id); + return LVecBase3f(res[0], res[1], res[2]); +} + +INLINE LVecBase4f OdeBody:: +get_quaternion() const { + const dReal *res = dBodyGetQuaternion(_id); + return LVecBase4f(res[0], res[1], res[2], res[3]); +} + +INLINE LVecBase3f OdeBody:: +get_linear_vel() const { + const dReal *res = dBodyGetLinearVel(_id); + return LVecBase3f(res[0], res[1], res[2]); +} + +INLINE LVecBase3f OdeBody:: +get_angular_vel() const { + const dReal *res = dBodyGetAngularVel(_id); + return LVecBase3f(res[0], res[1], res[2]); +} + +INLINE void OdeBody:: +set_mass(OdeMass &mass) { + dBodySetMass(_id, mass.get_mass_ptr()); +} + +INLINE OdeMass OdeBody:: +get_mass() const { + OdeMass mass; + dBodyGetMass(_id, mass.get_mass_ptr()); + return mass; +} + +INLINE void OdeBody:: +add_force(dReal fx, dReal fy, dReal fz) { + dBodyAddForce(_id, fx, fy, fz); +} + +INLINE void OdeBody:: +add_torque(dReal fx, dReal fy, dReal fz) { + dBodyAddTorque(_id, fx, fy, fz); +} + +INLINE void OdeBody:: +add_rel_force(dReal fx, dReal fy, dReal fz) { + dBodyAddRelForce(_id, fx, fy, fz); +} + +INLINE void OdeBody:: +add_rel_torque(dReal fx, dReal fy, dReal fz) { + dBodyAddRelTorque(_id, fx, fy, fz); +} + +INLINE void OdeBody:: +add_force_at_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) { + dBodyAddForceAtPos(_id, fx, fy, fz, px, py, pz); +} + +INLINE void OdeBody:: +add_force_at_rel_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) { + dBodyAddForceAtRelPos(_id, fx, fy, fz, px, py, pz); +} + +INLINE void OdeBody:: +add_rel_force_at_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) { + dBodyAddRelForceAtPos(_id, fx, fy, fz, px, py, pz); +} + +INLINE void OdeBody:: +add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) { + dBodyAddRelForceAtRelPos(_id, fx, fy, fz, px, py, pz); +} + +INLINE void OdeBody:: +set_force(dReal x, dReal y, dReal z) { + dBodySetForce(_id, x, y, z); +} + +INLINE void OdeBody:: +set_torque(dReal x, dReal y, dReal z) { + dBodySetTorque(_id, x, y, z); +} + +INLINE LPoint3f OdeBody:: +get_rel_point_pos(dReal px, dReal py, dReal pz) const { + dVector3 result; + dBodyGetRelPointPos(_id, px, py, pz, result); + return LPoint3f(result[0], result[1], result[2]); +} + +INLINE LPoint3f OdeBody:: +get_rel_point_vel(dReal px, dReal py, dReal pz) const { + dVector3 result; + dBodyGetRelPointVel(_id, px, py, pz, result); + return LPoint3f(result[0], result[1], result[2]); +} + +INLINE LPoint3f OdeBody:: +get_point_vel(dReal px, dReal py, dReal pz) const { + dVector3 result; + dBodyGetPointVel(_id, px, py, pz, result); + return LPoint3f(result[0], result[1], result[2]); +} + +INLINE LPoint3f OdeBody:: +get_pos_rel_point(dReal px, dReal py, dReal pz) const { + dVector3 result; + dBodyGetPosRelPoint(_id, px, py, pz, result); + return LPoint3f(result[0], result[1], result[2]); +} + +INLINE LVecBase3f OdeBody:: +vector_to_world(dReal px, dReal py, dReal pz) const { + dVector3 result; + dBodyVectorToWorld(_id, px, py, pz, result); + return LVecBase3f(result[0], result[1], result[2]); +} + +INLINE LVecBase3f OdeBody:: +vector_from_world(dReal px, dReal py, dReal pz) const { + dVector3 result; + dBodyVectorFromWorld(_id, px, py, pz, result); + return LVecBase3f(result[0], result[1], result[2]); +} + +INLINE void OdeBody:: +set_finite_rotation_mode(int mode) { + dBodySetFiniteRotationMode(_id, mode); +} + +INLINE void OdeBody:: +set_finite_rotation_axis(dReal x, dReal y, dReal z) { + dBodySetFiniteRotationAxis(_id, x, y, z); +} + +INLINE int OdeBody:: +get_finite_rotation_mode() const { + return dBodyGetFiniteRotationMode(_id); +} + +INLINE LVecBase3f OdeBody:: +get_finite_rotation_axis() const { + dVector3 result; + dBodyGetFiniteRotationAxis(_id, result); + return LVecBase3f(result[0], result[1], result[2]); +} + +INLINE int OdeBody:: +get_num_joints() const { + return dBodyGetNumJoints(_id); +} + +INLINE void OdeBody:: +enable() { + dBodyEnable(_id); +} + +INLINE void OdeBody:: +disable() { + dBodyDisable(_id); +} + +INLINE int OdeBody:: +is_enabled() const { + return dBodyIsEnabled(_id); +} + +INLINE void OdeBody:: +set_gravity_mode(int mode) { + dBodySetGravityMode(_id, mode); +} + +INLINE int OdeBody:: +get_gravity_mode() const { + return dBodyGetGravityMode(_id); +} diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx new file mode 100755 index 0000000000..32d2eced3b --- /dev/null +++ b/panda/src/ode/odeBody.cxx @@ -0,0 +1,60 @@ +// Filename: odeBody.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeBody.h" + +TypeHandle OdeBody::_type_handle; + +OdeBody:: +OdeBody() : + _id(0) { +} + +OdeBody:: +OdeBody(dBodyID id) : + _id(id) { +} + +OdeBody:: +OdeBody(OdeWorld &world) : + _id(dBodyCreate(world.get_id())) { +} + +OdeBody:: +~OdeBody() { +} + +void OdeBody:: +destroy() { + dBodyDestroy(_id); +} + +void OdeBody:: +get_joint(int index, OdeJoint &joint) const { + joint._id = dBodyGetJoint(_id, index); +} + +void OdeBody:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out << "" << get_type() \ + << "(id = " << _id \ + << ")"; + #endif //] NDEBUG +} diff --git a/panda/src/ode/odeBody.h b/panda/src/ode/odeBody.h new file mode 100755 index 0000000000..683e42b62c --- /dev/null +++ b/panda/src/ode/odeBody.h @@ -0,0 +1,142 @@ +// Filename: odeBody.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEBODY_H +#define ODEBODY_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeWorld.h" +#include "odeMass.h" + +class OdeJoint; +class OdeGeom; +//////////////////////////////////////////////////////////////////// +// Class : OdeBody +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeBody : public TypedObject { + friend class OdeJoint; + friend class OdeGeom; + +protected: + OdeBody(dBodyID id); + +PUBLISHED: + OdeBody(); + OdeBody(OdeWorld &world); + virtual ~OdeBody(); + void destroy(); + + INLINE void set_auto_disable_linear_threshold(dReal linear_threshold); + INLINE void set_auto_disable_angular_threshold(dReal angular_threshold); + INLINE void set_auto_disable_steps(int steps); + INLINE void set_auto_disable_time(dReal time); + INLINE void set_auto_disable_flag(int do_auto_disable); + INLINE void set_auto_disable_defaults(); + INLINE void set_data(void *data); + + INLINE void set_position(dReal x, dReal y, dReal z); + INLINE void set_rotation(const LMatrix3f r); + INLINE void set_quaternion(const LQuaternionf q); + INLINE void set_linear_vel(dReal x, dReal y, dReal z); + INLINE void set_angular_vel(dReal x, dReal y, dReal z); + INLINE void set_mass(OdeMass &mass); + + + INLINE dReal get_auto_disable_linear_threshold() const; + INLINE dReal get_auto_disable_angular_threshold() const; + INLINE int get_auto_disable_steps() const; + INLINE dReal get_auto_disable_time() const; + INLINE int get_auto_disable_flag() const; + INLINE void* get_data() const; + + INLINE LVecBase3f get_position() const; + INLINE LVecBase3f get_rotation() const; + INLINE LVecBase4f get_quaternion() const; + INLINE LVecBase3f get_linear_vel() const; + INLINE LVecBase3f get_angular_vel() const; + INLINE OdeMass get_mass() const; + + INLINE void add_force(dReal fx, dReal fy, dReal fz); + INLINE void add_torque(dReal fx, dReal fy, dReal fz); + INLINE void add_rel_force(dReal fx, dReal fy, dReal fz); + INLINE void add_rel_torque(dReal fx, dReal fy, dReal fz); + INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); + INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); + INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); + INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz, + dReal px, dReal py, dReal pz); + INLINE void set_force(dReal x, dReal y, dReal z); + INLINE void set_torque(dReal x, dReal y, dReal z); + + INLINE LPoint3f get_rel_point_pos(dReal px, dReal py, dReal pz) const; + INLINE LPoint3f get_rel_point_vel(dReal px, dReal py, dReal pz) const; + INLINE LPoint3f get_point_vel(dReal px, dReal py, dReal pz) const; + INLINE LPoint3f get_pos_rel_point(dReal px, dReal py, dReal pz) const; + INLINE LVecBase3f vector_to_world(dReal px, dReal py, dReal pz) const; + INLINE LVecBase3f vector_from_world(dReal px, dReal py, dReal pz) const; + + INLINE void set_finite_rotation_mode(int mode); + INLINE void set_finite_rotation_axis(dReal x, dReal y, dReal z); + INLINE int get_finite_rotation_mode() const; + INLINE LVecBase3f get_finite_rotation_axis() const; + + INLINE int get_num_joints() const; + void get_joint(int index, OdeJoint &joint) const; + INLINE void enable(); + INLINE void disable(); + INLINE int is_enabled() const; + INLINE void set_gravity_mode(int mode); + INLINE int get_gravity_mode() const; + + virtual void write(ostream &out = cout, unsigned int indent=0) const; + +public: + INLINE dBodyID get_id() const; + +private: + dBodyID _id; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeBody", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeBody.I" + +#endif diff --git a/panda/src/ode/odeBoxGeom.I b/panda/src/ode/odeBoxGeom.I new file mode 100755 index 0000000000..0b060db7a8 --- /dev/null +++ b/panda/src/ode/odeBoxGeom.I @@ -0,0 +1,35 @@ +// Filename: odeBoxGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeBoxGeom:: +set_lengths(dReal lx, dReal ly, dReal lz) { + dGeomBoxSetLengths(_id, lx, ly, lz); +} + +INLINE LVecBase3f OdeBoxGeom:: +get_lengths() { + dVector3 res; + dGeomBoxGetLengths(_id, res); + return LVecBase3f(res[0], res[1], res[2]); +} + +INLINE dReal OdeBoxGeom:: +get_point_depth(dReal x, dReal y, dReal z) { + return dGeomBoxPointDepth(_id, x, y, z); +} + diff --git a/panda/src/ode/odeBoxGeom.cxx b/panda/src/ode/odeBoxGeom.cxx new file mode 100644 index 0000000000..32c504ec51 --- /dev/null +++ b/panda/src/ode/odeBoxGeom.cxx @@ -0,0 +1,36 @@ +// Filename: odeBoxGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeBoxGeom.h" + +TypeHandle OdeBoxGeom::_type_handle; + +OdeBoxGeom:: +OdeBoxGeom(dReal lx, dReal ly, dReal lz) : + OdeGeom(dCreateBox(0, lx, ly, lz)) { +} + +OdeBoxGeom:: +OdeBoxGeom(OdeSpace &space, dReal lx, dReal ly, dReal lz) : + OdeGeom(dCreateBox(space.get_id(), lx, ly, lz)) { +} + +OdeBoxGeom:: +~OdeBoxGeom() { +} diff --git a/panda/src/ode/odeBoxGeom.h b/panda/src/ode/odeBoxGeom.h new file mode 100644 index 0000000000..9f7c9bdc01 --- /dev/null +++ b/panda/src/ode/odeBoxGeom.h @@ -0,0 +1,66 @@ +// Filename: odeBoxGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEBOXGEOM_H +#define ODEBOXGEOM_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeBoxGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeBoxGeom : public OdeGeom { +PUBLISHED: + OdeBoxGeom(dReal lx, dReal ly, dReal lz); + OdeBoxGeom(OdeSpace &space, dReal lx, dReal ly, dReal lz); + virtual ~OdeBoxGeom(); + + INLINE void set_lengths(dReal lx, dReal ly, dReal lz); + INLINE LVecBase3f get_lengths(); + INLINE dReal get_point_depth(dReal x, dReal y, dReal z); + +public: + INLINE static int get_geom_class() { return dBoxClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeBoxGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeBoxGeom.I" + +#endif diff --git a/panda/src/ode/odeCappedCylinderGeom.I b/panda/src/ode/odeCappedCylinderGeom.I new file mode 100755 index 0000000000..49e3fd7592 --- /dev/null +++ b/panda/src/ode/odeCappedCylinderGeom.I @@ -0,0 +1,46 @@ +// Filename: odeCappedCylinderGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeCappedCylinderGeom:: +set_params(dReal radius, dReal length) { + dGeomCapsuleSetParams(_id, radius, length); +} + +INLINE void OdeCappedCylinderGeom:: +get_params(dReal *radius, dReal *length) const { + dGeomCapsuleGetParams(_id, radius, length); +} + +INLINE dReal OdeCappedCylinderGeom:: +get_radius() const { + dReal radius, length; + dGeomCapsuleGetParams(_id, &radius, &length); + return radius; +} + +INLINE dReal OdeCappedCylinderGeom:: +get_length() const { + dReal radius, length; + dGeomCapsuleGetParams(_id, &radius, &length); + return length; +} + +INLINE dReal OdeCappedCylinderGeom:: +get_point_depth(dReal x, dReal y, dReal z) const { + return dGeomCapsulePointDepth(_id, x, y, z); +} diff --git a/panda/src/ode/odeCappedCylinderGeom.cxx b/panda/src/ode/odeCappedCylinderGeom.cxx new file mode 100755 index 0000000000..0927646103 --- /dev/null +++ b/panda/src/ode/odeCappedCylinderGeom.cxx @@ -0,0 +1,36 @@ +// Filename: odeCappedCylinderGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeCappedCylinderGeom.h" + +TypeHandle OdeCappedCylinderGeom::_type_handle; + +OdeCappedCylinderGeom:: +OdeCappedCylinderGeom(dReal radius, dReal length) : + OdeGeom(dCreateCapsule(0, radius, length)) { +} + +OdeCappedCylinderGeom:: +OdeCappedCylinderGeom(OdeSpace &space, dReal radius, dReal length) : + OdeGeom(dCreateCapsule(space.get_id(), radius, length)) { +} + +OdeCappedCylinderGeom:: +~OdeCappedCylinderGeom() { +} diff --git a/panda/src/ode/odeCappedCylinderGeom.h b/panda/src/ode/odeCappedCylinderGeom.h new file mode 100755 index 0000000000..ca9aab4c92 --- /dev/null +++ b/panda/src/ode/odeCappedCylinderGeom.h @@ -0,0 +1,68 @@ +// Filename: odeCappedCylinderGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODECAPPEDCYLINDERGEOM_H +#define ODECAPPEDCYLINDERGEOM_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeCappedCylinderGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeCappedCylinderGeom : public OdeGeom { +PUBLISHED: + OdeCappedCylinderGeom(dReal radius, dReal length); + OdeCappedCylinderGeom(OdeSpace &space, dReal radius, dReal length); + virtual ~OdeCappedCylinderGeom(); + + INLINE void set_params(dReal radius, dReal length); + INLINE void get_params(dReal *radius, dReal *length) const; + INLINE dReal get_radius() const; + INLINE dReal get_length() const; + INLINE dReal get_point_depth(dReal x, dReal y, dReal z) const; + +public: + INLINE static int get_geom_class() { return dCapsuleClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeCappedCylinderGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeCappedCylinderGeom.I" + +#endif diff --git a/panda/src/ode/odeContact.I b/panda/src/ode/odeContact.I new file mode 100755 index 0000000000..88b23b97f8 --- /dev/null +++ b/panda/src/ode/odeContact.I @@ -0,0 +1,54 @@ +// Filename: odeContact.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE OdeSurfaceParameters OdeContact:: +get_surface() const { + return OdeSurfaceParameters(_contact.surface); +} + +INLINE OdeContactGeom OdeContact:: +get_geom() { + return OdeContactGeom(_contact.geom); +} + +INLINE LVecBase3f OdeContact:: +get_fdir1() const { + return LVecBase3f(_contact.fdir1[0], + _contact.fdir1[1], + _contact.fdir1[2]); +} + + +INLINE void OdeContact:: +set_surface(const OdeSurfaceParameters &surface_parameters) { + _contact.surface = *(surface_parameters.get_surface_parameters_ptr()); +} + +INLINE void OdeContact:: +set_geom(const OdeContactGeom &contact_geom) { + _contact.geom = *(contact_geom.get_contact_geom_ptr()); +} + +INLINE void OdeContact:: +set_fdir1(const LVecBase3f &fdir1) { + _contact.fdir1[0] = fdir1[0]; + _contact.fdir1[1] = fdir1[1]; + _contact.fdir1[2] = fdir1[2]; +} + + diff --git a/panda/src/ode/odeContact.cxx b/panda/src/ode/odeContact.cxx new file mode 100755 index 0000000000..1982aae2fe --- /dev/null +++ b/panda/src/ode/odeContact.cxx @@ -0,0 +1,41 @@ +// Filename: odeContact.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeContact.h" + +TypeHandle OdeContact::_type_handle; + +OdeContact:: +OdeContact() : + _contact() { +} + +OdeContact:: +OdeContact(const dContact &contact) : + _contact(contact) { +} + +OdeContact:: +~OdeContact() { +} + +const dContact* OdeContact:: +get_contact_ptr() const { + return &_contact; +} diff --git a/panda/src/ode/odeContact.h b/panda/src/ode/odeContact.h new file mode 100755 index 0000000000..b7d29ef8b6 --- /dev/null +++ b/panda/src/ode/odeContact.h @@ -0,0 +1,77 @@ +// Filename: odeContact.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODECONTACT_H +#define ODECONTACT_H + +#include "pandabase.h" +#include "typedReferenceCount.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeSurfaceParameters.h" +#include "odeContactGeom.h" + + +//////////////////////////////////////////////////////////////////// +// Class : OdeContact +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeContact : public TypedReferenceCount { +PUBLISHED: + OdeContact(); + // OdeContact(const OdeContact ©); + OdeContact(const dContact &contact); + virtual ~OdeContact(); + + INLINE OdeSurfaceParameters get_surface() const; + INLINE OdeContactGeom get_geom(); + INLINE LVecBase3f get_fdir1() const; + + INLINE void set_surface(const OdeSurfaceParameters &surface_parameters); + INLINE void set_geom(const OdeContactGeom &contact_geom); + INLINE void set_fdir1(const LVecBase3f &fdir1); + +public: + const dContact* get_contact_ptr() const; + +private: + void operator = (const OdeContact ©); + dContact _contact; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedReferenceCount::init_type(); + register_type(_type_handle, "OdeContact", + TypedReferenceCount::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeContact.I" + +#endif diff --git a/panda/src/ode/odeContactGeom.I b/panda/src/ode/odeContactGeom.I new file mode 100755 index 0000000000..7d6c95a277 --- /dev/null +++ b/panda/src/ode/odeContactGeom.I @@ -0,0 +1,87 @@ +// Filename: odeContactGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE LVecBase3f OdeContactGeom:: +get_pos() const { + return LVecBase3f(_contact_geom.pos[0], + _contact_geom.pos[1], + _contact_geom.pos[2]); +} + +INLINE LVecBase3f OdeContactGeom:: +get_normal() const { + return LVecBase3f(_contact_geom.normal[0], + _contact_geom.normal[1], + _contact_geom.normal[2]); +} + +INLINE dReal OdeContactGeom:: +get_depth() const { + return _contact_geom.depth; +} + +INLINE OdeGeom OdeContactGeom:: +get_g1() const { + return OdeGeom(_contact_geom.g1); +} + +INLINE OdeGeom OdeContactGeom:: +get_g2() const { + return OdeGeom(_contact_geom.g2); +} + +INLINE int OdeContactGeom:: +get_side1() const { + return _contact_geom.side1; +} + +INLINE int OdeContactGeom:: +get_side2() const { + return _contact_geom.side2; +} + +INLINE void OdeContactGeom:: +set_pos(const LVecBase3f &pos){ + _contact_geom.pos[0] = pos[0]; + _contact_geom.pos[1] = pos[1]; + _contact_geom.pos[2] = pos[2]; +} + +INLINE void OdeContactGeom:: +set_normal(const LVecBase3f &normal){ + _contact_geom.normal[0] = normal[0]; + _contact_geom.normal[1] = normal[1]; + _contact_geom.normal[2] = normal[2]; +} + +INLINE void OdeContactGeom:: +set_depth(const dReal depth){ + _contact_geom.depth = depth; +} + +INLINE void OdeContactGeom:: +set_g1(const OdeGeom &geom){ + _contact_geom.g1 = geom._id; +} + +INLINE void OdeContactGeom:: +set_g2(const OdeGeom &geom){ + _contact_geom.g2 = geom._id; +} + + diff --git a/panda/src/ode/odeContactGeom.cxx b/panda/src/ode/odeContactGeom.cxx new file mode 100755 index 0000000000..fa738a43e2 --- /dev/null +++ b/panda/src/ode/odeContactGeom.cxx @@ -0,0 +1,84 @@ +// Filename: odeContactGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeContactGeom.h" + +TypeHandle OdeContactGeom::_type_handle; + +OdeContactGeom:: +OdeContactGeom() : + _contact_geom() { +} + +OdeContactGeom:: +OdeContactGeom(const OdeContactGeom ©) : + _contact_geom() { + _contact_geom.pos[0] = copy._contact_geom.pos[0]; + _contact_geom.pos[1] = copy._contact_geom.pos[1]; + _contact_geom.pos[2] = copy._contact_geom.pos[2]; + _contact_geom.normal[0] = copy._contact_geom.normal[0]; + _contact_geom.normal[1] = copy._contact_geom.normal[1]; + _contact_geom.normal[2] = copy._contact_geom.normal[2]; + _contact_geom.depth = copy._contact_geom.depth; + _contact_geom.g1 = copy._contact_geom.g1; + _contact_geom.g2 = copy._contact_geom.g2; + _contact_geom.side1 = copy._contact_geom.side1; + _contact_geom.side2 = copy._contact_geom.side2; +} + +OdeContactGeom:: +OdeContactGeom(const dContactGeom &contact_geom) : + _contact_geom() { + _contact_geom.pos[0] = contact_geom.pos[0]; + _contact_geom.pos[1] = contact_geom.pos[1]; + _contact_geom.pos[2] = contact_geom.pos[2]; + _contact_geom.normal[0] = contact_geom.normal[0]; + _contact_geom.normal[1] = contact_geom.normal[1]; + _contact_geom.normal[2] = contact_geom.normal[2]; + _contact_geom.depth = contact_geom.depth; + _contact_geom.g1 = contact_geom.g1; + _contact_geom.g2 = contact_geom.g2; + _contact_geom.side1 = contact_geom.side1; + _contact_geom.side2 = contact_geom.side2; +} + +OdeContactGeom:: +~OdeContactGeom() { +} + +const dContactGeom* OdeContactGeom:: +get_contact_geom_ptr() const { + return &_contact_geom; +} + +void OdeContactGeom:: +operator = (const OdeContactGeom ©) { + _contact_geom.pos[0] = copy._contact_geom.pos[0]; + _contact_geom.pos[1] = copy._contact_geom.pos[1]; + _contact_geom.pos[2] = copy._contact_geom.pos[2]; + _contact_geom.normal[0] = copy._contact_geom.normal[0]; + _contact_geom.normal[1] = copy._contact_geom.normal[1]; + _contact_geom.normal[2] = copy._contact_geom.normal[2]; + _contact_geom.depth = copy._contact_geom.depth; + _contact_geom.g1 = copy._contact_geom.g1; + _contact_geom.g2 = copy._contact_geom.g2; + _contact_geom.side1 = copy._contact_geom.side1; + _contact_geom.side2 = copy._contact_geom.side2; +} + diff --git a/panda/src/ode/odeContactGeom.h b/panda/src/ode/odeContactGeom.h new file mode 100755 index 0000000000..e0ab002ed1 --- /dev/null +++ b/panda/src/ode/odeContactGeom.h @@ -0,0 +1,85 @@ +// Filename: odeContactGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODECONTACTGEOM_H +#define ODECONTACTGEOM_H + +#include "pandabase.h" +#include "typedReferenceCount.h" +#include "luse.h" + +#include "ode/ode.h" +#include "OdeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeContactGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeContactGeom : public TypedReferenceCount { + friend class OdeContact; + +protected: + OdeContactGeom(const dContactGeom &contact_geom); + +PUBLISHED: + OdeContactGeom(); + OdeContactGeom(const OdeContactGeom ©); + virtual ~OdeContactGeom(); + + INLINE LVecBase3f get_pos() const; + INLINE LVecBase3f get_normal() const; + INLINE dReal get_depth() const; + INLINE OdeGeom get_g1() const; + INLINE OdeGeom get_g2() const; + INLINE int get_side1() const; + INLINE int get_side2() const; + + INLINE void set_pos(const LVecBase3f &pos); + INLINE void set_normal(const LVecBase3f &normal); + INLINE void set_depth(const dReal depth); + INLINE void set_g1(const OdeGeom &geom); + INLINE void set_g2(const OdeGeom &geom); + +public: + const dContactGeom* get_contact_geom_ptr() const; + +private: + void operator = (const OdeContactGeom ©); + dContactGeom _contact_geom; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedReferenceCount::init_type(); + register_type(_type_handle, "OdeContactGeom", + TypedReferenceCount::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeContactGeom.I" + +#endif diff --git a/panda/src/ode/odeContactJoint.I b/panda/src/ode/odeContactJoint.I new file mode 100755 index 0000000000..b18fd39ac7 --- /dev/null +++ b/panda/src/ode/odeContactJoint.I @@ -0,0 +1,17 @@ +// Filename: odeContactJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// diff --git a/panda/src/ode/odeContactJoint.cxx b/panda/src/ode/odeContactJoint.cxx new file mode 100755 index 0000000000..bc28477811 --- /dev/null +++ b/panda/src/ode/odeContactJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeContactJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeContactJoint.h" + +TypeHandle OdeContactJoint::_type_handle; + +OdeContactJoint:: +OdeContactJoint(OdeWorld &world, const OdeContact &contact) : + OdeJoint(dJointCreateContact(world.get_id(), 0, contact.get_contact_ptr())) { +} + +OdeContactJoint:: +OdeContactJoint(OdeWorld &world, OdeJointGroup &joint_group, const OdeContact &contact) : + OdeJoint(dJointCreateContact(world.get_id(), joint_group.get_id(), contact.get_contact_ptr())) { +} + +OdeContactJoint:: +~OdeContactJoint() { +} diff --git a/panda/src/ode/odeContactJoint.h b/panda/src/ode/odeContactJoint.h new file mode 100644 index 0000000000..b071b357dc --- /dev/null +++ b/panda/src/ode/odeContactJoint.h @@ -0,0 +1,43 @@ +#ifndef ODECONTACTJOINT_H +#define ODECONTACTJOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" +#include "odeContact.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeContactJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeContactJoint : public OdeJoint { +PUBLISHED: + OdeContactJoint(OdeWorld &world, const OdeContact &contact); + OdeContactJoint(OdeWorld &world, OdeJointGroup &joint_group, const OdeContact &contact); + virtual ~OdeContactJoint(); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeContactJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeContactJoint.I" + +#endif diff --git a/panda/src/ode/odeConvexGeom.I b/panda/src/ode/odeConvexGeom.I new file mode 100755 index 0000000000..6e02f494b0 --- /dev/null +++ b/panda/src/ode/odeConvexGeom.I @@ -0,0 +1,23 @@ +// Filename: odeBoxGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeGeom:: +set_convex(dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount, unsigned int *_polygons) { + dGeomSetConvex(_id, *_planes, _count, *_points, _pointcount, *_polygons); +} + diff --git a/panda/src/ode/odeConvexGeom.cxx b/panda/src/ode/odeConvexGeom.cxx new file mode 100644 index 0000000000..a6302fefe5 --- /dev/null +++ b/panda/src/ode/odeConvexGeom.cxx @@ -0,0 +1,36 @@ +// Filename: odeConvexGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeConvexGeom.h" + +TypeHandle OdeConvexGeom::_type_handle; + +OdeConvexGeom:: +OdeConvexGeom(dReal radius, dReal length) : + OdeGeom(dCreateConvex(0, radius, length)) { +} + +OdeConvexGeom:: +OdeConvexGeom(OdeSpace &space, dReal radius, dReal length) : + OdeGeom(dCreateConvex(space.get_id(), radius, length)) { +} + +OdeConvexGeom:: +~OdeConvexGeom() { +} diff --git a/panda/src/ode/odeConvexGeom.h b/panda/src/ode/odeConvexGeom.h new file mode 100755 index 0000000000..9ccea2c776 --- /dev/null +++ b/panda/src/ode/odeConvexGeom.h @@ -0,0 +1,63 @@ +// Filename: odeConvexGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODECONVEXGEOM_H +#define ODECONVEXGEOM_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeConvexGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeConvexGeom : public OdeGeom { +PUBLISHED: + OdeConvexGeom(); + virtual ~OdeConvexGeom(); + + INLINE void set_convex(dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount, unsigned int *_polygons); + +public: + INLINE static int get_geom_class() { return dConvexClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeConvexGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeConvexGeom.I" + +#endif diff --git a/panda/src/ode/odeCylinderGeom.I b/panda/src/ode/odeCylinderGeom.I new file mode 100755 index 0000000000..c1763f84ca --- /dev/null +++ b/panda/src/ode/odeCylinderGeom.I @@ -0,0 +1,41 @@ +// Filename: odeCylinderGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeCylinderGeom:: +set_params(dReal radius, dReal length) { + dGeomCylinderSetParams(_id, radius, length); +} + +INLINE void OdeCylinderGeom:: +get_params(dReal *radius, dReal *length) const { + dGeomCapsuleGetParams(_id, radius, length); +} + +INLINE dReal OdeCylinderGeom:: +get_radius() const { + dReal radius, length; + dGeomCylinderGetParams(_id, &radius, &length); + return radius; +} + +INLINE dReal OdeCylinderGeom:: +get_length() const { + dReal radius, length; + dGeomCylinderGetParams(_id, &radius, &length); + return length; +} diff --git a/panda/src/ode/odeCylinderGeom.cxx b/panda/src/ode/odeCylinderGeom.cxx new file mode 100644 index 0000000000..8060f74d2a --- /dev/null +++ b/panda/src/ode/odeCylinderGeom.cxx @@ -0,0 +1,36 @@ +// Filename: odeCylinderGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeCylinderGeom.h" + +TypeHandle OdeCylinderGeom::_type_handle; + +OdeCylinderGeom:: +OdeCylinderGeom(dReal radius, dReal length) : + OdeGeom(dCreateCylinder(0, radius, length)) { +} + +OdeCylinderGeom:: +OdeCylinderGeom(OdeSpace &space, dReal radius, dReal length) : + OdeGeom(dCreateCylinder(space.get_id(), radius, length)) { +} + +OdeCylinderGeom:: +~OdeCylinderGeom() { +} diff --git a/panda/src/ode/odeCylinderGeom.h b/panda/src/ode/odeCylinderGeom.h new file mode 100755 index 0000000000..4a6925c005 --- /dev/null +++ b/panda/src/ode/odeCylinderGeom.h @@ -0,0 +1,67 @@ +// Filename: odeCylinderGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODECYLINDERGEOM_H +#define ODECYLINDERGEOM_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeCylinderGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeCylinderGeom : public OdeGeom { +PUBLISHED: + OdeCylinderGeom(dReal radius, dReal length); + OdeCylinderGeom(OdeSpace &space, dReal radius, dReal length); + virtual ~OdeCylinderGeom(); + + INLINE void set_params(dReal radius, dReal length); + INLINE void get_params(dReal *radius, dReal *length) const; + INLINE dReal get_radius() const; + INLINE dReal get_length() const; + +public: + INLINE static int get_geom_class() { return dCylinderClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeCylinderGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeCylinderGeom.I" + +#endif diff --git a/panda/src/ode/odeFixedJoint.I b/panda/src/ode/odeFixedJoint.I new file mode 100755 index 0000000000..b6facb57a7 --- /dev/null +++ b/panda/src/ode/odeFixedJoint.I @@ -0,0 +1,22 @@ +// Filename: odeFixedJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeFixedJoint:: +set_fixed() { + dJointSetFixed(_id); +} diff --git a/panda/src/ode/odeFixedJoint.cxx b/panda/src/ode/odeFixedJoint.cxx new file mode 100644 index 0000000000..6109f39867 --- /dev/null +++ b/panda/src/ode/odeFixedJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeFixedJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeFixedJoint.h" + +TypeHandle OdeFixedJoint::_type_handle; + +OdeFixedJoint:: +OdeFixedJoint(OdeWorld &world) : + OdeJoint(dJointCreateFixed(world.get_id(), 0)) { +} + +OdeFixedJoint:: +OdeFixedJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateFixed(world.get_id(), joint_group.get_id())) { +} + +OdeFixedJoint:: +~OdeFixedJoint() { +} diff --git a/panda/src/ode/odeFixedJoint.h b/panda/src/ode/odeFixedJoint.h new file mode 100644 index 0000000000..861692823f --- /dev/null +++ b/panda/src/ode/odeFixedJoint.h @@ -0,0 +1,44 @@ +#ifndef ODEFIXEDJOINT_H +#define ODEFIXEDJOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeFixedJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeFixedJoint : public OdeJoint { +PUBLISHED: + OdeFixedJoint(OdeWorld &world); + OdeFixedJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeFixedJoint(); + + INLINE void set_fixed(); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeFixedJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeFixedJoint.I" + +#endif diff --git a/panda/src/ode/odeGeom.I b/panda/src/ode/odeGeom.I new file mode 100755 index 0000000000..a83202dcbf --- /dev/null +++ b/panda/src/ode/odeGeom.I @@ -0,0 +1,190 @@ +// Filename: odeGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE dGeomID OdeGeom:: +get_id() const { + return _id; +} + +INLINE OdeBody OdeGeom:: +get_body() const { + return OdeBody(dGeomGetBody(_id)); +} + +INLINE void OdeGeom:: +set_body(OdeBody &body) { + dGeomSetBody(_id, body.get_id()); +} + +/* +INLINE void OdeGeom:: +set_data(void* data) { + dGeomSetData(_id, data); +} +*/ + +INLINE void OdeGeom:: +set_position(dReal x, dReal y, dReal z) { + dGeomSetPosition(_id, x, y, z); +} + +INLINE void OdeGeom:: +set_rotation(const LMatrix3f &r) { + dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0, + r._m.data[3], r._m.data[4], r._m.data[5], 0, + r._m.data[6], r._m.data[7], r._m.data[8], 0 }; + dGeomSetRotation(_id, rot); +} + +INLINE void OdeGeom:: +set_quaternion(const LQuaternionf &q) { + dQuaternion quat = { q[0], q[1], q[2], q[3] }; + dGeomSetQuaternion(_id, quat); +} + +INLINE LPoint3f OdeGeom:: +get_position() const { + const dReal *pos = dGeomGetPosition(_id); + return LPoint3f(pos[0], pos[1], pos[2]); +} + +INLINE LMatrix3f OdeGeom:: +get_rotation() const { + const dReal *rot = dGeomGetRotation(_id); + return LMatrix3f(rot[0], rot[1], rot[2], + rot[4], rot[5], rot[6], + rot[8], rot[9], rot[10]); +} + +INLINE LQuaternionf OdeGeom:: +get_quaternion() const { + dQuaternion res; + dGeomGetQuaternion(_id, res); + return LQuaternionf(res[0], res[1], res[2], res[3]); +} + +/* +INLINE void OdeGeom:: +get_aabb(dReal aabb[6]) const { + return dGeomGetAABB(_id, aabb[6]); +} +*/ + +INLINE int OdeGeom:: +is_space() { + return dGeomIsSpace(_id); +} + +INLINE int OdeGeom:: +get_class() const { + return dGeomGetClass(_id); +} + +INLINE void OdeGeom:: +set_category_bits(unsigned long bits) { + dGeomSetCategoryBits(_id, bits); +} + +INLINE void OdeGeom:: +set_collide_bits(unsigned long bits) { + dGeomSetCollideBits(_id, bits); +} + +INLINE void OdeGeom:: +enable() { + dGeomEnable(_id); +} + +INLINE void OdeGeom:: +disable() { + dGeomDisable(_id); +} + +INLINE int OdeGeom:: +is_enabled() { + return dGeomIsEnabled(_id); +} + +INLINE void OdeGeom:: +set_offset_position(dReal x, dReal y, dReal z) { + dGeomSetOffsetPosition(_id, x, y, z); +} + +INLINE void OdeGeom:: +set_offset_rotation(const LMatrix3f &r) { + dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0, + r._m.data[3], r._m.data[4], r._m.data[5], 0, + r._m.data[6], r._m.data[7], r._m.data[8], 0 }; + dGeomSetOffsetRotation(_id, rot); +} + +INLINE void OdeGeom:: +set_offset_quaternion(const LQuaternionf &q) { + dQuaternion quat = { q[0], q[1], q[2], q[3] }; + dGeomSetOffsetQuaternion(_id, quat); +} + +INLINE void OdeGeom:: +set_offset_world_position(dReal x, dReal y, dReal z) { + dGeomSetOffsetWorldPosition(_id, x, y, z); +} + +INLINE void OdeGeom:: +set_offset_world_rotation(const LMatrix3f &r) { + dMatrix3 rot = { r._m.data[0], r._m.data[1], r._m.data[2], 0, + r._m.data[3], r._m.data[4], r._m.data[5], 0, + r._m.data[6], r._m.data[7], r._m.data[8], 0 }; + dGeomSetOffsetWorldRotation(_id, rot); +} + +INLINE void OdeGeom:: +set_offset_world_quaternion(const LQuaternionf &q) { + dQuaternion quat = { q[0], q[1], q[2], q[3] }; + dGeomSetOffsetWorldQuaternion(_id, quat); +} + +INLINE void OdeGeom:: +clear_offset() { + dGeomClearOffset(_id); +} + +INLINE int OdeGeom:: +is_offset() { + return dGeomIsOffset(_id); +} + +INLINE LPoint3f OdeGeom:: +get_offset_position() const { + const dReal *pos = dGeomGetOffsetPosition(_id); + return LPoint3f(pos[0], pos[1], pos[2]); +} + +INLINE LMatrix3f OdeGeom:: +get_offset_rotation() const { + const dReal *rot = dGeomGetOffsetRotation(_id); + return LMatrix3f(rot[0], rot[1], rot[2], + rot[4], rot[5], rot[6], + rot[8], rot[9], rot[10]); +} + +INLINE LQuaternionf OdeGeom:: +get_offset_quaternion() const { + dQuaternion res; + dGeomGetOffsetQuaternion(_id, res); + return LQuaternionf(res[0], res[1], res[2], res[3]); +} diff --git a/panda/src/ode/odeGeom.cxx b/panda/src/ode/odeGeom.cxx new file mode 100755 index 0000000000..960c0326e0 --- /dev/null +++ b/panda/src/ode/odeGeom.cxx @@ -0,0 +1,60 @@ +// Filename: odeGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeGeom.h" + +TypeHandle OdeGeom::_type_handle; + +OdeGeom:: +OdeGeom() : + _id(0) { + odegeom_cat.debug() << get_type() << "(" << _id << ")\n"; +} + +OdeGeom:: +OdeGeom(dGeomID id) : + _id(id) { + odegeom_cat.debug() << get_type() << "(" << _id << ")\n"; +} + +OdeGeom:: +~OdeGeom() { +} + +void OdeGeom:: +destroy() { + if (get_class() == OdeTriMeshGeom::get_geom_class()) { + OdeTriMeshGeom::unlink_data(_id); + } +} + +void OdeGeom:: +get_space(OdeSpace &space) const { + space._id = dGeomGetSpace(_id); +} + + +void OdeGeom:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out << get_type() << "(id = " << _id << ")"; + #endif //] NDEBUG +} + diff --git a/panda/src/ode/odeGeom.h b/panda/src/ode/odeGeom.h new file mode 100755 index 0000000000..3f4ca31160 --- /dev/null +++ b/panda/src/ode/odeGeom.h @@ -0,0 +1,107 @@ +// Filename: odeGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEGEOM_H +#define ODEGEOM_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeSpace.h" // Needed for derived classes +#include "odeBody.h" + +class OdeTriMeshGeom; + +//////////////////////////////////////////////////////////////////// +// Class : OdeGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeGeom : public TypedObject { + friend class OdeContactGeom; + friend class OdeSpace; + +protected: + OdeGeom(dGeomID id); + +PUBLISHED: + OdeGeom(); + virtual ~OdeGeom(); + void destroy(); + + //INLINE void set_data(void* data); + INLINE void set_body(OdeBody &body); + INLINE OdeBody get_body() const; + INLINE void set_position(dReal x, dReal y, dReal z); + INLINE void set_rotation(const LMatrix3f &r); + INLINE void set_quaternion(const LQuaternionf &q); + INLINE LPoint3f get_position() const; + INLINE LMatrix3f get_rotation() const; + INLINE LQuaternionf get_quaternion() const; + //INLINE void get_aabb(dReal aabb[6]) const; + INLINE int is_space(); + INLINE int get_class() const; + INLINE void set_category_bits(unsigned long bits); + INLINE void set_collide_bits(unsigned long bits); + INLINE void enable(); + INLINE void disable(); + INLINE int is_enabled(); + INLINE void set_offset_position(dReal x, dReal y, dReal z); + INLINE void set_offset_rotation(const LMatrix3f &r); + INLINE void set_offset_quaternion(const LQuaternionf &q); + INLINE void set_offset_world_position(dReal x, dReal y, dReal z); + INLINE void set_offset_world_rotation(const LMatrix3f &r); + INLINE void set_offset_world_quaternion(const LQuaternionf &q); + INLINE void clear_offset(); + INLINE int is_offset(); + INLINE LPoint3f get_offset_position() const; + INLINE LMatrix3f get_offset_rotation() const; + INLINE LQuaternionf get_offset_quaternion() const; + + void get_space(OdeSpace &space) const; + virtual void write(ostream &out = cout, unsigned int indent=0) const; +public: + INLINE dGeomID get_id() const; + + INLINE static int get_geom_class() { return -1; }; + +protected: + dGeomID _id; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeGeom", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeGeom.I" + +#endif diff --git a/panda/src/ode/odeHashSpace.I b/panda/src/ode/odeHashSpace.I new file mode 100755 index 0000000000..ce80498d3f --- /dev/null +++ b/panda/src/ode/odeHashSpace.I @@ -0,0 +1,36 @@ +// Filename: odeHashSpace.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeHashSpace:: +set_levels(int minlevel, int maxlevel) { + dHashSpaceSetLevels(_id, minlevel, maxlevel); +} + +INLINE int OdeHashSpace:: +get_min_level() const { + int min, max; + dHashSpaceGetLevels(_id, &min, &max); + return min; +} + +INLINE int OdeHashSpace:: +get_max_level() const { + int min, max; + dHashSpaceGetLevels(_id, &min, &max); + return max; +} diff --git a/panda/src/ode/odeHashSpace.cxx b/panda/src/ode/odeHashSpace.cxx new file mode 100755 index 0000000000..8edfa5741d --- /dev/null +++ b/panda/src/ode/odeHashSpace.cxx @@ -0,0 +1,37 @@ +// Filename: odeHashSpace.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeHashSpace.h" + +TypeHandle OdeHashSpace::_type_handle; + +OdeHashSpace:: +OdeHashSpace() : + OdeSpace(dHashSpaceCreate(0)) { +} + +OdeHashSpace:: +OdeHashSpace(OdeSpace &space) : + OdeSpace(dHashSpaceCreate(space.get_id())) { +} + +OdeHashSpace:: +~OdeHashSpace() { +} + diff --git a/panda/src/ode/odeHashSpace.h b/panda/src/ode/odeHashSpace.h new file mode 100755 index 0000000000..056fd0ba64 --- /dev/null +++ b/panda/src/ode/odeHashSpace.h @@ -0,0 +1,65 @@ +// Filename: odeHashSpace.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEHASHSPACE_H +#define ODEHASHSPACE_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeSpace.h" + + +//////////////////////////////////////////////////////////////////// +// Class : OdeHashSpace +// Description : +////////////////////////////////////////////////////////////////////c +class EXPCL_PANDAODE OdeHashSpace : public OdeSpace { +PUBLISHED: + OdeHashSpace(); + OdeHashSpace(OdeSpace &space); + virtual ~OdeHashSpace(); + + INLINE void set_levels(int minlevel, int maxlevel); + INLINE int get_min_level() const; + INLINE int get_max_level() const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeSpace::init_type(); + register_type(_type_handle, "OdeHashSpace", + OdeSpace::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeHashSpace.I" + +#endif + diff --git a/panda/src/ode/odeHeightFieldGeom.h b/panda/src/ode/odeHeightFieldGeom.h new file mode 100644 index 0000000000..2016f2ef9c --- /dev/null +++ b/panda/src/ode/odeHeightFieldGeom.h @@ -0,0 +1,68 @@ +// Filename: odeBoxGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEBOXGEOM_H +#define ODEBOXGEOM_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeBoxGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeBoxGeom : public OdeGeom { +PUBLISHED: + OdeBoxGeom(); + virtual ~OdeBoxGeom(); + + INLINE dHeightfieldDataID heightfield_data_create(); + INLINE void heightfield_data_destroy(dHeightfieldDataID d); + INLINE void heightfield_data_build_callback(dHeightfieldDataID d, void* p_user_data, dHeightfieldGetHeight* p_callback, dReal width, dReal depth, int width_samples, int depth_samples, dReal scale, dReal offset, dReal thickness, int b_wrap); + INLINE void heightfield_data_build_byte(dHeightfieldDataID d, const unsigned char* p_height_data, int b_copy_height_data, dReal width, dReal depth, int width_samples, int depth_samples, dReal scale, dReal offset, dReal thickness, int b_wrap); + INLINE void heightfield_data_build_short(dHeightfieldDataID d, const short* p_height_data, int b_copy_height_data, dReal width, dReal depth, int width_samples, int depth_samples, dReal scale, dReal offset, dReal thickness, int b_wrap); + INLINE void heightfield_data_build_single(dHeightfieldDataID d, const float* p_height_data, int b_copy_height_data, dReal width, dReal depth, int width_samples, int depth_samples, dReal scale, dReal offset, dReal thickness, int b_wrap); + INLINE void heightfield_data_build_double(dHeightfieldDataID d, const double* p_height_data, int b_copy_height_data, dReal width, dReal depth, int width_samples, int depth_samples, dReal scale, dReal offset, dReal thickness, int b_wrap); + INLINE void heightfield_data_set_bounds(dHeightfieldDataID d, dReal min_height, dReal max_height); + INLINE void heightfield_set_heightfield_data(dHeightfieldDataID d); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeBoxGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeBoxGeom.I" + +#endif diff --git a/panda/src/ode/odeHinge2Joint.I b/panda/src/ode/odeHinge2Joint.I new file mode 100755 index 0000000000..f83a2c6ad6 --- /dev/null +++ b/panda/src/ode/odeHinge2Joint.I @@ -0,0 +1,83 @@ +// Filename: odeHinge2Joint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +INLINE void OdeHinge2Joint:: +set_hinge2_anchor(dReal x, dReal y, dReal z) { + dJointSetHinge2Anchor(_id, x, y, z); +} + +INLINE void OdeHinge2Joint:: +set_hinge2_axis1(dReal x, dReal y, dReal z) { + dJointSetHinge2Axis1(_id, x, y, z); +} + +INLINE void OdeHinge2Joint:: +set_hinge2_axis2(dReal x, dReal y, dReal z) { + dJointSetHinge2Axis2(_id, x, y, z); +} + +INLINE void OdeHinge2Joint:: +set_hinge2_param(int parameter, dReal value) { + dJointSetHinge2Param(_id, parameter, value); +} + +INLINE void OdeHinge2Joint:: +add_hinge2_torques(dReal torque1, dReal torque2) { + dJointAddHinge2Torques(_id, torque1, torque2); +} + +INLINE void OdeHinge2Joint:: +get_hinge2_anchor(dVector3 result) const { + return dJointGetHinge2Anchor(_id, result); +} + +INLINE void OdeHinge2Joint:: +get_hinge2_anchor2(dVector3 result) const { + return dJointGetHinge2Anchor2(_id, result); +} + +INLINE void OdeHinge2Joint:: +get_hinge2_axis1(dVector3 result) const { + return dJointGetHinge2Axis1(_id, result); +} + +INLINE void OdeHinge2Joint:: +get_hinge2_axis2(dVector3 result) const { + return dJointGetHinge2Axis2(_id, result); +} + +INLINE dReal OdeHinge2Joint:: +get_hinge2_param(int parameter) const { + return dJointGetHinge2Param(_id, parameter); +} + +INLINE dReal OdeHinge2Joint:: +get_hinge2_angle1() const { + return dJointGetHinge2Angle1(_id); +} + +INLINE dReal OdeHinge2Joint:: +get_hinge2_angle1_rate() const { + return dJointGetHinge2Angle1Rate(_id); +} + +INLINE dReal OdeHinge2Joint:: +get_hinge2_angle2_rate() const { + return dJointGetHinge2Angle2Rate(_id); +} diff --git a/panda/src/ode/odeHinge2Joint.cxx b/panda/src/ode/odeHinge2Joint.cxx new file mode 100644 index 0000000000..75b15f4829 --- /dev/null +++ b/panda/src/ode/odeHinge2Joint.cxx @@ -0,0 +1,36 @@ +// Filename: odeHinge2Joint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeHinge2Joint.h" + +TypeHandle OdeHinge2Joint::_type_handle; + +OdeHinge2Joint:: +OdeHinge2Joint(OdeWorld &world) : + OdeJoint(dJointCreateHinge2(world.get_id(), 0)) { +} + +OdeHinge2Joint:: +OdeHinge2Joint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateHinge2(world.get_id(), joint_group.get_id())) { +} + +OdeHinge2Joint:: +~OdeHinge2Joint() { +} diff --git a/panda/src/ode/odeHinge2Joint.h b/panda/src/ode/odeHinge2Joint.h new file mode 100644 index 0000000000..cbfa6899e0 --- /dev/null +++ b/panda/src/ode/odeHinge2Joint.h @@ -0,0 +1,57 @@ +#ifndef ODEHINGE2JOINT_H +#define ODEHINGE2JOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeHinge2Joint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeHinge2Joint : public OdeJoint { +PUBLISHED: + OdeHinge2Joint(OdeWorld &world, OdeJointGroup &joint_group); + OdeHinge2Joint(OdeWorld &world); + virtual ~OdeHinge2Joint(); + + INLINE void set_hinge2_anchor(dReal x, dReal y, dReal z); + INLINE void set_hinge2_axis1(dReal x, dReal y, dReal z); + INLINE void set_hinge2_axis2(dReal x, dReal y, dReal z); + INLINE void set_hinge2_param(int parameter, dReal value); + INLINE void add_hinge2_torques(dReal torque1, dReal torque2); + + INLINE void get_hinge2_anchor(dVector3 result) const; + INLINE void get_hinge2_anchor2(dVector3 result) const; + INLINE void get_hinge2_axis1(dVector3 result) const; + INLINE void get_hinge2_axis2(dVector3 result) const; + INLINE dReal get_hinge2_param(int parameter) const; + INLINE dReal get_hinge2_angle1() const; + INLINE dReal get_hinge2_angle1_rate() const; + INLINE dReal get_hinge2_angle2_rate() const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeHinge2Joint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeHinge2Joint.I" + +#endif diff --git a/panda/src/ode/odeHingeJoint.I b/panda/src/ode/odeHingeJoint.I new file mode 100755 index 0000000000..ae9030de1f --- /dev/null +++ b/panda/src/ode/odeHingeJoint.I @@ -0,0 +1,73 @@ +// Filename: odeHingeJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeHingeJoint:: +set_hinge_anchor(dReal x, dReal y, dReal z) { + dJointSetHingeAnchor(_id, x, y, z); +} + +INLINE void OdeHingeJoint:: +set_hinge_anchor_delta(dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az) { + dJointSetHingeAnchorDelta(_id, x, y, z, ax, ay, az); +} + +INLINE void OdeHingeJoint:: +set_hinge_axis(dReal x, dReal y, dReal z) { + dJointSetHingeAxis(_id, x, y, z); +} + +INLINE void OdeHingeJoint:: +set_hinge_param(int parameter, dReal value) { + dJointSetHingeParam(_id, parameter, value); +} + +INLINE void OdeHingeJoint:: +add_hinge_torque(dReal torque) { + dJointAddHingeTorque(_id, torque); +} + +INLINE void OdeHingeJoint:: +get_hinge_anchor(dVector3 result) const { + return dJointGetHingeAnchor(_id, result); +} + +INLINE void OdeHingeJoint:: +get_hinge_anchor2(dVector3 result) const { + return dJointGetHingeAnchor2(_id, result); +} + +INLINE void OdeHingeJoint:: +get_hinge_axis(dVector3 result) const { + return dJointGetHingeAxis(_id, result); +} + +INLINE dReal OdeHingeJoint:: +get_hinge_param(int parameter) const { + return dJointGetHingeParam(_id, parameter); +} + +INLINE dReal OdeHingeJoint:: +get_hinge_angle() const { + return dJointGetHingeAngle(_id); +} + +INLINE dReal OdeHingeJoint:: +get_hinge_angle_rate() const { + return dJointGetHingeAngleRate(_id); +} + diff --git a/panda/src/ode/odeHingeJoint.cxx b/panda/src/ode/odeHingeJoint.cxx new file mode 100644 index 0000000000..7f9b3f19ed --- /dev/null +++ b/panda/src/ode/odeHingeJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeHingeJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeHingeJoint.h" + +TypeHandle OdeHingeJoint::_type_handle; + +OdeHingeJoint:: +OdeHingeJoint(OdeWorld &world) : + OdeJoint(dJointCreateHinge(world.get_id(), 0)) { +} + +OdeHingeJoint:: +OdeHingeJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateHinge(world.get_id(), joint_group.get_id())) { +} + +OdeHingeJoint:: +~OdeHingeJoint() { +} diff --git a/panda/src/ode/odeHingeJoint.h b/panda/src/ode/odeHingeJoint.h new file mode 100755 index 0000000000..81e22401db --- /dev/null +++ b/panda/src/ode/odeHingeJoint.h @@ -0,0 +1,54 @@ +#ifndef ODEHINGEJOINT_H +#define ODEHINGEJOINT_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeHingeJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeHingeJoint : public OdeJoint { +PUBLISHED: + OdeHingeJoint(OdeWorld &world); + OdeHingeJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeHingeJoint(); + + INLINE void set_hinge_anchor(dReal x, dReal y, dReal z); + INLINE void set_hinge_anchor_delta(dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az); + INLINE void set_hinge_axis(dReal x, dReal y, dReal z); + INLINE void set_hinge_param(int parameter, dReal value); + INLINE void add_hinge_torque(dReal torque); + + INLINE void get_hinge_anchor(dVector3 result) const; + INLINE void get_hinge_anchor2(dVector3 result) const; + INLINE void get_hinge_axis(dVector3 result) const; + INLINE dReal get_hinge_param(int parameter) const; + INLINE dReal get_hinge_angle() const; + INLINE dReal get_hinge_angle_rate() const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeHingeJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeHingeJoint.I" + +#endif diff --git a/panda/src/ode/odeJoint.I b/panda/src/ode/odeJoint.I new file mode 100755 index 0000000000..9a165b57ab --- /dev/null +++ b/panda/src/ode/odeJoint.I @@ -0,0 +1,47 @@ +// Filename: odeJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE dJointID OdeJoint:: +get_id() const { + return _id; +} + +INLINE void OdeJoint:: +set_data(void *data) { + dJointSetData(_id, data); +} + +INLINE void *OdeJoint:: +get_data() { + return dJointGetData(_id); +} + +INLINE int OdeJoint:: +get_joint_type() const { + return dJointGetType(_id); +} + +INLINE void OdeJoint:: +set_feedback(dJointFeedback *feedback) { + dJointSetFeedback(_id, feedback); +} + +INLINE dJointFeedback *OdeJoint:: +get_feedback() { + return dJointGetFeedback(_id); +} diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx new file mode 100755 index 0000000000..4b21110d8c --- /dev/null +++ b/panda/src/ode/odeJoint.cxx @@ -0,0 +1,89 @@ +// Filename: odeJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeJoint.h" + +TypeHandle OdeJoint::_type_handle; + +OdeJoint:: +OdeJoint(dJointID id) : + _id(id) { + ostream &out = odejoint_cat.debug(); + out << get_type() << "(" << _id << ")\n"; +} + +OdeJoint:: +~OdeJoint() { +} + +void OdeJoint:: +destroy() { + dJointDestroy(_id); +} + +void OdeJoint:: +attach(const OdeBody &body1, const OdeBody &body2) { + dJointAttach(_id, body1.get_id(), body2.get_id()); +} + +void OdeJoint:: +attach(const OdeBody &body, int index) { + if (index == 0) { + dJointAttach(_id, body.get_id(), 0); + } else { + dJointAttach(_id, 0, body.get_id()); + } +} + +void OdeJoint:: +detach() { + dJointAttach(_id, 0, 0); +} + +void OdeJoint:: +get_body(int index, OdeBody &body) const { + body._id = dJointGetBody(_id, index); +} + +void OdeJoint:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out << "" << get_type() \ + << "(id = " << _id \ + << ", body1 = "; + OdeBody body; + get_body(0, body); + if (body.get_id() != 0) { + body.write(out); + } + else { + out << "0"; + } + out << ", body2 = "; + get_body(1, body); + if (body.get_id() != 0) { + body.write(out); + } + else { + out << "0"; + } + out << ")"; + + #endif //] NDEBUG +} diff --git a/panda/src/ode/odeJoint.h b/panda/src/ode/odeJoint.h new file mode 100755 index 0000000000..446a4b3959 --- /dev/null +++ b/panda/src/ode/odeJoint.h @@ -0,0 +1,88 @@ +// Filename: odeJoint.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEJOINT_H +#define ODEJOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeWorld.h" // Needed for derived classes +#include "odeJointGroup.h" + + +class OdeBody; + + +//////////////////////////////////////////////////////////////////// +// Class : OdeJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeJoint : public TypedObject { + friend class OdeBody; + friend class OdeUtil; + +protected: + OdeJoint(dJointID id); + +PUBLISHED: + virtual ~OdeJoint(); + void destroy(); + + INLINE void set_data(void *data); + INLINE void *get_data(); + INLINE int get_joint_type() const; + void get_body(int index, OdeBody &body) const; + INLINE void set_feedback(dJointFeedback *); + INLINE dJointFeedback *get_feedback(); + + void attach(const OdeBody &body1, const OdeBody &body2); + void attach(const OdeBody &body, int index); + void detach(); + + virtual void write(ostream &out = cout, unsigned int indent=0) const; + +public: + INLINE dJointID get_id() const; + +protected: + dJointID _id; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeJoint", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeJoint.I" + +#endif diff --git a/panda/src/ode/odeJointGroup.I b/panda/src/ode/odeJointGroup.I new file mode 100755 index 0000000000..31e8355203 --- /dev/null +++ b/panda/src/ode/odeJointGroup.I @@ -0,0 +1,28 @@ +// Filename: odeJointGroup.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE dJointGroupID OdeJointGroup:: +get_id() const { + return _id; +} + +INLINE void OdeJointGroup:: +empty() const { + dJointGroupEmpty(_id); +} + diff --git a/panda/src/ode/odeJointGroup.cxx b/panda/src/ode/odeJointGroup.cxx new file mode 100755 index 0000000000..f3323f7d80 --- /dev/null +++ b/panda/src/ode/odeJointGroup.cxx @@ -0,0 +1,36 @@ +// Filename: odeJointGroup.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeJointGroup.h" + +TypeHandle OdeJointGroup::_type_handle; + +OdeJointGroup:: +OdeJointGroup() : + _id(dJointGroupCreate(0)) { +} + +OdeJointGroup:: +~OdeJointGroup() { +} + +void OdeJointGroup:: +destroy() { + dJointGroupDestroy(_id); +} diff --git a/panda/src/ode/odeJointGroup.h b/panda/src/ode/odeJointGroup.h new file mode 100755 index 0000000000..676e3a821d --- /dev/null +++ b/panda/src/ode/odeJointGroup.h @@ -0,0 +1,67 @@ +// Filename: odeJointGroup.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEJOINTGROUP_H +#define ODEJOINTGROUP_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeJointGroup +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeJointGroup : public TypedObject { +PUBLISHED: + OdeJointGroup(); + virtual ~OdeJointGroup(); + void destroy(); + + INLINE void empty() const; + +public: + INLINE dJointGroupID get_id() const; + +private: + dJointGroupID _id; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeJointGroup", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeJointGroup.I" + +#endif + diff --git a/panda/src/ode/odeLMotorJoint.I b/panda/src/ode/odeLMotorJoint.I new file mode 100755 index 0000000000..7222049ad6 --- /dev/null +++ b/panda/src/ode/odeLMotorJoint.I @@ -0,0 +1,49 @@ +// Filename: odeLMotorJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +INLINE void OdeLMotorJoint:: +set_l_motor_num_axes(int num) { + dJointSetLMotorNumAxes(_id, num); +} + +INLINE void OdeLMotorJoint:: +set_l_motor_axis(int anum, int rel, dReal x, dReal y, dReal z) { + dJointSetLMotorAxis(_id, anum, rel, x, y, z); +} + +INLINE void OdeLMotorJoint:: +set_l_motor_param(int parameter, dReal value) { + dJointSetLMotorParam(_id, parameter, value); +} + +INLINE int OdeLMotorJoint:: +get_l_motor_num_axes() const { + return dJointGetLMotorNumAxes(_id); +} + +INLINE void OdeLMotorJoint:: +get_l_motor_axis(int anum, dVector3 result) const { + return dJointGetLMotorAxis(_id, anum, result); +} + +INLINE dReal OdeLMotorJoint:: +get_l_motor_param(int parameter) const { + return dJointGetLMotorParam(_id, parameter); +} + diff --git a/panda/src/ode/odeLMotorJoint.cxx b/panda/src/ode/odeLMotorJoint.cxx new file mode 100644 index 0000000000..4865ace922 --- /dev/null +++ b/panda/src/ode/odeLMotorJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeLMotorJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeLMotorJoint.h" + +TypeHandle OdeLMotorJoint::_type_handle; + +OdeLMotorJoint:: +OdeLMotorJoint(OdeWorld &world ) : + OdeJoint(dJointCreateLMotor(world.get_id(), 0)) { +} + +OdeLMotorJoint:: +OdeLMotorJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateLMotor(world.get_id(), joint_group.get_id())) { +} + +OdeLMotorJoint:: +~OdeLMotorJoint() { +} diff --git a/panda/src/ode/odeLMotorJoint.h b/panda/src/ode/odeLMotorJoint.h new file mode 100755 index 0000000000..78cda52996 --- /dev/null +++ b/panda/src/ode/odeLMotorJoint.h @@ -0,0 +1,49 @@ +#ifndef ODELMOTORJOINT_H +#define ODELMOTORJOINT_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeLMotorJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeLMotorJoint : public OdeJoint { +PUBLISHED: + OdeLMotorJoint(OdeWorld &world); + OdeLMotorJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeLMotorJoint(); + + INLINE void set_l_motor_num_axes(int num); + INLINE void set_l_motor_axis(int anum, int rel, dReal x, dReal y, dReal z); + INLINE void set_l_motor_param(int parameter, dReal value); + + INLINE int get_l_motor_num_axes() const; + INLINE void get_l_motor_axis(int anum, dVector3 result) const; + INLINE dReal get_l_motor_param(int parameter) const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeLMotorJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeLMotorJoint.I" + +#endif diff --git a/panda/src/ode/odeMass.I b/panda/src/ode/odeMass.I new file mode 100755 index 0000000000..161c60b10c --- /dev/null +++ b/panda/src/ode/odeMass.I @@ -0,0 +1,130 @@ +// Filename: odeMass.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE int OdeMass:: +check() { + return dMassCheck(&_mass); +} + +INLINE void OdeMass:: +set_zero() { + _mass.setZero(); +} + +INLINE void OdeMass:: +set_parameters(dReal themass, + dReal cgx, dReal cgy, dReal cgz, + dReal I11, dReal I22, dReal I33, + dReal I12, dReal I13, dReal I23) { + _mass.setParameters(themass, + cgx, cgy, cgz, + I11, I22, I33, + I12, I13, I23); +} + +INLINE void OdeMass:: +set_sphere(dReal density, dReal radius) { + _mass.setSphere(density, radius); +} + +INLINE void OdeMass:: +set_sphere_total(dReal total_mass, dReal radius) { + dMassSetSphereTotal(&_mass, total_mass, radius); +} + +INLINE void OdeMass:: +set_capsule(dReal density, int direction, + dReal radius, dReal length) { + _mass.setCapsule(density, direction, + radius, length); +} + +INLINE void OdeMass:: +set_capsule_total(dReal total_mass, int direction, + dReal radius, dReal length) { + dMassSetCapsuleTotal(&_mass, + total_mass, direction, + radius, length); +} + +INLINE void OdeMass:: +set_cylinder(dReal density, int direction, + dReal radius, dReal length) { + dMassSetCylinder(&_mass, + density,direction, + radius,length); +} + +INLINE void OdeMass:: +set_cylinder_total(dReal total_mass, int direction, + dReal radius, dReal length) { + dMassSetCylinderTotal(&_mass, total_mass, direction, + radius, length); +} + +INLINE void OdeMass:: +set_box(dReal density, + dReal lx, dReal ly, dReal lz) { + _mass.setBox(density, + lx, ly, lz); +} + +INLINE void OdeMass:: +set_box_total(dReal total_mass, + dReal lx, dReal ly, dReal lz) { + dMassSetBoxTotal(&_mass, + total_mass, + lx, ly, lz); +} + +INLINE void OdeMass:: +adjust(dReal newmass) { + _mass.adjust(newmass); +} + +INLINE void OdeMass:: +translate(dReal x, dReal y, dReal z) { + _mass.translate(x, y, z); +} + +INLINE void OdeMass:: +rotate(const dMatrix3 R) { + _mass.rotate(R); +} + +INLINE void OdeMass:: +add(OdeMass &other) { + _mass.add(other.get_mass_ptr()); +} + +INLINE dReal OdeMass:: +get_magnitude() const { + return _mass.mass; +} + +INLINE LPoint3f OdeMass:: +get_center() const { + return LPoint3f(_mass.c[0], _mass.c[1], _mass.c[2]); +} + +INLINE LMatrix3f OdeMass:: +get_inertia() const { + return LMatrix3f(_mass.I[0], _mass.I[1], _mass.I[2] , + _mass.I[4], _mass.I[5], _mass.I[6] , + _mass.I[8], _mass.I[9], _mass.I[10]); +} diff --git a/panda/src/ode/odeMass.cxx b/panda/src/ode/odeMass.cxx new file mode 100755 index 0000000000..72f9a2b34c --- /dev/null +++ b/panda/src/ode/odeMass.cxx @@ -0,0 +1,67 @@ +// Filename: odeMass.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeMass.h" + +TypeHandle OdeMass::_type_handle; + +OdeMass:: +OdeMass() : + _mass() { +} + +OdeMass:: +OdeMass(const OdeMass ©) : + _mass() { + _mass.setParameters(copy._mass.mass, + copy._mass.c[0], copy._mass.c[1], copy._mass.c[2], + copy._mass.I[0], copy._mass.I[5], copy._mass.I[10], + copy._mass.I[1], copy._mass.I[2], copy._mass.I[4]); +} + +OdeMass:: +~OdeMass() { +} + +dMass* OdeMass:: +get_mass_ptr() { + return &_mass; +} + +void OdeMass:: +operator = (const OdeMass ©) { + _mass.setParameters(copy._mass.mass, + copy._mass.c[0], copy._mass.c[1], copy._mass.c[2], + copy._mass.I[0], copy._mass.I[5], copy._mass.I[10], + copy._mass.I[1], copy._mass.I[2], copy._mass.I[4]); + +} + + +void OdeMass:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); + out << get_type() \ + << "(mag = " << get_magnitude() \ + << ", center = " << get_center() \ + << ", inertia = " << get_inertia() \ + << ")"; + #endif //] NDEBUG +} diff --git a/panda/src/ode/odeMass.h b/panda/src/ode/odeMass.h new file mode 100755 index 0000000000..1eafd3636e --- /dev/null +++ b/panda/src/ode/odeMass.h @@ -0,0 +1,96 @@ +// Filename: odeMass.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEMASS_H +#define ODEMASS_H + +#include "pandabase.h" +#include "typedReferenceCount.h" +#include "luse.h" + +#include "ode/ode.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeMass +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeMass : public TypedReferenceCount { +PUBLISHED: + OdeMass(); + OdeMass(const OdeMass ©); + virtual ~OdeMass(); + + INLINE int check(); + INLINE void set_zero(); + INLINE void set_parameters(dReal themass, + dReal cgx, dReal cgy, dReal cgz, + dReal I11, dReal I22, dReal I33, + dReal I12, dReal I13, dReal I23); + INLINE void set_sphere(dReal density, dReal radius); + INLINE void set_sphere_total(dReal total_mass, dReal radius); + INLINE void set_capsule(dReal density, int direction, + dReal radius, dReal length); + INLINE void set_capsule_total(dReal total_mass, int direction, + dReal radius, dReal length); + INLINE void set_cylinder(dReal density, int direction, + dReal radius, dReal length); + INLINE void set_cylinder_total(dReal total_mass, int direction, + dReal radius, dReal length); + INLINE void set_box(dReal density, + dReal lx, dReal ly, dReal lz); + INLINE void set_box_total(dReal total_mass, + dReal lx, dReal ly, dReal lz); + INLINE void adjust(dReal newmass); + INLINE void translate(dReal x, dReal y, dReal z); + INLINE void rotate(const dMatrix3 R); + INLINE void add(OdeMass &other); + + INLINE dReal get_magnitude() const; + INLINE LPoint3f get_center() const; + INLINE LMatrix3f get_inertia() const; + + virtual void write(ostream &out = cout, unsigned int indent=0) const; + +public: + dMass* get_mass_ptr(); + +private: + void operator = (const OdeMass ©); + dMass _mass; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedReferenceCount::init_type(); + register_type(_type_handle, "OdeMass", + TypedReferenceCount::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeMass.I" + +#endif diff --git a/panda/src/ode/odeNullJoint.I b/panda/src/ode/odeNullJoint.I new file mode 100755 index 0000000000..431dc99376 --- /dev/null +++ b/panda/src/ode/odeNullJoint.I @@ -0,0 +1,17 @@ +// Filename: odeNullJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// diff --git a/panda/src/ode/odeNullJoint.cxx b/panda/src/ode/odeNullJoint.cxx new file mode 100644 index 0000000000..3fafc0dd9c --- /dev/null +++ b/panda/src/ode/odeNullJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeNullJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeNullJoint.h" + +TypeHandle OdeNullJoint::_type_handle; + +OdeNullJoint:: +OdeNullJoint(OdeWorld &world) : + OdeJoint(dJointCreateNull(world.get_id(), 0)) { +} + +OdeNullJoint:: +OdeNullJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateNull(world.get_id(), joint_group.get_id())) { +} + +OdeNullJoint:: +~OdeNullJoint() { +} diff --git a/panda/src/ode/odeNullJoint.h b/panda/src/ode/odeNullJoint.h new file mode 100755 index 0000000000..8383e70800 --- /dev/null +++ b/panda/src/ode/odeNullJoint.h @@ -0,0 +1,41 @@ +#ifndef ODENULLJOINT_H +#define ODENULLJOINT_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeNullJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeNullJoint : public OdeJoint { +PUBLISHED: + OdeNullJoint(OdeWorld &world); + OdeNullJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeNullJoint(); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeNullJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeNullJoint.I" + +#endif diff --git a/panda/src/ode/odePlane2dJoint.I b/panda/src/ode/odePlane2dJoint.I new file mode 100755 index 0000000000..afe62e7ed0 --- /dev/null +++ b/panda/src/ode/odePlane2dJoint.I @@ -0,0 +1,32 @@ +// Filename: odePlane2dJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdePlane2dJoint:: +set_plane2_dxparam(int parameter, dReal value) { + dJointSetPlane2DXParam(_id, parameter, value); +} + +INLINE void OdePlane2dJoint:: +set_plane2_dyparam(int parameter, dReal value) { + dJointSetPlane2DYParam(_id, parameter, value); +} + +INLINE void OdePlane2dJoint:: +set_plane2_dangle_param(int parameter, dReal value) { + dJointSetPlane2DAngleParam(_id, parameter, value); +} diff --git a/panda/src/ode/odePlane2dJoint.cxx b/panda/src/ode/odePlane2dJoint.cxx new file mode 100644 index 0000000000..9769eb9ac7 --- /dev/null +++ b/panda/src/ode/odePlane2dJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odePlane2dJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odePlane2dJoint.h" + +TypeHandle OdePlane2dJoint::_type_handle; + +OdePlane2dJoint:: +OdePlane2dJoint(OdeWorld &world) : + OdeJoint(dJointCreatePlane2D(world.get_id(), 0)) { +} + +OdePlane2dJoint:: +OdePlane2dJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreatePlane2D(world.get_id(), joint_group.get_id())) { +} + +OdePlane2dJoint:: +~OdePlane2dJoint() { +} diff --git a/panda/src/ode/odePlane2dJoint.h b/panda/src/ode/odePlane2dJoint.h new file mode 100755 index 0000000000..bc2b82ac06 --- /dev/null +++ b/panda/src/ode/odePlane2dJoint.h @@ -0,0 +1,45 @@ +#ifndef ODEPLANE2DJOINT_H +#define ODEPLANE2DJOINT_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdePlane2dJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdePlane2dJoint : public OdeJoint { +PUBLISHED: + OdePlane2dJoint(OdeWorld &world); + OdePlane2dJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdePlane2dJoint(); + + INLINE void set_plane2_dxparam(int parameter, dReal value); + INLINE void set_plane2_dyparam(int parameter, dReal value); + INLINE void set_plane2_dangle_param(int parameter, dReal value); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdePlane2dJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odePlane2dJoint.I" + +#endif diff --git a/panda/src/ode/odePlaneGeom.I b/panda/src/ode/odePlaneGeom.I new file mode 100755 index 0000000000..2f4ff37ee0 --- /dev/null +++ b/panda/src/ode/odePlaneGeom.I @@ -0,0 +1,34 @@ +// Filename: odePlaneGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdePlaneGeom:: +set_params(dReal a, dReal b, dReal c, dReal d) { + dGeomPlaneSetParams(_id, a, b, c, d); +} + +INLINE LVecBase4f OdePlaneGeom:: +get_params() const { + dVector4 res; + dGeomPlaneGetParams(_id, res); + return LVecBase4f(res[0], res[1], res[2], res[3]); +} + +INLINE dReal OdePlaneGeom:: +get_point_depth(dReal x, dReal y, dReal z) const { + return dGeomPlanePointDepth(_id, x, y, z); +} diff --git a/panda/src/ode/odePlaneGeom.cxx b/panda/src/ode/odePlaneGeom.cxx new file mode 100644 index 0000000000..0b5a1fa4d7 --- /dev/null +++ b/panda/src/ode/odePlaneGeom.cxx @@ -0,0 +1,36 @@ +// Filename: odePlaneGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odePlaneGeom.h" + +TypeHandle OdePlaneGeom::_type_handle; + +OdePlaneGeom:: +OdePlaneGeom(dReal a, dReal b, dReal c, dReal d) : + OdeGeom(dCreatePlane(0, a, b, c, d)) { +} + +OdePlaneGeom:: +OdePlaneGeom(OdeSpace &space, dReal a, dReal b, dReal c, dReal d) : + OdeGeom(dCreatePlane(space.get_id(), a, b, c, d)) { +} + +OdePlaneGeom:: +~OdePlaneGeom() { +} diff --git a/panda/src/ode/odePlaneGeom.h b/panda/src/ode/odePlaneGeom.h new file mode 100755 index 0000000000..2b3b92c708 --- /dev/null +++ b/panda/src/ode/odePlaneGeom.h @@ -0,0 +1,65 @@ +// Filename: odePlaneGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEPLANEGEOM_H +#define ODEPLANEGEOM_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdePlaneGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdePlaneGeom : public OdeGeom { +PUBLISHED: + OdePlaneGeom(dReal a, dReal b, dReal c, dReal d); + OdePlaneGeom(OdeSpace &space, dReal a, dReal b, dReal c, dReal d); + virtual ~OdePlaneGeom(); + + INLINE void set_params(dReal a, dReal b, dReal c, dReal d); + INLINE LVecBase4f get_params() const; + INLINE dReal get_point_depth(dReal x, dReal y, dReal z) const; + +public: + INLINE static int get_geom_class() { return dPlaneClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdePlaneGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odePlaneGeom.I" + +#endif diff --git a/panda/src/ode/odeQuadTreeSpace.I b/panda/src/ode/odeQuadTreeSpace.I new file mode 100755 index 0000000000..877bce7710 --- /dev/null +++ b/panda/src/ode/odeQuadTreeSpace.I @@ -0,0 +1,18 @@ +// Filename: odeQuadTreeSpace.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + diff --git a/panda/src/ode/odeQuadTreeSpace.cxx b/panda/src/ode/odeQuadTreeSpace.cxx new file mode 100755 index 0000000000..b8ac6a7cba --- /dev/null +++ b/panda/src/ode/odeQuadTreeSpace.cxx @@ -0,0 +1,61 @@ +// Filename: odeQuadTreeSpace.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeQuadTreeSpace.h" + +TypeHandle OdeQuadTreeSpace::_type_handle; + +typedef struct { dVector4 vec; } sdVector4; + +sdVector4 LVec3TodVector4(const LVecBase3f& vec) { + sdVector4 sdVec4; + + sdVec4.vec[0] = vec[0]; + sdVec4.vec[1] = vec[1]; + sdVec4.vec[2] = vec[2]; + sdVec4.vec[3] = 0; + + return sdVec4; +} + +OdeQuadTreeSpace:: +OdeQuadTreeSpace(const LPoint3f ¢er, + const LVecBase3f &extents, + const int depth) : + OdeSpace(dQuadTreeSpaceCreate(0, + LVec3TodVector4(center).vec, + LVec3TodVector4(extents).vec, + depth)) { +} + +OdeQuadTreeSpace:: +OdeQuadTreeSpace(OdeSpace &space, + const LPoint3f ¢er, + const LVecBase3f &extents, + const int depth) : + OdeSpace(dQuadTreeSpaceCreate(space.get_id(), + LVec3TodVector4(center).vec, + LVec3TodVector4(extents).vec, + depth)) { +} + +OdeQuadTreeSpace:: +~OdeQuadTreeSpace() { +} + diff --git a/panda/src/ode/odeQuadTreeSpace.h b/panda/src/ode/odeQuadTreeSpace.h new file mode 100755 index 0000000000..0882760a02 --- /dev/null +++ b/panda/src/ode/odeQuadTreeSpace.h @@ -0,0 +1,65 @@ +// Filename: odeQuadTreeSpace.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEQUADTREESPACE_H +#define ODEQUADTREESPACE_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeSpace.h" + + +//////////////////////////////////////////////////////////////////// +// Class : OdeQuadTreeSpace +// Description : +////////////////////////////////////////////////////////////////////c +class EXPCL_PANDAODE OdeQuadTreeSpace : public OdeSpace { +PUBLISHED: + OdeQuadTreeSpace(const LPoint3f ¢er, + const LVecBase3f &extents, + const int depth); + OdeQuadTreeSpace(OdeSpace &space, + const LPoint3f ¢er, + const LVecBase3f &extents, + const int depth); + virtual ~OdeQuadTreeSpace(); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeSpace::init_type(); + register_type(_type_handle, "OdeQuadTreeSpace", + OdeSpace::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeQuadTreeSpace.I" + +#endif + diff --git a/panda/src/ode/odeRayGeom.I b/panda/src/ode/odeRayGeom.I new file mode 100755 index 0000000000..996a8b0ca4 --- /dev/null +++ b/panda/src/ode/odeRayGeom.I @@ -0,0 +1,88 @@ +// Filename: odeRayGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// +INLINE void OdeRayGeom:: +set_length(dReal length) { + dGeomRaySetLength(_id, length); +} + +INLINE dReal OdeRayGeom:: +get_length() { + return dGeomRayGetLength(_id); +} + +INLINE void OdeRayGeom:: +set(dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz) { + dGeomRaySet(_id, px, py, pz, dx, dy, dz); +} + + +INLINE void OdeRayGeom:: +get(LVecBase3f &start, LVecBase3f &dir) const { + dVector3 s, d; + dGeomRayGet(_id, s, d); + start.set(s[0], s[1], s[2]); + dir.set(d[0], d[1], d[2]); +} + +INLINE LVecBase3f OdeRayGeom:: +get_start() const { + dVector3 start, dir; + dGeomRayGet(_id, start, dir); + return LVecBase3f(start[0], start[1], start[2]); +} + +INLINE LVecBase3f OdeRayGeom:: +get_direction() const { + dVector3 start, dir; + dGeomRayGet(_id, start, dir); + return LVecBase3f(dir[0], dir[1], dir[2]); +} + +INLINE void OdeRayGeom:: +set_params(int first_contact, int backface_cull) { + dGeomRaySetParams(_id, first_contact, backface_cull); +} + +INLINE void OdeRayGeom:: +get_params(int &first_contact, int &backface_cull) const { + dGeomRayGetParams(_id, &first_contact, &backface_cull); +} + +INLINE int OdeRayGeom:: +get_first_contact() const { + int fc, bc; + dGeomRayGetParams(_id, &fc, &bc); + return fc; +} + +INLINE int OdeRayGeom:: +get_backface_cull() const { + int fc, bc; + dGeomRayGetParams(_id, &fc, &bc); + return bc; +} + +INLINE void OdeRayGeom:: +set_closest_hit(int closest_hit) { + dGeomRaySetClosestHit(_id, closest_hit); +} + +INLINE int OdeRayGeom:: +get_closest_hit() { + return dGeomRayGetClosestHit(_id); +} diff --git a/panda/src/ode/odeRayGeom.cxx b/panda/src/ode/odeRayGeom.cxx new file mode 100644 index 0000000000..bfcf3e843e --- /dev/null +++ b/panda/src/ode/odeRayGeom.cxx @@ -0,0 +1,36 @@ +// Filename: odeRayGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeRayGeom.h" + +TypeHandle OdeRayGeom::_type_handle; + +OdeRayGeom:: +OdeRayGeom(dReal length) : + OdeGeom(dCreateRay(0, length)) { +} + +OdeRayGeom:: +OdeRayGeom(OdeSpace &space, dReal length) : + OdeGeom(dCreateRay(space.get_id(), length)) { +} + +OdeRayGeom:: +~OdeRayGeom() { +} diff --git a/panda/src/ode/odeRayGeom.h b/panda/src/ode/odeRayGeom.h new file mode 100755 index 0000000000..e69a63891b --- /dev/null +++ b/panda/src/ode/odeRayGeom.h @@ -0,0 +1,74 @@ +// Filename: odeRayGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODERAYGEOM_H +#define ODERAYGEOM_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeRayGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeRayGeom : public OdeGeom { +PUBLISHED: + OdeRayGeom(dReal length); + OdeRayGeom(OdeSpace &space, dReal length); + virtual ~OdeRayGeom(); + + INLINE void set_length(dReal length); + INLINE dReal get_length(); + INLINE void set(dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz); + INLINE void get(LVecBase3f &start, LVecBase3f &dir) const; + INLINE LVecBase3f get_start() const; + INLINE LVecBase3f get_direction() const; + INLINE void set_params(int first_contact, int backface_cull); + INLINE void get_params(int &first_contact, int &backface_cull) const; + INLINE int get_first_contact() const; + INLINE int get_backface_cull() const; + INLINE void set_closest_hit(int closest_hit); + INLINE int get_closest_hit(); + +public: + INLINE static int get_geom_class() { return dRayClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeRayGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeRayGeom.I" + +#endif diff --git a/panda/src/ode/odeSimpleSpace.I b/panda/src/ode/odeSimpleSpace.I new file mode 100755 index 0000000000..081a949dbf --- /dev/null +++ b/panda/src/ode/odeSimpleSpace.I @@ -0,0 +1,17 @@ +// Filename: odeSimpleSpace.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// diff --git a/panda/src/ode/odeSimpleSpace.cxx b/panda/src/ode/odeSimpleSpace.cxx new file mode 100755 index 0000000000..cf5c05d762 --- /dev/null +++ b/panda/src/ode/odeSimpleSpace.cxx @@ -0,0 +1,37 @@ +// Filename: odeSimpleSpace.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeSimpleSpace.h" + +TypeHandle OdeSimpleSpace::_type_handle; + +OdeSimpleSpace:: +OdeSimpleSpace() : + OdeSpace(dSimpleSpaceCreate(0)) { +} + +OdeSimpleSpace:: +OdeSimpleSpace(OdeSpace &space) : + OdeSpace(dSimpleSpaceCreate(space.get_id())) { +} + +OdeSimpleSpace:: +~OdeSimpleSpace() { +} + diff --git a/panda/src/ode/odeSimpleSpace.h b/panda/src/ode/odeSimpleSpace.h new file mode 100755 index 0000000000..33104944f1 --- /dev/null +++ b/panda/src/ode/odeSimpleSpace.h @@ -0,0 +1,60 @@ +// Filename: odeSimpleSpace.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODESIMPLESPACE_H +#define ODESIMPLESPACE_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeSpace.h" + + +//////////////////////////////////////////////////////////////////// +// Class : OdeSimpleSpace +// Description : +////////////////////////////////////////////////////////////////////c +class EXPCL_PANDAODE OdeSimpleSpace : public OdeSpace { +PUBLISHED: + OdeSimpleSpace(); + OdeSimpleSpace(OdeSpace &space); + virtual ~OdeSimpleSpace(); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeSpace::init_type(); + register_type(_type_handle, "OdeSimpleSpace", + OdeSpace::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeSimpleSpace.I" + +#endif + diff --git a/panda/src/ode/odeSliderJoint.I b/panda/src/ode/odeSliderJoint.I new file mode 100755 index 0000000000..a0826ad353 --- /dev/null +++ b/panda/src/ode/odeSliderJoint.I @@ -0,0 +1,57 @@ +// Filename: odeSliderJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeSliderJoint:: +set_slider_axis(dReal x, dReal y, dReal z) { + dJointSetSliderAxis(_id, x, y, z); +} + +INLINE void OdeSliderJoint:: +set_slider_axis_delta(dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az) { + dJointSetSliderAxisDelta(_id, x, y, z, ax, ay, az); +} + +INLINE void OdeSliderJoint:: +set_slider_param(int parameter, dReal value) { + dJointSetSliderParam(_id, parameter, value); +} + +INLINE void OdeSliderJoint:: +add_slider_force(dReal force) { + dJointAddSliderForce(_id, force); +} + +INLINE dReal OdeSliderJoint:: +get_slider_position() const { + return dJointGetSliderPosition(_id); +} + +INLINE dReal OdeSliderJoint:: +get_slider_position_rate() const { + return dJointGetSliderPositionRate(_id); +} + +INLINE void OdeSliderJoint:: +get_slider_axis(dVector3 result) const { + return dJointGetSliderAxis(_id, result); +} + +INLINE dReal OdeSliderJoint:: +get_slider_param(int parameter) const { + return dJointGetSliderParam(_id, parameter); +} diff --git a/panda/src/ode/odeSliderJoint.cxx b/panda/src/ode/odeSliderJoint.cxx new file mode 100644 index 0000000000..07fb6d0be0 --- /dev/null +++ b/panda/src/ode/odeSliderJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeSliderJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeSliderJoint.h" + +TypeHandle OdeSliderJoint::_type_handle; + +OdeSliderJoint:: +OdeSliderJoint(OdeWorld &world) : + OdeJoint(dJointCreateSlider(world.get_id(), 0)) { +} + +OdeSliderJoint:: +OdeSliderJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateSlider(world.get_id(), joint_group.get_id())) { +} + +OdeSliderJoint:: +~OdeSliderJoint() { +} diff --git a/panda/src/ode/odeSliderJoint.h b/panda/src/ode/odeSliderJoint.h new file mode 100755 index 0000000000..4783ea4727 --- /dev/null +++ b/panda/src/ode/odeSliderJoint.h @@ -0,0 +1,51 @@ +#ifndef ODESLIDERJOINT_H +#define ODESLIDERJOINT_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeSliderJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeSliderJoint : public OdeJoint { +PUBLISHED: + OdeSliderJoint(OdeWorld &world); + OdeSliderJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeSliderJoint(); + + INLINE void set_slider_axis(dReal x, dReal y, dReal z); + INLINE void set_slider_axis_delta(dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az); + INLINE void set_slider_param(int parameter, dReal value); + INLINE void add_slider_force(dReal force); + + INLINE dReal get_slider_position() const; + INLINE dReal get_slider_position_rate() const; + INLINE void get_slider_axis(dVector3 result) const; + INLINE dReal get_slider_param(int parameter) const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeSliderJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeSliderJoint.I" + +#endif diff --git a/panda/src/ode/odeSpace.I b/panda/src/ode/odeSpace.I new file mode 100755 index 0000000000..7bb22a36fa --- /dev/null +++ b/panda/src/ode/odeSpace.I @@ -0,0 +1,86 @@ +// Filename: odeSpace.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +INLINE dSpaceID OdeSpace:: +get_id() const { + return _id; +} + +INLINE void OdeSpace:: +set_cleanup(int mode) { + dSpaceSetCleanup(_id, mode); +} + +INLINE int OdeSpace:: +get_cleanup() const { + return dSpaceGetCleanup(_id); +} + +INLINE int OdeSpace:: +get_num_geoms() const { + return dSpaceGetNumGeoms(_id); +} + +INLINE OdeSpace OdeSpace:: +get_space() const { + return OdeSpace(dGeomGetSpace((dGeomID)_id)); +} + +/* +INLINE void OdeSpace:: +get_aabb(dReal aabb[6]) const { + return dGeomGetAABB((dGeomID)_id, aabb[6]); +} +*/ + +INLINE int OdeSpace:: +is_space() { + return dGeomIsSpace((dGeomID)_id); +} + +INLINE int OdeSpace:: +get_class() const { + return dGeomGetClass((dGeomID)_id); +} + +INLINE void OdeSpace:: +set_category_bits(unsigned long bits) { + dGeomSetCategoryBits((dGeomID)_id, bits); +} + +INLINE void OdeSpace:: +set_collide_bits(unsigned long bits) { + dGeomSetCollideBits((dGeomID)_id, bits); +} + +INLINE void OdeSpace:: +enable() { + dGeomEnable((dGeomID)_id); +} + +INLINE void OdeSpace:: +disable() { + dGeomDisable((dGeomID)_id); +} + +INLINE int OdeSpace:: +is_enabled() { + return dGeomIsEnabled((dGeomID)_id); +} + diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx new file mode 100755 index 0000000000..70cc18ad31 --- /dev/null +++ b/panda/src/ode/odeSpace.cxx @@ -0,0 +1,93 @@ +// Filename: odeSpace.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeSpace.h" + +TypeHandle OdeSpace::_type_handle; + +OdeSpace:: +OdeSpace(dSpaceID id) : + _id(id) { +} + +OdeSpace:: +~OdeSpace() { +} + +void OdeSpace:: +destroy() { + if (get_cleanup()) { + OdeGeom geom; + for (int i = 0; i < get_num_geoms(); ++i) { + get_geom(i, geom); + if (geom.get_class() == OdeTriMeshGeom::get_geom_class()) { + OdeTriMeshGeom::unlink_data(geom.get_id()); + } + } + } + dSpaceDestroy(_id); +} + +int OdeSpace:: +query(const OdeGeom& geom) const { + return dSpaceQuery(_id, geom.get_id()); +} + +int OdeSpace:: +query(const OdeSpace& space) const { + return dSpaceQuery(_id, (dGeomID)space.get_id()); +} + +void OdeSpace:: +add(OdeSpace& space) { + dSpaceAdd(_id, (dGeomID)space.get_id()); +} + +void OdeSpace:: +remove(OdeSpace& space) { + dSpaceRemove(_id, (dGeomID)space.get_id()); +} + +void OdeSpace:: +add(OdeGeom& geom) { + dSpaceAdd(_id, geom.get_id()); +} + +void OdeSpace:: +remove(OdeGeom& geom) { + dSpaceRemove(_id, geom.get_id()); +} + +void OdeSpace:: +clean() { + dSpaceClean(_id); +} + +void OdeSpace:: +get_geom(int i, OdeGeom &geom) { + geom._id = dSpaceGetGeom(_id, i); +} + +void OdeSpace:: +write(ostream &out, unsigned int indent) const { + #ifndef NDEBUG //[ + out.width(indent); out << "" << get_type() << "(id = " << _id << ")"; + #endif //] NDEBUG +} + diff --git a/panda/src/ode/odeSpace.h b/panda/src/ode/odeSpace.h new file mode 100755 index 0000000000..e7e9bd610b --- /dev/null +++ b/panda/src/ode/odeSpace.h @@ -0,0 +1,97 @@ +// Filename: odeSpace.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODESPACE_H +#define ODESPACE_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +class OdeGeom; +class OdeTriMeshGeom; + +//////////////////////////////////////////////////////////////////// +// Class : OdeSpace +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeSpace : public TypedObject { + friend class OdeGeom; + +protected: + OdeSpace(dSpaceID id); + +PUBLISHED: + virtual ~OdeSpace(); + void destroy(); + + INLINE void set_cleanup(int mode); + INLINE int get_cleanup() const; + INLINE int query(const OdeGeom& geom) const; + INLINE int query(const OdeSpace& space) const; + INLINE int get_num_geoms() const; + // INLINE void get_aabb() const; + INLINE int is_space(); + INLINE int get_class() const; + INLINE void set_category_bits(unsigned long bits); + INLINE void set_collide_bits(unsigned long bits); + INLINE void enable(); + INLINE void disable(); + INLINE int is_enabled(); + + void add(OdeGeom& geom); + void add(OdeSpace& space); + void remove(OdeGeom& geom); + void remove(OdeSpace& space); + void clean(); + void get_geom(int i, OdeGeom &geom); + + INLINE OdeSpace get_space() const; + + virtual void write(ostream &out = cout, unsigned int indent=0) const; + +public: + INLINE dSpaceID get_id() const; + +protected: + dSpaceID _id; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeSpace", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeSpace.I" + +#endif + diff --git a/panda/src/ode/odeSphereGeom.I b/panda/src/ode/odeSphereGeom.I new file mode 100755 index 0000000000..389c2b6a45 --- /dev/null +++ b/panda/src/ode/odeSphereGeom.I @@ -0,0 +1,33 @@ +// Filename: odeSphereGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeSphereGeom:: +set_radius(dReal radius) { + dGeomSphereSetRadius(_id, radius); +} + +INLINE dReal OdeSphereGeom:: +get_radius() const { + return dGeomSphereGetRadius(_id); +} + +INLINE dReal OdeSphereGeom:: +get_point_depth(dReal x, dReal y, dReal z) const { + return dGeomSpherePointDepth(_id, x, y, z); +} + diff --git a/panda/src/ode/odeSphereGeom.cxx b/panda/src/ode/odeSphereGeom.cxx new file mode 100755 index 0000000000..a0fceab3f4 --- /dev/null +++ b/panda/src/ode/odeSphereGeom.cxx @@ -0,0 +1,42 @@ +// Filename: odeSphereGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeSphereGeom.h" + +TypeHandle OdeSphereGeom::_type_handle; + +OdeSphereGeom:: +OdeSphereGeom(dReal radius) : + OdeGeom(dCreateSphere(0, radius)) { +} + +OdeSphereGeom:: +OdeSphereGeom(OdeGeom &geom) : + OdeGeom(geom.get_id()) { + nassertv(dGeomGetClass(_id) == dSphereClass); +} + +OdeSphereGeom:: +OdeSphereGeom(OdeSpace &space, dReal radius) : + OdeGeom(dCreateSphere(space.get_id(), radius)) { +} + +OdeSphereGeom:: +~OdeSphereGeom() { +} diff --git a/panda/src/ode/odeSphereGeom.h b/panda/src/ode/odeSphereGeom.h new file mode 100755 index 0000000000..016054dcd6 --- /dev/null +++ b/panda/src/ode/odeSphereGeom.h @@ -0,0 +1,66 @@ +// Filename: odeSphereGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODESPHEREGEOM_H +#define ODESPHEREGEOM_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeSphereGeom +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeSphereGeom : public OdeGeom { +PUBLISHED: + OdeSphereGeom(dReal radius); + OdeSphereGeom(OdeSpace &space, dReal radius); + OdeSphereGeom(OdeGeom &geom); + virtual ~OdeSphereGeom(); + + INLINE void set_radius(dReal radius); + INLINE dReal get_radius() const; + INLINE dReal get_point_depth(dReal x, dReal y, dReal z) const; + +public: + INLINE static int get_geom_class() { return dSphereClass; }; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeSphereGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeSphereGeom.I" + +#endif diff --git a/panda/src/ode/odeSurfaceParameters.I b/panda/src/ode/odeSurfaceParameters.I new file mode 100755 index 0000000000..ceab262a2a --- /dev/null +++ b/panda/src/ode/odeSurfaceParameters.I @@ -0,0 +1,130 @@ +// Filename: odeSurfaceParameters.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeSurfaceParameters:: +set_mode(int mode) { + _surface_parameters.mode = mode; +} + +INLINE void OdeSurfaceParameters:: +set_mu(dReal mu) { + _surface_parameters.mu = mu; +} + +INLINE void OdeSurfaceParameters:: +set_mu2(dReal mu2) { + _surface_parameters.mu2 = mu2; +} + +INLINE void OdeSurfaceParameters:: +set_bounce(dReal bounce) { + _surface_parameters.bounce = bounce; +} + +INLINE void OdeSurfaceParameters:: +set_bounce_vel(dReal bounce_vel) { + _surface_parameters.bounce_vel = bounce_vel; +} + +INLINE void OdeSurfaceParameters:: +set_soft_erp(dReal soft_erp) { + _surface_parameters.soft_erp = soft_erp; +} + +INLINE void OdeSurfaceParameters:: +set_soft_cfm(dReal soft_cfm) { + _surface_parameters.soft_cfm = soft_cfm; +} + +INLINE void OdeSurfaceParameters:: +set_motion1(dReal motion) { + _surface_parameters.motion1 = motion; +} + +INLINE void OdeSurfaceParameters:: +set_motion2(dReal motion) { + _surface_parameters.motion2 = motion; +} + +INLINE void OdeSurfaceParameters:: +set_slip1(dReal slip) { + _surface_parameters.slip1 = slip; +} + +INLINE void OdeSurfaceParameters:: +set_slip2(dReal slip) { + _surface_parameters.slip2 = slip; +} + + +INLINE int OdeSurfaceParameters:: +get_mode() const { + return _surface_parameters.mode; +} + +INLINE dReal OdeSurfaceParameters:: +get_mu() const { + return _surface_parameters.mu; +} + +INLINE dReal OdeSurfaceParameters:: +get_mu2() const { + return _surface_parameters.mu2; +} + +INLINE dReal OdeSurfaceParameters:: +get_bounce() const { + return _surface_parameters.bounce; +} + +INLINE dReal OdeSurfaceParameters:: +get_bounce_vel() const { + return _surface_parameters.bounce_vel; +} + +INLINE dReal OdeSurfaceParameters:: +get_soft_erp() const { + return _surface_parameters.soft_erp; +} + +INLINE dReal OdeSurfaceParameters:: +get_soft_cfm() const { + return _surface_parameters.soft_cfm; +} + +INLINE dReal OdeSurfaceParameters:: +get_motion1() const { + return _surface_parameters.motion1; +} + +INLINE dReal OdeSurfaceParameters:: +get_motion2() const { + return _surface_parameters.motion2; +} + +INLINE dReal OdeSurfaceParameters:: +get_slip1() const { + return _surface_parameters.slip1; +} + +INLINE dReal OdeSurfaceParameters:: +get_slip2() const { + return _surface_parameters.slip2; +} + + diff --git a/panda/src/ode/odeSurfaceParameters.cxx b/panda/src/ode/odeSurfaceParameters.cxx new file mode 100755 index 0000000000..e143ce00d4 --- /dev/null +++ b/panda/src/ode/odeSurfaceParameters.cxx @@ -0,0 +1,84 @@ +// Filename: odeSurfaceParameters.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeSurfaceParameters.h" + +TypeHandle OdeSurfaceParameters::_type_handle; + +OdeSurfaceParameters:: +OdeSurfaceParameters(int mode, dReal mu) : + _surface_parameters() { + if (mu < 0) { + mu = 0; + } else if (mu > dInfinity) { + mu = dInfinity; + } + _surface_parameters.mode = mode; + _surface_parameters.mu = mu; + + _surface_parameters.mu2 = 0; + _surface_parameters.bounce = 0; + _surface_parameters.bounce = 0; + _surface_parameters.soft_erp = 0; + _surface_parameters.soft_cfm = 0; + _surface_parameters.motion1 = 0; + _surface_parameters.motion2 = 0; + _surface_parameters.slip1 = 0; + _surface_parameters.slip2 = 0; +} + +OdeSurfaceParameters:: +OdeSurfaceParameters(const dSurfaceParameters &surface_parameters) : + _surface_parameters() { + _surface_parameters.mode = surface_parameters.mode; + _surface_parameters.mu = surface_parameters.mu; + _surface_parameters.mu2 = surface_parameters.mu2; + _surface_parameters.bounce = surface_parameters.bounce; + _surface_parameters.bounce = surface_parameters.bounce_vel; + _surface_parameters.soft_erp = surface_parameters.soft_erp; + _surface_parameters.soft_cfm = surface_parameters.soft_cfm; + _surface_parameters.motion1 = surface_parameters.motion1; + _surface_parameters.motion2 = surface_parameters.motion2; + _surface_parameters.slip1 = surface_parameters.slip1; + _surface_parameters.slip2 = surface_parameters.slip2; +} + +OdeSurfaceParameters:: +~OdeSurfaceParameters() { +} + +const dSurfaceParameters *OdeSurfaceParameters:: +get_surface_parameters_ptr() const { + return &_surface_parameters; +} + +void OdeSurfaceParameters:: +operator = (const OdeSurfaceParameters ©) { + _surface_parameters.mode = copy._surface_parameters.mode; + _surface_parameters.mu = copy._surface_parameters.mu; + _surface_parameters.mu2 = copy._surface_parameters.mu2; + _surface_parameters.bounce = copy._surface_parameters.bounce; + _surface_parameters.bounce = copy._surface_parameters.bounce_vel; + _surface_parameters.soft_erp = copy._surface_parameters.soft_erp; + _surface_parameters.soft_cfm = copy._surface_parameters.soft_cfm; + _surface_parameters.motion1 = copy._surface_parameters.motion1; + _surface_parameters.motion2 = copy._surface_parameters.motion2; + _surface_parameters.slip1 = copy._surface_parameters.slip1; + _surface_parameters.slip2 = copy._surface_parameters.slip2; +} diff --git a/panda/src/ode/odeSurfaceParameters.h b/panda/src/ode/odeSurfaceParameters.h new file mode 100755 index 0000000000..f50b1b6c8d --- /dev/null +++ b/panda/src/ode/odeSurfaceParameters.h @@ -0,0 +1,127 @@ +// Filename: odeSurfaceParameters.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODESURFACEPARAMETERS_H +#define ODESURFACEPARAMETERS_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +class OdeContact; + +//////////////////////////////////////////////////////////////////// +// Class : OdeSurfaceParameters +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeSurfaceParameters : public TypedObject { + friend class OdeContact; + +protected: + OdeSurfaceParameters(const dSurfaceParameters &surface_parameters); + +PUBLISHED: + enum ModeFlags { MF_contact_mu2 = 0x001, + MF_contactFDir1 = 0x002, + MF_contactBounce = 0x004, + MF_contactSoftERP = 0x008, + MF_contactSoftCFM = 0x010, + MF_contactMotion1 = 0x020, + MF_contactMotion2 = 0x040, + MF_contactSlip1 = 0x080, + MF_contactSlip2 = 0x100, + + MF_contactApprox0 = 0x0000, + MF_contactApprox1_1 = 0x1000, + MF_contactApprox1_2 = 0x2000, + MF_contactApprox1 = 0x3000 }; + + /* + // Interrogate doesn't seem to handle this so well + enum ModeFlags { MF_contact_mu2 = dContactMu2, + MF_contactFDir1 = dContactFDir1, + MF_contactBounce = dContactBounce, + MF_contactSoftERP = dContactSoftERP, + MF_contactSoftCFM = dContactSoftCFM, + MF_contactMotion1 = dContactMotion1, + MF_contactMotion2 = dContactMotion2, + MF_contactSlip1 = dContactSlip1, + MF_contactSlip2 = dContactSlip2, + // MF_contactApprox0 = dContactApprox0, + MF_contactApprox1_1 = dContactApprox1_1, + MF_contactApprox1_2 = dContactApprox1_2, + MF_contactApprox1 = dContactApprox1 }; + */ + + OdeSurfaceParameters(int mode = 0, dReal mu = 0); + virtual ~OdeSurfaceParameters(); + + INLINE void set_mode(int mode); + INLINE void set_mu(dReal mu); + INLINE void set_mu2(dReal mu2); + INLINE void set_bounce(dReal bounce); + INLINE void set_bounce_vel(dReal bounce_vel); + INLINE void set_soft_erp(dReal soft_erp); + INLINE void set_soft_cfm(dReal soft_cfm); + INLINE void set_motion1(dReal motion); + INLINE void set_motion2(dReal motion); + INLINE void set_slip1(dReal slip); + INLINE void set_slip2(dReal slip); + + INLINE int get_mode() const; + INLINE dReal get_mu() const; + INLINE dReal get_mu2() const; + INLINE dReal get_bounce() const; + INLINE dReal get_bounce_vel() const; + INLINE dReal get_soft_erp() const; + INLINE dReal get_soft_cfm() const; + INLINE dReal get_motion1() const; + INLINE dReal get_motion2() const; + INLINE dReal get_slip1() const; + INLINE dReal get_slip2() const; + +public: + const dSurfaceParameters *get_surface_parameters_ptr() const; + +private: + void operator = (const OdeSurfaceParameters ©); + dSurfaceParameters _surface_parameters; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeSurfaceParameters", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeSurfaceParameters.I" + +#endif diff --git a/panda/src/ode/odeTriMeshData.I b/panda/src/ode/odeTriMeshData.I new file mode 100755 index 0000000000..ad87d4a1d7 --- /dev/null +++ b/panda/src/ode/odeTriMeshData.I @@ -0,0 +1,88 @@ +// Filename: odeTriMeshData.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE dTriMeshDataID OdeTriMeshData:: +get_id() const { + return _id; +} + +/* +INLINE void OdeTriMeshData:: +set(int data_id, void* in_data) { + dGeomTriMeshDataSet(_id, data_id, in_data); +} + +INLINE void* OdeTriMeshData:: +get(int data_id) { + dGeomTriMeshDataGet(_id,data_id); +} +*/ + +INLINE void OdeTriMeshData:: +build_single(const void* vertices, int vertex_stride, int vertex_count, const void* indices, int index_count, int tri_stride) { + odetrimeshdata_cat.debug() << "build_single(" << vertices << ", " << vertex_stride << ", " << vertex_count << ", " << indices << ", " << index_count << ", " << tri_stride << ")\n"; + dGeomTriMeshDataBuildSingle(_id, vertices, vertex_stride, vertex_count, indices, index_count, tri_stride); +} + +INLINE void OdeTriMeshData:: +build_single1(const void* vertices, int vertex_stride, int vertex_count, const void* indices, int index_count, int tri_stride, const void* normals) { + dGeomTriMeshDataBuildSingle1(_id, vertices, vertex_stride, vertex_count, indices, index_count, tri_stride, normals); +} + +INLINE void OdeTriMeshData:: +build_double(const void* vertices, int vertex_stride, int vertex_count, const void* indices, int index_count, int tri_stride) { + dGeomTriMeshDataBuildDouble(_id, vertices, vertex_stride, vertex_count, indices, index_count, tri_stride); +} + +INLINE void OdeTriMeshData:: +build_double1(const void* vertices, int vertex_stride, int vertex_count, const void* indices, int index_count, int tri_stride, const void* normals) { + dGeomTriMeshDataBuildDouble1(_id, vertices, vertex_stride, vertex_count, indices, index_count, tri_stride, normals); +} + +INLINE void OdeTriMeshData:: +build_simple(const dReal* vertices, int vertex_count, const int* indices, int index_count) { + dGeomTriMeshDataBuildSimple(_id, vertices, vertex_count, indices, index_count); +} + +INLINE void OdeTriMeshData:: +build_simple1(const dReal* vertices, int vertex_count, const int* indices, int index_count, const int* normals) { + dGeomTriMeshDataBuildSimple1(_id, vertices, vertex_count, indices, index_count, normals); +} + +INLINE void OdeTriMeshData:: +preprocess() { + dGeomTriMeshDataPreprocess(_id); +} + +/* +INLINE void OdeTriMeshData:: +get_buffer(unsigned char** buf, int* buf_len) const { + return dGeomTriMeshDataGetBuffer(_id, buf, buf_len); +} + +INLINE void OdeTriMeshData:: +set_buffer(unsigned char* buf) { + dGeomTriMeshDataSetBuffer(_id, buf); +} + +INLINE void OdeTriMeshData:: +update() { + dGeomTriMeshDataUpdate(_id); +} + +*/ \ No newline at end of file diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx new file mode 100755 index 0000000000..99cbd0ccde --- /dev/null +++ b/panda/src/ode/odeTriMeshData.cxx @@ -0,0 +1,236 @@ +// Filename: odeTriMeshData.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// +#include "config_ode.h" +#include "odeTriMeshData.h" + +TypeHandle OdeTriMeshData::_type_handle; + +OdeTriMeshData:: +OdeTriMeshData(const NodePath& model, bool use_normals) : + _id(dGeomTriMeshDataCreate()), + _vertices(0), + _faces(0), + _num_vertices(0), + _num_faces(0), + _normals(false) { + odetrimeshdata_cat.debug() << get_type() << "(" << _id << ")" << "\n"; + + process_model(model, use_normals); + + write_faces(odetrimeshdata_cat.debug()); + + if (!use_normals) { + build_single(_vertices, sizeof(StridedVertex), _num_vertices, + _faces, _num_faces * 3, sizeof(StridedTri)); + } else { + build_single1(_vertices, sizeof(StridedVertex), _num_vertices, + _faces, _num_faces * 3, sizeof(StridedTri), + _normals); + } + preprocess(); +} + +OdeTriMeshData:: +~OdeTriMeshData() { + odetrimeshdata_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n"; + dGeomTriMeshDataDestroy(_id); + if (_vertices != 0) { + delete[] _vertices; + _vertices = 0; + } + if (_faces != 0) { + delete[] _faces; + _faces = 0; + } + if (_normals != 0) { + delete[] _normals; + _normals = 0; + } +} + +void OdeTriMeshData:: +process_model(const NodePath& model, bool &use_normals) { + // TODO: assert if _vertices is something other than 0. + ostream &out = odetrimeshdata_cat.debug(); + out << "process_model(" << model << ")" << "\n"; + + NodePathCollection geomNodePaths = model.find_all_matches("**/+GeomNode"); + if (model.node()->get_type() == GeomNode::get_class_type()) { + geomNodePaths.add_path(model); + } + + for (int i = 0; i < geomNodePaths.get_num_paths(); ++i) { + analyze((GeomNode*)geomNodePaths[i].node()); + } + + odetrimeshdata_cat.debug() << "Found " << _num_vertices << " vertices.\n"; + odetrimeshdata_cat.debug() << "Found " << _num_faces << " faces.\n"; + + _vertices = new StridedVertex[_num_vertices]; + _faces = new StridedTri[_num_faces]; + + _num_vertices = 0, _num_faces = 0; + + for (int i = 0; i < geomNodePaths.get_num_paths(); ++i) { + process_geom_node((GeomNode*)geomNodePaths[i].node()); + odetrimeshdata_cat.debug() << "_num_vertices now at " << _num_vertices << "\n"; + } + + odetrimeshdata_cat.debug() << "Filled " << _num_faces << " triangles(" \ + << _num_vertices << " vertices)\n"; +} + +void OdeTriMeshData:: +process_geom_node(const GeomNode *geomNode) { + ostream &out = odetrimeshdata_cat.debug(); + out.width(2); out << "" << "process_geom_node(" << *geomNode << ")" << "\n"; + for (int i = 0; i < geomNode->get_num_geoms(); ++i) { + process_geom(geomNode->get_geom(i)); + } +} + +void OdeTriMeshData:: +process_geom(const Geom *geom) { + ostream &out = odetrimeshdata_cat.debug(); + out.width(4); out << "" << "process_geom(" << *geom << ")" << "\n"; + if (geom->get_primitive_type() != Geom::PT_polygons) { + return; + } + + CPT(GeomVertexData) vData = geom->get_vertex_data(); + + for (int i = 0; i < geom->get_num_primitives(); ++i) { + process_primitive(geom->get_primitive(i), vData); + } +} + +void OdeTriMeshData:: +process_primitive(const GeomPrimitive *primitive, + CPT(GeomVertexData) vData) { + GeomVertexReader vReader(vData, "vertex"); + GeomVertexReader nReader(vData, "normal"); + LVecBase3f vertex, normal; + //CPT(GeomPrimitive) dPrimitive = primitive->decompose(); + CPT(GeomPrimitive) dPrimitive = primitive; + ostream &out = odetrimeshdata_cat.debug(); + out.width(6); out << "" << "process_primitive(" << *dPrimitive << ")" << "\n"; + + + if (dPrimitive->get_type() == GeomTriangles::get_class_type()) { + for (int i = 0; i < dPrimitive->get_num_primitives(); i++, _num_faces++) { + int s = dPrimitive->get_primitive_start(i); + int e = dPrimitive->get_primitive_end(i); + out.width(8); out << "" << "primitive " << i << ":" << "\n"; + for (int j = s, m = 0; j < e; j++, m++, _num_vertices++) { + int vRowIndex = dPrimitive->get_vertex(j); + vReader.set_row(vRowIndex); + nReader.set_row(vRowIndex); + vertex = vReader.get_data3f(); + normal = nReader.get_data3f(); + _faces[_num_faces].Indices[m] = _num_vertices; + + _vertices[_num_vertices].Vertex[0] = vertex[0]; + _vertices[_num_vertices].Vertex[1] = vertex[1]; + _vertices[_num_vertices].Vertex[2] = vertex[2]; + + out.width(10); out << "" << "vertex " << j << " has: pos(" \ + << vertex << ") normal(" << normal << ")" << "\n"; + } + } + } else if (dPrimitive->get_type() == GeomTristrips::get_class_type()){ + for (int i = 0; i < dPrimitive->get_num_primitives(); i++, _num_faces++) { + int s = dPrimitive->get_primitive_start(i); + int e = dPrimitive->get_primitive_end(i); + out.width(8); out << "" << "primitive " << i << ":" << "\n"; + for (int j = s, m = 0; j < e; j++, m++, _num_vertices++) { + int vRowIndex = dPrimitive->get_vertex(j); + vReader.set_row(vRowIndex); + nReader.set_row(vRowIndex); + vertex = vReader.get_data3f(); + normal = nReader.get_data3f(); + + _vertices[_num_vertices].Vertex[0] = vertex[0]; + _vertices[_num_vertices].Vertex[1] = vertex[1]; + _vertices[_num_vertices].Vertex[2] = vertex[2]; + out.width(10); out << "" << "vertex " << j << " has: pos(" \ + << vertex << ") normal(" << normal << ")" << "\n"; + if (m < 3) { + _faces[_num_faces].Indices[m] = _num_vertices; + } else { + _num_faces++; + if ( m & 1) { + _faces[_num_faces].Indices[0] = _num_vertices-1; + _faces[_num_faces].Indices[1] = _num_vertices-2; + _faces[_num_faces].Indices[2] = _num_vertices; + } else { + _faces[_num_faces].Indices[0] = _num_vertices-2; + _faces[_num_faces].Indices[1] = _num_vertices-1; + _faces[_num_faces].Indices[2] = _num_vertices; + } + } + } + out << "\n"; + } + } +} +void OdeTriMeshData:: +analyze(const GeomNode *geomNode) { + for (int i = 0; i < geomNode->get_num_geoms(); ++i) { + analyze(geomNode->get_geom(i)); + } +} + +void OdeTriMeshData:: +analyze(const Geom *geom) { + if (geom->get_primitive_type() != Geom::PT_polygons) { + return; + } + + for (int i = 0; i < geom->get_num_primitives(); ++i) { + analyze(geom->get_primitive(i)); + } +} + +void OdeTriMeshData:: +analyze(const GeomPrimitive *primitive) { + for (int i = 0; i < primitive->get_num_primitives(); ++i) { + _num_vertices += primitive->get_primitive_num_vertices(i); + _num_faces += primitive->get_primitive_num_faces(i); + } +} + +void OdeTriMeshData:: +write_faces(ostream &out) const { + out<<"\n"; + for (unsigned int i = 0; i < _num_faces; ++i) { + out.width(2); out << "Face " << i << ":\n"; + for (int j = 0; j < 3; ++j) { + out.width(4); + out << "(" << _vertices[_faces[i].Indices[j]].Vertex[0] \ + << ", " << _vertices[_faces[i].Indices[j]].Vertex[1] \ + << ", " << _vertices[_faces[i].Indices[j]].Vertex[2] << ")\n" ; + } + } +} + +void OdeTriMeshData:: +write(ostream &out, unsigned int indent) const { + out.width(indent); out << "" << get_type() << "(id = " << _id << ") : " \ + << "" << "Vertices: " << _num_vertices << ", " \ + << "" << "Triangles: " << _num_faces << "\n"; +} diff --git a/panda/src/ode/odeTriMeshData.h b/panda/src/ode/odeTriMeshData.h new file mode 100755 index 0000000000..93d6024484 --- /dev/null +++ b/panda/src/ode/odeTriMeshData.h @@ -0,0 +1,123 @@ +// Filename: odeTriMeshData.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODETRIMESHDATA_H +#define ODETRIMESHDATA_H + +#include "pandabase.h" +#include "typedReferenceCount.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "nodePathCollection.h" +#include "geomNode.h" +#include "geomVertexData.h" +#include "geomVertexReader.h" +#include "geomTriangles.h" +#include "geomTristrips.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeTriMeshData +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeTriMeshData : public TypedReferenceCount { +PUBLISHED: + OdeTriMeshData(const NodePath& model, bool use_normals = false); + virtual ~OdeTriMeshData(); + + enum DataType { DT_face_normals, + DT_last_transformation }; + // INLINE void set(int data_id, void* in_data); + // INLINE void* get(int data_id); + // INLINE void get_buffer(unsigned char** buf, int* buf_len) const; + // INLINE void set_buffer(unsigned char* buf); + // INLINE void update(); + virtual void write(ostream &out = cout, unsigned int indent=0) const; + void write_faces(ostream &out) const; + +public: + INLINE void build_single(const void* vertices, int vertex_stride, int vertex_count, \ + const void* indices, int index_count, int tri_stride); + INLINE void build_single1(const void* vertices, int vertex_stride, int vertex_count, \ + const void* indices, int index_count, int tri_stride, \ + const void* normals); + INLINE void build_double(const void* vertices, int vertex_stride, int vertex_count, \ + const void* indices, int index_count, int tri_stride); + INLINE void build_double1(const void* vertices, int vertex_stride, int vertex_count, \ + const void* indices, int index_count, int tri_stride, \ + const void* normals); + INLINE void build_simple(const dReal* vertices, int vertex_count, \ + const int* indices, int index_count); + INLINE void build_simple1(const dReal* vertices, int vertex_count, \ + const int* indices, int index_count, \ + const int* normals); + INLINE void preprocess(); + + INLINE dTriMeshDataID get_id() const; + +private: + void process_model(const NodePath& model, bool &use_normals); + void process_geom_node(const GeomNode *geomNode); + void process_geom(const Geom *geom); + void process_primitive(const GeomPrimitive *primitive, + CPT(GeomVertexData) vData); + void analyze(const GeomNode *geomNode); + void analyze(const Geom *geom); + void analyze(const GeomPrimitive *geom); + +protected: + struct StridedVertex{ + dReal Vertex[3]; + }; + struct StridedTri{ + int Indices[3]; + }; + struct FaceNormal{ + dVector3 Normal; + }; + + dTriMeshDataID _id; + StridedVertex *_vertices; + StridedTri *_faces; + FaceNormal *_normals; + + unsigned int _num_vertices; + unsigned int _num_faces; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedReferenceCount::init_type(); + register_type(_type_handle, "OdeTriMeshData", + TypedReferenceCount::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeTriMeshData.I" + +#endif diff --git a/panda/src/ode/odeTriMeshGeom.I b/panda/src/ode/odeTriMeshGeom.I new file mode 100755 index 0000000000..3d29ba5861 --- /dev/null +++ b/panda/src/ode/odeTriMeshGeom.I @@ -0,0 +1,71 @@ +// Filename: odeTriMeshGeom.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeTriMeshGeom:: +set_data(OdeTriMeshData &data) { + unlink_data(_id); + dGeomTriMeshSetData(_id, data.get_id()); + link_data(_id, data); +} + +INLINE PT(OdeTriMeshData) OdeTriMeshGeom:: +get_data() const { + return MeshData[_id]; +} + +INLINE void OdeTriMeshGeom:: +enable_TC(int geom_class, int enable){ + dGeomTriMeshEnableTC(_id, geom_class, enable); +} + +INLINE int OdeTriMeshGeom:: +is_TC_enabled(int geom_class) const { + return dGeomTriMeshIsTCEnabled(_id, geom_class); +} + +INLINE void OdeTriMeshGeom:: +clear_TC_cache(const OdeGeom &geom){ + dGeomTriMeshClearTCCache(_id); +} + +INLINE void OdeTriMeshGeom:: +get_triangle(int face_index, LPoint3f &v0, LPoint3f &v1, LPoint3f &v2) const { + dVector3 dv0, dv1, dv2; + dGeomTriMeshGetTriangle(_id, face_index, &dv0, &dv1, &dv2); + + v0.set(dv0[0], dv0[1], dv0[2]); + v1.set(dv1[0], dv1[1], dv1[2]); + v2.set(dv2[0], dv2[1], dv2[2]); +} + +INLINE LPoint3f OdeTriMeshGeom:: +get_point(int face_index, dReal u, dReal v) const { + dVector3 out; + dGeomTriMeshGetPoint(_id, face_index, u, v, out); + return LPoint3f(out[0], out[1], out[2]); +} + +INLINE int OdeTriMeshGeom:: +get_num_triangles() const { + return dGeomTriMeshGetTriangleCount(_id); +} + +INLINE dTriMeshDataID OdeTriMeshGeom:: +get_data_id() const { + return dGeomTriMeshGetTriMeshDataID(_id); +} \ No newline at end of file diff --git a/panda/src/ode/odeTriMeshGeom.cxx b/panda/src/ode/odeTriMeshGeom.cxx new file mode 100755 index 0000000000..63ededcb4b --- /dev/null +++ b/panda/src/ode/odeTriMeshGeom.cxx @@ -0,0 +1,63 @@ +// Filename: odeTriMeshGeom.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeTriMeshGeom.h" + +TypeHandle OdeTriMeshGeom::_type_handle; +TriMeshDataMap OdeTriMeshGeom::MeshData; + +OdeTriMeshGeom:: +OdeTriMeshGeom(OdeTriMeshData &data) : + OdeGeom(dCreateTriMesh(0, data.get_id(), 0, 0, 0)) { + link_data(_id, data); +} + +OdeTriMeshGeom:: +OdeTriMeshGeom(OdeSpace &space, OdeTriMeshData &data) : + OdeGeom(dCreateTriMesh(space.get_id(), data.get_id(), 0, 0, 0)) { + link_data(_id, data); +} + +OdeTriMeshGeom:: +OdeTriMeshGeom(OdeTriMeshGeom ©) : + OdeGeom(dCreateTriMesh(0, copy.get_data_id(), 0, 0, 0)) { +} + +OdeTriMeshGeom:: +~OdeTriMeshGeom() { +} + +void OdeTriMeshGeom:: +link_data(dGeomID id, OdeTriMeshData &data) { + odegeom_cat.debug() << get_class_type() << "(" << id << ") linking to data: " << data.get_id() << "\n"; + MeshData[id] = &data; +} + +void OdeTriMeshGeom:: +unlink_data(dGeomID id) { + TriMeshDataMap::iterator iter = MeshData.find(id); + + if (iter != MeshData.end()) { + odegeom_cat.debug() << get_class_type() << "(" << id << ") unlinking from data: " << iter->second->get_id() << "\n"; + } else { + odegeom_cat.warning() << get_class_type() << "(" << id << ") Unlinking from absent data!\n"; + } + + MeshData.erase(id); +} diff --git a/panda/src/ode/odeTriMeshGeom.h b/panda/src/ode/odeTriMeshGeom.h new file mode 100755 index 0000000000..aa6d92e416 --- /dev/null +++ b/panda/src/ode/odeTriMeshGeom.h @@ -0,0 +1,85 @@ +// Filename: odeTriMeshGeom.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODETRIMESHGEOM_H +#define ODETRIMESHGEOM_H + +#include "pandabase.h" +#include "luse.h" + +#include "ode/ode.h" +#include "odeGeom.h" +#include "odeTriMeshData.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeTriMeshGeom +// Description : +//////////////////////////////////////////////////////////////////// + +typedef pmap TriMeshDataMap; + +class EXPCL_PANDAODE OdeTriMeshGeom : public OdeGeom { +protected: + static TriMeshDataMap MeshData; + +PUBLISHED: + //ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback); + OdeTriMeshGeom(OdeTriMeshData &data); + OdeTriMeshGeom(OdeSpace &space, OdeTriMeshData &data); + OdeTriMeshGeom(OdeTriMeshGeom ©); + virtual ~OdeTriMeshGeom(); + + INLINE void set_data(OdeTriMeshData &data); + INLINE PT(OdeTriMeshData) get_data() const; + INLINE void enable_TC(int geom_class, int enable); + INLINE int is_TC_enabled(int geom_class) const; + INLINE void clear_TC_cache(const OdeGeom &geom); + INLINE void get_triangle(int face_index, LPoint3f &v0, LPoint3f &v1, LPoint3f &v2) const; + INLINE LPoint3f get_point(int face_index, dReal u, dReal v) const; + INLINE int get_num_triangles() const; + +public: + INLINE static int get_geom_class() { return dTriMeshClass; }; + INLINE dTriMeshDataID get_data_id() const; + static void link_data(dGeomID, OdeTriMeshData &data); + static void unlink_data(dGeomID); + +private: + void operator = (const OdeTriMeshGeom ©); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeGeom::init_type(); + register_type(_type_handle, "OdeTriMeshGeom", + OdeGeom::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeTriMeshGeom.I" + +#endif diff --git a/panda/src/ode/odeUniversalJoint.I b/panda/src/ode/odeUniversalJoint.I new file mode 100755 index 0000000000..0a7ebcf453 --- /dev/null +++ b/panda/src/ode/odeUniversalJoint.I @@ -0,0 +1,87 @@ +// Filename: odeUniversalJoint.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE void OdeUniversalJoint:: +set_universal_anchor(dReal x, dReal y, dReal z) { + dJointSetUniversalAnchor(_id, x, y, z); +} + +INLINE void OdeUniversalJoint:: +set_universal_axis1(dReal x, dReal y, dReal z) { + dJointSetUniversalAxis1(_id, x, y, z); +} + +INLINE void OdeUniversalJoint:: +set_universal_axis2(dReal x, dReal y, dReal z) { + dJointSetUniversalAxis2(_id, x, y, z); +} + +INLINE void OdeUniversalJoint:: +set_universal_param(int parameter, dReal value) { + dJointSetUniversalParam(_id, parameter, value); +} + +INLINE void OdeUniversalJoint:: +add_universal_torques(dReal torque1, dReal torque2) { + dJointAddUniversalTorques(_id, torque1, torque2); +} + +INLINE void OdeUniversalJoint:: +get_universal_anchor(dVector3 result) const { + return dJointGetUniversalAnchor(_id, result); +} + +INLINE void OdeUniversalJoint:: +get_universal_anchor2(dVector3 result) const { + return dJointGetUniversalAnchor2(_id, result); +} + +INLINE void OdeUniversalJoint:: +get_universal_axis1(dVector3 result) const { + return dJointGetUniversalAxis1(_id, result); +} + +INLINE void OdeUniversalJoint:: +get_universal_axis2(dVector3 result) const { + return dJointGetUniversalAxis2(_id, result); +} + +INLINE dReal OdeUniversalJoint:: +get_universal_param(int parameter) const { + return dJointGetUniversalParam(_id, parameter); +} + +INLINE dReal OdeUniversalJoint:: +get_universal_angle1() const { + return dJointGetUniversalAngle1(_id); +} + +INLINE dReal OdeUniversalJoint:: +get_universal_angle2() const { + return dJointGetUniversalAngle2(_id); +} + +INLINE dReal OdeUniversalJoint:: +get_universal_angle1_rate() const { + return dJointGetUniversalAngle1Rate(_id); +} + +INLINE dReal OdeUniversalJoint:: +get_universal_angle2_rate() const { + return dJointGetUniversalAngle2Rate(_id); +} diff --git a/panda/src/ode/odeUniversalJoint.cxx b/panda/src/ode/odeUniversalJoint.cxx new file mode 100644 index 0000000000..084ac4c6b6 --- /dev/null +++ b/panda/src/ode/odeUniversalJoint.cxx @@ -0,0 +1,36 @@ +// Filename: odeUniversalJoint.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeUniversalJoint.h" + +TypeHandle OdeUniversalJoint::_type_handle; + +OdeUniversalJoint:: +OdeUniversalJoint(OdeWorld &world) : + OdeJoint(dJointCreateUniversal(world.get_id(), 0)) { +} + +OdeUniversalJoint:: +OdeUniversalJoint(OdeWorld &world, OdeJointGroup &joint_group) : + OdeJoint(dJointCreateUniversal(world.get_id(), joint_group.get_id())) { +} + +OdeUniversalJoint:: +~OdeUniversalJoint() { +} diff --git a/panda/src/ode/odeUniversalJoint.h b/panda/src/ode/odeUniversalJoint.h new file mode 100644 index 0000000000..adcf6e05cb --- /dev/null +++ b/panda/src/ode/odeUniversalJoint.h @@ -0,0 +1,58 @@ +#ifndef ODEUNIVERSALJOINT_H +#define ODEUNIVERSALJOINT_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" + +#include "odeJoint.h" + +//////////////////////////////////////////////////////////////////// +// Class : OdeUniversalJoint +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeUniversalJoint : public OdeJoint { +PUBLISHED: + OdeUniversalJoint(OdeWorld &world); + OdeUniversalJoint(OdeWorld &world, OdeJointGroup &joint_group); + virtual ~OdeUniversalJoint(); + + INLINE void set_universal_anchor(dReal x, dReal y, dReal z); + INLINE void set_universal_axis1(dReal x, dReal y, dReal z); + INLINE void set_universal_axis2(dReal x, dReal y, dReal z); + INLINE void set_universal_param(int parameter, dReal value); + INLINE void add_universal_torques(dReal torque1, dReal torque2); + + INLINE void get_universal_anchor(dVector3 result) const; + INLINE void get_universal_anchor2(dVector3 result) const; + INLINE void get_universal_axis1(dVector3 result) const; + INLINE void get_universal_axis2(dVector3 result) const; + INLINE dReal get_universal_param(int parameter) const; + INLINE dReal get_universal_angle1() const; + INLINE dReal get_universal_angle2() const; + INLINE dReal get_universal_angle1_rate() const; + INLINE dReal get_universal_angle2_rate() const; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + OdeJoint::init_type(); + register_type(_type_handle, "OdeUniversalJoint", + OdeJoint::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeUniversalJoint.I" + +#endif diff --git a/panda/src/ode/odeUtil.cxx b/panda/src/ode/odeUtil.cxx new file mode 100755 index 0000000000..c798430d22 --- /dev/null +++ b/panda/src/ode/odeUtil.cxx @@ -0,0 +1,60 @@ +// Filename: odeUtil.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "odeUtil.h" + +void OdeUtil:: +get_connecting_joint(const OdeBody &body1, const OdeBody &body2, OdeJoint &joint) { + joint._id = dConnectingJoint(body1.get_id(),body2.get_id()); +} + +/* +OdeJointList OdeUtil:: +get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { + const int max_possible_joints = min(body1.get_num_joints(), body1.get_num_joints()); + + dJointID *joint_list_store = new dJointID[max_possible_joints]; + OdeJointList joint_list; + + int num_joints = dConnectingJointList(body1.get_id(), + body2.get_id(), + joint_list_store); + + for (int i = 0; i < num_joints; i++) { + joint_list.push_back(body1.get_world()->get_joint(joint_list_store[i])); + } + + delete joint_list_store; + return joint_list; +} +*/ + +int OdeUtil:: +are_connected(const OdeBody &body1, const OdeBody &body2) { + return dAreConnected(body1.get_id(),body2.get_id()); +} + +int OdeUtil:: +are_connected_excluding(const OdeBody &body1, + const OdeBody &body2, + const int joint_type) { + return dAreConnectedExcluding(body1.get_id(), + body2.get_id(), + joint_type); +} + diff --git a/panda/src/ode/odeUtil.h b/panda/src/ode/odeUtil.h new file mode 100755 index 0000000000..b4ae4d1707 --- /dev/null +++ b/panda/src/ode/odeUtil.h @@ -0,0 +1,51 @@ +// Filename: odeUtil.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEUTIL_H +#define ODEUTIL_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +class OdeBody; +class OdeJoint; + +//////////////////////////////////////////////////////////////////// +// Class : OdeUtil +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeUtil { +PUBLISHED: + static void get_connecting_joint(const OdeBody &body1, + const OdeBody &body2, + OdeJoint &joint); + // static OdeJointList get_connecting_joint_list(const OdeBody &body1, + // const OdeBody &body2); + static int are_connected(const OdeBody &body1, + const OdeBody &body2); + static int are_connected_excluding(const OdeBody &body1, + const OdeBody &body2, + const int joint_type); + +}; + +// #include "odeUtil.I" + +#endif diff --git a/panda/src/ode/odeWorld.I b/panda/src/ode/odeWorld.I new file mode 100755 index 0000000000..53c12e1d20 --- /dev/null +++ b/panda/src/ode/odeWorld.I @@ -0,0 +1,186 @@ +// Filename: odeWorld.I +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +INLINE dWorldID OdeWorld:: +get_id() const { + return _id; +} + +INLINE void OdeWorld:: +set_gravity(dReal x, dReal y, dReal z) { + dWorldSetGravity(_id, x, y, z); +} + +INLINE LVecBase3f OdeWorld:: +get_gravity() const { + dVector3 gravity; + dWorldGetGravity(_id, gravity); + + return LVecBase3f(gravity[0],gravity[1],gravity[2]); +} + +INLINE void OdeWorld:: +set_erp(dReal erp) { + dWorldSetERP(_id, erp); +} + +INLINE dReal OdeWorld:: +get_erp() const { + return dWorldGetERP(_id); +} + +INLINE void OdeWorld:: +set_cfm(dReal cfm) { + dWorldSetCFM(_id, cfm); +} + +INLINE dReal OdeWorld:: +get_cfm() const { + return dWorldGetCFM(_id); +} + +INLINE void OdeWorld:: +step(dReal stepsize) { + dWorldStep(_id, stepsize); +} + +INLINE LVecBase3f OdeWorld:: +impulse_to_force(dReal stepsize, \ + dReal ix, dReal iy, dReal iz){ + dVector3 force; + dWorldImpulseToForce(_id, + stepsize, + ix, iy, iz, + force); + return LVecBase3f(force[0], force[1], force[2]); +} + +INLINE void OdeWorld:: +quick_step(dReal stepsize) { + dWorldQuickStep(_id, stepsize); +} + +INLINE void OdeWorld:: +set_quick_step_num_iterations(int num) { + dWorldSetQuickStepNumIterations(_id, num); +} + +INLINE int OdeWorld:: +get_quick_step_num_iterations() const { + return dWorldGetQuickStepNumIterations(_id); +} + +INLINE void OdeWorld:: +set_quick_step_w(dReal over_relaxation) { + dWorldSetQuickStepW(_id, over_relaxation); +} + +INLINE dReal OdeWorld:: +get_quick_step_w() const { + return dWorldGetQuickStepW(_id); +} + +INLINE void OdeWorld:: +set_contact_max_correcting_vel(dReal vel) { + dWorldSetContactMaxCorrectingVel(_id, vel); +} + +INLINE dReal OdeWorld:: +get_contact_max_correcting_vel() const { + return dWorldGetContactMaxCorrectingVel(_id); +} + +INLINE void OdeWorld:: +set_contact_surface_layer(dReal depth) { + dWorldSetContactSurfaceLayer(_id, depth); +} + +INLINE dReal OdeWorld:: +get_contact_surface_layer() const { + return dWorldGetContactSurfaceLayer(_id); +} + +INLINE void OdeWorld:: +step_fast1(dReal stepsize, int maxiterations) { + dWorldStepFast1(_id, stepsize, maxiterations); +} + +INLINE void OdeWorld:: +set_auto_enable_depth_sf1(int auto_enable_depth) { + dWorldSetAutoEnableDepthSF1(_id, auto_enable_depth); +} + +INLINE int OdeWorld:: +get_auto_enable_depth_sf1() const { + return dWorldGetAutoEnableDepthSF1(_id); +} + +INLINE dReal OdeWorld:: +get_auto_disable_linear_threshold() const { + return dWorldGetAutoDisableLinearThreshold(_id); +} + +INLINE void OdeWorld:: +set_auto_disable_linear_threshold(dReal linear_threshold) { + dWorldSetAutoDisableLinearThreshold(_id, linear_threshold); +} + +INLINE dReal OdeWorld:: +get_auto_disable_angular_threshold() const { + return dWorldGetAutoDisableAngularThreshold(_id); +} + +INLINE void OdeWorld:: +set_auto_disable_angular_threshold(dReal angular_threshold) { + dWorldSetAutoDisableAngularThreshold(_id, angular_threshold); +} + +INLINE int OdeWorld:: +get_auto_disable_steps() const { + return dWorldGetAutoDisableSteps(_id); +} + +INLINE void OdeWorld:: +set_auto_disable_steps(int steps) { + dWorldSetAutoDisableSteps(_id, steps); +} + +INLINE dReal OdeWorld:: +get_auto_disable_time() const { + return dWorldGetAutoDisableTime(_id); +} + +INLINE void OdeWorld:: +set_auto_disable_time(dReal time) { + dWorldSetAutoDisableTime(_id, time); +} + +INLINE int OdeWorld:: +get_auto_disable_flag() const { + return dWorldGetAutoDisableFlag(_id); +} + +INLINE void OdeWorld:: +set_auto_disable_flag(int do_auto_disable) { + dWorldSetAutoDisableFlag(_id, do_auto_disable); +} + +INLINE string OdeWorld:: +get_name() const { + return _name; +} \ No newline at end of file diff --git a/panda/src/ode/odeWorld.cxx b/panda/src/ode/odeWorld.cxx new file mode 100755 index 0000000000..efc109719d --- /dev/null +++ b/panda/src/ode/odeWorld.cxx @@ -0,0 +1,45 @@ +// Filename: odeWorld.cxx +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_ode.h" +#include "odeWorld.h" + +TypeHandle OdeWorld::_type_handle; + +OdeWorld:: +OdeWorld(const string &name) : + _name(name), + _id(dWorldCreate()) { + odeworld_cat.debug() << get_type() << "(" << _id << ")" << "\n"; +} + +OdeWorld:: +OdeWorld(const OdeWorld ©) : + _name(copy._name), + _id(copy._id) { +} + +OdeWorld:: +~OdeWorld() { + odeworld_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n"; +} + +void OdeWorld:: +destroy() { + dWorldDestroy(_id); +} diff --git a/panda/src/ode/odeWorld.h b/panda/src/ode/odeWorld.h new file mode 100755 index 0000000000..36908f68c5 --- /dev/null +++ b/panda/src/ode/odeWorld.h @@ -0,0 +1,103 @@ +// Filename: odeWorld.h +// Created by: joswilso (27Dec06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ODEWORLD_H +#define ODEWORLD_H + +#include "pandabase.h" +#include "typedObject.h" +#include "luse.h" + +#include "ode/ode.h" +class OdeBody; +class OdeJoint; + +//////////////////////////////////////////////////////////////////// +// Class : OdeWorld +// Description : +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAODE OdeWorld : public TypedObject { +PUBLISHED: + OdeWorld(const string &name = ""); + OdeWorld(const OdeWorld ©); + virtual ~OdeWorld(); + void destroy(); + + INLINE void set_gravity(dReal x, dReal y, dReal z); + INLINE LVecBase3f get_gravity() const; + INLINE void set_erp(dReal erp); + INLINE dReal get_erp() const; + INLINE void set_cfm(dReal cfm); + INLINE dReal get_cfm() const; + INLINE void step(dReal stepsize); + INLINE LVecBase3f impulse_to_force(dReal stepsize, \ + dReal ix, dReal iy, dReal iz); + INLINE void quick_step(dReal stepsize); + INLINE void set_quick_step_num_iterations(int num); + INLINE int get_quick_step_num_iterations() const; + INLINE void set_quick_step_w(dReal over_relaxation); + INLINE dReal get_quick_step_w() const; + INLINE void set_contact_max_correcting_vel(dReal vel); + INLINE dReal get_contact_max_correcting_vel() const; + INLINE void set_contact_surface_layer(dReal depth); + INLINE dReal get_contact_surface_layer() const; + INLINE void step_fast1(dReal stepsize, int maxiterations); + INLINE void set_auto_enable_depth_sf1(int auto_enable_depth); + INLINE int get_auto_enable_depth_sf1() const; + INLINE dReal get_auto_disable_linear_threshold() const; + INLINE void set_auto_disable_linear_threshold(dReal linear_threshold); + INLINE dReal get_auto_disable_angular_threshold() const; + INLINE void set_auto_disable_angular_threshold(dReal angular_threshold); + INLINE int get_auto_disable_steps() const; + INLINE void set_auto_disable_steps(int steps); + INLINE dReal get_auto_disable_time() const; + INLINE void set_auto_disable_time(dReal time); + INLINE int get_auto_disable_flag() const; + INLINE void set_auto_disable_flag(int do_auto_disable); + + INLINE string get_name() const; + +public: + INLINE dWorldID get_id() const; + +private: + string _name; + dWorldID _id; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "OdeWorld", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "odeWorld.I" + +#endif + diff --git a/panda/src/ode/pode_composite1.cxx b/panda/src/ode/pode_composite1.cxx new file mode 100755 index 0000000000..e5fae93056 --- /dev/null +++ b/panda/src/ode/pode_composite1.cxx @@ -0,0 +1,14 @@ + +#include "config_ode.cxx" +#include "odeWorld.cxx" +#include "odeBody.cxx" +#include "odeJoint.cxx" +#include "odeMass.cxx" +#include "odeJointGroup.cxx" +#include "odeUtil.cxx" +#include "odeSpace.cxx" +#include "odeGeom.cxx" +#include "odeSurfaceParameters.cxx" +#include "odeContactGeom.cxx" +#include "odeContact.cxx" + diff --git a/panda/src/ode/pode_composite2.cxx b/panda/src/ode/pode_composite2.cxx new file mode 100755 index 0000000000..98eecccba4 --- /dev/null +++ b/panda/src/ode/pode_composite2.cxx @@ -0,0 +1,13 @@ + +#include "odeAMotorJoint.cxx" +#include "odeBallJoint.cxx" +#include "odeContactJoint.cxx" +#include "odeFixedJoint.cxx" +#include "odeHingeJoint.cxx" +#include "odeHinge2Joint.cxx" +#include "odeLMotorJoint.cxx" +#include "odePlane2dJoint.cxx" +#include "odeNullJoint.cxx" +#include "odeSliderJoint.cxx" +#include "odeUniversalJoint.cxx" + diff --git a/panda/src/ode/pode_composite3.cxx b/panda/src/ode/pode_composite3.cxx new file mode 100755 index 0000000000..c75d4f3dc1 --- /dev/null +++ b/panda/src/ode/pode_composite3.cxx @@ -0,0 +1,12 @@ + +#include "odeBoxGeom.cxx" +#include "odeCappedCylinderGeom.cxx" +#include "odeCylinderGeom.cxx" +#include "odePlaneGeom.cxx" +#include "odeSphereGeom.cxx" +#include "odeRayGeom.cxx" +#include "odeTriMeshData.cxx" +#include "odeTriMeshGeom.cxx" +#include "odeSimpleSpace.cxx" +#include "odeHashSpace.cxx" +#include "odeQuadTreeSpace.cxx" diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index e13014552f..a1fb0f5d06 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -132,6 +132,14 @@ #define EXPTP_PANDAMESA extern #endif +#ifdef BUILDING_PANDAODE + #define EXPCL_PANDAODE __declspec(dllexport) + #define EXPTP_PANDAODE +#else + #define EXPCL_PANDAODE __declspec(dllimport) + #define EXPTP_PANDAODE extern +#endif + #ifdef BUILDING_PANDAPHYSICS #define EXPCL_PANDAPHYSICS __declspec(dllexport) #define EXPTP_PANDAPHYSICS @@ -205,6 +213,9 @@ #define EXPCL_PANDAMESA #define EXPTP_PANDAMESA +#define EXPCL_PANDAODE +#define EXPTP_PANDAODE + #define EXPCL_PANDAPHYSICS #define EXPTP_PANDAPHYSICS