Panda3D
forceNode.h
1 // Filename: forceNode.h
2 // Created by: charles (02Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef FORCENODE_H
16 #define FORCENODE_H
17 
18 #include "pandaNode.h"
19 #include "pvector.h"
20 
21 #include "baseForce.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : ForceNode
25 // Description : A force that lives in the scene graph and is
26 // therefore subject to local coordinate systems.
27 // An example of this would be simulating gravity
28 // in a rotating space station. or something.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDAPHYSICS ForceNode : public PandaNode {
31 PUBLISHED:
32  ForceNode(const string &name);
33  INLINE void clear();
34  INLINE BaseForce *get_force(int index) const;
35  INLINE int get_num_forces() const;
36  MAKE_SEQ(get_forces, get_num_forces, get_force);
37  INLINE void add_force(BaseForce *force);
38 
39  void add_forces_from(const ForceNode &other);
40  void remove_force(BaseForce *f);
41  void remove_force(int index);
42 
43  virtual void output(ostream &out) const;
44  virtual void write_forces(ostream &out, unsigned int indent=0) const;
45  virtual void write(ostream &out, unsigned int indent=0) const;
46 
47 public:
48  virtual ~ForceNode();
49  virtual bool safe_to_flatten() const { return false; }
50  virtual PandaNode *make_copy() const;
51 
52 protected:
53  ForceNode(const ForceNode &copy);
54 
55 private:
57  ForceVector _forces;
58 
59 public:
60  static TypeHandle get_class_type() {
61  return _type_handle;
62  }
63  static void init_type() {
64  PandaNode::init_type();
65  register_type(_type_handle, "ForceNode",
66  PandaNode::get_class_type());
67  }
68  virtual TypeHandle get_type() const {
69  return get_class_type();
70  }
71  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
72 
73 private:
74  static TypeHandle _type_handle;
75 };
76 
77 #include "forceNode.I"
78 
79 #endif // FORCENODE_H
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
A force that lives in the scene graph and is therefore subject to local coordinate systems...
Definition: forceNode.h:30
pure virtual base class for all forces that could POSSIBLY exist.
Definition: baseForce.h:32
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating ...
Definition: forceNode.h:49