Panda3D
 All Classes Functions Variables Enumerations
linearSinkForce.cxx
1 // Filename: linearSinkForce.cxx
2 // Created by: charles (21Jun00)
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 "linearSinkForce.h"
16 
17 TypeHandle LinearSinkForce::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function : LinearSinkForce
21 // Access : Public
22 // Description : Simple constructor
23 ////////////////////////////////////////////////////////////////////
25 LinearSinkForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a,
26  bool mass) :
27  LinearDistanceForce(p, f, r, a, mass) {
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function : LinearSinkForce
32 // Access : Public
33 // Description : Simple constructor
34 ////////////////////////////////////////////////////////////////////
37  LinearDistanceForce(LPoint3(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED,
38  1.0f, 1.0f, true) {
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function : LinearSinkForce
43 // Access : Public
44 // Description : copy constructor
45 ////////////////////////////////////////////////////////////////////
48  LinearDistanceForce(copy) {
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function : ~LinearSinkForce
53 // Access : Public
54 // Description : Simple destructor
55 ////////////////////////////////////////////////////////////////////
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function : make_copy
62 // Access : Public
63 // Description : copier
64 ////////////////////////////////////////////////////////////////////
65 LinearForce *LinearSinkForce::
66 make_copy() {
67  return new LinearSinkForce(*this);
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function : get_child_vector
72 // Access : Public
73 // Description : virtual force query
74 ////////////////////////////////////////////////////////////////////
75 LVector3 LinearSinkForce::
76 get_child_vector(const PhysicsObject *po) {
77  return (get_force_center() - po->get_position()) * get_scalar_term();
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<<"LinearSinkForce";
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<<"LinearSinkForce:\n";
103  LinearDistanceForce::write(out, indent+2);
104  #endif //] NDEBUG
105 }
LPoint3 get_position() const
Position Query.
LinearSinkForce()
Simple constructor.
LPoint3 get_force_center() const
force_center query
A body on which physics will be applied.
Definition: physicsObject.h:29
virtual ~LinearSinkForce()
Simple destructor.
Pure virtual class for sinks and sources.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:25
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to &lt;out&gt;.
PN_stdfloat get_scalar_term() const
calculate the term based on falloff
virtual void output(ostream &out) const
Write a string representation of this instance to &lt;out&gt;.
Attractor force.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to &lt;out&gt;.