From 29b4df01d42b7e0716ff5d47172560b5101141c6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 3 Oct 2003 01:47:23 +0000 Subject: [PATCH] extend interface for egg2flt --- panda/src/egg/eggGroup.cxx | 177 +++++++++++++++++++++++++++---------- panda/src/egg/eggGroup.h | 8 ++ panda/src/egg/eggNode.I | 74 ++++++++++++++++ panda/src/egg/eggNode.h | 7 ++ 4 files changed, 218 insertions(+), 48 deletions(-) diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index ce17517048..e209b185ee 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -195,18 +195,58 @@ write(ostream &out, int indent_level) const { get_lod().write(out, indent_level + 2); } + write_billboard_flags(out, indent_level + 2); + write_collide_flags(out, indent_level + 2); + write_model_flags(out, indent_level + 2); + write_switch_flags(out, indent_level + 2); + + if (has_transform()) { + EggTransform3d::write(out, indent_level + 2); + } + + write_object_types(out, indent_level + 2); + write_decal_flags(out, indent_level + 2); + write_tags(out, indent_level + 2); + write_render_mode(out, indent_level + 2); + + // 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! + EggGroupNode::write(out, indent_level + 2); + write_vertex_ref(out, indent_level + 2); + + indent(out, indent_level) << "}\n"; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_billboard_flags +// Access: Public +// Description: Writes just the entry and related fields to +// the indicated ostream. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_billboard_flags(ostream &out, int indent_level) const { if (get_billboard_type() != BT_none) { - indent(out, indent_level + 2) + indent(out, indent_level) << " { " << get_billboard_type() << " }\n"; } if (has_billboard_center()) { - indent(out, indent_level + 2) + indent(out, indent_level) << " { " << get_billboard_center() << " }\n"; } +} +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_collide_flags +// Access: Public +// Description: Writes just the entry and related fields to +// the indicated ostream. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_collide_flags(ostream &out, int indent_level) const { if (get_cs_type() != CST_none) { - indent(out, indent_level + 2) << " "; + indent(out, indent_level) << " "; if (has_collision_name()) { enquote_string(out, get_collision_name()) << " "; } @@ -218,95 +258,136 @@ write(ostream &out, int indent_level) const { } if (has_collide_mask()) { - indent(out, indent_level + 2) + indent(out, indent_level) << " collide-mask { 0x"; get_collide_mask().output_hex(out, 0); out << " }\n"; } if (has_from_collide_mask()) { - indent(out, indent_level + 2) + indent(out, indent_level) << " from-collide-mask { 0x"; get_from_collide_mask().output_hex(out, 0); out << " }\n"; } if (has_into_collide_mask()) { - indent(out, indent_level + 2) + indent(out, indent_level) << " into-collide-mask { 0x"; get_into_collide_mask().output_hex(out, 0); out << " }\n"; } +} +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_model_flags +// Access: Public +// Description: Writes the flag and related flags to the +// indicated ostream. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_model_flags(ostream &out, int indent_level) const { if (get_dcs_type() != DC_none) { - indent(out, indent_level + 2) + indent(out, indent_level) << " { " << get_dcs_type() << " }\n"; } if (get_dart_type() != DT_none) { - indent(out, indent_level + 2) + indent(out, indent_level) << " { " << get_dart_type() << " }\n"; } - if (get_switch_flag()) { - indent(out, indent_level + 2) << " { 1 }\n"; - if (get_switch_fps() != 0.0) { - indent(out, indent_level + 2) - << " fps { " << get_switch_fps() << " }\n"; - } - } - - if (has_transform()) { - EggTransform3d::write(out, indent_level + 2); - } - - vector_string::const_iterator oi; - for (oi = _object_types.begin(); oi != _object_types.end(); ++oi) { - indent(out, indent_level + 2) - << " { "; - enquote_string(out, (*oi)) << " }\n"; - } - if (get_model_flag()) { - indent(out, indent_level + 2) << " { 1 }\n"; + indent(out, indent_level) << " { 1 }\n"; } if (get_texlist_flag()) { - indent(out, indent_level + 2) << " { 1 }\n"; - } - - if (get_nofog_flag()) { - indent(out, indent_level + 2) << " no-fog { 1 }\n"; - } - - if (get_decal_flag()) { - indent(out, indent_level + 2) << " decal { 1 }\n"; + indent(out, indent_level) << " { 1 }\n"; } if (get_direct_flag()) { - indent(out, indent_level + 2) << " direct { 1 }\n"; + indent(out, indent_level) << " direct { 1 }\n"; } +} - EggRenderMode::write(out, indent_level + 2); +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_switch_flags +// Access: Public +// Description: Writes the flag and related flags to the +// indicated ostream. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_switch_flags(ostream &out, int indent_level) const { + if (get_switch_flag()) { + indent(out, indent_level) << " { 1 }\n"; + if (get_switch_fps() != 0.0) { + indent(out, indent_level) + << " fps { " << get_switch_fps() << " }\n"; + } + } +} +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_object_types +// Access: Public +// Description: Writes just the entries, if any, to the +// indicated ostream. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_object_types(ostream &out, int indent_level) const { + vector_string::const_iterator oi; + for (oi = _object_types.begin(); oi != _object_types.end(); ++oi) { + indent(out, indent_level) + << " { "; + enquote_string(out, (*oi)) << " }\n"; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_decal_flags +// Access: Public +// Description: Writes the flags related to decalling, if any. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_decal_flags(ostream &out, int indent_level) const { + if (get_decal_flag()) { + indent(out, indent_level) << " decal { 1 }\n"; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_tags +// Access: Public +// Description: Writes just the entries, if any, to the +// indicated ostream. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_tags(ostream &out, int indent_level) const { TagData::const_iterator ti; for (ti = _tag_data.begin(); ti != _tag_data.end(); ++ti) { const string &key = (*ti).first; const string &value = (*ti).second; - indent(out, indent_level + 2) << " "; + indent(out, indent_level) << " "; enquote_string(out, key) << " {\n"; - enquote_string(out, value, indent_level + 4) << "\n"; - indent(out, indent_level + 2) << "}\n"; + enquote_string(out, value, indent_level + 2) << "\n"; + indent(out, indent_level) << "}\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! - EggGroupNode::write(out, indent_level + 2); - write_vertex_ref(out, indent_level + 2); +//////////////////////////////////////////////////////////////////// +// Function: EggGroup::write_render_mode +// Access: Public +// Description: Writes the flags inherited from EggRenderMode and +// similar flags that control obscure render effects. +//////////////////////////////////////////////////////////////////// +void EggGroup:: +write_render_mode(ostream &out, int indent_level) const { + EggRenderMode::write(out, indent_level); - indent(out, indent_level) << "}\n"; + if (get_nofog_flag()) { + indent(out, indent_level) << " no-fog { 1 }\n"; + } } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index f8e959f0e6..f7f446bf82 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -100,6 +100,14 @@ public: ~EggGroup(); virtual void write(ostream &out, int indent_level) const; + void write_billboard_flags(ostream &out, int indent_level) const; + void write_collide_flags(ostream &out, int indent_level) const; + void write_model_flags(ostream &out, int indent_level) const; + void write_switch_flags(ostream &out, int indent_level) const; + void write_object_types(ostream &out, int indent_level) const; + void write_decal_flags(ostream &out, int indent_level) const; + void write_tags(ostream &out, int indent_level) const; + void write_render_mode(ostream &out, int indent_level) const; virtual bool is_joint() const; diff --git a/panda/src/egg/eggNode.I b/panda/src/egg/eggNode.I index 44ba997935..e44d655ec4 100644 --- a/panda/src/egg/eggNode.I +++ b/panda/src/egg/eggNode.I @@ -232,6 +232,80 @@ get_node_to_vertex() const { } } +//////////////////////////////////////////////////////////////////// +// Function: EggNode::get_vertex_frame_ptr +// Access: Public +// Description: Returns either a NULL pointer or a unique pointer +// shared by nodes with the same get_vertex_frame() +// matrix. +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4d *EggNode:: +get_vertex_frame_ptr() const { + return _vertex_frame; +} + + +//////////////////////////////////////////////////////////////////// +// Function: EggNode::get_node_frame_ptr +// Access: Public +// Description: Returns either a NULL pointer or a unique pointer +// shared by nodes with the same get_node_frame() +// matrix. +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4d *EggNode:: +get_node_frame_ptr() const { + return _node_frame; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggNode::get_vertex_frame_inv_ptr +// Access: Public +// Description: Returns either a NULL pointer or a unique pointer +// shared by nodes with the same get_vertex_frame_inv() +// matrix. +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4d *EggNode:: +get_vertex_frame_inv_ptr() const { + return _vertex_frame_inv; +} + + +//////////////////////////////////////////////////////////////////// +// Function: EggNode::get_node_frame_inv_ptr +// Access: Public +// Description: Returns either a NULL pointer or a unique pointer +// shared by nodes with the same get_node_frame_inv() +// matrix. +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4d *EggNode:: +get_node_frame_inv_ptr() const { + return _node_frame_inv; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggNode::get_vertex_to_node_ptr +// Access: Public +// Description: Returns either a NULL pointer or a unique pointer +// shared by nodes with the same get_vertex_to_node() +// matrix. +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4d *EggNode:: +get_vertex_to_node_ptr() const { + return _vertex_to_node; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggNode::get_node_to_vertex_ptr +// Access: Public +// Description: Returns either a NULL pointer or a unique pointer +// shared by nodes with the same get_node_to_vertex() +// matrix. +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4d *EggNode:: +get_node_to_vertex_ptr() const { + return _node_to_vertex; +} + //////////////////////////////////////////////////////////////////// // Function: EggNode::transform diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index 01879bd02b..24c2b65acd 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -58,6 +58,13 @@ public: INLINE const LMatrix4d &get_vertex_to_node() const; INLINE const LMatrix4d &get_node_to_vertex() const; + INLINE const LMatrix4d *get_vertex_frame_ptr()const; + INLINE const LMatrix4d *get_node_frame_ptr()const; + INLINE const LMatrix4d *get_vertex_frame_inv_ptr()const; + INLINE const LMatrix4d *get_node_frame_inv_ptr()const; + INLINE const LMatrix4d *get_vertex_to_node_ptr()const; + INLINE const LMatrix4d *get_node_to_vertex_ptr()const; + INLINE void transform(const LMatrix4d &mat); INLINE void transform_vertices_only(const LMatrix4d &mat); INLINE void flatten_transforms();