Panda3D
linearNoiseForce.h
1 // Filename: linearNoiseForce.h
2 // Created by: charles (13Jun00)
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 #ifndef LINEARNOISEFORCE_H
16 #define LINEARNOISEFORCE_H
17 
18 #include "pandabase.h"
19 #include "linearRandomForce.h"
20 #include "configVariableInt.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : LinearNoiseForce
24 // Description : Repeating noise force vector.
25 ////////////////////////////////////////////////////////////////////
26 class EXPCL_PANDAPHYSICS LinearNoiseForce : public LinearRandomForce {
27 PUBLISHED:
28  LinearNoiseForce(PN_stdfloat a = 1.0f, bool m = false);
30  virtual ~LinearNoiseForce();
31 
32  virtual void output(ostream &out) const;
33  virtual void write(ostream &out, unsigned int indent=0) const;
34 
35 public:
36  static ConfigVariableInt _random_seed;
37  static void init_noise_tables();
38 
39 private:
40  static unsigned char _prn_table[256];
41  static LVector3 _gradient_table[256];
42  static bool _initialized;
43 
44  INLINE PN_stdfloat cubic_step(const PN_stdfloat x) const;
45  INLINE LVector3 vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const;
46 
47  INLINE unsigned char get_prn_entry(const LPoint3& point) const;
48  INLINE unsigned char get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const;
49 
50  INLINE LVector3& get_lattice_entry(const LPoint3& point);
51  INLINE LVector3& get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z);
52 
53  INLINE unsigned char prn_lookup(int index) const;
54 
55  virtual LVector3 get_child_vector(const PhysicsObject *po);
56  virtual LinearForce *make_copy();
57 
58 public:
59  static TypeHandle get_class_type() {
60  return _type_handle;
61  }
62  static void init_type() {
63  LinearRandomForce::init_type();
64  register_type(_type_handle, "LinearNoiseForce",
65  LinearRandomForce::get_class_type());
66  }
67  virtual TypeHandle get_type() const {
68  return get_class_type();
69  }
70  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
71 
72 private:
73  static TypeHandle _type_handle;
74 };
75 
76 #include "linearNoiseForce.I"
77 
78 #endif // LINEARNOISEFORCE_H
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
Pure virtual, parent to noiseForce and jitterForce.
A body on which physics will be applied.
Definition: physicsObject.h:29
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
Repeating noise force vector.
This is a convenience class to specialize ConfigVariable as an integer type.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.