Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions

TextureStage Class Reference

Defines the properties of a named stage of the multitexture pipeline. More...

#include "textureStage.h"

Inheritance diagram for TextureStage:
TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Public Types

enum  CombineMode {
  CM_undefined, CM_replace, CM_modulate, CM_add,
  CM_add_signed, CM_interpolate, CM_subtract, CM_dot3_rgb,
  CM_dot3_rgba
}
enum  CombineOperand {
  CO_undefined, CO_src_color, CO_one_minus_src_color, CO_src_alpha,
  CO_one_minus_src_alpha
}
enum  CombineSource {
  CS_undefined, CS_texture, CS_constant, CS_primary_color,
  CS_previous, CS_constant_color_scale, CS_last_saved_result
}
enum  Mode {
  M_modulate, M_decal, M_blend, M_replace,
  M_add, M_combine, M_blend_color_scale, M_modulate_glow,
  M_modulate_gloss, M_normal, M_normal_height, M_glow,
  M_gloss, M_height, M_selector, M_normal_gloss
}

Public Member Functions

 TextureStage (const string &name)
 Initialize the texture stage at construction.
 TextureStage (TextureStage &copy)
 Initialize the texture stage from other.
int compare_to (const TextureStage &other) const
 Returns a number less than zero if this TextureStage sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.
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 TypeHandle force_init_type ()
int get_alpha_scale () const
 See set_alpha_scale().
LColor get_color () const
 return the color for this stage
CombineMode get_combine_alpha_mode () const
 Get combine_alpha_mode.
CombineOperand get_combine_alpha_operand0 () const
 Get operand0 of combine_alpha_mode.
CombineOperand get_combine_alpha_operand1 () const
 Get operand1 of combine_alpha_mode.
CombineOperand get_combine_alpha_operand2 () const
 Get operand2 of combine_alpha_mode.
CombineSource get_combine_alpha_source0 () const
 Get source0 of combine_alpha_mode.
CombineSource get_combine_alpha_source1 () const
 Get source1 of combine_alpha_mode.
CombineSource get_combine_alpha_source2 () const
 Get source2 of combine_alpha_mode.
CombineMode get_combine_rgb_mode () const
 Get the combine_rgb_mode.
CombineOperand get_combine_rgb_operand0 () const
 Get operand0 of combine_rgb_mode.
CombineOperand get_combine_rgb_operand1 () const
 Get operand1 of combine_rgb_mode.
CombineOperand get_combine_rgb_operand2 () const
 Get operand2 of combine_rgb_mode.
CombineSource get_combine_rgb_source0 () const
 Get source0 of combine_rgb_mode.
CombineSource get_combine_rgb_source1 () const
 Get source1 of combine_rgb_mode.
CombineSource get_combine_rgb_source2 () const
 Get source2 of combine_rgb_mode.
Mode get_mode () const
 Return the mode of this stage.
const string & get_name () const
 Returns the name of this texture stage.
int get_num_combine_alpha_operands () const
 Returns the number of meaningful operands that may be retrieved via get_combine_alpha_sourceN() and get_combine_alpha_operandN().
int get_num_combine_rgb_operands () const
 Returns the number of meaningful operands that may be retrieved via get_combine_rgb_sourceN() and get_combine_rgb_operandN().
int get_priority () const
 Returns the priority associated with this stage.
int get_rgb_scale () const
 See set_rgb_scale().
bool get_saved_result () const
 Returns the current setting of the saved_result flag.
int get_sort () const
 Returns the sort order of this texture stage.
int get_tex_view_offset () const
 Returns the current setting of the tex_view_offset.
InternalNameget_texcoord_name () const
 Returns the InternalName.
virtual TypeHandle get_type () const
bool involves_color_scale () const
 Returns true if the TextureStage is affected by the setting of the current ColorScaleAttrib, false otherwise.
bool is_fixed_function () const
 Returns true if the TextureStage is relevant to the classic fixed function pipeline.
bool operator!= (const TextureStage &other) const
bool operator< (const TextureStage &other) const
void operator= (const TextureStage &copy)
 just copy the members of other to this
bool operator== (const TextureStage &other) const
void output (ostream &out) const
 Just a single line output.
void set_alpha_scale (int alpha_scale)
 Sets an additional factor that will scale the alpha component after the texture has been applied.
