Panda3D
linearNoiseForce.h
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 linearNoiseForce.h
10  * @author charles
11  * @date 2000-06-13
12  */
13 
14 #ifndef LINEARNOISEFORCE_H
15 #define LINEARNOISEFORCE_H
16 
17 #include "pandabase.h"
18 #include "linearRandomForce.h"
19 #include "configVariableInt.h"
20 
21 /**
22  * Repeating noise force vector.
23  */
24 class EXPCL_PANDA_PHYSICS LinearNoiseForce : public LinearRandomForce {
25 PUBLISHED:
26  explicit LinearNoiseForce(PN_stdfloat a = 1.0f, bool m = false);
28  virtual ~LinearNoiseForce();
29 
30  virtual void output(std::ostream &out) const;
31  virtual void write(std::ostream &out, int indent=0) const;
32 
33 public:
34  static ConfigVariableInt _random_seed;
35  static void init_noise_tables();
36 
37 private:
38  static unsigned char _prn_table[256];
39  static LVector3 _gradient_table[256];
40  static bool _initialized;
41 
42  INLINE PN_stdfloat cubic_step(const PN_stdfloat x) const;
43  INLINE LVector3 vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const;
44 
45  INLINE unsigned char get_prn_entry(const LPoint3& point) const;
46  INLINE unsigned char get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const;
47 
48  INLINE LVector3& get_lattice_entry(const LPoint3& point);
49  INLINE LVector3& get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z);
50 
51  INLINE unsigned char prn_lookup(int index) const;
52 
53  virtual LVector3 get_child_vector(const PhysicsObject *po);
54  virtual LinearForce *make_copy();
55 
56 public:
57  static TypeHandle get_class_type() {
58  return _type_handle;
59  }
60  static void init_type() {
61  LinearRandomForce::init_type();
62  register_type(_type_handle, "LinearNoiseForce",
63  LinearRandomForce::get_class_type());
64  }
65  virtual TypeHandle get_type() const {
66  return get_class_type();
67  }
68  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
69 
70 private:
71  static TypeHandle _type_handle;
72 };
73 
74 #include "linearNoiseForce.I"
75 
76 #endif // LINEARNOISEFORCE_H
virtual void output(std::ostream &out) 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:27
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:23
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.
Repeating noise force vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:81
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.