Panda3D
 All Classes Functions Variables Enumerations
physicalNode.cxx
1 // Filename: physicalNode.cxx
2 // Created by: charles (01Aug00)
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 #include "physicalNode.h"
16 
17 // static stuff.
18 TypeHandle PhysicalNode::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function : PhysicalNode
22 // Access : public
23 // Description : default constructor
24 ////////////////////////////////////////////////////////////////////
26 PhysicalNode(const string &name) :
27  PandaNode(name)
28 {
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function : PhysicalNode
33 // Access : protected
34 // Description : copy constructor
35 ////////////////////////////////////////////////////////////////////
37 PhysicalNode(const PhysicalNode &copy) :
38  PandaNode(copy), _physicals(copy._physicals) {
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function : ~PhysicalNode
43 // Access : protected, virtual
44 // Description : destructor
45 ////////////////////////////////////////////////////////////////////
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function : make_copy
52 // Access : public, virtual
53 // Description : dynamic child copy
54 ////////////////////////////////////////////////////////////////////
56 make_copy() const {
57  return new PhysicalNode(*this);
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function : add_physicals_from
62 // Access : public
63 // Description : append operation
64 ////////////////////////////////////////////////////////////////////
65 void PhysicalNode::
67  pvector< PT(Physical) >::iterator last = _physicals.end() - 1;
68 
69  _physicals.insert(_physicals.end(),
70  other._physicals.begin(), other._physicals.end());
71 
72  for (; last != _physicals.end(); last++) {
73  (*last)->_physical_node = this;
74  }
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function : remove_physical
79 // Access : public
80 // Description : remove operation
81 ////////////////////////////////////////////////////////////////////
82 void PhysicalNode::
85  PT(Physical) ptp = physical;
86  found = find(_physicals.begin(), _physicals.end(), ptp);
87  if (found == _physicals.end())
88  return;
89  _physicals.erase(found);
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function : remove_physical
94 // Access : public
95 // Description : remove operation
96 ////////////////////////////////////////////////////////////////////
97 void PhysicalNode::
98 remove_physical(int index) {
99  nassertv(index >= 0 && index <= (int)_physicals.size());
100 
102  remove = _physicals.begin() + index;
103  (*remove)->_physical_node = (PhysicalNode *) NULL;
104 
105  _physicals.erase(remove);
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function : write
110 // Access : Public
111 // Description : Write a string representation of this instance to
112 // <out>.
113 ////////////////////////////////////////////////////////////////////
114 void PhysicalNode::
115 write(ostream &out, unsigned int indent) const {
116  #ifndef NDEBUG //[
117  out.width(indent); out<<""; out<<"PhysicalNode:\n";
118  //PandaNode::write(out, indent+2);
119  #endif //] NDEBUG
120 }
void add_physicals_from(const PhysicalNode &other)
append operation
PhysicalNode(const string &name)
default constructor
void remove_physical(Physical *physical)
remove operation
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual PandaNode * make_copy() const
dynamic child copy
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to &lt;out&gt;.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
Graph node that encapsulated a series of physical objects.
Definition: physicalNode.h:31
Defines a set of physically modeled attributes.
Definition: physical.h:40
virtual ~PhysicalNode()
destructor
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85