Panda3D
Loading...
Searching...
No Matches
linearForce.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file linearForce.cxx
10 * @author charles
11 * @date 2000-06-14
12 */
13
14#include "datagram.h"
15#include "datagramIterator.h"
16#include "bamReader.h"
17#include "bamWriter.h"
18
19#include "linearForce.h"
20
21TypeHandle LinearForce::_type_handle;
22
23/**
24 * Default/component-based constructor
25 */
26LinearForce::
27LinearForce(PN_stdfloat a, bool mass) :
28 BaseForce(true),
29 _amplitude(a), _mass_dependent(mass),
30 _x_mask(true), _y_mask(true), _z_mask(true) {
31}
32
33/**
34 * copy constructor
35 */
36LinearForce::
37LinearForce(const LinearForce& copy) :
38 BaseForce(copy) {
39 _amplitude = copy._amplitude;
40 _mass_dependent = copy._mass_dependent;
41 _x_mask = copy._x_mask;
42 _y_mask = copy._y_mask;
43 _z_mask = copy._z_mask;
44}
45
46/**
47 * Destructor
48 */
52
53/**
54
55 */
56LVector3 LinearForce::
57get_vector(const PhysicsObject *po) {
58 LVector3 child_vector = get_child_vector(po) * _amplitude;
59 nassertr(!child_vector.is_nan(), LVector3::zero());
60
61 if (_x_mask == false)
62 child_vector[0] = 0.0f;
63
64 if (_y_mask == false)
65 child_vector[1] = 0.0f;
66
67 if (_z_mask == false)
68 child_vector[2] = 0.0f;
69
70 return child_vector;
71}
72
73/**
74
75 */
76bool LinearForce::
77is_linear() const {
78 return true;
79}
80
81/**
82 * Write a string representation of this instance to <out>.
83 */
85output(std::ostream &out) const {
86 #ifndef NDEBUG //[
87 out<<"LinearForce (id "<<this<<")";
88 #endif //] NDEBUG
89}
90
91/**
92 * Write a string representation of this instance to <out>.
93 */
95write(std::ostream &out, int indent) const {
96 #ifndef NDEBUG //[
97 out.width(indent); out<<""; out<<"LinearForce (id "<<this<<")\n";
98 out.width(indent+2); out<<""; out<<"_amplitude "<<_amplitude<<"\n";
99 out.width(indent+2); out<<""; out<<"_mass_dependent "<<_mass_dependent<<"\n";
100 out.width(indent+2); out<<""; out<<"_x_mask "<<_x_mask<<"\n";
101 out.width(indent+2); out<<""; out<<"_y_mask "<<_y_mask<<"\n";
102 out.width(indent+2); out<<""; out<<"_z_mask "<<_z_mask<<"\n";
103 BaseForce::write(out, indent+2);
104 #endif //] NDEBUG
105}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pure virtual base class for all forces that could POSSIBLY exist.
Definition baseForce.h:29
virtual void write(std::ostream &out, int indent_level=0) const
Write a string representation of this instance to <out>.
Definition baseForce.cxx:59
A force that acts on a PhysicsObject by way of an Integrator.
Definition linearForce.h:23
~LinearForce()
Destructor.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
A body on which physics will be applied.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.