22 (
"default_noise_force_seed", 665);
24 bool LinearNoiseForce::_initialized =
false;
25 unsigned char LinearNoiseForce::_prn_table[256];
26 LVector3 LinearNoiseForce::_gradient_table[256];
39 LVector3 *gtable = _gradient_table;
40 for (
int i = 0; i < 256; ++i) {
42 _prn_table[i] = rand() & 255;
45 *gtable++ = random_unit_vector();
55 if (_initialized ==
false) {
87 LVector3 LinearNoiseForce::
92 int int_x, int_y, int_z;
93 PN_stdfloat frac_x, frac_y, frac_z;
96 frac_x = p[0] - int_x;
99 frac_y = p[1] - int_y;
102 frac_z = p[2] - int_z;
105 PN_stdfloat cubic_x, cubic_y, cubic_z;
107 cubic_x = cubic_step(frac_x);
108 cubic_y = cubic_step(frac_y);
109 cubic_z = cubic_step(frac_z);
112 LVector3 temp0, temp1, temp2, temp3;
115 temp0 = vlerp(cubic_x, get_lattice_entry(p),
116 get_lattice_entry(p[0] + 1.0f, p[1], p[2]));
118 temp1 = vlerp(cubic_x, get_lattice_entry(p[0], p[1], p[2] + 1.0f),
119 get_lattice_entry(p[0] + 1.0f, p[1], p[2] + 1.0f));
121 temp2 = vlerp(cubic_x, get_lattice_entry(p[0], p[1] + 1.0f, p[2]),
122 get_lattice_entry(p[0] + 1.0f, p[1] + 1.0f, p[2]));
124 temp3 = vlerp(cubic_x, get_lattice_entry(p[0], p[1] + 1.0f, p[2] + 1.0f),
125 get_lattice_entry(p[0] + 1.0f, p[1] + 1.0f, p[2] + 1.0f));
128 temp0 = vlerp(cubic_z, temp0, temp1);
129 temp1 = vlerp(cubic_z, temp2, temp3);
132 return vlerp(cubic_y, temp0, temp1);
141 out<<
""<<
"LinearNoiseForce";
152 out<<
""<<
"LinearNoiseForce:";
153 out.width(
indent+2); out<<
""; out<<
"_random_seed"<<_random_seed<<
" (class)\n";
154 out.width(
indent+2); out<<
""; out<<
"_initialized"<<_initialized<<
" (class)\n";
155 out.width(
indent+2); out<<
""; out<<
"_gradient_table"<<_gradient_table<<
" (class)\n";
156 out.width(
indent+2); out<<
""; out<<
"_prn_table"<<_prn_table<<
" (class)\n";
virtual ~LinearNoiseForce()
destructor
Pure virtual, parent to noiseForce and jitterForce.
LinearNoiseForce(PN_stdfloat a=1.0f, bool m=false)
constructor
A body on which physics will be applied.
A force that acts on a PhysicsObject by way of an Integrator.
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>.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Repeating noise force vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void init_noise_tables()
One-time config function, sets up the PRN lattice.
LPoint3 get_position() const
Position Query.
This is a convenience class to specialize ConfigVariable as an integer type.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.