Panda3D
 All Classes Functions Variables Enumerations
linearUserDefinedForce.cxx
1 // Filename: linearUserDefinedForce.cxx
2 // Created by: charles (31Jul00)
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 "linearUserDefinedForce.h"
16 
17 TypeHandle LinearUserDefinedForce::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function : LinearUserDefinedForce
21 // Access : public
22 // Description : constructor
23 ////////////////////////////////////////////////////////////////////
26  PN_stdfloat a, bool md) :
27  LinearForce(a, md),
28  _proc(proc)
29 {
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function : LinearUserDefinedForce
34 // Access : public
35 // Description : copy constructor
36 ////////////////////////////////////////////////////////////////////
39  LinearForce(copy) {
40  _proc = copy._proc;
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function : ~LinearUserDefinedForce
45 // Access : public
46 // Description : destructor
47 ////////////////////////////////////////////////////////////////////
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function : make_copy
54 // Access : private, virtual
55 // Description : child copier
56 ////////////////////////////////////////////////////////////////////
57 LinearForce *LinearUserDefinedForce::
58 make_copy() {
59  return new LinearUserDefinedForce(*this);
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function : get_child_vector
64 // Access : private, virtual
65 // Description : force builder
66 ////////////////////////////////////////////////////////////////////
67 LVector3 LinearUserDefinedForce::
68 get_child_vector(const PhysicsObject *po) {
69  return _proc(po);
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function : output
74 // Access : Public
75 // Description : Write a string representation of this instance to
76 // <out>.
77 ////////////////////////////////////////////////////////////////////
79 output(ostream &out) const {
80  #ifndef NDEBUG //[
81  out<<"LinearUserDefinedForce";
82  #endif //] NDEBUG
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function : write
87 // Access : Public
88 // Description : Write a string representation of this instance to
89 // <out>.
90 ////////////////////////////////////////////////////////////////////
92 write(ostream &out, unsigned int indent) const {
93  #ifndef NDEBUG //[
94  out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n";
95  LinearForce::write(out, indent+2);
96  #endif //] NDEBUG
97 }
a programmable force that takes an evaluator fn.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to &lt;out&gt;.
virtual void output(ostream &out) const
Write a string representation of this instance to &lt;out&gt;.
A body on which physics will be applied.
Definition: physicsObject.h:29
virtual ~LinearUserDefinedForce()
destructor
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
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
LinearUserDefinedForce(LVector3(*proc)(const PhysicsObject *)=NULL, PN_stdfloat a=1.0f, bool md=false)
constructor
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to &lt;out&gt;.