22(
"default_noise_force_seed", 665);
24bool LinearNoiseForce::_initialized =
false;
25unsigned char LinearNoiseForce::_prn_table[256];
26LVector3 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) {
87LVector3 LinearNoiseForce::
92 PN_stdfloat int_x, int_y, int_z;
93 PN_stdfloat frac_x, frac_y, frac_z;
95 frac_x = std::modf(p[0], &int_x);
96 frac_y = std::modf(p[1], &int_y);
97 frac_z = std::modf(p[2], &int_z);
100 PN_stdfloat cubic_x, cubic_y, cubic_z;
102 cubic_x = cubic_step(frac_x);
103 cubic_y = cubic_step(frac_y);
104 cubic_z = cubic_step(frac_z);
107 LVector3 temp0, temp1, temp2, temp3;
110 temp0 = vlerp(cubic_x, get_lattice_entry(p),
111 get_lattice_entry(p[0] + 1.0f, p[1], p[2]));
113 temp1 = vlerp(cubic_x, get_lattice_entry(p[0], p[1], p[2] + 1.0f),
114 get_lattice_entry(p[0] + 1.0f, p[1], p[2] + 1.0f));
116 temp2 = vlerp(cubic_x, get_lattice_entry(p[0], p[1] + 1.0f, p[2]),
117 get_lattice_entry(p[0] + 1.0f, p[1] + 1.0f, p[2]));
119 temp3 = vlerp(cubic_x, get_lattice_entry(p[0], p[1] + 1.0f, p[2] + 1.0f),
120 get_lattice_entry(p[0] + 1.0f, p[1] + 1.0f, p[2] + 1.0f));
123 temp0 = vlerp(cubic_z, temp0, temp1);
124 temp1 = vlerp(cubic_z, temp2, temp3);
127 return vlerp(cubic_y, temp0, temp1);
134output(std::ostream &out)
const {
136 out<<
""<<
"LinearNoiseForce";
147 out<<
""<<
"LinearNoiseForce:";
148 out.width(
indent+2); out<<
""; out<<
"_random_seed"<<_random_seed<<
" (class)\n";
149 out.width(
indent+2); out<<
""; out<<
"_initialized"<<_initialized<<
" (class)\n";
150 out.width(
indent+2); out<<
""; out<<
"_gradient_table"<<_gradient_table<<
" (class)\n";
151 out.width(
indent+2); out<<
""; out<<
"_prn_table"<<_prn_table<<
" (class)\n";
This is a convenience class to specialize ConfigVariable as an integer type.
A force that acts on a PhysicsObject by way of an Integrator.
Repeating noise force vector.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
static void init_noise_tables()
One-time config function, sets up the PRN lattice.
virtual ~LinearNoiseForce()
destructor
LinearNoiseForce(PN_stdfloat a=1.0f, bool m=false)
constructor
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Pure virtual, parent to noiseForce and jitterForce.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
A body on which physics will be applied.
get_position
Position Query.
TypeHandle is the identifier used to differentiate C++ class types.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.