00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef FOG_H
00020 #define FOG_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pandaNode.h"
00025 #include "luse.h"
00026 #include "cmath.h"
00027 #include "deg_2_rad.h"
00028
00029 class TransformState;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class EXPCL_PANDA Fog : public PandaNode {
00051 PUBLISHED:
00052 Fog(const string &name);
00053
00054 protected:
00055 Fog(const Fog ©);
00056
00057 public:
00058 virtual ~Fog();
00059
00060 virtual PandaNode *make_copy() const;
00061 virtual void xform(const LMatrix4f &mat);
00062
00063 PUBLISHED:
00064 enum Mode {
00065 M_linear,
00066 M_exponential,
00067 M_exponential_squared
00068 };
00069
00070 INLINE Mode get_mode() const;
00071 INLINE void set_mode(Mode mode);
00072
00073 INLINE const Colorf &get_color() const;
00074 INLINE void set_color(float r, float g, float b);
00075 INLINE void set_color(const Colorf &color);
00076
00077 INLINE void set_linear_range(float onset, float opaque);
00078
00079 INLINE const LPoint3f &get_linear_onset_point() const;
00080 INLINE void set_linear_onset_point(float x, float y, float z);
00081 INLINE void set_linear_onset_point(const LPoint3f &linear_onset_point);
00082
00083 INLINE const LPoint3f &get_linear_opaque_point() const;
00084 INLINE void set_linear_opaque_point(const LPoint3f &linear_opaque_point);
00085 INLINE void set_linear_opaque_point(float x, float y, float z);
00086
00087 INLINE void set_linear_fallback(float angle, float onset, float opaque);
00088
00089 INLINE float get_exp_density() const;
00090 INLINE void set_exp_density(float exp_density);
00091
00092 void output(ostream &out) const;
00093
00094 public:
00095 void adjust_to_camera(const TransformState *camera_transform);
00096 void get_linear_range(float &onset, float &opaque);
00097
00098 protected:
00099 void compute_density();
00100
00101 public:
00102 static void register_with_read_factory();
00103 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00104
00105 protected:
00106 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00107 void fillin(DatagramIterator &scan, BamReader *manager);
00108
00109 protected:
00110 Mode _mode;
00111 Colorf _color;
00112 LPoint3f _linear_onset_point;
00113 LPoint3f _linear_opaque_point;
00114 float _exp_density;
00115
00116 float _linear_fallback_cosa;
00117 float _linear_fallback_onset, _linear_fallback_opaque;
00118
00119 float _transformed_onset, _transformed_opaque;
00120
00121 public:
00122 static TypeHandle get_class_type() {
00123 return _type_handle;
00124 }
00125 static void init_type() {
00126 PandaNode::init_type();
00127 register_type(_type_handle, "Fog",
00128 PandaNode::get_class_type());
00129 }
00130 virtual TypeHandle get_type() const {
00131 return get_class_type();
00132 }
00133 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00134
00135 private:
00136 static TypeHandle _type_handle;
00137 };
00138
00139 EXPCL_PANDA ostream &operator << (ostream &out, Fog::Mode mode);
00140
00141 INLINE ostream &operator << (ostream &out, const Fog &fog) {
00142 fog.output(out);
00143 return out;
00144 }
00145
00146 #include "fog.I"
00147
00148 #endif