Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/physics/physical.h

Go to the documentation of this file.
00001 // Filename: physical.h
00002 // Created by:  charles (14Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PHYSICAL_H
00020 #define PHYSICAL_H
00021 
00022 #include <pandabase.h>
00023 #include <pointerTo.h>
00024 #include <typedReferenceCount.h>
00025 
00026 #include "pvector.h"
00027 #include "plist.h"
00028 
00029 #include "physicsObject.h"
00030 #include "linearForce.h"
00031 #include "angularForce.h"
00032 
00033 class PhysicalNode;
00034 class PhysicsManager;
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //       Class : Physical
00038 // Description : Defines a set of physically modeled attributes.
00039 //               If you want physics applied to your class, derive
00040 //               it from this.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDAPHYSICS Physical : public TypedReferenceCount {
00043 private:
00044   PhysicsManager *_physics_manager;
00045   PhysicalNode *_physical_node;
00046 
00047 protected:
00048   // containers
00049   pvector< PT(PhysicsObject) > _physics_objects;
00050   pvector< PT(LinearForce) > _linear_forces;
00051   pvector< PT(AngularForce) > _angular_forces;
00052 
00053   // this pointer exists to make life easy.  If a physical exists
00054   // with only one element (i.e. NOT a particle system or set-physical),
00055   // then this pointer points at the only physicsobject.  The object
00056   // is still of course contained in the _physics_objects vector, but
00057   // this is kind of a quicker way there.
00058   PhysicsObject *_phys_body;
00059 
00060 PUBLISHED:
00061   Physical(int ttl_objects = 1, bool pre_alloc = false);
00062   Physical(const Physical& copy);
00063 
00064   virtual ~Physical(void);
00065 
00066   // helpers
00067   INLINE PhysicsManager *get_physics_manager(void) const;
00068   INLINE PhysicalNode *get_physical_node(void) const;
00069   INLINE PhysicsObject *get_phys_body(void) const;
00070 
00071   INLINE void clear_linear_forces(void);
00072   INLINE void clear_angular_forces(void);
00073   INLINE void clear_physics_objects(void);
00074   INLINE void add_linear_force(LinearForce *f);
00075   INLINE void add_angular_force(AngularForce *f);
00076   INLINE void add_physics_object(PhysicsObject *po);
00077   INLINE void remove_linear_force(LinearForce *f);
00078   INLINE void remove_angular_force(AngularForce *f);
00079 
00080   INLINE int get_num_linear_forces(void) const;
00081   INLINE PT(LinearForce) get_linear_force(int index) const;
00082   INLINE int get_num_angular_forces(void) const;
00083   INLINE PT(AngularForce) get_angular_force(int index) const;
00084 
00085 public:
00086   INLINE const pvector< PT(PhysicsObject) > &get_object_vector(void) const;
00087   INLINE const pvector< PT(LinearForce) > &get_linear_forces(void) const;
00088   INLINE const pvector< PT(AngularForce) > &get_angular_forces(void) const;
00089 
00090   friend class PhysicsManager;
00091   friend class PhysicalNode;
00092 
00093 public:
00094   static TypeHandle get_class_type(void) {
00095     return _type_handle;
00096   }
00097   static void init_type(void) {
00098     TypedReferenceCount::init_type();
00099     register_type(_type_handle, "Physical",
00100                   TypedReferenceCount::get_class_type());
00101   }
00102   virtual TypeHandle get_type(void) const {
00103     return get_class_type();
00104   }
00105   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00106 
00107 private:
00108   static TypeHandle _type_handle;
00109 };
00110 
00111 #include "physical.I"
00112 
00113 #endif // __PHYSICAL_H__

Generated on Fri May 2 00:43:02 2003 for Panda by doxygen1.3