Panda3D
forceNode.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file forceNode.h
10  * @author charles
11  * @date 2000-08-02
12  */
13 
14 #ifndef FORCENODE_H
15 #define FORCENODE_H
16 
17 #include "pandaNode.h"
18 #include "pvector.h"
19 
20 #include "baseForce.h"
21 
22 /**
23  * A force that lives in the scene graph and is therefore subject to local
24  * coordinate systems. An example of this would be simulating gravity in a
25  * rotating space station. or something.
26  */
27 class EXPCL_PANDA_PHYSICS ForceNode : public PandaNode {
28 PUBLISHED:
29  explicit ForceNode(const std::string &name);
30  INLINE void clear();
31  INLINE BaseForce *get_force(size_t index) const;
32  INLINE size_t get_num_forces() const;
33  MAKE_SEQ(get_forces, get_num_forces, get_force);
34  INLINE void add_force(BaseForce *force);
35 
36  void add_forces_from(const ForceNode &other);
37  void set_force(size_t index, BaseForce *force);
38  void insert_force(size_t index, BaseForce *force);
39  void remove_force(BaseForce *force);
40  void remove_force(size_t index);
41 
42  MAKE_SEQ_PROPERTY(forces, get_num_forces, get_force, set_force, remove_force, insert_force);
43 
44  virtual void output(std::ostream &out) const;
45  virtual void write_forces(std::ostream &out, int indent=0) const;
46  virtual void write(std::ostream &out, int indent=0) const;
47 
48 public:
49  virtual ~ForceNode();
50  virtual bool safe_to_flatten() const { return false; }
51  virtual PandaNode *make_copy() const;
52 
53 protected:
54  ForceNode(const ForceNode &copy);
55 
56 private:
57  typedef pvector< PT(BaseForce) > ForceVector;
58  ForceVector _forces;
59 
60 public:
61  static TypeHandle get_class_type() {
62  return _type_handle;
63  }
64  static void init_type() {
65  PandaNode::init_type();
66  register_type(_type_handle, "ForceNode",
67  PandaNode::get_class_type());
68  }
69  virtual TypeHandle get_type() const {
70  return get_class_type();
71  }
72  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
73 
74 private:
75  static TypeHandle _type_handle;
76 };
77 
78 #include "forceNode.I"
79 
80 #endif // FORCENODE_H
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
A force that lives in the scene graph and is therefore subject to local coordinate systems.
Definition: forceNode.h:27
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
pure virtual base class for all forces that could POSSIBLY exist.
Definition: baseForce.h:29
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:487
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:50