32~TexProjectorEffect() {
42 if (_empty_effect ==
nullptr) {
43 _empty_effect = return_new(
new TexProjectorEffect);
63 TexProjectorEffect *effect =
new TexProjectorEffect(*
this);
64 StageDef &def = effect->_stages[stage];
67 def.set_lens_index(lens_index);
68 return return_new(effect);
77 TexProjectorEffect *effect =
new TexProjectorEffect(*
this);
78 effect->_stages.erase(stage);
79 return return_new(effect);
88 return _stages.empty();
98 Stages::const_iterator mi = _stages.find(stage);
99 return (mi != _stages.end());
109 Stages::const_iterator mi = _stages.
find(stage);
111 return (*mi).second._from;
124 Stages::const_iterator mi = _stages.
find(stage);
126 return (*mi).second._to;
136 Stages::const_iterator mi = _stages.find(stage);
137 nassertr(mi != _stages.end(), 0);
138 return (*mi).second._lens_index;
144void TexProjectorEffect::
145output(std::ostream &out)
const {
146 out << get_type() <<
":";
148 Stages::const_iterator mi;
149 for (mi = _stages.begin(); mi != _stages.end(); ++mi) {
151 const StageDef &def = (*mi).second;
152 out <<
" " << stage->
get_name() <<
"(" << def._to
153 <<
", " << def._from <<
", " << def._lens_index <<
")";
164 return !_stages.empty();
185 Stages::const_iterator mi;
186 for (mi = _stages.begin(); mi != _stages.end(); ++mi) {
188 const StageDef &def = (*mi).second;
192 if (def._to_lens_node !=
nullptr &&
193 def._to_lens_node->
get_lens() !=
nullptr) {
196 Lens *lens = def._to_lens_node->
get_lens(def._lens_index);
197 if (lens !=
nullptr) {
203 if (fixmat ==
nullptr) {
204 fixmat = TransformState::make_pos_hpr_scale
205 (LVecBase3(0.5f, 0.5f, 0.0f),
206 LVecBase3(0.0f, 0.0f, 0.0f),
207 LVecBase3(0.5f, 0.5f, 1.0f));
211 transform = fixmat->compose(projmat)->compose(transform);
215 if (!transform->is_identity()) {
217 tex_matrix->
add_stage(stage, transform));
221 if (!tex_matrix->is_empty()) {
238int TexProjectorEffect::
241 DCAST_INTO_R(ta, other, 0);
243 Stages::const_iterator ai, bi;
244 ai = _stages.begin();
245 bi = ta->_stages.begin();
246 while (ai != _stages.end() && bi != ta->_stages.end()) {
247 if ((*ai).first < (*bi).first) {
251 }
else if ((*bi).first < (*ai).first) {
257 int compare = (*ai).second.compare_to((*bi).second);
266 if (bi != ta->_stages.end()) {
271 if (ai != _stages.end()) {
329 effect->fillin(scan, manager);
338void TexProjectorEffect::
340 RenderEffect::fillin(scan, manager);
348 nassertv(num_stages == 0);
354void TexProjectorEffect::StageDef::
357 if (!_to.is_empty() && _to.node()->is_of_type(LensNode::get_class_type())) {
358 DCAST_INTO_V(_to_lens_node, _to.node());
360 _to_lens_node =
nullptr;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Lens * get_lens(int index=0) const
Returns a pointer to the particular Lens associated with this LensNode, or NULL if there is not yet a...
A base class for any number of different kinds of lenses, linear and otherwise.
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,...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
NodePath find(const std::string &path) const
Searches for a node below the referenced node that matches the indicated string.
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
const TransformState * get_transform(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete transform object set on this node.
This is the base class for a number of special render effects that may be set on scene graph nodes to...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
static ConstPointerTo< RenderState > make(const RenderAttrib *attrib, int override=0)
Returns a RenderState with one attribute set.
ConstPointerTo< RenderState > compose(const RenderState *other) const
Returns a new RenderState object that represents the composition of this state with the other state.
Applies a transform matrix to UV's before they are rendered.
static ConstPointerTo< RenderAttrib > make()
Constructs a TexMatrixAttrib that applies no stages at all.
ConstPointerTo< RenderAttrib > add_stage(TextureStage *stage, const TransformState *transform, int override=0) const
Returns a new TexMatrixAttrib just like this one, with the indicated transform for the given stage.
This effect automatically applies a computed texture matrix to the specified texture stage,...
int get_lens_index(TextureStage *stage) const
Returns the lens_index associated with the TexProjectorEffect on the indicated stage.
static ConstPointerTo< RenderEffect > make()
Constructs a TexProjectorEffect that modifies no stages at all.
bool is_empty() const
Returns true if no stages are defined in the TexProjectorEffect, false if at least one is.
ConstPointerTo< RenderEffect > remove_stage(TextureStage *stage) const
Returns a new TexProjectorEffect just like this one, with the indicated stage removed.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
ConstPointerTo< RenderEffect > add_stage(TextureStage *stage, const NodePath &from, const NodePath &to, int lens_index=0) const
Returns a new TexProjectorEffect just like this one, with the indicated projection for the given stag...
NodePath get_to(TextureStage *stage) const
Returns the "to" node associated with the TexProjectorEffect on the indicated stage.
static void register_with_read_factory()
Tells the BamReader how to create objects of type TexProjectorEffect.
bool has_stage(TextureStage *stage) const
Returns true if there is a transform associated with the indicated stage, or false otherwise (in whic...
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined.
NodePath get_from(TextureStage *stage) const
Returns the "from" node associated with the TexProjectorEffect on the indicated stage.
virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, ConstPointerTo< TransformState > &node_transform, ConstPointerTo< RenderState > &node_state) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
Defines the properties of a named stage of the multitexture pipeline.
get_name
Returns the name of this texture stage.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
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().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.