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