void set_color (const LColor &color)
 Set the color for this stage.
void set_combine_alpha (CombineMode mode, CombineSource source0, CombineOperand operand0)
 Specifies any of the CombineMode values that represent a one-parameter operation.
void set_combine_alpha (CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1)
 Specifies any of the CombineMode values that represent a two-parameter operation.
void set_combine_alpha (CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1, CombineSource source2, CombineOperand operand2)
 Specifies any of the CombineMode values that represent a one-parameter operation.
void set_combine_rgb (CombineMode mode, CombineSource source0, CombineOperand operand0)
 Specifies any of the CombineMode values that represent a one-parameter operation.
void set_combine_rgb (CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1, CombineSource source2, CombineOperand operand2)
 Specifies any of the CombineMode values that represent a one-parameter operation.
void set_combine_rgb (CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1)
 Specifies any of the CombineMode values that represent a two-parameter operation.
void set_mode (Mode mode)
 Set the mode of this texture stage.
void set_name (const string &name)
 Changes the name of this texture stage.
void set_priority (int priority)
 Changes the relative importance of the texture associated with this stage relative to the other texture stages that are applied simultaneously.
void set_rgb_scale (int rgb_scale)
 Sets an additional factor that will scale all three r, g, b components after the texture has been applied.
void set_saved_result (bool saved_result)
 Sets the saved_result flag.
void set_sort (int sort)
 Changes the order in which the texture associated with this stage is rendered relative to the other texture stages.
void set_tex_view_offset (int tex_view_offset)
 Sets the tex_view_offset value.
void set_texcoord_name (const string &texcoord_name)
 Indicate which set of UV's this texture stage will use.
void set_texcoord_name (InternalName *name)
 Indicate which set of UV's this texture stage will use.
bool uses_color () const
 Returns true if the TextureStage makes use of whatever color is specified in set_color(), false otherwise.
bool uses_last_saved_result () const
 Returns true if the TextureStage makes use of the CS_primary_color combine source.
bool uses_primary_color () const
 Returns true if the TextureStage makes use of the CS_primary_color combine source.
void write (ostream &out) const
 Writes the details of this stage.
virtual void write_datagram (BamWriter *manager, Datagram &me)
 Function to write the important information in the particular object to a Datagram.

Static Public Member Functions

static TypeHandle get_class_type ()
static TextureStageget_default ()
 Returns the default TextureStage that will be used for all texturing that does not name a particular stage.
static UpdateSeq get_sort_seq ()
 Returns a global sequence number that is incremented any time any TextureStage in the world changes sort or priority.
static void init_type ()
static TypedWritablemake_TextureStage (const FactoryParams &params)
 Factory method to generate a TextureStage object.
static void register_with_read_factory ()
 Factory method to generate a TextureStage object.

Protected Member Functions

void fillin (DatagramIterator &scan, BamReader *manager)
 Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place.

Detailed Description

Defines the properties of a named stage of the multitexture pipeline.

The TextureAttrib will associated a number of these stages with Texture objects, and the GSG will render geometry by sorting all of the currently active TextureStages in order and then issuing the appropriate rendering calls to activate them.

Definition at line 38 of file textureStage.h.


Constructor & Destructor Documentation

TextureStage::TextureStage ( const string &  name)

Initialize the texture stage at construction.

Definition at line 31 of file textureStage.cxx.

Referenced by get_default(), and make_TextureStage().

TextureStage::TextureStage ( TextureStage copy) [inline]

Initialize the texture stage from other.

Definition at line 22 of file textureStage.I.


Member Function Documentation

int TextureStage::compare_to ( const TextureStage other) const
int TextureStage::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 444 of file textureStage.cxx.

void TextureStage::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place.

Reimplemented from TypedWritable.

Definition at line 397 of file textureStage.cxx.

References DatagramIterator::get_bool(), BamReader::get_file_minor_ver(), DatagramIterator::get_int32(), DatagramIterator::get_string(), DatagramIterator::get_uint8(), LVecBase4f::read_datagram(), and BamReader::read_pointer().

Referenced by make_TextureStage().

int TextureStage::get_alpha_scale ( ) const [inline]

See set_alpha_scale().

Definition at line 256 of file textureStage.I.

Referenced by compare_to(), and write().

