Panda3D
angularVectorForce.cxx
1 // Filename: angularVectorForce.cxx
2 // Created by: charles (09Aug00)
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 "angularVectorForce.h"
16 
17 TypeHandle AngularVectorForce::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function : AngularVectorForce
21 // Access : public
22 // Description : constructor
23 ////////////////////////////////////////////////////////////////////
26  AngularForce(), _fvec(vec) {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function : AngularVectorForce
31 // Access : public
32 // Description : constructor
33 ////////////////////////////////////////////////////////////////////
35 AngularVectorForce(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) :
36  AngularForce() {
37  _fvec.set_hpr(LVecBase3(h, p, r));
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function : AngularVectorForce
42 // Access : public
43 // Description : copy constructor
44 ////////////////////////////////////////////////////////////////////
47  AngularForce(copy) {
48  _fvec = copy._fvec;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function : ~AngularVectorForce
53 // Access : public, virtual
54 // Description : destructor
55 ////////////////////////////////////////////////////////////////////
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function : make_copy
62 // Access : private, virtual
63 // Description : dynamic copier
64 ////////////////////////////////////////////////////////////////////
65 AngularForce *AngularVectorForce::
66 make_copy() const {
67  return new AngularVectorForce(*this);
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function : get_child_quat
72 // Access : private, virtual
73 // Description : query
74 ////////////////////////////////////////////////////////////////////
75 LRotation AngularVectorForce::
76 get_child_quat(const PhysicsObject *) {
77  return _fvec;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function : output
82 // Access : Public
83 // Description : Write a string representation of this instance to
84 // <out>.
85 ////////////////////////////////////////////////////////////////////
87 output(ostream &out) const {
88  #ifndef NDEBUG //[
89  out<<"AngularVectorForce";
90  #endif //] NDEBUG
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function : write
95 // Access : Public
96 // Description : Write a string representation of this instance to
97 // <out>.
98 ////////////////////////////////////////////////////////////////////
100 write(ostream &out, unsigned int indent) const {
101  #ifndef NDEBUG //[
102  out.width(indent); out<<""; out<<"AngularVectorForce:\n";
103  out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n";
104  AngularForce::write(out, indent+2);
105  #endif //] NDEBUG
106 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This is a unit quaternion representing a rotation.
Definition: lrotation.h:92
virtual ~AngularVectorForce()
destructor
AngularVectorForce(const LRotation &quat)
constructor
A body on which physics will be applied.
Definition: physicsObject.h:29
a simple directed torque force, the angular equivalent of simple vector force.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
void set_hpr(const LVecBase3f &hpr, CoordinateSystem cs=CS_default)
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
pure virtual parent of all quat-based forces.
Definition: angularForce.h:24
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.