Panda3D

forceNode.h

00001 // Filename: forceNode.h
00002 // Created by:  charles (02Aug00)
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 FORCENODE_H
00016 #define FORCENODE_H
00017 
00018 #include "pandaNode.h"
00019 #include "pvector.h"
00020 
00021 #include "baseForce.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //        Class : ForceNode
00025 //  Description : A force that lives in the scene graph and is
00026 //                therefore subject to local coordinate systems.
00027 //                An example of this would be simulating gravity
00028 //                in a rotating space station.  or something.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDAPHYSICS ForceNode : public PandaNode {
00031 PUBLISHED:
00032   ForceNode(const string &name);
00033   INLINE void clear();
00034   INLINE BaseForce *get_force(int index) const;
00035   INLINE int get_num_forces() const;
00036   MAKE_SEQ(get_forces, get_num_forces, get_force);
00037   INLINE void add_force(BaseForce *force);
00038 
00039   void add_forces_from(const ForceNode &other);
00040   void remove_force(BaseForce *f);
00041   void remove_force(int index);
00042   
00043   virtual void output(ostream &out) const;
00044   virtual void write_forces(ostream &out, unsigned int indent=0) const;
00045   virtual void write(ostream &out, unsigned int indent=0) const;
00046 
00047 public:
00048   virtual ~ForceNode();
00049   virtual bool safe_to_flatten() const { return false; }
00050   virtual PandaNode *make_copy() const;
00051 
00052 protected:
00053   ForceNode(const ForceNode &copy);
00054 
00055 private:
00056   typedef pvector< PT(BaseForce) > ForceVector;
00057   ForceVector _forces;
00058 
00059 public:
00060   static TypeHandle get_class_type() {
00061     return _type_handle;
00062   }
00063   static void init_type() {
00064     PandaNode::init_type();
00065     register_type(_type_handle, "ForceNode",
00066                   PandaNode::get_class_type());
00067   }
00068   virtual TypeHandle get_type() const {
00069     return get_class_type();
00070   }
00071   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00072 
00073 private:
00074   static TypeHandle _type_handle;
00075 };
00076 
00077 #include "forceNode.I"
00078 
00079 #endif // FORCENODE_H
 All Classes Functions Variables Enumerations