Panda3D
linearControlForce.cxx
1 // Filename: linearControlForce.cxx
2 // Created by: Dave Schuyler (2006)
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 "datagram.h"
16 #include "datagramIterator.h"
17 #include "bamReader.h"
18 #include "bamWriter.h"
19 
20 #include "linearControlForce.h"
21 
22 TypeHandle LinearControlForce::_type_handle;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Function : LinearControlForce
26 // Access : Public
27 // Description : Vector Constructor
28 ////////////////////////////////////////////////////////////////////
30 LinearControlForce(const PhysicsObject *po, PN_stdfloat a, bool mass) :
31  LinearForce(a, mass),
32  _physics_object(po),
33  _fvec(0.0f, 0.0f, 0.0f) {
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function : LinearControlForce
38 // Access : Public
39 // Description : Copy Constructor
40 ////////////////////////////////////////////////////////////////////
43  LinearForce(copy) {
44  _physics_object = copy._physics_object;
45  _fvec = copy._fvec;
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function : LinearControlForce
50 // Access : Public
51 // Description : Destructor
52 ////////////////////////////////////////////////////////////////////
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function : make_copy
59 // Access : Public, virtual
60 // Description : copier
61 ////////////////////////////////////////////////////////////////////
62 LinearForce *LinearControlForce::
63 make_copy() {
64  return new LinearControlForce(*this);
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function : get_child_vector
69 // Access : Public
70 // Description : vector access
71 ////////////////////////////////////////////////////////////////////
72 LVector3 LinearControlForce::
73 get_child_vector(const PhysicsObject *po) {
74  if (_physics_object != 0 && po == _physics_object) {
75  return _fvec;
76  } else {
77  return LVector3::zero();
78  }
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function : output
83 // Access : Public
84 // Description : Write a string representation of this instance to
85 // <out>.
86 ////////////////////////////////////////////////////////////////////
88 output(ostream &out) const {
89  #ifndef NDEBUG //[
90  out<<"LinearControlForce";
91  #endif //] NDEBUG
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function : write
96 // Access : Public
97 // Description : Write a string representation of this instance to
98 // <out>.
99 ////////////////////////////////////////////////////////////////////
101 write(ostream &out, unsigned int indent) const {
102  #ifndef NDEBUG //[
103  out.width(indent); out<<""; out<<"LinearControlForce:\n";
104  out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n";
105  out.width(indent+2); out<<""; out<<"_physics_object "<<_physics_object<<"\n";
106  LinearForce::write(out, indent+2);
107  #endif //] NDEBUG
108 }
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
virtual ~LinearControlForce()
Destructor.
A body on which physics will be applied.
Definition: physicsObject.h:29
static const LVector3f & zero()
Returns a zero-length vector.
Definition: lvector3.h:270
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:25
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
Simple directed vector force.
LinearControlForce(const PhysicsObject *po=0, PN_stdfloat a=1.0f, bool mass=false)
Vector Constructor.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85