15 #include "textureStage.h" 16 #include "internalName.h" 17 #include "bamReader.h" 18 #include "bamWriter.h" 35 _texcoord_name = InternalName::get_texcoord();
37 _color.set(0.0f, 0.0f, 0.0f, 1.0f);
40 _saved_result =
false;
42 _combine_rgb_mode = CM_undefined;
43 _num_combine_rgb_operands = 0;
44 _combine_rgb_source0 = CS_undefined;
45 _combine_rgb_operand0 = CO_undefined;
46 _combine_rgb_source1 = CS_undefined;
47 _combine_rgb_operand1 = CO_undefined;
48 _combine_rgb_source2 = CS_undefined;
49 _combine_rgb_operand2 = CO_undefined;
50 _combine_alpha_mode = CM_undefined;
51 _num_combine_alpha_operands = 0;
52 _combine_alpha_source0 = CS_undefined;
53 _combine_alpha_operand0 = CO_undefined;
54 _combine_alpha_source1 = CS_undefined;
55 _combine_alpha_operand1 = CO_undefined;
56 _combine_alpha_source2 = CS_undefined;
57 _combine_alpha_operand2 = CO_undefined;
60 _involves_color_scale =
false;
72 _priority = other._priority;
73 _texcoord_name = other._texcoord_name;
75 _color = other._color;
76 _rgb_scale = other._rgb_scale;
77 _alpha_scale = other._alpha_scale;
78 _saved_result = other._saved_result;
79 _tex_view_offset = other._tex_view_offset;
81 _combine_rgb_mode = other._combine_rgb_mode;
82 _combine_rgb_source0 = other._combine_rgb_source0;
83 _combine_rgb_operand0 = other._combine_rgb_operand0;
84 _combine_rgb_source1 = other._combine_rgb_source1;
85 _combine_rgb_operand1 = other._combine_rgb_operand1;
86 _combine_rgb_source2 = other._combine_rgb_source2;
87 _combine_rgb_operand2 = other._combine_rgb_operand2;
88 _combine_alpha_mode = other._combine_alpha_mode;
89 _combine_alpha_source0 = other._combine_alpha_source0;
90 _combine_alpha_operand0 = _combine_alpha_operand0;
91 _combine_alpha_source1 = other._combine_alpha_source1;
92 _combine_alpha_operand1 = other._combine_alpha_operand1;
93 _combine_alpha_source2 = other._combine_alpha_source2;
94 _combine_alpha_operand2 = other._combine_alpha_operand2;
96 _uses_color = other._uses_color;
97 _involves_color_scale = other._involves_color_scale;
276 out <<
"TextureStage " <<
get_name();
286 get_expected_num_combine_operands(TextureStage::CombineMode cm) {
316 operand_valid_for_rgb(TextureStage::CombineOperand co) {
322 case CO_one_minus_src_color:
324 case CO_one_minus_src_alpha:
338 operand_valid_for_alpha(TextureStage::CombineOperand co) {
342 case CO_one_minus_src_color:
346 case CO_one_minus_src_alpha:
373 parse_params(params, scan, manager);
380 me->fillin(scan, manager);
401 _mode = (TextureStage::Mode) scan.
get_uint8();
407 _tex_view_offset = 0;
412 _combine_rgb_mode = (TextureStage::CombineMode) scan.
get_uint8();
413 _num_combine_rgb_operands = scan.
get_uint8();
414 _combine_rgb_source0 = (TextureStage::CombineSource) scan.
get_uint8();
415 _combine_rgb_operand0 = (TextureStage::CombineOperand) scan.
get_uint8();
416 _combine_rgb_source1 = (TextureStage::CombineSource) scan.
get_uint8();
417 _combine_rgb_operand1 = (TextureStage::CombineOperand) scan.
get_uint8();
418 _combine_rgb_source2 = (TextureStage::CombineSource) scan.
get_uint8();
419 _combine_rgb_operand2 = (TextureStage::CombineOperand) scan.
get_uint8();
421 _combine_alpha_mode = (TextureStage::CombineMode) scan.
get_uint8();
422 _num_combine_alpha_operands = scan.
get_uint8();
423 _combine_alpha_source0 = (TextureStage::CombineSource) scan.
get_uint8();
424 _combine_alpha_operand0 = (TextureStage::CombineOperand) scan.
get_uint8();
425 _combine_alpha_source1 = (TextureStage::CombineSource) scan.
get_uint8();
426 _combine_alpha_operand1 = (TextureStage::CombineOperand) scan.
get_uint8();
427 _combine_alpha_source2 = (TextureStage::CombineSource) scan.
get_uint8();
428 _combine_alpha_operand2 = (TextureStage::CombineOperand) scan.
get_uint8();
430 update_color_flags();
444 _texcoord_name = DCAST(InternalName, p_list[pi++]);
485 me.
add_uint8(_num_combine_alpha_operands);
496 operator << (ostream &out, TextureStage::Mode mode) {
498 case TextureStage::M_modulate:
499 return out <<
"modulate";
501 case TextureStage::M_decal:
502 return out <<
"decal";
504 case TextureStage::M_blend:
505 return out <<
"blend";
507 case TextureStage::M_replace:
508 return out <<
"replace";
510 case TextureStage::M_add:
513 case TextureStage::M_combine:
514 return out <<
"combine";
516 case TextureStage::M_blend_color_scale:
517 return out <<
"blend_color_scale";
519 case TextureStage::M_modulate_glow:
520 return out <<
"modulate_glow";
522 case TextureStage::M_modulate_gloss:
523 return out <<
"modulate_gloss";
525 case TextureStage::M_normal:
526 return out <<
"normal";
528 case TextureStage::M_normal_height:
529 return out <<
"normal_height";
531 case TextureStage::M_glow:
532 return out <<
"glow";
534 case TextureStage::M_gloss:
535 return out <<
"gloss";
537 case TextureStage::M_height:
538 return out <<
"height";
540 case TextureStage::M_selector:
541 return out <<
"selector";
543 case TextureStage::M_normal_gloss:
544 return out <<
"normal_gloss";
547 return out <<
"**invalid Mode(" << (int)mode <<
")**";
551 operator << (ostream &out, TextureStage::CombineMode cm) {
553 case TextureStage::CM_undefined:
554 return out <<
"undefined";
556 case TextureStage::CM_replace:
557 return out <<
"replace";
559 case TextureStage::CM_modulate:
560 return out <<
"modulate";
562 case TextureStage::CM_add:
565 case TextureStage::CM_add_signed:
566 return out <<
"add_signed";
568 case TextureStage::CM_interpolate:
569 return out <<
"interpolate";
571 case TextureStage::CM_subtract:
572 return out <<
"subtract";
574 case TextureStage::CM_dot3_rgb:
575 return out <<
"dot3_rgb";
577 case TextureStage::CM_dot3_rgba:
578 return out <<
"dot3_rgba";
581 return out <<
"**invalid CombineMode(" << (int)cm <<
")**";
585 operator << (ostream &out, TextureStage::CombineSource cs) {
587 case TextureStage::CS_undefined:
588 return out <<
"undefined";
590 case TextureStage::CS_texture:
591 return out <<
"texture";
593 case TextureStage::CS_constant:
594 return out <<
"constant";
596 case TextureStage::CS_primary_color:
597 return out <<
"primary_color";
599 case TextureStage::CS_previous:
600 return out <<
"previous";
602 case TextureStage::CS_constant_color_scale:
603 return out <<
"constant_color_scale";
605 case TextureStage::CS_last_saved_result:
606 return out <<
"last_saved_result";
609 return out <<
"**invalid CombineSource(" << (int)cs <<
")**";
613 operator << (ostream &out, TextureStage::CombineOperand co) {
615 case TextureStage::CO_undefined:
616 return out <<
"undefined";
618 case TextureStage::CO_src_color:
619 return out <<
"src_color";
621 case TextureStage::CO_one_minus_src_color:
622 return out <<
"one_minus_src_color";
624 case TextureStage::CO_src_alpha:
625 return out <<
"src_alpha";
627 case TextureStage::CO_one_minus_src_alpha:
628 return out <<
"one_minus_src_alpha";
631 return out <<
"**invalid CombineOperand(" << (int)co <<
")**";
CombineSource get_combine_alpha_source2() const
Get source2 of combine_alpha_mode.
void add_uint8(PN_uint8 value)
Adds an unsigned 8-bit integer to the datagram.
static TypedWritable * make_TextureStage(const FactoryParams ¶ms)
Factory method to generate a TextureStage object.
bool get_bool()
Extracts a boolean value.
void add_string(const string &str)
Adds a variable-length string to the datagram.
LColor get_color() const
return the color for this stage
CombineOperand get_combine_alpha_operand0() const
Get operand0 of combine_alpha_mode.
int get_rgb_scale() const
See set_rgb_scale().
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_alpha_scale() const
See set_alpha_scale().
TextureStage(const string &name)
Initialize the texture stage at construction.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Mode get_mode() const
Return the mode of this stage.
PN_int32 get_int32()
Extracts a signed 32-bit integer.
PN_uint8 get_uint8()
Extracts an unsigned 8-bit integer.
int get_num_combine_alpha_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_alpha_sourceN() and g...
CombineOperand get_combine_rgb_operand1() const
Get operand1 of combine_rgb_mode.
string get_string()
Extracts a variable-length string.
void output(ostream &out) const
Just a single line output.
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.
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 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()...
CombineOperand get_combine_rgb_operand0() const
Get operand0 of combine_rgb_mode.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
int get_num_combine_rgb_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_rgb_sourceN() and get...
InternalName * get_texcoord_name() const
See set_texcoord_name.
CombineMode get_combine_alpha_mode() const
Get combine_alpha_mode.
int get_tex_view_offset() const
Returns the current setting of the tex_view_offset.
CombineOperand get_combine_alpha_operand1() const
Get operand1 of combine_alpha_mode.
int get_priority() const
Returns the priority associated with this stage.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
const string & get_name() const
Returns the name of this texture stage.
void write_datagram(Datagram &destination) const
Writes the vector to the Datagram using add_stdfloat().
void write(ostream &out) const
Writes the details of this stage.
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
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.
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.
void add_int32(PN_int32 value)
Adds a signed 32-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
static TextureStage * get_default()
Returns the default TextureStage that will be used for all texturing that does not name a particular ...
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 ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
int get_sort() const
Returns the sort order of this texture stage.
bool get_saved_result() const
Returns the current setting of the saved_result flag.