LColor TextureStage::get_color ( ) const [inline]

return the color for this stage

Definition at line 205 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), and write().

TextureStage::CombineMode TextureStage::get_combine_alpha_mode ( ) const [inline]

Get combine_alpha_mode.

Definition at line 572 of file textureStage.I.

Referenced by compare_to(), and write().

TextureStage::CombineOperand TextureStage::get_combine_alpha_operand0 ( ) const [inline]

Get operand0 of combine_alpha_mode.

Definition at line 604 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineOperand TextureStage::get_combine_alpha_operand1 ( ) const [inline]

Get operand1 of combine_alpha_mode.

Definition at line 624 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineOperand TextureStage::get_combine_alpha_operand2 ( ) const [inline]

Get operand2 of combine_alpha_mode.

Definition at line 644 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineSource TextureStage::get_combine_alpha_source0 ( ) const [inline]

Get source0 of combine_alpha_mode.

Definition at line 594 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineSource TextureStage::get_combine_alpha_source1 ( ) const [inline]

Get source1 of combine_alpha_mode.

Definition at line 614 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineSource TextureStage::get_combine_alpha_source2 ( ) const [inline]

Get source2 of combine_alpha_mode.

Definition at line 634 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineMode TextureStage::get_combine_rgb_mode ( ) const [inline]

Get the combine_rgb_mode.

Definition at line 408 of file textureStage.I.

Referenced by compare_to(), and write().

TextureStage::CombineOperand TextureStage::get_combine_rgb_operand0 ( ) const [inline]

Get operand0 of combine_rgb_mode.

Definition at line 440 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineOperand TextureStage::get_combine_rgb_operand1 ( ) const [inline]

Get operand1 of combine_rgb_mode.

Definition at line 460 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineOperand TextureStage::get_combine_rgb_operand2 ( ) const [inline]

Get operand2 of combine_rgb_mode.

Definition at line 480 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineSource TextureStage::get_combine_rgb_source0 ( ) const [inline]

Get source0 of combine_rgb_mode.

Definition at line 430 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineSource TextureStage::get_combine_rgb_source1 ( ) const [inline]

Get source1 of combine_rgb_mode.

Definition at line 450 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage::CombineSource TextureStage::get_combine_rgb_source2 ( ) const [inline]

Get source2 of combine_rgb_mode.

Definition at line 470 of file textureStage.I.

Referenced by ShaderGenerator::combine_source_as_string(), compare_to(), and write().

TextureStage * TextureStage::get_default ( ) [inline, static]

Returns the default TextureStage that will be used for all texturing that does not name a particular stage.

This generally handles the normal single-texture case.

Definition at line 733 of file textureStage.I.

References TextureStage().

Referenced by UvScrollNode::cull_callback(), TexMatrixAttrib::get_mat(), make_TextureStage(), NodePathCollection::set_texture(), NodePath::set_texture(), and write_datagram().

TextureStage::Mode TextureStage::get_mode ( ) const [inline]

Return the mode of this stage.

Definition at line 173 of file textureStage.I.

Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), and write().

const string & TextureStage::get_name ( ) const [inline]

Returns the name of this texture stage.

Definition at line 32 of file textureStage.I.

Referenced by NodePath::clear_normal_map(), compare_to(), NodePath::find_all_texture_stages(), TextureStageCollection::find_texture_stage(), output(), and write().

int TextureStage::get_num_combine_alpha_operands ( ) const [inline]

Returns the number of meaningful operands that may be retrieved via get_combine_alpha_sourceN() and get_combine_alpha_operandN().

Definition at line 584 of file textureStage.I.

Referenced by compare_to(), and write().

int TextureStage::get_num_combine_rgb_operands ( ) const [inline]

Returns the number of meaningful operands that may be retrieved via get_combine_rgb_sourceN() and get_combine_rgb_operandN().

Definition at line 420 of file textureStage.I.

Referenced by compare_to(), and write().

int TextureStage::get_priority ( ) const [inline]

Returns the priority associated with this stage.

This is specially helpful for cards that do not support more than n stages of multi-texturing.

Definition at line 113 of file textureStage.I.

Referenced by compare_to(), and write().

int TextureStage::get_rgb_scale ( ) const [inline]

See set_rgb_scale().

