Panda3D
 All Classes Functions Variables Enumerations
odeWorld.h
00001 // Filename: odeWorld.h
00002 // Created by:  joswilso (27Dec06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef ODEWORLD_H
00016 #define ODEWORLD_H
00017 
00018 #include "pandabase.h"
00019 #include "typedObject.h"
00020 #include "luse.h"
00021 #include "ode_includes.h"
00022 #include "pmap.h"
00023 #include "numeric_types.h"
00024 
00025 
00026 #include "ode_includes.h"
00027 #include "odeHelperStructs.h"
00028 
00029 class OdeBody;
00030 class OdeJoint;
00031     
00032 
00033 
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : OdeWorld
00037 // Description : 
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDAODE OdeWorld : public TypedObject {
00040 PUBLISHED:
00041   OdeWorld();
00042   OdeWorld(const OdeWorld &copy);
00043   virtual ~OdeWorld();
00044   void destroy();
00045   INLINE bool is_empty() const;
00046   INLINE dWorldID get_id() const;
00047 
00048   INLINE void set_gravity(dReal x, dReal y, dReal z);
00049   INLINE void set_gravity(const LVecBase3f &vec);
00050   INLINE void set_erp(dReal erp);
00051   INLINE void set_cfm(dReal cfm);
00052   INLINE void set_quick_step_num_iterations(int num);
00053 
00054   INLINE void set_quick_step_w(dReal over_relaxation);
00055   INLINE void set_contact_max_correcting_vel(dReal vel);
00056   INLINE void set_contact_surface_layer(dReal depth);
00057   INLINE void set_auto_enable_depth_sf1(int auto_enable_depth);
00058   INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
00059   INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
00060   INLINE void set_auto_disable_steps(int steps);
00061   INLINE void set_auto_disable_time(dReal time);
00062   INLINE void set_auto_disable_flag(int do_auto_disable);
00063 
00064   INLINE LVecBase3f get_gravity() const;
00065   INLINE dReal get_erp() const;
00066   INLINE dReal get_cfm() const;
00067   INLINE int get_quick_step_num_iterations() const;
00068   INLINE dReal get_quick_step_w() const;
00069   INLINE dReal get_contact_max_correcting_vel() const;
00070   INLINE dReal get_contact_surface_layer() const;
00071   INLINE int get_auto_enable_depth_sf1() const;
00072   INLINE dReal get_auto_disable_linear_threshold() const;
00073   INLINE dReal get_auto_disable_angular_threshold() const;
00074   INLINE int get_auto_disable_steps() const;
00075   INLINE dReal get_auto_disable_time() const;
00076   INLINE int get_auto_disable_flag() const;
00077 
00078   INLINE LVecBase3f impulse_to_force(dReal stepsize, \
00079                                      dReal ix, dReal iy, dReal iz);
00080   INLINE LVecBase3f impulse_to_force(dReal stepsize, \
00081                                      const LVecBase3f &impulse);
00082 
00083   INLINE void step(dReal stepsize);
00084   INLINE void quick_step(dReal stepsize);
00085   INLINE void step_fast1(dReal stepsize, int maxiterations);
00086 
00087   INLINE int compare_to(const OdeWorld &other) const;
00088 
00089   void init_surface_table(PN_uint8 num_surfaces);
00090   //void assign_surface_body(OdeBody& body, int surface);
00091   void add_body_dampening(OdeBody& body, int surface);
00092   void set_surface_entry(PN_uint8 pos1, PN_uint8 pos2, 
00093                          dReal mu, 
00094                          dReal bounce, 
00095                          dReal bounce_vel, 
00096                          dReal soft_erp,
00097                          dReal soft_cfm,
00098                          dReal slip,
00099                          dReal dampen);
00100   float apply_dampening(float dt, OdeBody& body);
00101   
00102   operator bool () const;
00103     
00104 public:
00105   INLINE sSurfaceParams& get_surface(PN_uint8 surface1, PN_uint8 surface2);
00106   INLINE void set_surface(int pos1, int pos2, sSurfaceParams& entry);
00107   INLINE sBodyParams get_surface_body(dBodyID id);
00108   INLINE void set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp);
00109 
00110   
00111 private:
00112   dWorldID _id;
00113   sSurfaceParams *_surface_table;
00114   PN_uint8 _num_surfaces;
00115   typedef pmap<dBodyID, sBodyParams> BodyDampenMap;
00116   BodyDampenMap _body_dampen_map;
00117 
00118 
00119 
00120 
00121 public:
00122   static TypeHandle get_class_type() {
00123     return _type_handle;
00124   }
00125   static void init_type() {
00126     TypedObject::init_type();
00127     register_type(_type_handle, "OdeWorld",
00128                   TypedObject::get_class_type());
00129   }
00130   virtual TypeHandle get_type() const {
00131     return get_class_type();
00132   }
00133   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00134 
00135 private:
00136   static TypeHandle _type_handle;
00137 };
00138 
00139 #include "odeWorld.I"
00140 
00141 #endif
00142 
 All Classes Functions Variables Enumerations