30 TextureStage(
const std::string &name) : _used_by_auto_shader(false) {
34 _texcoord_name = InternalName::get_texcoord();
36 _color.set(0.0f, 0.0f, 0.0f, 1.0f);
39 _saved_result =
false;
41 _combine_rgb_mode = CM_undefined;
42 _num_combine_rgb_operands = 0;
43 _combine_rgb_source0 = CS_undefined;
44 _combine_rgb_operand0 = CO_undefined;
45 _combine_rgb_source1 = CS_undefined;
46 _combine_rgb_operand1 = CO_undefined;
47 _combine_rgb_source2 = CS_undefined;
48 _combine_rgb_operand2 = CO_undefined;
49 _combine_alpha_mode = CM_undefined;
50 _num_combine_alpha_operands = 0;
51 _combine_alpha_source0 = CS_undefined;
52 _combine_alpha_operand0 = CO_undefined;
53 _combine_alpha_source1 = CS_undefined;
54 _combine_alpha_operand1 = CO_undefined;
55 _combine_alpha_source2 = CS_undefined;
56 _combine_alpha_operand2 = CO_undefined;
59 _involves_color_scale =
false;
69 _priority = other._priority;
70 _texcoord_name = other._texcoord_name;
72 _color = other._color;
73 _rgb_scale = other._rgb_scale;
74 _alpha_scale = other._alpha_scale;
75 _saved_result = other._saved_result;
76 _tex_view_offset = other._tex_view_offset;
78 _combine_rgb_mode = other._combine_rgb_mode;
79 _combine_rgb_source0 = other._combine_rgb_source0;
80 _combine_rgb_operand0 = other._combine_rgb_operand0;
81 _combine_rgb_source1 = other._combine_rgb_source1;
82 _combine_rgb_operand1 = other._combine_rgb_operand1;
83 _combine_rgb_source2 = other._combine_rgb_source2;
84 _combine_rgb_operand2 = other._combine_rgb_operand2;
85 _combine_alpha_mode = other._combine_alpha_mode;
86 _combine_alpha_source0 = other._combine_alpha_source0;
87 _combine_alpha_operand0 = other._combine_alpha_operand0;
88 _combine_alpha_source1 = other._combine_alpha_source1;
89 _combine_alpha_operand1 = other._combine_alpha_operand1;
90 _combine_alpha_source2 = other._combine_alpha_source2;
91 _combine_alpha_operand2 = other._combine_alpha_operand2;
93 _uses_color = other._uses_color;
94 _involves_color_scale = other._involves_color_scale;
96 _used_by_auto_shader =
false;
266 out <<
"TextureStage " <<
get_name();
274 get_expected_num_combine_operands(TextureStage::CombineMode cm) {
302 operand_valid_for_rgb(TextureStage::CombineOperand co) {
308 case CO_one_minus_src_color:
310 case CO_one_minus_src_alpha:
322 operand_valid_for_alpha(TextureStage::CombineOperand co) {
326 case CO_one_minus_src_color:
330 case CO_one_minus_src_alpha:
360 me->fillin(scan, manager);
378 _mode = (TextureStage::Mode) scan.
get_uint8();
379 _color.read_datagram(scan);
384 _tex_view_offset = 0;
389 _combine_rgb_mode = (TextureStage::CombineMode) scan.
get_uint8();
390 _num_combine_rgb_operands = scan.
get_uint8();
391 _combine_rgb_source0 = (TextureStage::CombineSource) scan.
get_uint8();
392 _combine_rgb_operand0 = (TextureStage::CombineOperand) scan.
get_uint8();
393 _combine_rgb_source1 = (TextureStage::CombineSource) scan.
get_uint8();
394 _combine_rgb_operand1 = (TextureStage::CombineOperand) scan.
get_uint8();
395 _combine_rgb_source2 = (TextureStage::CombineSource) scan.
get_uint8();
396 _combine_rgb_operand2 = (TextureStage::CombineOperand) scan.
get_uint8();
398 _combine_alpha_mode = (TextureStage::CombineMode) scan.
get_uint8();
399 _num_combine_alpha_operands = scan.
get_uint8();
400 _combine_alpha_source0 = (TextureStage::CombineSource) scan.
get_uint8();
401 _combine_alpha_operand0 = (TextureStage::CombineOperand) scan.
get_uint8();
402 _combine_alpha_source1 = (TextureStage::CombineSource) scan.
get_uint8();
403 _combine_alpha_operand1 = (TextureStage::CombineOperand) scan.
get_uint8();
404 _combine_alpha_source2 = (TextureStage::CombineSource) scan.
get_uint8();
405 _combine_alpha_operand2 = (TextureStage::CombineOperand) scan.
get_uint8();
407 update_color_flags();
441 _color.write_datagram(me);
460 me.
add_uint8(_num_combine_alpha_operands);
471 operator << (ostream &out, TextureStage::Mode mode) {
473 case TextureStage::M_modulate:
474 return out <<
"modulate";
476 case TextureStage::M_decal:
477 return out <<
"decal";
479 case TextureStage::M_blend:
480 return out <<
"blend";
482 case TextureStage::M_replace:
483 return out <<
"replace";
485 case TextureStage::M_add:
488 case TextureStage::M_combine:
489 return out <<
"combine";
491 case TextureStage::M_blend_color_scale:
492 return out <<
"blend_color_scale";
494 case TextureStage::M_modulate_glow:
495 return out <<
"modulate_glow";
497 case TextureStage::M_modulate_gloss:
498 return out <<
"modulate_gloss";
500 case TextureStage::M_normal:
501 return out <<
"normal";
503 case TextureStage::M_normal_height:
504 return out <<
"normal_height";
506 case TextureStage::M_glow:
507 return out <<
"glow";
509 case TextureStage::M_gloss:
510 return out <<
"gloss";
512 case TextureStage::M_height:
513 return out <<
"height";
515 case TextureStage::M_selector:
516 return out <<
"selector";
518 case TextureStage::M_normal_gloss:
519 return out <<
"normal_gloss";
522 return out <<
"**invalid Mode(" << (int)mode <<
")**";
526 operator << (ostream &out, TextureStage::CombineMode cm) {
528 case TextureStage::CM_undefined:
529 return out <<
"undefined";
531 case TextureStage::CM_replace:
532 return out <<
"replace";
534 case TextureStage::CM_modulate:
535 return out <<
"modulate";
537 case TextureStage::CM_add:
540 case TextureStage::CM_add_signed:
541 return out <<
"add_signed";
543 case TextureStage::CM_interpolate:
544 return out <<
"interpolate";
546 case TextureStage::CM_subtract:
547 return out <<
"subtract";
549 case TextureStage::CM_dot3_rgb:
550 return out <<
"dot3_rgb";
552 case TextureStage::CM_dot3_rgba:
553 return out <<
"dot3_rgba";
556 return out <<
"**invalid CombineMode(" << (int)cm <<
")**";
560 operator << (ostream &out, TextureStage::CombineSource cs) {
562 case TextureStage::CS_undefined:
563 return out <<
"undefined";
565 case TextureStage::CS_texture:
566 return out <<
"texture";
568 case TextureStage::CS_constant:
569 return out <<
"constant";
571 case TextureStage::CS_primary_color:
572 return out <<
"primary_color";
574 case TextureStage::CS_previous:
575 return out <<
"previous";
577 case TextureStage::CS_constant_color_scale:
578 return out <<
"constant_color_scale";
580 case TextureStage::CS_last_saved_result:
581 return out <<
"last_saved_result";
584 return out <<
"**invalid CombineSource(" << (int)cs <<
")**";
588 operator << (ostream &out, TextureStage::CombineOperand co) {
590 case TextureStage::CO_undefined:
591 return out <<
"undefined";
593 case TextureStage::CO_src_color:
594 return out <<
"src_color";
596 case TextureStage::CO_one_minus_src_color:
597 return out <<
"one_minus_src_color";
599 case TextureStage::CO_src_alpha:
600 return out <<
"src_alpha";
602 case TextureStage::CO_one_minus_src_alpha:
603 return out <<
"one_minus_src_alpha";
606 return out <<
"**invalid CombineOperand(" << (int)co <<
")**";
CombineSource get_combine_alpha_source2() const
Get source2 of combine_alpha_mode.
get_tex_view_offset
Returns the current setting of the tex_view_offset.
get_name
Returns the name of this texture stage.
static TypedWritable * make_TextureStage(const FactoryParams ¶ms)
Factory method to generate a TextureStage object.
bool get_bool()
Extracts a boolean value.
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
CombineOperand get_combine_alpha_operand0() const
Get operand0 of combine_alpha_mode.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
int get_num_combine_alpha_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_alpha_sourceN() and g...
int32_t get_int32()
Extracts a signed 32-bit integer.
CombineOperand get_combine_rgb_operand1() const
Get operand1 of combine_rgb_mode.
std::string get_string()
Extracts a variable-length string.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
CombineSource get_combine_rgb_source1() const
Get source1 of combine_rgb_mode.
get_rgb_scale
See set_rgb_scale().
void output(std::ostream &out) const
Just a single line output.
get_mode
Return the mode of this stage.
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...
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.
void add_bool(bool value)
Adds a boolean value to the datagram.
CombineSource get_combine_alpha_source0() const
Get source0 of combine_alpha_mode.
CombineSource get_combine_rgb_source2() const
Get source2 of combine_rgb_mode.
static void register_with_read_factory()
Factory method to generate a TextureStage object.
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().
void write(std::ostream &out) const
Writes the details of this stage.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CombineOperand get_combine_rgb_operand0() const
Get operand0 of combine_rgb_mode.
void add_string(const std::string &str)
Adds a variable-length string 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.
int get_num_combine_rgb_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_rgb_sourceN() and get...
get_saved_result
Returns the current setting of the saved_result flag.
CombineMode get_combine_alpha_mode() const
Get combine_alpha_mode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_alpha_scale
See set_alpha_scale().
get_color
return the color for this stage
CombineOperand get_combine_alpha_operand1() const
Get operand1 of combine_alpha_mode.
Encodes a string name in a hash table, mapping it to a pointer.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
CombineMode get_combine_rgb_mode() const
Get the combine_rgb_mode.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
CombineSource get_combine_rgb_source0() const
Get source0 of combine_rgb_mode.
void operator=(const TextureStage ©)
just copy the members of other to this
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
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 &me)
Function to write the important information in the particular object to a Datagram.
get_sort
Returns the sort order of this texture stage.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
CombineOperand get_combine_rgb_operand2() const
Get operand2 of combine_rgb_mode.
CombineSource get_combine_alpha_source1() const
Get source1 of combine_alpha_mode.
CombineOperand get_combine_alpha_operand2() const
Get operand2 of combine_alpha_mode.
A class to retrieve the individual data elements previously stored in a Datagram.
get_priority
Returns the priority associated with this stage.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
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 ...
get_texcoord_name
See set_texcoord_name.
TextureStage(const std::string &name)
Initialize the texture stage at construction.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
get_default
Returns the default TextureStage that will be used for all texturing that does not name a particular ...