Definition at line 231 of file textureStage.I.

Referenced by compare_to(), and write().

bool TextureStage::get_saved_result ( ) const [inline]

Returns the current setting of the saved_result flag.

See set_saved_result().

Definition at line 288 of file textureStage.I.

Referenced by compare_to(), and write().

int TextureStage::get_sort ( ) const [inline]

Returns the sort order of this texture stage.

Definition at line 75 of file textureStage.I.

Referenced by compare_to(), and write().

UpdateSeq TextureStage::get_sort_seq ( ) [inline, static]

Returns a global sequence number that is incremented any time any TextureStage in the world changes sort or priority.

This is used by TextureAttrib to determine when it is necessary to re-sort its internal array of stages.

Definition at line 750 of file textureStage.I.

int TextureStage::get_tex_view_offset ( ) const [inline]

Returns the current setting of the tex_view_offset.

See set_tex_view_offset().

Definition at line 316 of file textureStage.I.

Referenced by compare_to(), and write().

InternalName * TextureStage::get_texcoord_name ( ) const [inline]
bool TextureStage::involves_color_scale ( ) const [inline]

Returns true if the TextureStage is affected by the setting of the current ColorScaleAttrib, false otherwise.

Definition at line 656 of file textureStage.I.

bool TextureStage::is_fixed_function ( ) const [inline]

Returns true if the TextureStage is relevant to the classic fixed function pipeline.

This excludes texture stages such as normal mapping and the like.

Definition at line 185 of file textureStage.I.

TypedWritable * TextureStage::make_TextureStage ( const FactoryParams params) [static]

Factory method to generate a TextureStage object.

Definition at line 372 of file textureStage.cxx.

References fillin(), DatagramIterator::get_bool(), get_default(), and TextureStage().

Referenced by register_with_read_factory().

void TextureStage::operator= ( const TextureStage copy)

just copy the members of other to this

Definition at line 69 of file textureStage.cxx.

void TextureStage::output ( ostream &  out) const

Just a single line output.

Definition at line 278 of file textureStage.cxx.

References get_name().

void TextureStage::register_with_read_factory ( ) [static]

Factory method to generate a TextureStage object.

Definition at line 362 of file textureStage.cxx.

References BamReader::get_factory(), make_TextureStage(), and Factory< Type >::register_factory().

void TextureStage::set_alpha_scale ( int  alpha_scale) [inline]

Sets an additional factor that will scale the alpha component after the texture has been applied.

This is used only when the mode is CM_combine.

The only legal values are 1, 2, or 4.

Definition at line 245 of file textureStage.I.

void TextureStage::set_color ( const LColor color) [inline]

Set the color for this stage.

Definition at line 195 of file textureStage.I.

void TextureStage::set_combine_alpha ( CombineMode  mode,
CombineSource  source0,
CombineOperand  operand0 
) [inline]

Specifies any of the CombineMode values that represent a one-parameter operation.

Specifically, this is CM_replace only.

Definition at line 492 of file textureStage.I.

void TextureStage::set_combine_alpha ( CombineMode  mode,
CombineSource  source0,
CombineOperand  operand0,
CombineSource  source1,
CombineOperand  operand1 
) [inline]

Specifies any of the CombineMode values that represent a two-parameter operation.

Specifically, this is everything except for CM_replace and CM_interpolate.

Definition at line 518 of file textureStage.I.

void TextureStage::set_combine_alpha ( CombineMode  mode,
CombineSource  source0,
CombineOperand  operand0,
CombineSource  source1,
CombineOperand  operand1,
CombineSource  source2,
CombineOperand  operand2 
) [inline]

Specifies any of the CombineMode values that represent a one-parameter operation.

Specifically, this is CM_interpolate only.

Definition at line 545 of file textureStage.I.

void TextureStage::set_combine_rgb ( CombineMode  mode,
CombineSource  source0,
CombineOperand  operand0 
) [inline]

Specifies any of the CombineMode values that represent a one-parameter operation.

Specifically, this is CM_replace only.

Definition at line 328 of file textureStage.I.

void TextureStage::set_combine_rgb ( CombineMode  mode,
CombineSource  source0,
CombineOperand  operand0,
CombineSource  source1,
CombineOperand  operand1 
) [inline]

Specifies any of the CombineMode values that represent a two-parameter operation.

