00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef LINEARNOISEFORCE_H
00016 #define LINEARNOISEFORCE_H
00017
00018 #include "pandabase.h"
00019 #include "linearRandomForce.h"
00020 #include "configVariableInt.h"
00021
00022
00023
00024
00025
00026 class EXPCL_PANDAPHYSICS LinearNoiseForce : public LinearRandomForce {
00027 PUBLISHED:
00028 LinearNoiseForce(PN_stdfloat a = 1.0f, bool m = false);
00029 LinearNoiseForce(const LinearNoiseForce ©);
00030 virtual ~LinearNoiseForce();
00031
00032 virtual void output(ostream &out) const;
00033 virtual void write(ostream &out, unsigned int indent=0) const;
00034
00035 public:
00036 static ConfigVariableInt _random_seed;
00037 static void init_noise_tables();
00038
00039 private:
00040 static unsigned char _prn_table[256];
00041 static LVector3 _gradient_table[256];
00042 static bool _initialized;
00043
00044 INLINE PN_stdfloat cubic_step(const PN_stdfloat x) const;
00045 INLINE LVector3 vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const;
00046
00047 INLINE unsigned char get_prn_entry(const LPoint3& point) const;
00048 INLINE unsigned char get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const;
00049
00050 INLINE LVector3& get_lattice_entry(const LPoint3& point);
00051 INLINE LVector3& get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z);
00052
00053 INLINE unsigned char prn_lookup(int index) const;
00054
00055 virtual LVector3 get_child_vector(const PhysicsObject *po);
00056 virtual LinearForce *make_copy();
00057
00058 public:
00059 static TypeHandle get_class_type() {
00060 return _type_handle;
00061 }
00062 static void init_type() {
00063 LinearRandomForce::init_type();
00064 register_type(_type_handle, "LinearNoiseForce",
00065 LinearRandomForce::get_class_type());
00066 }
00067 virtual TypeHandle get_type() const {
00068 return get_class_type();
00069 }
00070 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00071
00072 private:
00073 static TypeHandle _type_handle;
00074 };
00075
00076 #include "linearNoiseForce.I"
00077
00078 #endif // LINEARNOISEFORCE_H