Panda3D

linearControlForce.h

00001 // Filename: linearControlForce.h
00002 // Created by: Dave Schuyler (2006)
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 LINEARCONTROLFORCE_H
00016 #define LINEARCONTROLFORCE_H
00017 
00018 #include "linearForce.h"
00019 
00020 ////////////////////////////////////////////////////////////////
00021 //       Class : LinearControlForce
00022 // Description : Simple directed vector force.  This force is 
00023 //               different from the others in that it can be
00024 //               global and still only affect a single object.
00025 //               That might not make sense for a physics simulation,
00026 //               but it's very handy for a game.  I.e. this is
00027 //               the force applied by user on the selected object.
00028 ////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDAPHYSICS LinearControlForce : public LinearForce {
00030 PUBLISHED:
00031   LinearControlForce(const PhysicsObject *po = 0, PN_stdfloat a = 1.0f,
00032     bool mass = false);
00033   LinearControlForce(const LinearControlForce &copy);
00034   virtual ~LinearControlForce();
00035 
00036   INLINE void clear_physics_object();
00037   INLINE void set_physics_object(const PhysicsObject *po);
00038   INLINE CPT(PhysicsObject) get_physics_object() const;
00039 
00040   INLINE void set_vector(const LVector3& v);
00041   INLINE void set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
00042 
00043   INLINE LVector3 get_local_vector() const;
00044   
00045   virtual void output(ostream &out) const;
00046   virtual void write(ostream &out, unsigned int indent=0) const;
00047 
00048 private:
00049   CPT(PhysicsObject) _physics_object;
00050   LVector3 _fvec;
00051 
00052   virtual LinearForce *make_copy();
00053   virtual LVector3 get_child_vector(const PhysicsObject *po);
00054 
00055 public:
00056   static TypeHandle get_class_type() {
00057     return _type_handle;
00058   }
00059   static void init_type() {
00060     LinearForce::init_type();
00061     register_type(_type_handle, "LinearControlForce",
00062                   LinearForce::get_class_type());
00063   }
00064   virtual TypeHandle get_type() const {
00065     return get_class_type();
00066   }
00067   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00068 
00069 private:
00070   static TypeHandle _type_handle;
00071 };
00072 
00073 #include "linearControlForce.I"
00074 
00075 #endif // LINEARCONTROLFORCE_H
 All Classes Functions Variables Enumerations