15 #include "texProjectorEffect.h" 16 #include "cullTraverserData.h" 17 #include "texMatrixAttrib.h" 19 #include "config_pgraph.h" 21 #include "bamReader.h" 22 #include "bamWriter.h" 24 #include "datagramIterator.h" 35 ~TexProjectorEffect() {
75 StageDef &def = effect->_stages[stage];
78 def.set_lens_index(lens_index);
79 return return_new(effect);
91 effect->_stages.erase(stage);
92 return return_new(effect);
101 bool TexProjectorEffect::
103 return _stages.empty();
114 bool TexProjectorEffect::
116 Stages::const_iterator mi = _stages.find(stage);
117 return (mi != _stages.end());
131 Stages::const_iterator mi = _stages.find(stage);
133 return (*mi).second._from;
151 Stages::const_iterator mi = _stages.find(stage);
153 return (*mi).second._to;
165 int TexProjectorEffect::
167 Stages::const_iterator mi = _stages.find(stage);
168 nassertr(mi != _stages.end(), 0);
169 return (*mi).second._lens_index;
177 void TexProjectorEffect::
178 output(ostream &out)
const {
179 out << get_type() <<
":";
181 Stages::const_iterator mi;
182 for (mi = _stages.begin(); mi != _stages.end(); ++mi) {
184 const StageDef &def = (*mi).second;
185 out <<
" " << stage->
get_name() <<
"(" << def._to
186 <<
", " << def._from <<
", " << def._lens_index <<
")";
199 bool TexProjectorEffect::
200 has_cull_callback()
const {
201 return !_stages.empty();
221 void TexProjectorEffect::
223 CPT(TransformState) &node_transform,
227 Stages::const_iterator mi;
228 for (mi = _stages.begin(); mi != _stages.end(); ++mi) {
230 const StageDef &def = (*mi).second;
232 CPT(TransformState) transform = def._from.get_transform(def._to);
234 if (def._to_lens_node != (
LensNode *)NULL &&
235 def._to_lens_node->get_lens() != (
Lens *)NULL) {
238 Lens *lens = def._to_lens_node->get_lens(def._lens_index);
245 static CPT(TransformState) fixmat;
246 if (fixmat == (TransformState *)NULL) {
247 fixmat = TransformState::make_pos_hpr_scale
254 transform = fixmat->compose(projmat)->compose(transform);
258 if (!transform->is_identity()) {
260 tex_matrix->add_stage(stage, transform));
264 if (!tex_matrix->is_empty()) {
265 node_state = node_state->compose(RenderState::make(tex_matrix));
284 int TexProjectorEffect::
287 DCAST_INTO_R(ta, other, 0);
289 Stages::const_iterator ai, bi;
290 ai = _stages.begin();
291 bi = ta->_stages.begin();
292 while (ai != _stages.end() && bi != ta->_stages.end()) {
293 if ((*ai).first < (*bi).first) {
297 }
else if ((*bi).first < (*ai).first) {
303 int compare = (*ai).second.compare_to((*bi).second);
312 if (bi != ta->_stages.end()) {
317 if (ai != _stages.end()) {
331 void TexProjectorEffect::
332 register_with_read_factory() {
386 parse_params(params, scan, manager);
387 effect->fillin(scan, manager);
399 void TexProjectorEffect::
401 RenderEffect::fillin(scan, manager);
409 nassertv(num_stages == 0);
417 void TexProjectorEffect::StageDef::
420 if (!_to.is_empty() && _to.node()->is_of_type(LensNode::get_class_type())) {
421 DCAST_INTO_V(_to_lens_node, _to.node());
This is the base class for all three-component vectors and points.
A base class for any number of different kinds of lenses, linear and otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A node that contains a Lens.
Base class for objects that can be written to and read from Bam files.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
const string & get_name() const
Returns the name of this texture stage.
Applies a transform matrix to UV's before they are rendered.
const LMatrix4 & get_projection_mat(StereoChannel channel=SC_mono) const
Returns the complete transformation matrix from a 3-d point in space to a point on the film...
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 WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This effect automatically applies a computed texture matrix to the specified texture stage...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Defines the properties of a named stage of the multitexture pipeline.
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...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...