Panda3D
|
Indicates the set of TextureStages and their associated Textures that should be applied to (or removed from) a node. More...
#include "textureAttrib.h"
Classes | |
class | CompareTextureStagePointer |
class | CompareTextureStagePriorities |
class | CompareTextureStageSort |
class | StageNode |
Public Member Functions | |
virtual int | complete_pointers (TypedWritable **plist, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). | |
CPT (RenderAttrib) add_on_stage(TextureStage *stage | |
CPT (RenderAttrib) remove_on_stage(TextureStage *stage) const | |
CPT (RenderAttrib) add_off_stage(TextureStage *stage | |
CPT (RenderAttrib) remove_off_stage(TextureStage *stage) const | |
CPT (RenderAttrib) unify_texture_stages(TextureStage *stage) const | |
CPT (TextureAttrib) filter_to_max(int max_texture_stages) const | |
virtual bool | cull_callback (CullTraverser *trav, const CullTraverserData &data) const |
If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
int | find_on_stage (const TextureStage *stage) const |
Returns the index number of the indicated TextureStage within the list of on_stages, or -1 if the indicated stage is not listed. | |
virtual TypeHandle | force_init_type () |
int | get_ff_tc_index (int n) const |
For each TextureStage listed in get_on_ff_stage(), this returns a unique index number for the texture coordinate name used by that TextureStage. | |
int | get_num_off_stages () const |
Returns the number of stages that are turned off by the attribute. | |
int | get_num_on_ff_stages () const |
Returns the number of on-stages that are relevant to the classic fixed function pipeline. | |
int | get_num_on_stages () const |
Returns the number of stages that are turned on by the attribute. | |
TextureStage * | get_off_stage (int n) const |
Returns the nth stage turned off by the attribute, sorted in arbitrary (pointer) order. | |
TextureStage * | get_on_ff_stage (int n) const |
Returns the nth stage turned on by the attribute, sorted in render order, including only those relevant to the classic fixed function pipeline. | |
TextureStage * | get_on_stage (int n) const |
Returns the nth stage turned on by the attribute, sorted in render order. | |
int | get_on_stage_override (TextureStage *stage) const |
Returns the override value associated with the indicated stage. | |
Texture * | get_on_texture (TextureStage *stage) const |
Returns the texture associated with the indicated stage, or NULL if no texture is associated. | |
virtual int | get_slot () const |
Texture * | get_texture () const |
If the TextureAttrib is not an 'off' TextureAttrib, returns the base-level texture that is associated. | |
virtual TypeHandle | get_type () const |
bool | has_all_off () const |
Returns true if this attrib turns off all stages (although it may also turn some on). | |
virtual bool | has_cull_callback () const |
Should be overridden by derived classes to return true if cull_callback() has been defined. | |
bool | has_off_stage (TextureStage *stage) const |
Returns true if the indicated stage is turned off by the attrib, false otherwise. | |
bool | has_on_stage (TextureStage *stage) const |
Returns true if the indicated stage is turned on by the attrib, false otherwise. | |
bool | is_identity () const |
Returns true if this is an identity attrib: it does not change the set of stages in use. | |
bool | is_off () const |
Returns true if the TextureAttrib is an 'off' TextureAttrib, indicating that it should disable texturing. | |
virtual bool | lower_attrib_can_override () const |
Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib objects of the same type interact. | |
MAKE_SEQ (get_off_stages, get_num_off_stages, get_off_stage) | |
MAKE_SEQ (get_on_ff_stages, get_num_on_ff_stages, get_on_ff_stage) | |
MAKE_SEQ (get_on_stages, get_num_on_stages, get_on_stage) | |
virtual void | output (ostream &out) const |
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 Public Member Functions | |
static | CPT (RenderAttrib) make(Texture *tex) |
static | CPT (RenderAttrib) make_off() |
static | CPT (RenderAttrib) make() |
static | CPT (RenderAttrib) make_all_off() |
static | CPT (RenderAttrib) make_default() |
static int | get_class_slot () |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type TextureAttrib. | |
Public Attributes | |
Texture int | override = 0) const |
int | override = 0) const |
Texture * | tex |
Protected Member Functions | |
TextureAttrib () | |
Use TextureAttrib::make() to construct a new TextureAttrib object. | |
TextureAttrib (const TextureAttrib ©) | |
Use TextureAttrib::make() to construct a new TextureAttrib object. | |
virtual int | compare_to_impl (const RenderAttrib *other) const |
Intended to be overridden by derived TextureAttrib types to return a unique number indicating whether this TextureAttrib is equivalent to the other one. | |
virtual | CPT (RenderAttrib) invert_compose_impl(const RenderAttrib *other) const |
virtual | CPT (RenderAttrib) compose_impl(const RenderAttrib *other) const |
virtual | CPT (RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new TextureAttrib. | |
virtual size_t | get_hash_impl () const |
Intended to be overridden by derived RenderAttrib types to return a unique hash for these particular properties. | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type TextureAttrib is encountered in the Bam file. |
Indicates the set of TextureStages and their associated Textures that should be applied to (or removed from) a node.
Definition at line 33 of file textureAttrib.h.
TextureAttrib::TextureAttrib | ( | ) | [inline, protected] |
Use TextureAttrib::make() to construct a new TextureAttrib object.
Definition at line 23 of file textureAttrib.I.
References UpdateSeq::old().
Referenced by make_from_bam().
TextureAttrib::TextureAttrib | ( | const TextureAttrib & | copy | ) | [inline, protected] |
Use TextureAttrib::make() to construct a new TextureAttrib object.
The copy constructor is only defined to facilitate methods like add_on_stage().
Definition at line 38 of file textureAttrib.I.
int TextureAttrib::compare_to_impl | ( | const RenderAttrib * | other | ) | const [protected, virtual] |
Intended to be overridden by derived TextureAttrib types to return a unique number indicating whether this TextureAttrib is equivalent to the other one.
This should return 0 if the two TextureAttrib objects are equivalent, a number less than zero if this one should be sorted before the other one, and a number greater than zero otherwise.
This will only be called with two TextureAttrib objects whose get_type() functions return the same.
Reimplemented from RenderAttrib.
Definition at line 483 of file textureAttrib.cxx.
References ordered_vector< Key, Compare >::begin(), and ordered_vector< Key, Compare >::end().
int TextureAttrib::complete_pointers | ( | TypedWritable ** | p_list, |
BamReader * | manager | ||
) | [virtual] |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Returns the number of pointers processed.
Reimplemented from TypedWritable.
Definition at line 835 of file textureAttrib.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), TextureStagePool::get_stage(), UpdateSeq::old(), ordered_vector< Key, Compare >::push_back(), ordered_vector< Key, Compare >::size(), and ov_set< Key, Compare >::sort().
bool TextureAttrib::cull_callback | ( | CullTraverser * | trav, |
const CullTraverserData & | data | ||
) | const [virtual] |
If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This is called each time the RenderAttrib is discovered applied to a Geom in the traversal. It should return true if the Geom is visible, false if it should be omitted.
Reimplemented from RenderAttrib.
Definition at line 455 of file textureAttrib.cxx.
References ordered_vector< Key, Compare >::begin(), Texture::cull_callback(), and ordered_vector< Key, Compare >::end().
void TextureAttrib::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new TextureAttrib.
Reimplemented from RenderAttrib.
Definition at line 902 of file textureAttrib.cxx.
References DatagramIterator::get_bool(), BamReader::get_file_minor_ver(), DatagramIterator::get_int32(), DatagramIterator::get_uint16(), ordered_vector< Key, Compare >::push_back(), and BamReader::read_pointer().
Referenced by make_from_bam().
int TextureAttrib::find_on_stage | ( | const TextureStage * | stage | ) | const |
Returns the index number of the indicated TextureStage within the list of on_stages, or -1 if the indicated stage is not listed.
Definition at line 111 of file textureAttrib.cxx.
References ordered_vector< Key, Compare >::begin(), and ordered_vector< Key, Compare >::end().
int TextureAttrib::get_ff_tc_index | ( | int | n | ) | const [inline] |
For each TextureStage listed in get_on_ff_stage(), this returns a unique index number for the texture coordinate name used by that TextureStage.
It is guaranteed to remain the same index number for each texcoord name (for a given set of TextureStages), even if the texture render order changes.
Definition at line 146 of file textureAttrib.I.
size_t TextureAttrib::get_hash_impl | ( | ) | const [protected, virtual] |
Intended to be overridden by derived RenderAttrib types to return a unique hash for these particular properties.
RenderAttribs that compare the same with compare_to_impl(), above, should return the same hash; RenderAttribs that compare differently should return a different hash.
Reimplemented from RenderAttrib.
Definition at line 578 of file textureAttrib.cxx.
References integer_hash< Key, Compare >::add_hash(), pointer_hash::add_hash(), ordered_vector< Key, Compare >::begin(), and ordered_vector< Key, Compare >::end().
int TextureAttrib::get_num_off_stages | ( | ) | const [inline] |
Returns the number of stages that are turned off by the attribute.
Definition at line 202 of file textureAttrib.I.
References ordered_vector< Key, Compare >::size().
Referenced by write_datagram().
int TextureAttrib::get_num_on_ff_stages | ( | ) | const [inline] |
Returns the number of on-stages that are relevant to the classic fixed function pipeline.
This excludes texture stages such as normal maps.
Definition at line 116 of file textureAttrib.I.
int TextureAttrib::get_num_on_stages | ( | ) | const [inline] |
Returns the number of stages that are turned on by the attribute.
Definition at line 91 of file textureAttrib.I.
Referenced by ShaderGenerator::analyze_renderstate(), GeomNode::apply_attribs_to_vertices(), NodePath::clear_normal_map(), GeomNode::r_prepare_scene(), and write_datagram().
TextureStage * TextureAttrib::get_off_stage | ( | int | n | ) | const [inline] |
Returns the nth stage turned off by the attribute, sorted in arbitrary (pointer) order.
Definition at line 213 of file textureAttrib.I.
References ordered_vector< Key, Compare >::size().
TextureStage * TextureAttrib::get_on_ff_stage | ( | int | n | ) | const [inline] |
Returns the nth stage turned on by the attribute, sorted in render order, including only those relevant to the classic fixed function pipeline.
This excludes texture stages such as normal maps.
Definition at line 130 of file textureAttrib.I.
TextureStage * TextureAttrib::get_on_stage | ( | int | n | ) | const [inline] |
Returns the nth stage turned on by the attribute, sorted in render order.
Definition at line 103 of file textureAttrib.I.
Referenced by ShaderGenerator::analyze_renderstate(), GeomNode::apply_attribs_to_vertices(), NodePath::clear_normal_map(), get_texture(), and GeomNode::r_prepare_scene().
int TextureAttrib::get_on_stage_override | ( | TextureStage * | stage | ) | const [inline] |
Returns the override value associated with the indicated stage.
Definition at line 185 of file textureAttrib.I.
References ordered_vector< Key, Compare >::end().
Texture * TextureAttrib::get_on_texture | ( | TextureStage * | stage | ) | const [inline] |
Returns the texture associated with the indicated stage, or NULL if no texture is associated.
Definition at line 169 of file textureAttrib.I.
References ordered_vector< Key, Compare >::end().
Referenced by get_texture(), NodePath::get_texture(), and GeomNode::r_prepare_scene().
Texture * TextureAttrib::get_texture | ( | ) | const [inline] |
If the TextureAttrib is not an 'off' TextureAttrib, returns the base-level texture that is associated.
Otherwise, return NULL.
Definition at line 76 of file textureAttrib.I.
References ordered_vector< Key, Compare >::empty(), get_on_stage(), and get_on_texture().
Referenced by EggRenderState::fill_state(), and NodePath::get_texture().
bool TextureAttrib::has_all_off | ( | ) | const [inline] |
Returns true if this attrib turns off all stages (although it may also turn some on).
Definition at line 237 of file textureAttrib.I.
Referenced by SpeedTreeNode::cull_callback(), and NodePath::has_texture_off().
bool TextureAttrib::has_cull_callback | ( | ) | const [virtual] |
Should be overridden by derived classes to return true if cull_callback() has been defined.
Otherwise, returns false to indicate cull_callback() does not need to be called for this node during the cull traversal.
Reimplemented from RenderAttrib.
Definition at line 429 of file textureAttrib.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), and Texture::has_cull_callback().
bool TextureAttrib::has_off_stage | ( | TextureStage * | stage | ) | const [inline] |
Returns true if the indicated stage is turned off by the attrib, false otherwise.
Definition at line 225 of file textureAttrib.I.
References ordered_vector< Key, Compare >::end(), and has_on_stage().
Referenced by NodePath::has_texture_off().
bool TextureAttrib::has_on_stage | ( | TextureStage * | stage | ) | const [inline] |
Returns true if the indicated stage is turned on by the attrib, false otherwise.
Definition at line 158 of file textureAttrib.I.
References ordered_vector< Key, Compare >::end().
Referenced by has_off_stage(), and NodePath::has_texture().
bool TextureAttrib::is_identity | ( | ) | const [inline] |
Returns true if this is an identity attrib: it does not change the set of stages in use.
Definition at line 248 of file textureAttrib.I.
References ordered_vector< Key, Compare >::empty().
bool TextureAttrib::is_off | ( | ) | const [inline] |
Returns true if the TextureAttrib is an 'off' TextureAttrib, indicating that it should disable texturing.
If multitexture is in effect, a TextureAttrib may not be strictly "on" or "off"; therefore, to get a more precise answer to this question, you should consider using has_all_off() or get_num_off_stages() or has_off_stage() instead.
Definition at line 64 of file textureAttrib.I.
References ordered_vector< Key, Compare >::empty().
bool TextureAttrib::lower_attrib_can_override | ( | ) | const [virtual] |
Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib objects of the same type interact.
This should return false if a RenderAttrib on a higher node will compose into a RenderAttrib on a lower node that has a higher override value, or false if the lower RenderAttrib will completely replace the state.
The default behavior is false: normally, a RenderAttrib in the graph cannot completely override a RenderAttrib above it, regardless of its override value--instead, the two attribs are composed. But for some kinds of RenderAttribs, it is useful to allow this kind of override.
This method only handles the one special case of a lower RenderAttrib with a higher override value. If the higher RenderAttrib has a higher override value, it always completely overrides. And if both RenderAttribs have the same override value, they are always composed.
Reimplemented from RenderAttrib.
Definition at line 352 of file textureAttrib.cxx.
TypedWritable * TextureAttrib::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type TextureAttrib is encountered in the Bam file.
It should create the TextureAttrib and extract its information from the file.
Definition at line 883 of file textureAttrib.cxx.
References fillin(), and TextureAttrib().
Referenced by register_with_read_factory().
void TextureAttrib::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type TextureAttrib.
Definition at line 789 of file textureAttrib.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from RenderAttrib.
Definition at line 800 of file textureAttrib.cxx.
References Datagram::add_bool(), Datagram::add_int32(), Datagram::add_uint16(), ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), get_num_off_stages(), get_num_on_stages(), and BamWriter::write_pointer().