Specifically, this is everything except for CM_replace and CM_interpolate.

Definition at line 354 of file textureStage.I.

void TextureStage::set_combine_rgb ( CombineMode  mode,
CombineSource  source0,
CombineOperand  operand0,
CombineSource  source1,
CombineOperand  operand1,
CombineSource  source2,
CombineOperand  operand2 
) [inline]

Specifies any of the CombineMode values that represent a one-parameter operation.

Specifically, this is CM_interpolate only.

Definition at line 381 of file textureStage.I.

void TextureStage::set_mode ( TextureStage::Mode  mode) [inline]

Set the mode of this texture stage.

Definition at line 157 of file textureStage.I.

void TextureStage::set_name ( const string &  name) [inline]

Changes the name of this texture stage.

Definition at line 42 of file textureStage.I.

void TextureStage::set_priority ( int  priority) [inline]

Changes the relative importance of the texture associated with this stage relative to the other texture stages that are applied simultaneously.

This is unrelated to set_sort(), which controls the order in which multiple textures are applied. The priority number is used to decide which of the requested textures are to be selected for rendering when more textures are requested than the hardware will support. The highest-priority n textures are selected for rendering, and then rendered in order by their sort factor.

Definition at line 96 of file textureStage.I.

void TextureStage::set_rgb_scale ( int  rgb_scale) [inline]

Sets an additional factor that will scale all three r, g, b components after the texture has been applied.

This is used only when the mode is CM_combine.

The only legal values are 1, 2, or 4.

Definition at line 220 of file textureStage.I.

void TextureStage::set_saved_result ( bool  saved_result) [inline]

Sets the saved_result flag.

When this is true, the output of this stage will be supplied as the "last_saved_result" source for any future stages, until the next TextureStage with a saved_result set true is encountered.

This can be used to reuse the results of this texture stage as input to more than one stage later in the pipeline.

The last texture in the pipeline (the one with the highest sort value) should not have this flag set.

Definition at line 277 of file textureStage.I.

void TextureStage::set_sort ( int  sort) [inline]

Changes the order in which the texture associated with this stage is rendered relative to the other texture stages.

When geometry is rendered with multiple textures, the textures are rendered in order from the lowest sort number to the highest sort number.

Also see set_priority(), which is used to select the most important textures for rendering when some must be omitted because of hardware limitations.

Definition at line 61 of file textureStage.I.

void TextureStage::set_tex_view_offset ( int  tex_view_offset) [inline]

Sets the tex_view_offset value.

This is used only when a special multiview texture is bound to the TextureStage, and it selects the particular view of the texture that is to be used.

This value is added to the similar parameter on DisplayRegion to derive the final texture view index that is selected for rendering.

Definition at line 305 of file textureStage.I.

void TextureStage::set_texcoord_name ( const string &  name) [inline]

Indicate which set of UV's this texture stage will use.

Geometry may have any number of associated UV sets, each of which must have a unique name.

Definition at line 137 of file textureStage.I.

References get_texcoord_name().

void TextureStage::set_texcoord_name ( InternalName name) [inline]

Indicate which set of UV's this texture stage will use.

Geometry may have any number of associated UV sets, each of which must have a unique name.

Definition at line 125 of file textureStage.I.

bool TextureStage::uses_color ( ) const [inline]

Returns true if the TextureStage makes use of whatever color is specified in set_color(), false otherwise.

Definition at line 668 of file textureStage.I.

bool TextureStage::uses_last_saved_result ( ) const [inline]

Returns true if the TextureStage makes use of the CS_primary_color combine source.

Definition at line 690 of file textureStage.I.

bool TextureStage::uses_primary_color ( ) const [inline]

Returns true if the TextureStage makes use of the CS_primary_color combine source.

Definition at line 679 of file textureStage.I.

void TextureStage::write ( ostream &  out) const
void TextureStage::write_datagram ( BamWriter manager,
Datagram me 
) [virtual]

Function to write the important information in the particular object to a Datagram.

Reimplemented from TypedWritable.

Definition at line 459 of file textureStage.cxx.

References Datagram::add_bool(), Datagram::add_int32(), Datagram::add_string(), Datagram::add_uint8(), get_default(), LVecBase4f::write_datagram(), and BamWriter::write_pointer().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations