31 operator << (std::ostream &out, Fog::Mode mode) {
34 return out <<
"linear";
36 case Fog::M_exponential:
37 return out <<
"exponential";
39 case Fog::M_exponential_squared:
40 return out <<
"exponential-squared";
43 return out <<
"**invalid**(" << (int)mode <<
")";
50 Fog(
const std::string &name) :
54 _color.set(1.0f, 1.0f, 1.0f, 1.0f);
55 _linear_onset_point.set(0.0f, 0.0f, 0.0f);
56 _linear_opaque_point.set(0.0f, 100.0f, 0.0f);
58 _linear_fallback_cosa = -1.0f;
59 _linear_fallback_onset = 0.0f;
60 _linear_fallback_opaque = 0.0f;
61 _transformed_onset = 0.0f;
62 _transformed_opaque = 0.0f;
69 Fog(
const Fog ©) :
74 _linear_onset_point = copy._linear_onset_point;
75 _linear_opaque_point = copy._linear_opaque_point;
76 _exp_density = copy._exp_density;
77 _linear_fallback_cosa = copy._linear_fallback_cosa;
78 _linear_fallback_onset = copy._linear_fallback_onset;
79 _linear_fallback_opaque = copy._linear_fallback_opaque;
80 _transformed_onset = copy._transformed_onset;
81 _transformed_opaque = copy._transformed_opaque;
98 return new Fog(*
this);
107 _linear_onset_point = _linear_onset_point * mat;
108 _linear_opaque_point = _linear_opaque_point * mat;
115 output(std::ostream &out)
const {
116 out <<
"fog: " << _mode;
119 out <<
"(" << _linear_onset_point <<
") -> (" 120 << _linear_opaque_point <<
")";
124 case M_exponential_squared:
137 LVector3 forward = LVector3::forward();
144 camera_transform->invert_compose(this_np.get_net_transform());
146 const LMatrix4 &mat = rel_transform->get_mat();
149 LVector3 fog_vector = (_linear_opaque_point - _linear_onset_point) * mat;
150 fog_vector.normalize();
151 PN_stdfloat cosa = fog_vector.dot(forward);
152 if (cabs(cosa) < _linear_fallback_cosa) {
154 _transformed_onset = _linear_fallback_onset;
155 _transformed_opaque = _linear_fallback_opaque;
158 _transformed_onset = forward.dot(_linear_onset_point * mat);
159 _transformed_opaque = forward.dot(_linear_opaque_point * mat);
164 _transformed_onset = forward.dot(_linear_onset_point);
165 _transformed_opaque = forward.dot(_linear_opaque_point);
174 onset = _transformed_onset;
175 opaque = _transformed_opaque;
195 _color.write_datagram(dg);
196 _linear_onset_point.write_datagram(dg);
197 _linear_opaque_point.write_datagram(dg);
216 node->fillin(scan, manager);
227 PandaNode::fillin(scan, manager);
230 _color.read_datagram(scan);
231 _linear_onset_point.read_datagram(scan);
232 _linear_opaque_point.read_datagram(scan);
void get_linear_range(PN_stdfloat &onset, PN_stdfloat &opaque)
Retrieves the current onset and offset ranges.
A basic node of the scene graph or data graph.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Fog.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
get_num_parents
Returns the number of parent nodes this node has.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void adjust_to_camera(const TransformState *camera_transform)
This function is intended to be called by the cull traverser to compute the appropriate camera-relati...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_int8(int8_t value)
Adds a signed 8-bit integer to the datagram.
Specifies how atmospheric fog effects are applied to geometry.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
int8_t get_int8()
Extracts a signed 8-bit integer.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.