From 7d29120cc9a79a4c17d6955472085071c1e2dd7a Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 26 May 2005 18:18:02 +0000 Subject: [PATCH] add objecttype glow --- panda/src/configfiles/panda.prc.pp | 3 + panda/src/doc/eggSyntax.txt | 23 ++ panda/src/egg/eggGroup.I | 238 +++++++++++----- panda/src/egg/eggGroup.cxx | 372 ++++++++++++++++++++------ panda/src/egg/eggGroup.h | 68 ++++- panda/src/egg/parser.yxx | 60 +++++ panda/src/egg2pg/eggLoader.cxx | 90 +++++++ panda/src/egg2pg/eggLoader.h | 7 + panda/src/pgraph/colorBlendAttrib.cxx | 38 +-- 9 files changed, 729 insertions(+), 170 deletions(-) diff --git a/panda/src/configfiles/panda.prc.pp b/panda/src/configfiles/panda.prc.pp index e269a4c31b..bda7f082d8 100644 --- a/panda/src/configfiles/panda.prc.pp +++ b/panda/src/configfiles/panda.prc.pp @@ -91,5 +91,8 @@ egg-object-type-bubble { Sphere keep descend } # collisions--it is ghostlike. egg-object-type-ghost collide-mask { 0 } +# "glow" is useful for halo effects and things of that ilk. It +# renders the object in add mode instead of the normal opaque mode. +egg-object-type-glow blend { add } #end 20_panda.prc diff --git a/panda/src/doc/eggSyntax.txt b/panda/src/doc/eggSyntax.txt index 61b8dd54ad..303fcd4aa3 100644 --- a/panda/src/doc/eggSyntax.txt +++ b/panda/src/doc/eggSyntax.txt @@ -1137,6 +1137,29 @@ GROUPING ENTRIES The value may be an ordinary decimal integer, or a hex number in the form 0x000, or a binary number in the form 0b000. + blend { mode } + + Specifies that a special blend mode should be applied geometry at + this level and below. The available options are none, add, + subtract, inv-subtract, min, and max. See ColorBlendAttrib. + + blendop-a { mode } + blendop-b { mode } + + If blend mode, above, is not none, this specifies the A and B + operands to the blend equation. Common options are zero, one, + incoming-color, one-minus-incoming-color. See ColorBlendAttrib + for the complete list of available options. The default is "one". + + blendr { red-value } + blendg { green-value } + blendb { blue-value } + blenda { alpha-value } + + If blend mode, above, is not none, and one of the blend operands + is constant-color or a related option, this defines the constant + color that will be used. + OTHER GROUP ATTRIBUTES diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index 9d4bbfced4..9a761b5095 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -19,7 +19,7 @@ //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_group_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE EggGroup::GroupType EggGroup:: @@ -29,7 +29,7 @@ get_group_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::is_instance_type -// Access: Public +// Access: Published // Description: Returns true if this group is an instance type node; // i.e. it begins the root of a local coordinate space. // This is not related to instancing (multiple copies of @@ -48,7 +48,7 @@ is_instance_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_billboard_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -62,7 +62,7 @@ set_billboard_type(BillboardType type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_billboard_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE EggGroup::BillboardType EggGroup:: @@ -72,7 +72,7 @@ get_billboard_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_billboard_center -// Access: Public +// Access: Published // Description: Sets the point around which the billboard will // rotate, if this node contains a billboard // specification. @@ -101,7 +101,7 @@ set_billboard_center(const LPoint3d &billboard_center) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_billboard_center -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -113,7 +113,7 @@ clear_billboard_center() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_billboard_center -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -123,7 +123,7 @@ has_billboard_center() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_billboard_center -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE const LPoint3d &EggGroup:: @@ -134,7 +134,7 @@ get_billboard_center() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_cs_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -146,7 +146,7 @@ set_cs_type(CollisionSolidType type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_cs_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE EggGroup::CollisionSolidType EggGroup:: @@ -156,7 +156,7 @@ get_cs_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_collision_name -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -166,7 +166,7 @@ set_collision_name(const string &collision_name) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_collision_name -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -176,7 +176,7 @@ clear_collision_name() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_collision_name -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -186,7 +186,7 @@ has_collision_name() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_collision_name -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE const string &EggGroup:: @@ -196,7 +196,7 @@ get_collision_name() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_collide_flags -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -208,7 +208,7 @@ set_collide_flags(int flags) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_collide_flags -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE EggGroup::CollideFlags EggGroup:: @@ -218,7 +218,7 @@ get_collide_flags() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_dcs_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -230,7 +230,7 @@ set_dcs_type(EggGroup::DCSType type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_dcs_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE EggGroup::DCSType EggGroup:: @@ -240,7 +240,7 @@ get_dcs_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_dcs_type -// Access: Public +// Access: Published // Description: Returns true if the specified DCS type is not // DC_none and not DC_unspecified. //////////////////////////////////////////////////////////////////// @@ -252,7 +252,7 @@ has_dcs_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_dart_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -264,7 +264,7 @@ set_dart_type(EggGroup::DartType type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_dart_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE EggGroup::DartType EggGroup:: @@ -274,7 +274,7 @@ get_dart_type() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_switch_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -288,7 +288,7 @@ set_switch_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_switch_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -298,7 +298,7 @@ get_switch_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_switch_fps -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -308,7 +308,7 @@ set_switch_fps(double fps) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_switch_fps -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE double EggGroup:: @@ -318,7 +318,7 @@ get_switch_fps() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::add_object_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -328,7 +328,7 @@ add_object_type(const string &object_type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_object_types -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -338,7 +338,7 @@ clear_object_types() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_num_object_types -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE int EggGroup:: @@ -348,7 +348,7 @@ get_num_object_types() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_object_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE string EggGroup:: @@ -359,7 +359,7 @@ get_object_type(int index) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_model_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -373,7 +373,7 @@ set_model_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_model_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -383,7 +383,7 @@ get_model_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_texlist_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -397,7 +397,7 @@ set_texlist_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_texlist_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -407,7 +407,7 @@ get_texlist_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_nofog_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -421,7 +421,7 @@ set_nofog_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_nofog_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -431,7 +431,7 @@ get_nofog_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_decal_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -445,7 +445,7 @@ set_decal_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_decal_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -455,7 +455,7 @@ get_decal_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_direct_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -469,7 +469,7 @@ set_direct_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_direct_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -480,7 +480,7 @@ get_direct_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_portal_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -494,7 +494,7 @@ set_portal_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_portal_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -504,7 +504,7 @@ get_portal_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_polylight_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -518,7 +518,7 @@ set_polylight_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_polylight_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -528,7 +528,7 @@ get_polylight_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_indexed_flag -// Access: Public +// Access: Published // Description: If this flag is true, geometry at this node and below // will be generated as indexed geometry. //////////////////////////////////////////////////////////////////// @@ -544,7 +544,7 @@ set_indexed_flag(bool flag) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_indexed_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -554,7 +554,7 @@ clear_indexed_flag() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_indexed_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -564,7 +564,7 @@ has_indexed_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_indexed_flag -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -575,7 +575,7 @@ get_indexed_flag() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -586,7 +586,7 @@ set_collide_mask(CollideMask mask) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -597,7 +597,7 @@ clear_collide_mask() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -607,7 +607,7 @@ has_collide_mask() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE CollideMask EggGroup:: @@ -617,7 +617,7 @@ get_collide_mask() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_from_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -628,7 +628,7 @@ set_from_collide_mask(CollideMask mask) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_from_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -639,7 +639,7 @@ clear_from_collide_mask() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_from_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -649,7 +649,7 @@ has_from_collide_mask() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_from_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE CollideMask EggGroup:: @@ -659,7 +659,7 @@ get_from_collide_mask() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_into_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -670,7 +670,7 @@ set_into_collide_mask(CollideMask mask) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_into_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -681,7 +681,7 @@ clear_into_collide_mask() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_into_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -691,7 +691,7 @@ has_into_collide_mask() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_into_collide_mask -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE CollideMask EggGroup:: @@ -699,9 +699,113 @@ get_into_collide_mask() const { return _into_collide_mask; } +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::set_blend_mode +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void EggGroup:: +set_blend_mode(EggGroup::BlendMode blend_mode) { + _blend_mode = blend_mode; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::get_blend_mode +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE EggGroup::BlendMode EggGroup:: +get_blend_mode() const { + return _blend_mode; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::set_blend_operand_a +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void EggGroup:: +set_blend_operand_a(EggGroup::BlendOperand blend_operand_a) { + _blend_operand_a = blend_operand_a; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::get_blend_operand_a +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE EggGroup::BlendOperand EggGroup:: +get_blend_operand_a() const { + return _blend_operand_a; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::set_blend_operand_b +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void EggGroup:: +set_blend_operand_b(EggGroup::BlendOperand blend_operand_b) { + _blend_operand_b = blend_operand_b; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::get_blend_operand_b +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE EggGroup::BlendOperand EggGroup:: +get_blend_operand_b() const { + return _blend_operand_b; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::set_blend_color +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void EggGroup:: +set_blend_color(const Colorf &blend_color) { + _blend_color = blend_color; + _flags2 |= F2_has_blend_color; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::clear_blend_color +// Access: Published +// Description: Removes the blend color specification. +//////////////////////////////////////////////////////////////////// +INLINE void EggGroup:: +clear_blend_color() { + _blend_color = Colorf::zero(); + _flags2 &= ~F2_has_blend_color; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::has_blend_color +// Access: Published +// Description: Returns true if the blend color has been specified, +// false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool EggGroup:: +has_blend_color() const { + return (_flags2 & F2_has_blend_color) != 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::get_blend_color +// Access: Published +// Description: Returns the blend color if one has been specified, or +// (0, 0, 0, 0) if one has not. +//////////////////////////////////////////////////////////////////// +INLINE const Colorf &EggGroup:: +get_blend_color() const { + return _blend_color; +} + //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_lod -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -711,7 +815,7 @@ set_lod(const EggSwitchCondition &lod) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::clear_lod -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: @@ -721,7 +825,7 @@ clear_lod() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_lod -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE bool EggGroup:: @@ -731,7 +835,7 @@ has_lod() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_lod -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE const EggSwitchCondition &EggGroup:: @@ -838,8 +942,8 @@ tag_end() const { } //////////////////////////////////////////////////////////////////// -// Function: EggGrop::tag_size -// Access: Public +// Function: EggGroup::tag_size +// Access: Published // Description: Returns the number of elements between tag_begin() // and tag_end(). // @@ -884,8 +988,8 @@ vref_end() const { } //////////////////////////////////////////////////////////////////// -// Function: EggGrop::vref_size -// Access: Public +// Function: EggGroup::vref_size +// Access: Published // Description: Returns the number of elements between vref_begin() // and vref_end(). // diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index f47120db8d..0d07fada25 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -32,7 +32,7 @@ TypeHandle EggGroup::_type_handle; //////////////////////////////////////////////////////////////////// // Function: EggGroup::Constructor -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// EggGroup:: @@ -40,11 +40,15 @@ EggGroup(const string &name) : EggGroupNode(name) { _flags = 0; _flags2 = 0; _fps = 0.0; + _blend_mode = BM_unspecified; + _blend_operand_a = BO_unspecified; + _blend_operand_b = BO_unspecified; + _blend_color = Colorf::zero(); } //////////////////////////////////////////////////////////////////// // Function: EggGroup::Copy Constructor -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// EggGroup:: @@ -54,7 +58,7 @@ EggGroup(const EggGroup ©) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::Copy assignment operator -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// EggGroup &EggGroup:: @@ -62,14 +66,18 @@ operator = (const EggGroup ©) { EggTransform3d::operator = (copy); _flags = copy._flags; _flags2 = copy._flags2; - // _collide_mask = copy._collide_mask; - // _from_collide_mask = copy._from_collide_mask; - // _into_collide_mask = copy._into_collide_mask; - // _billboard_center = copy._billboard_center; + _collide_mask = copy._collide_mask; + _from_collide_mask = copy._from_collide_mask; + _into_collide_mask = copy._into_collide_mask; + _billboard_center = copy._billboard_center; _object_types = copy._object_types; _collision_name = copy._collision_name; _fps = copy._fps; - // _lod = copy._lod; + _lod = copy._lod; + _blend_mode = copy._blend_mode; + _blend_operand_a = copy._blend_operand_a; + _blend_operand_b = copy._blend_operand_b; + _blend_color = copy._blend_color; _tag_data = copy._tag_data; @@ -101,7 +109,7 @@ operator = (const EggGroup ©) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::Destructor -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// EggGroup:: @@ -111,7 +119,7 @@ EggGroup:: //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_group_type -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// void EggGroup:: @@ -129,7 +137,7 @@ set_group_type(GroupType type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::has_object_type -// Access: Public +// Access: Published // Description: Returns true if the indicated object type has been // added to the group, or false otherwise. //////////////////////////////////////////////////////////////////// @@ -146,7 +154,7 @@ has_object_type(const string &object_type) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::remove_object_type -// Access: Public +// Access: Published // Description: Removes the first instance of the indicated object // type from the group if it is present. Returns true // if the object type was found and removed, false @@ -166,7 +174,7 @@ remove_object_type(const string &object_type) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write -// Access: Public, Virtual +// Access: Published, Virtual // Description: Writes the group and all of its children to the // indicated output stream in Egg format. //////////////////////////////////////////////////////////////////// @@ -228,6 +236,33 @@ write(ostream &out, int indent_level) const { << " indexed { " << get_indexed_flag() << " }\n"; } + if (get_blend_mode() != BM_unspecified) { + indent(out, indent_level) + << " blend { " << get_blend_mode() << " }\n"; + } + + if (get_blend_operand_a() != BO_unspecified) { + indent(out, indent_level) + << " blendop-a { " << get_blend_operand_a() << " }\n"; + } + + if (get_blend_operand_b() != BO_unspecified) { + indent(out, indent_level) + << " blendop-b { " << get_blend_operand_b() << " }\n"; + } + + if (has_blend_color()) { + const Colorf &c = get_blend_color(); + indent(out, indent_level) + << " blendr { " << c[0] << " }\n"; + indent(out, indent_level) + << " blendg { " << c[1] << " }\n"; + indent(out, indent_level) + << " blendb { " << c[2] << " }\n"; + indent(out, indent_level) + << " blenda { " << c[3] << " }\n"; + } + // We have to write the children nodes before we write the vertex // references, since we might be referencing a vertex that's defined // in one of those children nodes! @@ -239,7 +274,7 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_billboard_flags -// Access: Public +// Access: Published // Description: Writes just the entry and related fields to // the indicated ostream. //////////////////////////////////////////////////////////////////// @@ -258,7 +293,7 @@ write_billboard_flags(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_collide_flags -// Access: Public +// Access: Published // Description: Writes just the entry and related fields to // the indicated ostream. //////////////////////////////////////////////////////////////////// @@ -300,7 +335,7 @@ write_collide_flags(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_model_flags -// Access: Public +// Access: Published // Description: Writes the flag and related flags to the // indicated ostream. //////////////////////////////////////////////////////////////////// @@ -331,7 +366,7 @@ write_model_flags(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_switch_flags -// Access: Public +// Access: Published // Description: Writes the flag and related flags to the // indicated ostream. //////////////////////////////////////////////////////////////////// @@ -348,7 +383,7 @@ write_switch_flags(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_object_types -// Access: Public +// Access: Published // Description: Writes just the entries, if any, to the // indicated ostream. //////////////////////////////////////////////////////////////////// @@ -364,7 +399,7 @@ write_object_types(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_decal_flags -// Access: Public +// Access: Published // Description: Writes the flags related to decaling, if any. //////////////////////////////////////////////////////////////////// void EggGroup:: @@ -376,7 +411,7 @@ write_decal_flags(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_tags -// Access: Public +// Access: Published // Description: Writes just the entries, if any, to the // indicated ostream. //////////////////////////////////////////////////////////////////// @@ -396,7 +431,7 @@ write_tags(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::write_render_mode -// Access: Public +// Access: Published // Description: Writes the flags inherited from EggRenderMode and // similar flags that control obscure render effects. //////////////////////////////////////////////////////////////////// @@ -411,7 +446,7 @@ write_render_mode(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::is_joint -// Access: Public, Virtual +// Access: Published, Virtual // Description: Returns true if this particular node represents a // entry or not. This is a handy thing to know // since Joints are sorted to the end of their sibling @@ -425,7 +460,7 @@ is_joint() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_alpha_mode -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // or EggPrimitive or some such object at this level or // above this group that has an alpha_mode other than @@ -442,7 +477,7 @@ determine_alpha_mode() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_depth_write_mode -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // or EggPrimitive or some such object at this level or // above this group that has a depth_write_mode other @@ -459,7 +494,7 @@ determine_depth_write_mode() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_depth_test_mode -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // or EggPrimitive or some such object at this level or // above this group that has a depth_test_mode other @@ -476,7 +511,7 @@ determine_depth_test_mode() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_visibility_mode -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // or EggPrimitive or some such object at this level or // above this group that has a visibility_mode other @@ -493,7 +528,7 @@ determine_visibility_mode() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_draw_order -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // or EggPrimitive or some such object at this level or // above this group that has a draw_order specified. @@ -510,7 +545,7 @@ determine_draw_order() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_bin -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // or EggPrimitive or some such object at this level or // above this group that has a bin specified. Returns a @@ -527,7 +562,7 @@ determine_bin() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_indexed -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // at this level or above that has the "indexed" scalar // set. Returns the value of the indexed scalar if it @@ -546,7 +581,7 @@ determine_indexed() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::determine_decal -// Access: Public, Virtual +// Access: Published, Virtual // Description: Walks back up the hierarchy, looking for an EggGroup // at this level or above that has the "decal" flag // set. Returns the value of the decal flag if it @@ -565,7 +600,7 @@ determine_decal() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::ref_vertex -// Access: Public +// Access: Published // Description: Adds the vertex to the set of those referenced by the // group, at the indicated membership level. If the // vertex is already being referenced, increases the @@ -602,7 +637,7 @@ ref_vertex(EggVertex *vert, double membership) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::unref_vertex -// Access: Public +// Access: Published // Description: Removes the vertex from the set of those referenced // by the group. Does nothing if the vertex is not // already reffed. @@ -622,7 +657,7 @@ unref_vertex(EggVertex *vert) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::unref_all_vertices -// Access: Public +// Access: Published // Description: Removes all vertices from the reference list. //////////////////////////////////////////////////////////////////// void EggGroup:: @@ -644,7 +679,7 @@ unref_all_vertices() { //////////////////////////////////////////////////////////////////// // Function: EggGroup::get_vertex_membership -// Access: Public +// Access: Published // Description: Returns the amount of membership of the indicated // vertex in this group. If the vertex is not reffed by // the group, returns 0. @@ -662,7 +697,7 @@ get_vertex_membership(const EggVertex *vert) const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::set_vertex_membership -// Access: Public +// Access: Published // Description: Explicitly sets the net membership of the indicated // vertex in this group to the given value. //////////////////////////////////////////////////////////////////// @@ -694,7 +729,7 @@ set_vertex_membership(EggVertex *vert, double membership) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::steal_vrefs -// Access: Public +// Access: Published // Description: Moves all of the vertex references from the indicated // other group into this one. If a given vertex was // previously shared by both groups, the relative @@ -717,7 +752,7 @@ steal_vrefs(EggGroup *other) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::test_vref_integrity -// Access: Public +// Access: Published // Description: Verifies that each vertex in the group exists and // that it knows it is referenced by the group. //////////////////////////////////////////////////////////////////// @@ -741,18 +776,18 @@ test_vref_integrity() const { //////////////////////////////////////////////////////////////////// // Function: EggGroup::string_group_type -// Access: Public, Static +// Access: Published, Static // Description: Returns the GroupType value associated with the given // string representation, or GT_invalid if the string // does not match any known GroupType value. //////////////////////////////////////////////////////////////////// EggGroup::GroupType EggGroup:: -string_group_type(const string &string) { - if (cmp_nocase_uh(string, "group") == 0) { +string_group_type(const string &strval) { + if (cmp_nocase_uh(strval, "group") == 0) { return GT_group; - } else if (cmp_nocase_uh(string, "instance") == 0) { + } else if (cmp_nocase_uh(strval, "instance") == 0) { return GT_instance; - } else if (cmp_nocase_uh(string, "joint") == 0) { + } else if (cmp_nocase_uh(strval, "joint") == 0) { return GT_joint; } else { return GT_invalid; @@ -761,18 +796,18 @@ string_group_type(const string &string) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::string_dart_type -// Access: Public, Static +// Access: Published, Static // Description: Returns the DartType value associated with the given // string representation, or DT_none if the string // does not match any known DartType value. //////////////////////////////////////////////////////////////////// EggGroup::DartType EggGroup:: -string_dart_type(const string &string) { - if (cmp_nocase_uh(string, "sync") == 0) { +string_dart_type(const string &strval) { + if (cmp_nocase_uh(strval, "sync") == 0) { return DT_sync; - } else if (cmp_nocase_uh(string, "nosync") == 0) { + } else if (cmp_nocase_uh(strval, "nosync") == 0) { return DT_nosync; - } else if (cmp_nocase_uh(string, "default") == 0) { + } else if (cmp_nocase_uh(strval, "default") == 0) { return DT_default; } else { return DT_none; @@ -781,20 +816,20 @@ string_dart_type(const string &string) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::string_dcs_type -// Access: Public, Static +// Access: Published, Static // Description: Returns the DCSType value associated with the given // string representation, or DC_unspecified if the // string does not match any known DCSType value. //////////////////////////////////////////////////////////////////// EggGroup::DCSType EggGroup:: -string_dcs_type(const string &string) { - if (cmp_nocase_uh(string, "none") == 0) { +string_dcs_type(const string &strval) { + if (cmp_nocase_uh(strval, "none") == 0) { return DC_none; - } else if (cmp_nocase_uh(string, "local") == 0) { + } else if (cmp_nocase_uh(strval, "local") == 0) { return DC_local; - } else if (cmp_nocase_uh(string, "net") == 0) { + } else if (cmp_nocase_uh(strval, "net") == 0) { return DC_net; - } else if (cmp_nocase_uh(string, "default") == 0) { + } else if (cmp_nocase_uh(strval, "default") == 0) { return DC_default; } else { return DC_unspecified; @@ -803,20 +838,20 @@ string_dcs_type(const string &string) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::string_billboard_type -// Access: Public, Static +// Access: Published, Static // Description: Returns the BillboardType value associated with the // given string representation, or BT_none if the string // does not match any known BillboardType value. //////////////////////////////////////////////////////////////////// EggGroup::BillboardType EggGroup:: -string_billboard_type(const string &string) { - if (cmp_nocase_uh(string, "axis") == 0) { +string_billboard_type(const string &strval) { + if (cmp_nocase_uh(strval, "axis") == 0) { return BT_axis; - } else if (cmp_nocase_uh(string, "point_eye") == 0) { + } else if (cmp_nocase_uh(strval, "point_eye") == 0) { return BT_point_camera_relative; - } else if (cmp_nocase_uh(string, "point_world") == 0) { + } else if (cmp_nocase_uh(strval, "point_world") == 0) { return BT_point_world_relative; - } else if (cmp_nocase_uh(string, "point") == 0) { + } else if (cmp_nocase_uh(strval, "point") == 0) { return BT_point_world_relative; } else { return BT_none; @@ -825,25 +860,25 @@ string_billboard_type(const string &string) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::string_cs_type -// Access: Public, Static +// Access: Published, Static // Description: Returns the CollisionSolidType value associated with the // given string representation, or CST_none if the string // does not match any known CollisionSolidType value. //////////////////////////////////////////////////////////////////// EggGroup::CollisionSolidType EggGroup:: -string_cs_type(const string &string) { - if (cmp_nocase_uh(string, "plane") == 0) { +string_cs_type(const string &strval) { + if (cmp_nocase_uh(strval, "plane") == 0) { return CST_plane; - } else if (cmp_nocase_uh(string, "polygon") == 0) { + } else if (cmp_nocase_uh(strval, "polygon") == 0) { return CST_polygon; - } else if (cmp_nocase_uh(string, "polyset") == 0) { + } else if (cmp_nocase_uh(strval, "polyset") == 0) { return CST_polyset; - } else if (cmp_nocase_uh(string, "sphere") == 0) { + } else if (cmp_nocase_uh(strval, "sphere") == 0) { return CST_sphere; - } else if (cmp_nocase_uh(string, "inv-sphere") == 0 || - cmp_nocase_uh(string, "invsphere") == 0) { + } else if (cmp_nocase_uh(strval, "inv-sphere") == 0 || + cmp_nocase_uh(strval, "invsphere") == 0) { return CST_inv_sphere; - } else if (cmp_nocase_uh(string, "tube") == 0) { + } else if (cmp_nocase_uh(strval, "tube") == 0) { return CST_tube; } else { return CST_none; @@ -852,7 +887,7 @@ string_cs_type(const string &string) { //////////////////////////////////////////////////////////////////// // Function: EggGroup::string_collide_flags -// Access: Public, Static +// Access: Published, Static // Description: Returns the CollideFlags value associated with the // given string representation, or CF_none if the string // does not match any known CollideFlags value. This @@ -860,28 +895,106 @@ string_cs_type(const string &string) { // to parse a string of keywords. //////////////////////////////////////////////////////////////////// EggGroup::CollideFlags EggGroup:: -string_collide_flags(const string &string) { - if (cmp_nocase_uh(string, "intangible") == 0) { +string_collide_flags(const string &strval) { + if (cmp_nocase_uh(strval, "intangible") == 0) { return CF_intangible; - } else if (cmp_nocase_uh(string, "event") == 0) { + } else if (cmp_nocase_uh(strval, "event") == 0) { return CF_event; - } else if (cmp_nocase_uh(string, "descend") == 0) { + } else if (cmp_nocase_uh(strval, "descend") == 0) { return CF_descend; - } else if (cmp_nocase_uh(string, "keep") == 0) { + } else if (cmp_nocase_uh(strval, "keep") == 0) { return CF_keep; - } else if (cmp_nocase_uh(string, "solid") == 0) { + } else if (cmp_nocase_uh(strval, "solid") == 0) { return CF_solid; - } else if (cmp_nocase_uh(string, "center") == 0) { + } else if (cmp_nocase_uh(strval, "center") == 0) { return CF_center; - } else if (cmp_nocase_uh(string, "turnstile") == 0) { + } else if (cmp_nocase_uh(strval, "turnstile") == 0) { return CF_turnstile; - } else if (cmp_nocase_uh(string, "level") == 0) { + } else if (cmp_nocase_uh(strval, "level") == 0) { return CF_level; } else { return CF_none; } } +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::string_blend_mode +// Access: Published, Static +// Description: Returns the BlendMode value associated with the +// given string representation, or BM_none if the string +// does not match any known BlendMode. +//////////////////////////////////////////////////////////////////// +EggGroup::BlendMode EggGroup:: +string_blend_mode(const string &strval) { + if (cmp_nocase_uh(strval, "none") == 0) { + return BM_none; + } else if (cmp_nocase_uh(strval, "add") == 0) { + return BM_add; + } else if (cmp_nocase_uh(strval, "subtract") == 0) { + return BM_subtract; + } else if (cmp_nocase_uh(strval, "inv_subtract") == 0) { + return BM_inv_subtract; + } else if (cmp_nocase_uh(strval, "min") == 0) { + return BM_min; + } else if (cmp_nocase_uh(strval, "max") == 0) { + return BM_max; + } else { + return BM_unspecified; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::string_blend_operand +// Access: Published, Static +// Description: Returns the BlendOperand value associated with the +// given string representation, or BO_none if the string +// does not match any known BlendOperand. +//////////////////////////////////////////////////////////////////// +EggGroup::BlendOperand EggGroup:: +string_blend_operand(const string &strval) { + if (cmp_nocase_uh(strval, "zero") == 0) { + return BO_zero; + } else if (cmp_nocase_uh(strval, "one") == 0) { + return BO_one; + } else if (cmp_nocase_uh(strval, "incoming_color") == 0) { + return BO_incoming_color; + } else if (cmp_nocase_uh(strval, "one_minus_incoming_color") == 0) { + return BO_one_minus_incoming_color; + } else if (cmp_nocase_uh(strval, "fbuffer_color") == 0) { + return BO_fbuffer_color; + } else if (cmp_nocase_uh(strval, "one_minus_fbuffer_color") == 0) { + return BO_one_minus_fbuffer_color; + } else if (cmp_nocase_uh(strval, "incoming_alpha") == 0) { + return BO_incoming_alpha; + } else if (cmp_nocase_uh(strval, "one_minus_incoming_alpha") == 0) { + return BO_one_minus_incoming_alpha; + } else if (cmp_nocase_uh(strval, "fbuffer_alpha") == 0) { + return BO_fbuffer_alpha; + } else if (cmp_nocase_uh(strval, "one_minus_fbuffer_alpha") == 0) { + return BO_one_minus_fbuffer_alpha; + } else if (cmp_nocase_uh(strval, "constant_color") == 0) { + return BO_constant_color; + } else if (cmp_nocase_uh(strval, "one_minus_constant_color") == 0) { + return BO_one_minus_constant_color; + } else if (cmp_nocase_uh(strval, "constant_alpha") == 0) { + return BO_constant_alpha; + } else if (cmp_nocase_uh(strval, "one_minus_constant_alpha") == 0) { + return BO_one_minus_constant_alpha; + } else if (cmp_nocase_uh(strval, "incoming_color_saturate") == 0) { + return BO_incoming_color_saturate; + } else if (cmp_nocase_uh(strval, "color_scale") == 0) { + return BO_color_scale; + } else if (cmp_nocase_uh(strval, "one_minus_color_scale") == 0) { + return BO_one_minus_color_scale; + } else if (cmp_nocase_uh(strval, "alpha_scale") == 0) { + return BO_alpha_scale; + } else if (cmp_nocase_uh(strval, "one_minus_alpha_scale") == 0) { + return BO_one_minus_alpha_scale; + } else { + return BO_unspecified; + } +} + //////////////////////////////////////////////////////////////////// @@ -1272,3 +1385,106 @@ ostream &operator << (ostream &out, EggGroup::CollideFlags t) { } return out; } + +//////////////////////////////////////////////////////////////////// +// Function: ostream << EggGroup::BlendMode +// Description: +//////////////////////////////////////////////////////////////////// +ostream & +operator << (ostream &out, EggGroup::BlendMode t) { + switch (t) { + case EggGroup::BM_unspecified: + return out << "unspecified"; + + case EggGroup::BM_none: + return out << "none"; + + case EggGroup::BM_add: + return out << "add"; + + case EggGroup::BM_subtract: + return out << "subtract"; + + case EggGroup::BM_inv_subtract: + return out << "inv_subtract"; + + case EggGroup::BM_min: + return out << "min"; + + case EggGroup::BM_max: + return out << "max"; + } + + return out << "**invalid EggGroup::BlendMode(" << (int)t << ")**"; +} + +//////////////////////////////////////////////////////////////////// +// Function: ostream << EggGroup::BlendOperand +// Description: +//////////////////////////////////////////////////////////////////// +ostream & +operator << (ostream &out, EggGroup::BlendOperand t) { + switch (t) { + case EggGroup::BO_unspecified: + return out << "unspecified"; + + case EggGroup::BO_zero: + return out << "zero"; + + case EggGroup::BO_one: + return out << "one"; + + case EggGroup::BO_incoming_color: + return out << "incomfing_color"; + + case EggGroup::BO_one_minus_incoming_color: + return out << "one_minus_incoming_color"; + + case EggGroup::BO_fbuffer_color: + return out << "fbuffer_color"; + + case EggGroup::BO_one_minus_fbuffer_color: + return out << "one_minus_fbuffer_color"; + + case EggGroup::BO_incoming_alpha: + return out << "incoming_alpha"; + + case EggGroup::BO_one_minus_incoming_alpha: + return out << "one_minus_incoming_alpha"; + + case EggGroup::BO_fbuffer_alpha: + return out << "fbuffer_alpha"; + + case EggGroup::BO_one_minus_fbuffer_alpha: + return out << "one_minus_fbuffer_alpha"; + + case EggGroup::BO_constant_color: + return out << "constant_color"; + + case EggGroup::BO_one_minus_constant_color: + return out << "one_minus_constant_color"; + + case EggGroup::BO_constant_alpha: + return out << "constant_alpha"; + + case EggGroup::BO_one_minus_constant_alpha: + return out << "one_minus_constant_alpha"; + + case EggGroup::BO_incoming_color_saturate: + return out << "incoming_color_saturate"; + + case EggGroup::BO_color_scale: + return out << "color_scale"; + + case EggGroup::BO_one_minus_color_scale: + return out << "one_minus_color_scale"; + + case EggGroup::BO_alpha_scale: + return out << "alpha_scale"; + + case EggGroup::BO_one_minus_alpha_scale: + return out << "one_minus_alpha_scale"; + } + + return out << "**invalid EggGroup::BlendOperand(" << (int)t << ")**"; +} diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index 98347f7db6..381aaff902 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -97,6 +97,41 @@ PUBLISHED: CF_intangible = 0x08000000, }; + // These correspond to ColorBlendAttrib::Mode (but not numerically). + enum BlendMode { + BM_unspecified, + BM_none, + BM_add, + BM_subtract, + BM_inv_subtract, + BM_min, + BM_max + }; + + // These correspond to ColorBlendAttrib::Operand (but not numerically). + enum BlendOperand { + BO_unspecified, + BO_zero, + BO_one, + BO_incoming_color, + BO_one_minus_incoming_color, + BO_fbuffer_color, + BO_one_minus_fbuffer_color, + BO_incoming_alpha, + BO_one_minus_incoming_alpha, + BO_fbuffer_alpha, + BO_one_minus_fbuffer_alpha, + BO_constant_color, + BO_one_minus_constant_color, + BO_constant_alpha, + BO_one_minus_constant_alpha, + BO_incoming_color_saturate, + BO_color_scale, + BO_one_minus_color_scale, + BO_alpha_scale, + BO_one_minus_alpha_scale, + }; + EggGroup(const string &name = ""); EggGroup(const EggGroup ©); EggGroup &operator = (const EggGroup ©); @@ -207,6 +242,17 @@ PUBLISHED: INLINE bool has_into_collide_mask() const; INLINE CollideMask get_into_collide_mask() const; + INLINE void set_blend_mode(BlendMode blend_mode); + INLINE BlendMode get_blend_mode() const; + INLINE void set_blend_operand_a(BlendOperand blend_operand_a); + INLINE BlendOperand get_blend_operand_a() const; + INLINE void set_blend_operand_b(BlendOperand blend_operand_b); + INLINE BlendOperand get_blend_operand_b() const; + INLINE void set_blend_color(const Colorf &blend_color); + INLINE void clear_blend_color(); + INLINE bool has_blend_color() const; + INLINE const Colorf &get_blend_color() const; + INLINE void set_lod(const EggSwitchCondition &lod); INLINE void clear_lod(); INLINE bool has_lod() const; @@ -242,12 +288,14 @@ PUBLISHED: void test_vref_integrity() const { } #endif // NDEBUG - static GroupType string_group_type(const string &string); - static DartType string_dart_type(const string &string); - static DCSType string_dcs_type(const string &string); - static BillboardType string_billboard_type(const string &string); - static CollisionSolidType string_cs_type(const string &string); - static CollideFlags string_collide_flags(const string &string); + static GroupType string_group_type(const string &strval); + static DartType string_dart_type(const string &strval); + static DCSType string_dcs_type(const string &strval); + static BillboardType string_billboard_type(const string &strval); + static CollisionSolidType string_cs_type(const string &strval); + static CollideFlags string_collide_flags(const string &strval); + static BlendMode string_blend_mode(const string &strval); + static BlendOperand string_blend_operand(const string &strval); protected: void write_vertex_ref(ostream &out, int indent_level) const; @@ -286,11 +334,17 @@ private: F2_polylight_flag = 0x00000100, F2_indexed_flag = 0x00000200, F2_has_indexed_flag = 0x00000400, + + F2_has_blend_color = 0x00000800, }; int _flags; int _flags2; CollideMask _collide_mask, _from_collide_mask, _into_collide_mask; + BlendMode _blend_mode; + BlendOperand _blend_operand_a; + BlendOperand _blend_operand_b; + Colorf _blend_color; LPoint3d _billboard_center; vector_string _object_types; string _collision_name; @@ -327,6 +381,8 @@ ostream &operator << (ostream &out, EggGroup::DCSType t); ostream &operator << (ostream &out, EggGroup::BillboardType t); ostream &operator << (ostream &out, EggGroup::CollisionSolidType t); ostream &operator << (ostream &out, EggGroup::CollideFlags t); +ostream &operator << (ostream &out, EggGroup::BlendMode t); +ostream &operator << (ostream &out, EggGroup::BlendOperand t); #include "eggGroup.I" diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 41fa161991..30fafec03f 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -1112,12 +1112,16 @@ group_body: if (cmp_nocase_uh(name, "fps") == 0) { group->set_switch_fps(value); + } else if (cmp_nocase_uh(name, "no_fog") == 0) { group->set_nofog_flag(value != 0); + } else if (cmp_nocase_uh(name, "decal") == 0) { group->set_decal_flag(value != 0); + } else if (cmp_nocase_uh(name, "direct") == 0) { group->set_direct_flag(value != 0); + } else if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { @@ -1125,6 +1129,7 @@ group_body: } else { group->set_alpha_mode(a); } + } else if (cmp_nocase_uh(name, "depth_write") == 0) { EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); @@ -1154,20 +1159,75 @@ group_body: } else if (cmp_nocase_uh(name, "draw_order") == 0) { group->set_draw_order(ulong_value); + } else if (cmp_nocase_uh(name, "bin") == 0) { group->set_bin(strval); + } else if (cmp_nocase_uh(name, "collide_mask") == 0) { group->set_collide_mask(group->get_collide_mask() | ulong_value); + } else if (cmp_nocase_uh(name, "from_collide_mask") == 0) { group->set_from_collide_mask(group->get_from_collide_mask() | ulong_value); + } else if (cmp_nocase_uh(name, "into_collide_mask") == 0) { group->set_into_collide_mask(group->get_into_collide_mask() | ulong_value); + } else if (cmp_nocase_uh(name, "portal") == 0) { group->set_portal_flag(value != 0); + } else if (cmp_nocase_uh(name, "polylight") == 0) { group->set_polylight_flag(value != 0); + } else if (cmp_nocase_uh(name, "indexed") == 0) { group->set_indexed_flag(value != 0); + + } else if (cmp_nocase_uh(name, "blend") == 0) { + EggGroup::BlendMode blend_mode = + EggGroup::string_blend_mode(strval); + if (blend_mode == EggGroup::BM_unspecified) { + eggyywarning("Unknown blend mode " + strval); + } else { + group->set_blend_mode(blend_mode); + } + + } else if (cmp_nocase_uh(name, "blendop_a") == 0) { + EggGroup::BlendOperand blend_operand = + EggGroup::string_blend_operand(strval); + if (blend_operand == EggGroup::BO_unspecified) { + eggyywarning("Unknown blend operand " + strval); + } else { + group->set_blend_operand_a(blend_operand); + } + + } else if (cmp_nocase_uh(name, "blendop_b") == 0) { + EggGroup::BlendOperand blend_operand = + EggGroup::string_blend_operand(strval); + if (blend_operand == EggGroup::BO_unspecified) { + eggyywarning("Unknown blend operand " + strval); + } else { + group->set_blend_operand_b(blend_operand); + } + + } else if (cmp_nocase_uh(name, "blendr") == 0) { + Colorf color = group->get_blend_color(); + color[0] = value; + group->set_blend_color(color); + + } else if (cmp_nocase_uh(name, "blendg") == 0) { + Colorf color = group->get_blend_color(); + color[1] = value; + group->set_blend_color(color); + + } else if (cmp_nocase_uh(name, "blendb") == 0) { + Colorf color = group->get_blend_color(); + color[2] = value; + group->set_blend_color(color); + + } else if (cmp_nocase_uh(name, "blenda") == 0) { + Colorf color = group->get_blend_color(); + color[3] = value; + group->set_blend_color(color); + } else { eggyywarning("Unknown group scalar " + name); } diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 2440f1b545..419315de6a 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -1868,6 +1868,16 @@ create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) { node->set_tag((*ti).first, (*ti).second); } + if (egg_group->get_blend_mode() != EggGroup::BM_unspecified && + egg_group->get_blend_mode() != EggGroup::BM_none) { + // Apply a ColorBlendAttrib to the group. + ColorBlendAttrib::Mode mode = get_color_blend_mode(egg_group->get_blend_mode()); + ColorBlendAttrib::Operand a = get_color_blend_operand(egg_group->get_blend_operand_a()); + ColorBlendAttrib::Operand b = get_color_blend_operand(egg_group->get_blend_operand_b()); + Colorf color = egg_group->get_blend_color(); + node->set_attrib(ColorBlendAttrib::make(mode, a, b, color)); + } + // If the group specified some property that should propagate down // to the leaves, we have to remember this node and apply the // property later, after we've created the actual geometry. @@ -3471,6 +3481,86 @@ get_combine_operand(const EggTexture *egg_tex, return TextureStage::CO_undefined; } +//////////////////////////////////////////////////////////////////// +// Function: EggLoader::get_color_blend_mode +// Access: Private, Static +// Description: Converts the EggGroup's BlendMode to the +// corresponding ColorBlendAttrib::Mode value. +//////////////////////////////////////////////////////////////////// +ColorBlendAttrib::Mode EggLoader:: +get_color_blend_mode(EggGroup::BlendMode mode) { + switch (mode) { + case EggGroup::BM_unspecified: + case EggGroup::BM_none: + return ColorBlendAttrib::M_none; + case EggGroup::BM_add: + return ColorBlendAttrib::M_add; + case EggGroup::BM_subtract: + return ColorBlendAttrib::M_subtract; + case EggGroup::BM_inv_subtract: + return ColorBlendAttrib::M_inv_subtract; + case EggGroup::BM_min: + return ColorBlendAttrib::M_min; + case EggGroup::BM_max: + return ColorBlendAttrib::M_max; + } + + return ColorBlendAttrib::M_none; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggLoader::get_color_blend_operand +// Access: Private, Static +// Description: Converts the EggGroup's BlendOperand to the +// corresponding ColorBlendAttrib::Operand value. +//////////////////////////////////////////////////////////////////// +ColorBlendAttrib::Operand EggLoader:: +get_color_blend_operand(EggGroup::BlendOperand operand) { + switch (operand) { + case EggGroup::BO_zero: + return ColorBlendAttrib::O_zero; + case EggGroup::BO_unspecified: + case EggGroup::BO_one: + return ColorBlendAttrib::O_one; + case EggGroup::BO_incoming_color: + return ColorBlendAttrib::O_incoming_color; + case EggGroup::BO_one_minus_incoming_color: + return ColorBlendAttrib::O_one_minus_incoming_color; + case EggGroup::BO_fbuffer_color: + return ColorBlendAttrib::O_fbuffer_color; + case EggGroup::BO_one_minus_fbuffer_color: + return ColorBlendAttrib::O_one_minus_fbuffer_color; + case EggGroup::BO_incoming_alpha: + return ColorBlendAttrib::O_incoming_alpha; + case EggGroup::BO_one_minus_incoming_alpha: + return ColorBlendAttrib::O_one_minus_incoming_alpha; + case EggGroup::BO_fbuffer_alpha: + return ColorBlendAttrib::O_fbuffer_alpha; + case EggGroup::BO_one_minus_fbuffer_alpha: + return ColorBlendAttrib::O_one_minus_fbuffer_alpha; + case EggGroup::BO_constant_color: + return ColorBlendAttrib::O_constant_color; + case EggGroup::BO_one_minus_constant_color: + return ColorBlendAttrib::O_one_minus_constant_color; + case EggGroup::BO_constant_alpha: + return ColorBlendAttrib::O_constant_alpha; + case EggGroup::BO_one_minus_constant_alpha: + return ColorBlendAttrib::O_one_minus_constant_alpha; + case EggGroup::BO_incoming_color_saturate: + return ColorBlendAttrib::O_incoming_color_saturate; + case EggGroup::BO_color_scale: + return ColorBlendAttrib::O_color_scale; + case EggGroup::BO_one_minus_color_scale: + return ColorBlendAttrib::O_one_minus_color_scale; + case EggGroup::BO_alpha_scale: + return ColorBlendAttrib::O_alpha_scale; + case EggGroup::BO_one_minus_alpha_scale: + return ColorBlendAttrib::O_one_minus_alpha_scale; + } + + return ColorBlendAttrib::O_zero; +} + //////////////////////////////////////////////////////////////////// // Function: EggLoader::VertexPoolTransform::operator < // Access: Public diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index 40b7eb3207..f5d58fa11b 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -37,6 +37,7 @@ #include "textureAttrib.h" #include "textureStage.h" #include "texGenAttrib.h" +#include "colorBlendAttrib.h" #include "eggTransform3d.h" #include "computedVerticesMaker.h" #include "qpgeomVertexData.h" @@ -208,6 +209,12 @@ private: get_combine_operand(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n); + static ColorBlendAttrib::Mode + get_color_blend_mode(EggGroup::BlendMode mode); + + static ColorBlendAttrib::Operand + get_color_blend_operand(EggGroup::BlendOperand operand); + Builder _builder; typedef pmap Textures; diff --git a/panda/src/pgraph/colorBlendAttrib.cxx b/panda/src/pgraph/colorBlendAttrib.cxx index 3914884263..e46c7d832e 100644 --- a/panda/src/pgraph/colorBlendAttrib.cxx +++ b/panda/src/pgraph/colorBlendAttrib.cxx @@ -256,61 +256,61 @@ ostream & operator << (ostream &out, ColorBlendAttrib::Operand operand) { switch (operand) { case ColorBlendAttrib::O_zero: - return out << "0"; + return out << "zero"; case ColorBlendAttrib::O_one: - return out << "1"; + return out << "one"; case ColorBlendAttrib::O_incoming_color: - return out << "ic"; + return out << "incomfing_color"; case ColorBlendAttrib::O_one_minus_incoming_color: - return out << "1-ic"; + return out << "one_minus_incoming_color"; case ColorBlendAttrib::O_fbuffer_color: - return out << "fc"; + return out << "fbuffer_color"; case ColorBlendAttrib::O_one_minus_fbuffer_color: - return out << "1-fc"; + return out << "one_minus_fbuffer_color"; case ColorBlendAttrib::O_incoming_alpha: - return out << "ia"; + return out << "incoming_alpha"; case ColorBlendAttrib::O_one_minus_incoming_alpha: - return out << "1-ia"; + return out << "one_minus_incoming_alpha"; case ColorBlendAttrib::O_fbuffer_alpha: - return out << "fa"; + return out << "fbuffer_alpha"; case ColorBlendAttrib::O_one_minus_fbuffer_alpha: - return out << "1-fa"; + return out << "one_minus_fbuffer_alpha"; case ColorBlendAttrib::O_constant_color: - return out << "cc"; + return out << "constant_color"; case ColorBlendAttrib::O_one_minus_constant_color: - return out << "1-cc"; + return out << "one_minus_constant_color"; case ColorBlendAttrib::O_constant_alpha: - return out << "ca"; + return out << "constant_alpha"; case ColorBlendAttrib::O_one_minus_constant_alpha: - return out << "1-ca"; + return out << "one_minus_constant_alpha"; case ColorBlendAttrib::O_incoming_color_saturate: - return out << "ics"; + return out << "incoming_color_saturate"; case ColorBlendAttrib::O_color_scale: - return out << "cs"; + return out << "color_scale"; case ColorBlendAttrib::O_one_minus_color_scale: - return out << "1-cs"; + return out << "one_minus_color_scale"; case ColorBlendAttrib::O_alpha_scale: - return out << "as"; + return out << "alpha_scale"; case ColorBlendAttrib::O_one_minus_alpha_scale: - return out << "1-as"; + return out << "one_minus_alpha_scale"; } return out << "**invalid ColorBlendAttrib::Operand(" << (int)operand << ")**";