From a7562e48d0b5c5cfcf2554613ecca378593d6b74 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 7 Oct 2003 13:37:59 +0000 Subject: [PATCH] publish egg interfaces --- .../src/extensions/EggGroupNode-extensions.py | 11 +++ .../src/extensions/EggPrimitive-extensions.py | 8 ++ panda/src/egg/Sources.pp | 1 + panda/src/egg/eggAnimData.h | 8 +- panda/src/egg/eggAttributes.h | 8 +- panda/src/egg/eggBin.h | 4 +- panda/src/egg/eggBinMaker.h | 8 +- panda/src/egg/eggComment.h | 6 +- panda/src/egg/eggCoordinateSystem.h | 4 +- panda/src/egg/eggCurve.h | 4 +- panda/src/egg/eggData.h | 15 ++- panda/src/egg/eggExternalReference.h | 4 +- panda/src/egg/eggFilenameNode.h | 6 +- panda/src/egg/eggGroup.h | 6 +- panda/src/egg/eggGroupNode.cxx | 91 ++++++++++++++----- panda/src/egg/eggGroupNode.h | 22 +++-- panda/src/egg/eggGroupUniquifier.h | 4 +- panda/src/egg/eggMaterial.h | 6 +- panda/src/egg/eggMaterialCollection.h | 10 +- panda/src/egg/eggMorph.h | 6 +- panda/src/egg/eggMorphList.h | 2 +- panda/src/egg/eggNameUniquifier.h | 4 +- panda/src/egg/eggNamedObject.I | 5 + panda/src/egg/eggNamedObject.cxx | 15 ++- panda/src/egg/eggNamedObject.h | 9 +- panda/src/egg/eggNode.h | 12 +-- panda/src/egg/eggNurbsCurve.h | 6 +- panda/src/egg/eggObject.h | 2 +- panda/src/egg/eggParameters.h | 2 +- panda/src/egg/eggPoint.h | 4 +- panda/src/egg/eggPolygon.h | 4 +- panda/src/egg/eggPolysetMaker.h | 2 +- panda/src/egg/eggPoolUniquifier.h | 4 +- panda/src/egg/eggPrimitive.I | 10 ++ panda/src/egg/eggPrimitive.cxx | 6 +- panda/src/egg/eggPrimitive.h | 11 ++- panda/src/egg/eggRenderMode.h | 2 +- panda/src/egg/eggSAnimData.h | 4 +- panda/src/egg/eggSurface.h | 4 +- panda/src/egg/eggSwitchCondition.h | 6 +- panda/src/egg/eggTable.h | 4 +- panda/src/egg/eggTexture.h | 8 +- panda/src/egg/eggTextureCollection.h | 10 +- panda/src/egg/eggTransform3d.h | 2 +- panda/src/egg/eggUserData.h | 2 +- panda/src/egg/eggUtilities.h | 6 +- panda/src/egg/eggVertex.h | 11 ++- panda/src/egg/eggVertexPool.h | 12 ++- panda/src/egg/eggXfmAnimData.h | 2 +- panda/src/egg/eggXfmSAnim.h | 2 +- panda/src/egg2pg/Sources.pp | 2 + panda/src/egg2pg/characterMaker.h | 2 +- panda/src/egg2pg/load_egg_file.cxx | 40 +++----- panda/src/egg2pg/load_egg_file.h | 4 +- 54 files changed, 283 insertions(+), 170 deletions(-) create mode 100644 direct/src/extensions/EggGroupNode-extensions.py create mode 100644 direct/src/extensions/EggPrimitive-extensions.py diff --git a/direct/src/extensions/EggGroupNode-extensions.py b/direct/src/extensions/EggGroupNode-extensions.py new file mode 100644 index 0000000000..660e556a8f --- /dev/null +++ b/direct/src/extensions/EggGroupNode-extensions.py @@ -0,0 +1,11 @@ + + # For iterating over children + def getChildren(self): + """Returns a Python list of the egg node's children.""" + result = [] + child = self.getFirstChild() + while (child != None): + result.append(child) + child = self.getNextChild() + return result + diff --git a/direct/src/extensions/EggPrimitive-extensions.py b/direct/src/extensions/EggPrimitive-extensions.py new file mode 100644 index 0000000000..60c5bf7392 --- /dev/null +++ b/direct/src/extensions/EggPrimitive-extensions.py @@ -0,0 +1,8 @@ + + # For iterating over vertices + def getVertices(self): + """Returns a Python list of the egg primitive's vertices.""" + result = [] + for i in range(self.getNumVertices()): + result.append(self.getVertex(i)) + return result diff --git a/panda/src/egg/Sources.pp b/panda/src/egg/Sources.pp index b0dd9977a0..2b74d875e6 100644 --- a/panda/src/egg/Sources.pp +++ b/panda/src/egg/Sources.pp @@ -87,6 +87,7 @@ pt_EggTexture.h vector_PT_EggTexture.h \ pt_EggVertex.h vector_PT_EggVertex.h + #define IGATESCAN all #end lib_target diff --git a/panda/src/egg/eggAnimData.h b/panda/src/egg/eggAnimData.h index 57888b2f1f..d27c2c1b53 100644 --- a/panda/src/egg/eggAnimData.h +++ b/panda/src/egg/eggAnimData.h @@ -19,12 +19,12 @@ #ifndef EGGANIMDATA_H #define EGGANIMDATA_H -#include +#include "pandabase.h" #include "eggNode.h" -#include -#include +#include "pointerToArray.h" +#include "pta_double.h" //////////////////////////////////////////////////////////////////// // Class : EggAnimData @@ -32,7 +32,7 @@ // which contain rows and columns of numbers. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggAnimData : public EggNode { -public: +PUBLISHED: INLINE EggAnimData(const string &name = ""); INLINE EggAnimData(const EggAnimData ©); diff --git a/panda/src/egg/eggAttributes.h b/panda/src/egg/eggAttributes.h index 6797908163..0f130969a3 100644 --- a/panda/src/egg/eggAttributes.h +++ b/panda/src/egg/eggAttributes.h @@ -19,12 +19,12 @@ #ifndef EGGATTRIBUTES_H #define EGGATTRIBUTES_H -#include +#include "pandabase.h" #include "eggMorphList.h" -#include -#include +#include "typedObject.h" +#include "luse.h" //////////////////////////////////////////////////////////////////// // Class : EggAttributes @@ -38,7 +38,7 @@ // EggObject a virtual base class is just no fun. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggAttributes { -public: +PUBLISHED: EggAttributes(); EggAttributes(const EggAttributes ©); EggAttributes &operator = (const EggAttributes ©); diff --git a/panda/src/egg/eggBin.h b/panda/src/egg/eggBin.h index 678585c055..0b5a0b40ba 100644 --- a/panda/src/egg/eggBin.h +++ b/panda/src/egg/eggBin.h @@ -19,7 +19,7 @@ #ifndef EGGBIN_H #define EGGBIN_H -#include +#include "pandabase.h" #include "eggGroup.h" @@ -32,7 +32,7 @@ // EggBinMaker. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggBin : public EggGroup { -public: +PUBLISHED: EggBin(const string &name = ""); EggBin(const EggGroup ©); EggBin(const EggBin ©); diff --git a/panda/src/egg/eggBinMaker.h b/panda/src/egg/eggBinMaker.h index 6905fb812b..d399c084fa 100644 --- a/panda/src/egg/eggBinMaker.h +++ b/panda/src/egg/eggBinMaker.h @@ -204,12 +204,12 @@ /////////////////////////////////////////////////////////////////// -#include +#include "pandabase.h" #include "eggObject.h" -#include -#include +#include "pointerTo.h" +#include "notify.h" #include "pset.h" #include "pmap.h" @@ -248,7 +248,7 @@ public: // comment above. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggBinMaker : public EggObject { -public: +PUBLISHED: EggBinMaker(); ~EggBinMaker(); diff --git a/panda/src/egg/eggComment.h b/panda/src/egg/eggComment.h index 0201097b02..fac135e19c 100644 --- a/panda/src/egg/eggComment.h +++ b/panda/src/egg/eggComment.h @@ -19,19 +19,17 @@ #ifndef EGGCOMMENT_H #define EGGCOMMENT_H -#include +#include "pandabase.h" #include "eggNode.h" -#include - /////////////////////////////////////////////////////////////////// // Class : EggComment // Description : A comment that appears in an egg file within a // entry. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggComment : public EggNode { -public: +PUBLISHED: INLINE EggComment(const string &node_name, const string &comment); INLINE EggComment(const EggComment ©); diff --git a/panda/src/egg/eggCoordinateSystem.h b/panda/src/egg/eggCoordinateSystem.h index 8754657482..a0fc7b8657 100644 --- a/panda/src/egg/eggCoordinateSystem.h +++ b/panda/src/egg/eggCoordinateSystem.h @@ -19,11 +19,11 @@ #ifndef EGGCOORDINATESYSTEM_H #define EGGCOORDINATESYSTEM_H -#include +#include "pandabase.h" #include "eggNode.h" #include "eggData.h" -#include +#include "coordinateSystem.h" /////////////////////////////////////////////////////////////////// diff --git a/panda/src/egg/eggCurve.h b/panda/src/egg/eggCurve.h index 8d4a65fdd5..5dd1334dea 100644 --- a/panda/src/egg/eggCurve.h +++ b/panda/src/egg/eggCurve.h @@ -19,7 +19,7 @@ #ifndef EGGCURVE_H #define EGGCURVE_H -#include +#include "pandabase.h" #include "eggPrimitive.h" @@ -29,7 +29,7 @@ // EggNurbsCurve. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggCurve : public EggPrimitive { -public: +PUBLISHED: INLINE EggCurve(const string &name = ""); INLINE EggCurve(const EggCurve ©); INLINE EggCurve &operator = (const EggCurve ©); diff --git a/panda/src/egg/eggData.h b/panda/src/egg/eggData.h index b927ad1a10..a4ca31f7e0 100644 --- a/panda/src/egg/eggData.h +++ b/panda/src/egg/eggData.h @@ -19,16 +19,13 @@ #ifndef EGGDATA_H #define EGGDATA_H -#include +#include "pandabase.h" #include "eggGroupNode.h" -#include -#include -#include -#include - -#include - +#include "filename.h" +#include "coordinateSystem.h" +#include "notify.h" +#include "dSearchPath.h" /////////////////////////////////////////////////////////////////// // Class : EggData @@ -44,7 +41,7 @@ // are the toplevel nodes in the egg file. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggData : public EggGroupNode { -public: +PUBLISHED: INLINE EggData(); INLINE EggData(const EggData ©); INLINE EggData &operator = (const EggData ©); diff --git a/panda/src/egg/eggExternalReference.h b/panda/src/egg/eggExternalReference.h index a13ea3aeb2..421d6789ac 100644 --- a/panda/src/egg/eggExternalReference.h +++ b/panda/src/egg/eggExternalReference.h @@ -19,7 +19,7 @@ #ifndef EGGEXTERNALREFERENCE_H #define EGGEXTERNALREFERENCE_H -#include +#include "pandabase.h" #include "eggFilenameNode.h" @@ -29,7 +29,7 @@ // be inserted at this point. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggExternalReference : public EggFilenameNode { -public: +PUBLISHED: EggExternalReference(const string &node_name, const string &filename); EggExternalReference(const EggExternalReference ©); EggExternalReference &operator = (const EggExternalReference ©); diff --git a/panda/src/egg/eggFilenameNode.h b/panda/src/egg/eggFilenameNode.h index e7dba75f71..4f999e47f4 100644 --- a/panda/src/egg/eggFilenameNode.h +++ b/panda/src/egg/eggFilenameNode.h @@ -19,10 +19,10 @@ #ifndef EGGFILENAMENODE_H #define EGGFILENAMENODE_H -#include +#include "pandabase.h" #include "eggNode.h" -#include +#include "filename.h" //////////////////////////////////////////////////////////////////// // Class : EggFilenameNode @@ -32,7 +32,7 @@ // EggTexture and EggExternalReference. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggFilenameNode : public EggNode { -public: +PUBLISHED: INLINE EggFilenameNode(); INLINE EggFilenameNode(const string &node_name, const Filename &filename); INLINE EggFilenameNode(const EggFilenameNode ©); diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index f7f446bf82..934f270c10 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -38,7 +38,7 @@ // to the , , and type nodes. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggGroup : public EggGroupNode, public EggRenderMode, public EggTransform3d { -public: +PUBLISHED: typedef pmap VertexRef; typedef pmap TagData; @@ -199,10 +199,12 @@ public: INLINE bool has_tag(const string &key) const; INLINE void clear_tag(const string &key); +public: INLINE TagData::const_iterator tag_begin() const; INLINE TagData::const_iterator tag_end() const; INLINE TagData::size_type tag_size() const; +PUBLISHED: void ref_vertex(EggVertex *vert, double membership = 1.0); void unref_vertex(EggVertex *vert); void unref_all_vertices(); @@ -210,10 +212,12 @@ public: void set_vertex_membership(EggVertex *vert, double membership); void steal_vrefs(EggGroup *other); +public: INLINE VertexRef::const_iterator vref_begin() const; INLINE VertexRef::const_iterator vref_end() const; INLINE VertexRef::size_type vref_size() const; +PUBLISHED: #ifndef NDEBUG void test_vref_integrity() const; #else diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index 6aace0b35d..951bdb5897 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -148,26 +148,6 @@ rend() const { return _children.rend(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -bool EggGroupNode:: -empty() const { - return _children.empty(); -} - -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -EggGroupNode::size_type EggGroupNode:: -size() const { - return _children.size(); -} - //////////////////////////////////////////////////////////////////// // Function: EggGroupNode::insert // Access: Public @@ -221,6 +201,26 @@ replace(iterator position, PT(EggNode) x) { *(Children::iterator &)position = x; } +//////////////////////////////////////////////////////////////////// +// Function: EggGroupNode::empty +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +bool EggGroupNode:: +empty() const { + return _children.empty(); +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroupNode::size +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +EggGroupNode::size_type EggGroupNode:: +size() const { + return _children.size(); +} + //////////////////////////////////////////////////////////////////// // Function: EggGroupNode::clear // Access: Public @@ -231,6 +231,45 @@ clear() { erase(begin(), end()); } +//////////////////////////////////////////////////////////////////// +// Function: EggGroupNode::get_first_child +// Access: Public +// Description: Returns the first child in the group's list of +// children, or NULL if the list of children is empty. +// Can be used with get_next_child() to return the +// complete list of children without using the iterator +// class; however, this is non-thread-safe, and so is +// not recommended except for languages other than C++ +// which cannot use the iterators. +//////////////////////////////////////////////////////////////////// +EggNode *EggGroupNode:: +get_first_child() { + _gnc_iterator = begin(); + return get_next_child(); +} + +//////////////////////////////////////////////////////////////////// +// Function: EggGroupNode::get_next_child +// Access: Public +// Description: Returns the next child in the group's list of +// children since the last call to get_first_child() or +// get_next_child(), or NULL if the last child has been +// returned. Can be used with get_first_child() to +// return the complete list of children without using +// the iterator class; however, this is non-thread-safe, +// and so is not recommended except for languages other +// than C++ which cannot use the iterators. +// +// It is an error to call this without previously +// calling get_first_child(). +//////////////////////////////////////////////////////////////////// +EggNode *EggGroupNode:: +get_next_child() { + if (_gnc_iterator != end()) { + return *_gnc_iterator++; + } + return NULL; +} //////////////////////////////////////////////////////////////////// // Function: EggGroupNode::add_child @@ -239,8 +278,9 @@ clear() { // If the child node is already a child of some other // node, removes it first. //////////////////////////////////////////////////////////////////// -PT(EggNode) EggGroupNode:: -add_child(PT(EggNode) node) { +EggNode *EggGroupNode:: +add_child(EggNode *node) { + PT(EggNode) ptnode = node; if (node->_parent != NULL) { node->_parent->remove_child(node); } @@ -257,14 +297,15 @@ add_child(PT(EggNode) node) { // group, does nothing and returns NULL. //////////////////////////////////////////////////////////////////// PT(EggNode) EggGroupNode:: -remove_child(PT(EggNode) node) { - iterator i = find(begin(), end(), node); +remove_child(EggNode *node) { + PT(EggNode) ptnode = node; + iterator i = find(begin(), end(), ptnode); if (i == end()) { return PT(EggNode)(); } else { // erase() calls prepare_remove_child(). erase(i); - return node; + return ptnode; } } diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index 7ac5875260..537e977958 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -63,7 +63,7 @@ private: // Here begins the actual public interface to EggGroupNode. -public: +PUBLISHED: EggGroupNode(const string &name = "") : EggNode(name) { } EggGroupNode(const EggGroupNode ©); EggGroupNode &operator = (const EggGroupNode ©); @@ -75,7 +75,7 @@ public: // pointers to EggNodes. The set of children is read-only, however, // except through the limited add_child/remove_child or insert/erase // interface. The following implements this. - +public: #ifdef WIN32_VC typedef const PT(EggNode) *pointer; typedef const PT(EggNode) *const_pointer; @@ -96,17 +96,26 @@ public: iterator end() const; reverse_iterator rbegin() const; reverse_iterator rend() const; - bool empty() const; - size_type size() const; iterator insert(iterator position, PT(EggNode) x); iterator erase(iterator position); iterator erase(iterator first, iterator last); void replace(iterator position, PT(EggNode) x); + +PUBLISHED: + bool empty() const; + size_type size() const; void clear(); - PT(EggNode) add_child(PT(EggNode) node); - PT(EggNode) remove_child(PT(EggNode) node); + // This is an alternate way to traverse the list of children. It is + // mainly provided for scripting code, which can't use the iterators + // defined above (they don't export through interrogate very well). + // These are, of course, non-thread-safe. + EggNode *get_first_child(); + EggNode *get_next_child(); + + EggNode *add_child(EggNode *node); + PT(EggNode) remove_child(EggNode *node); void steal_children(EggGroupNode &other); EggNode *find_child(const string &name) const; @@ -143,6 +152,7 @@ protected: private: Children _children; + const_iterator _gnc_iterator; // Don't try to use these private functions. User code should add // and remove children via add_child()/remove_child(), or via the diff --git a/panda/src/egg/eggGroupUniquifier.h b/panda/src/egg/eggGroupUniquifier.h index fa27f13825..f0899c631f 100644 --- a/panda/src/egg/eggGroupUniquifier.h +++ b/panda/src/egg/eggGroupUniquifier.h @@ -19,7 +19,7 @@ #ifndef EGGGROUPUNIQUIFIER_H #define EGGGROUPUNIQUIFIER_H -#include +#include "pandabase.h" #include "eggNameUniquifier.h" @@ -31,7 +31,7 @@ // you want it. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggGroupUniquifier : public EggNameUniquifier { -public: +PUBLISHED: EggGroupUniquifier(); virtual string get_category(EggNode *node); diff --git a/panda/src/egg/eggMaterial.h b/panda/src/egg/eggMaterial.h index ec6259323a..a0da789d3d 100644 --- a/panda/src/egg/eggMaterial.h +++ b/panda/src/egg/eggMaterial.h @@ -19,18 +19,18 @@ #ifndef EGGMATERIAL_H #define EGGMATERIAL_H -#include +#include "pandabase.h" #include "eggNode.h" -#include +#include "luse.h" /////////////////////////////////////////////////////////////////// // Class : EggMaterial // Description : //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggMaterial : public EggNode { -public: +PUBLISHED: EggMaterial(const string &mref_name); EggMaterial(const EggMaterial ©); diff --git a/panda/src/egg/eggMaterialCollection.h b/panda/src/egg/eggMaterialCollection.h index a2c4d214a8..050541cb83 100644 --- a/panda/src/egg/eggMaterialCollection.h +++ b/panda/src/egg/eggMaterialCollection.h @@ -19,13 +19,12 @@ #ifndef EGGMATERIALCOLLECTION_H #define EGGMATERIALCOLLECTION_H -#include +#include "pandabase.h" #include "eggMaterial.h" #include "eggGroupNode.h" #include "vector_PT_EggMaterial.h" -#include #include "pmap.h" //////////////////////////////////////////////////////////////////// @@ -55,7 +54,7 @@ public: // Here begins the actual public interface to EggMaterialCollection. -public: +PUBLISHED: EggMaterialCollection(); EggMaterialCollection(const EggMaterialCollection ©); EggMaterialCollection &operator = (const EggMaterialCollection ©); @@ -64,9 +63,12 @@ public: void clear(); int extract_materials(EggGroupNode *node); + +public: EggGroupNode::iterator insert_materials(EggGroupNode *node); EggGroupNode::iterator insert_materials(EggGroupNode *node, EggGroupNode::iterator position); +PUBLISHED: int find_used_materials(EggNode *node); void remove_unused_materials(EggNode *node); @@ -80,11 +82,13 @@ public: // Can be used to traverse all the materials in the collection, in // order as last sorted. +public: INLINE iterator begin() const; INLINE iterator end() const; INLINE bool empty() const; INLINE size_type size() const; +PUBLISHED: bool add_material(EggMaterial *material); bool remove_material(EggMaterial *material); diff --git a/panda/src/egg/eggMorph.h b/panda/src/egg/eggMorph.h index 4d9ea3fd8f..5c46ea04a3 100644 --- a/panda/src/egg/eggMorph.h +++ b/panda/src/egg/eggMorph.h @@ -19,10 +19,10 @@ #ifndef EGGMORPH_H #define EGGMORPH_H -#include +#include "pandabase.h" -#include -#include +#include "namable.h" +#include "luse.h" #include "pset.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index 19ff1e4ee5..4dbb78d7b4 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -23,7 +23,7 @@ #include "eggMorph.h" -#include +#include "indent.h" #include "pvector.h" diff --git a/panda/src/egg/eggNameUniquifier.h b/panda/src/egg/eggNameUniquifier.h index 2a5a506f1f..7219971f5f 100644 --- a/panda/src/egg/eggNameUniquifier.h +++ b/panda/src/egg/eggNameUniquifier.h @@ -74,7 +74,7 @@ // /////////////////////////////////////////////////////////////////// -#include +#include "pandabase.h" #include "eggObject.h" @@ -90,7 +90,7 @@ class EggNode; // comment above. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggNameUniquifier : public EggObject { -public: +PUBLISHED: EggNameUniquifier(); ~EggNameUniquifier(); diff --git a/panda/src/egg/eggNamedObject.I b/panda/src/egg/eggNamedObject.I index 0ef5d2a663..5efb7289c1 100644 --- a/panda/src/egg/eggNamedObject.I +++ b/panda/src/egg/eggNamedObject.I @@ -48,3 +48,8 @@ operator = (const EggNamedObject ©) { Namable::operator = (copy); return *this; } + +INLINE ostream &operator << (ostream &out, const EggNamedObject &n) { + n.output(out); + return out; +} diff --git a/panda/src/egg/eggNamedObject.cxx b/panda/src/egg/eggNamedObject.cxx index 3399c73ee3..3dc766aaf2 100644 --- a/panda/src/egg/eggNamedObject.cxx +++ b/panda/src/egg/eggNamedObject.cxx @@ -19,10 +19,23 @@ #include "eggNamedObject.h" #include "eggMiscFuncs.h" -#include +#include "indent.h" TypeHandle EggNamedObject::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: EggNamedObject::output +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void EggNamedObject:: +output(ostream &out) const { + out << get_type(); + if (has_name()) { + out << " " << get_name(); + } +} + //////////////////////////////////////////////////////////////////// // Function: EggNamedObject::write_header // Access: Public diff --git a/panda/src/egg/eggNamedObject.h b/panda/src/egg/eggNamedObject.h index 65ca4d1bc1..5ff84b9b27 100644 --- a/panda/src/egg/eggNamedObject.h +++ b/panda/src/egg/eggNamedObject.h @@ -27,15 +27,18 @@ //////////////////////////////////////////////////////////////////// // Class : EggNamedObject -// Description : This is a fairly high-level base class--any egg +// Description : This is a fairly low-level base class--any egg // object that has a name. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggNamedObject : public EggObject, public Namable { -public: +PUBLISHED: INLINE EggNamedObject(const string &name = ""); INLINE EggNamedObject(const EggNamedObject ©); INLINE EggNamedObject &operator = (const EggNamedObject ©); + void output(ostream &out) const; + +public: void write_header(ostream &out, int indent_level, const char *egg_keyword) const; @@ -59,6 +62,8 @@ private: static TypeHandle _type_handle; }; +INLINE ostream &operator << (ostream &out, const EggNamedObject &n); + #include "eggNamedObject.I" #endif diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index 24c2b65acd..cce59bcdca 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -19,14 +19,14 @@ #ifndef EGGNODE_H #define EGGNODE_H -#include +#include "pandabase.h" #include "eggNamedObject.h" -#include -#include -#include -#include +#include "typedObject.h" +#include "lmatrix.h" +#include "pointerTo.h" +#include "referenceCount.h" class EggGroupNode; class EggRenderMode; @@ -40,7 +40,7 @@ class EggTextureCollection; // include things like vertices. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggNode : public EggNamedObject { -public: +PUBLISHED: INLINE EggNode(const string &name = ""); INLINE EggNode(const EggNode ©); INLINE EggNode &operator = (const EggNode ©); diff --git a/panda/src/egg/eggNurbsCurve.h b/panda/src/egg/eggNurbsCurve.h index 85be2e3ce1..b00af4e10d 100644 --- a/panda/src/egg/eggNurbsCurve.h +++ b/panda/src/egg/eggNurbsCurve.h @@ -19,18 +19,18 @@ #ifndef EGGNURBSCURVE_H #define EGGNURBSCURVE_H -#include +#include "pandabase.h" #include "eggCurve.h" -#include +#include "vector_double.h" //////////////////////////////////////////////////////////////////// // Class : EggNurbsCurve // Description : A parametric NURBS curve. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggNurbsCurve : public EggCurve { -public: +PUBLISHED: INLINE EggNurbsCurve(const string &name = ""); INLINE EggNurbsCurve(const EggNurbsCurve ©); INLINE EggNurbsCurve &operator = (const EggNurbsCurve ©); diff --git a/panda/src/egg/eggObject.h b/panda/src/egg/eggObject.h index d34b2c88ca..81592ea17e 100644 --- a/panda/src/egg/eggObject.h +++ b/panda/src/egg/eggObject.h @@ -30,7 +30,7 @@ // (Almost) all things egg inherit from this. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggObject : public TypedReferenceCount { -public: +PUBLISHED: INLINE EggObject(); INLINE EggObject(const EggObject ©); INLINE EggObject &operator = (const EggObject ©); diff --git a/panda/src/egg/eggParameters.h b/panda/src/egg/eggParameters.h index b37c7b54fa..7344f506c3 100644 --- a/panda/src/egg/eggParameters.h +++ b/panda/src/egg/eggParameters.h @@ -19,7 +19,7 @@ #ifndef EGGPARAMETERS_H #define EGGPARAMETERS_H -#include +#include "pandabase.h" /////////////////////////////////////////////////////////////////// // Class : EggParameters diff --git a/panda/src/egg/eggPoint.h b/panda/src/egg/eggPoint.h index 663f6f3d04..2a5b521ffd 100644 --- a/panda/src/egg/eggPoint.h +++ b/panda/src/egg/eggPoint.h @@ -19,7 +19,7 @@ #ifndef EGGPOINT_H #define EGGPOINT_H -#include +#include "pandabase.h" #include "eggPrimitive.h" @@ -29,7 +29,7 @@ // by a single entry. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggPoint : public EggPrimitive { -public: +PUBLISHED: INLINE EggPoint(const string &name = ""); INLINE EggPoint(const EggPoint ©); INLINE EggPoint &operator = (const EggPoint ©); diff --git a/panda/src/egg/eggPolygon.h b/panda/src/egg/eggPolygon.h index 1e64d1bd2f..b690853e3e 100644 --- a/panda/src/egg/eggPolygon.h +++ b/panda/src/egg/eggPolygon.h @@ -19,7 +19,7 @@ #ifndef EGGPOLYGON_H #define EGGPOLYGON_H -#include +#include "pandabase.h" #include "eggPrimitive.h" @@ -28,7 +28,7 @@ // Description : A single polygon. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggPolygon : public EggPrimitive { -public: +PUBLISHED: INLINE EggPolygon(const string &name = ""); INLINE EggPolygon(const EggPolygon ©); INLINE EggPolygon &operator = (const EggPolygon ©); diff --git a/panda/src/egg/eggPolysetMaker.h b/panda/src/egg/eggPolysetMaker.h index 9a4ef7a2d3..123f7794ea 100644 --- a/panda/src/egg/eggPolysetMaker.h +++ b/panda/src/egg/eggPolysetMaker.h @@ -38,7 +38,7 @@ // of this class. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggPolysetMaker : public EggBinMaker { -public: +PUBLISHED: // The BinNumber serves to identify why a particular EggBin was // created. enum BinNumber { diff --git a/panda/src/egg/eggPoolUniquifier.h b/panda/src/egg/eggPoolUniquifier.h index 9888c67ad3..fe41905f6c 100644 --- a/panda/src/egg/eggPoolUniquifier.h +++ b/panda/src/egg/eggPoolUniquifier.h @@ -19,7 +19,7 @@ #ifndef EGGPOOLUNIQUIFIER_H #define EGGPOOLUNIQUIFIER_H -#include +#include "pandabase.h" #include "eggNameUniquifier.h" @@ -32,7 +32,7 @@ // an egg file. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggPoolUniquifier : public EggNameUniquifier { -public: +PUBLISHED: EggPoolUniquifier(); virtual string get_category(EggNode *node); diff --git a/panda/src/egg/eggPrimitive.I b/panda/src/egg/eggPrimitive.I index 06f3d39201..432cf64f8f 100644 --- a/panda/src/egg/eggPrimitive.I +++ b/panda/src/egg/eggPrimitive.I @@ -313,6 +313,16 @@ clear() { erase(begin(), end()); } +//////////////////////////////////////////////////////////////////// +// Function: EggPrimitive::get_num_vertices +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE int EggPrimitive:: +get_num_vertices() const { + return size(); +} + //////////////////////////////////////////////////////////////////// // Function: EggPrimitive::set_vertex // Access: Public diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index 830f986e15..b90033888a 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -22,8 +22,8 @@ #include "eggTextureCollection.h" #include "lexerDefs.h" -#include -#include +#include "indent.h" +#include "vector_int.h" TypeHandle EggPrimitive::_type_handle; @@ -334,7 +334,7 @@ add_vertex(EggVertex *vertex) { //////////////////////////////////////////////////////////////////// // Function: EggPrimitive::remove_vertex // Access: Public -// Description: Removes the indicated vertex vertex from the +// Description: Removes the indicated vertex from the // primitive and returns it. If the vertex was not // already in the primitive, does nothing and returns // NULL. diff --git a/panda/src/egg/eggPrimitive.h b/panda/src/egg/eggPrimitive.h index 3f1e5542e9..211dca0b23 100644 --- a/panda/src/egg/eggPrimitive.h +++ b/panda/src/egg/eggPrimitive.h @@ -19,7 +19,7 @@ #ifndef EGGPRIMITIVE_H #define EGGPRIMITIVE_H -#include +#include "pandabase.h" #include "eggNode.h" #include "eggAttributes.h" @@ -31,7 +31,7 @@ #include "pt_EggMaterial.h" #include "vector_PT_EggVertex.h" -#include +#include "pointerTo.h" #include "pvector.h" class EggVertexPool; @@ -62,7 +62,7 @@ private: // Here begins the actual public interface to EggPrimitive. -public: +PUBLISHED: INLINE EggPrimitive(const string &name = ""); INLINE EggPrimitive(const EggPrimitive ©); INLINE EggPrimitive &operator = (const EggPrimitive ©); @@ -101,7 +101,7 @@ public: // pointers to EggVertex objects. The set of vertices is read-only, // however, except through the limited add_vertex/remove_vertex or // insert/erase interface. The following implements this. - +public: #ifdef WIN32_VC typedef PT_EggVertex *pointer; typedef PT_EggVertex *const_pointer; @@ -131,6 +131,8 @@ public: INLINE iterator erase(iterator position); iterator erase(iterator first, iterator last); INLINE void replace(iterator position, EggVertex *vertex); + +PUBLISHED: INLINE void clear(); EggVertex *add_vertex(EggVertex *vertex); @@ -138,6 +140,7 @@ public: void copy_vertices(const EggPrimitive &other); // These are shorthands if you don't want to use the iterators. + INLINE int get_num_vertices() const; INLINE void set_vertex(int index, EggVertex *vertex); INLINE EggVertex *get_vertex(int index) const; diff --git a/panda/src/egg/eggRenderMode.h b/panda/src/egg/eggRenderMode.h index 678785db3a..94e55818a1 100644 --- a/panda/src/egg/eggRenderMode.h +++ b/panda/src/egg/eggRenderMode.h @@ -38,7 +38,7 @@ // EggObject a virtual base class is just no fun. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggRenderMode { -public: +PUBLISHED: INLINE EggRenderMode(); INLINE EggRenderMode(const EggRenderMode ©); INLINE EggRenderMode &operator = (const EggRenderMode ©); diff --git a/panda/src/egg/eggSAnimData.h b/panda/src/egg/eggSAnimData.h index 4f97b5d7bc..b77c2cde10 100644 --- a/panda/src/egg/eggSAnimData.h +++ b/panda/src/egg/eggSAnimData.h @@ -19,7 +19,7 @@ #ifndef EGGSANIMDATA_H #define EGGSANIMDATA_H -#include +#include "pandabase.h" #include "eggAnimData.h" @@ -30,7 +30,7 @@ // target, or as one column in an EggXfmSAnim. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggSAnimData : public EggAnimData { -public: +PUBLISHED: INLINE EggSAnimData(const string &name = ""); INLINE EggSAnimData(const EggSAnimData ©); INLINE EggSAnimData &operator = (const EggSAnimData ©); diff --git a/panda/src/egg/eggSurface.h b/panda/src/egg/eggSurface.h index ff6c02d76f..4d30fd61af 100644 --- a/panda/src/egg/eggSurface.h +++ b/panda/src/egg/eggSurface.h @@ -19,7 +19,7 @@ #ifndef EGGSURFACE_H #define EGGSURFACE_H -#include +#include "pandabase.h" #include "eggPrimitive.h" @@ -29,7 +29,7 @@ // EggNurbsSurface. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggSurface : public EggPrimitive { -public: +PUBLISHED: INLINE EggSurface(const string &name = ""); INLINE EggSurface(const EggSurface ©); INLINE EggSurface &operator = (const EggSurface ©); diff --git a/panda/src/egg/eggSwitchCondition.h b/panda/src/egg/eggSwitchCondition.h index 59a148d8e4..ef02fb6be2 100644 --- a/panda/src/egg/eggSwitchCondition.h +++ b/panda/src/egg/eggSwitchCondition.h @@ -19,10 +19,10 @@ #ifndef EGGSWITCHCONDITION #define EGGSWITCHCONDITION -#include +#include "pandabase.h" #include "eggObject.h" -#include +#include "luse.h" //////////////////////////////////////////////////////////////////// // Class : EggSwitchCondition @@ -35,7 +35,7 @@ // actually supported. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggSwitchCondition : public EggObject { -public: +PUBLISHED: virtual EggSwitchCondition *make_copy() const=0; virtual void write(ostream &out, int indent_level) const=0; diff --git a/panda/src/egg/eggTable.h b/panda/src/egg/eggTable.h index efb19171eb..10e5edc4c2 100644 --- a/panda/src/egg/eggTable.h +++ b/panda/src/egg/eggTable.h @@ -19,7 +19,7 @@ #ifndef EGGTABLE_H #define EGGTABLE_H -#include +#include "pandabase.h" #include "eggGroupNode.h" @@ -33,7 +33,7 @@ // hierarchy of tables. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggTable : public EggGroupNode { -public: +PUBLISHED: enum TableType { TT_invalid, TT_table, diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index db96d8edae..b400e4aaba 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -19,21 +19,21 @@ #ifndef EGGTEXTURE_H #define EGGTEXTURE_H -#include +#include "pandabase.h" #include "eggRenderMode.h" #include "eggFilenameNode.h" -#include +#include "luse.h" //////////////////////////////////////////////////////////////////// -// Class : EggTexture +// Class : EggTexture // Description : Defines a texture map that may be applied to // geometry. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggTexture : public EggFilenameNode, public EggRenderMode { -public: +PUBLISHED: EggTexture(const string &tref_name, const string &filename); EggTexture(const EggTexture ©); EggTexture &operator = (const EggTexture ©); diff --git a/panda/src/egg/eggTextureCollection.h b/panda/src/egg/eggTextureCollection.h index d081fbe114..6dff2a8563 100644 --- a/panda/src/egg/eggTextureCollection.h +++ b/panda/src/egg/eggTextureCollection.h @@ -19,13 +19,12 @@ #ifndef EGGTEXTURECOLLECTION_H #define EGGTEXTURECOLLECTION_H -#include +#include "pandabase.h" #include "eggTexture.h" #include "eggGroupNode.h" #include "vector_PT_EggTexture.h" -#include #include "pmap.h" //////////////////////////////////////////////////////////////////// @@ -55,7 +54,7 @@ public: // Here begins the actual public interface to EggTextureCollection. -public: +PUBLISHED: EggTextureCollection(); EggTextureCollection(const EggTextureCollection ©); EggTextureCollection &operator = (const EggTextureCollection ©); @@ -64,9 +63,12 @@ public: void clear(); int extract_textures(EggGroupNode *node); + +public: EggGroupNode::iterator insert_textures(EggGroupNode *node); EggGroupNode::iterator insert_textures(EggGroupNode *node, EggGroupNode::iterator position); +PUBLISHED: int find_used_textures(EggNode *node); void remove_unused_textures(EggNode *node); @@ -80,11 +82,13 @@ public: // Can be used to traverse all the textures in the collection, in // order as last sorted. +public: INLINE iterator begin() const; INLINE iterator end() const; INLINE bool empty() const; INLINE size_type size() const; +PUBLISHED: bool add_texture(EggTexture *texture); bool remove_texture(EggTexture *texture); diff --git a/panda/src/egg/eggTransform3d.h b/panda/src/egg/eggTransform3d.h index b4d4127e84..aac8215485 100644 --- a/panda/src/egg/eggTransform3d.h +++ b/panda/src/egg/eggTransform3d.h @@ -31,7 +31,7 @@ // computes a 4x4 matrix. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggTransform3d { -public: +PUBLISHED: EggTransform3d(); EggTransform3d(const EggTransform3d ©); EggTransform3d &operator = (const EggTransform3d ©); diff --git a/panda/src/egg/eggUserData.h b/panda/src/egg/eggUserData.h index db8ec8a5d4..6e0a9bfc9d 100644 --- a/panda/src/egg/eggUserData.h +++ b/panda/src/egg/eggUserData.h @@ -36,7 +36,7 @@ // object only. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggUserData : public TypedReferenceCount { -public: +PUBLISHED: INLINE EggUserData(); INLINE EggUserData(const EggUserData ©); INLINE EggUserData &operator = (const EggUserData ©); diff --git a/panda/src/egg/eggUtilities.h b/panda/src/egg/eggUtilities.h index e94dbb2f34..8ac71fb9da 100644 --- a/panda/src/egg/eggUtilities.h +++ b/panda/src/egg/eggUtilities.h @@ -28,13 +28,13 @@ // //////////////////////////////////////////////////////////////////// -#include +#include "pandabase.h" #include "eggTexture.h" #include "pt_EggTexture.h" -#include -#include +#include "filename.h" +#include "pointerTo.h" #include "pset.h" #include "pmap.h" diff --git a/panda/src/egg/eggVertex.h b/panda/src/egg/eggVertex.h index 13743c623e..dfd69a6730 100644 --- a/panda/src/egg/eggVertex.h +++ b/panda/src/egg/eggVertex.h @@ -19,14 +19,14 @@ #ifndef EGGVERTEX_H #define EGGVERTEX_H -#include +#include "pandabase.h" #include "eggObject.h" #include "eggAttributes.h" #include "eggMorphList.h" -#include -#include +#include "referenceCount.h" +#include "luse.h" #include "pset.h" class EggVertexPool; @@ -44,6 +44,7 @@ public: typedef pset GroupRef; typedef pmultiset PrimitiveRef; +PUBLISHED: EggVertex(); EggVertex(const EggVertex ©); EggVertex &operator = (const EggVertex ©); @@ -84,17 +85,21 @@ public: void transform(const LMatrix4d &mat); +public: GroupRef::const_iterator gref_begin() const; GroupRef::const_iterator gref_end() const; GroupRef::size_type gref_size() const; +PUBLISHED: bool has_gref(const EggGroup *group) const; void copy_grefs_from(const EggVertex &other); void clear_grefs(); +public: PrimitiveRef::const_iterator pref_begin() const; PrimitiveRef::const_iterator pref_end() const; PrimitiveRef::size_type pref_size() const; +PUBLISHED: int has_pref(const EggPrimitive *prim) const; #ifndef NDEBUG diff --git a/panda/src/egg/eggVertexPool.h b/panda/src/egg/eggVertexPool.h index 13d08bf945..6f3fbe2e8c 100644 --- a/panda/src/egg/eggVertexPool.h +++ b/panda/src/egg/eggVertexPool.h @@ -19,17 +19,17 @@ #ifndef EGGVERTEXPOOL_H #define EGGVERTEXPOOL_H -#include +#include "pandabase.h" #include "eggVertex.h" #include "eggNode.h" #include "pt_EggVertex.h" -#include +#include "pointerTo.h" #include "pset.h" #include "pmap.h" -#include -#include +#include "lmatrix.h" +#include "iterator_types.h" //////////////////////////////////////////////////////////////////// // Class : EggVertexPool @@ -72,7 +72,7 @@ public: // Here begins the actual public interface to EggVertexPool. -public: +PUBLISHED: EggVertexPool(const string &name); EggVertexPool(const EggVertexPool ©); ~EggVertexPool(); @@ -84,12 +84,14 @@ public: // Returns 0 if the pool is empty. int get_highest_index() const; +public: // Can be used to traverse all the vertices in index number order. iterator begin() const; iterator end() const; bool empty() const; size_type size() const; +PUBLISHED: // add_vertex() adds a freshly-allocated vertex. It is up to the // user to allocate the vertex. void add_vertex(EggVertex *vertex, int index = -1); diff --git a/panda/src/egg/eggXfmAnimData.h b/panda/src/egg/eggXfmAnimData.h index 6a5e3179ee..fd23b1c455 100644 --- a/panda/src/egg/eggXfmAnimData.h +++ b/panda/src/egg/eggXfmAnimData.h @@ -34,7 +34,7 @@ // currently--it's replaced by EggXfmSAnim. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggXfmAnimData : public EggAnimData { -public: +PUBLISHED: INLINE EggXfmAnimData(const string &name = "", CoordinateSystem cs = CS_default); EggXfmAnimData(const EggXfmSAnim &convert_from); diff --git a/panda/src/egg/eggXfmSAnim.h b/panda/src/egg/eggXfmSAnim.h index f15e7d7f64..7cc6740843 100644 --- a/panda/src/egg/eggXfmSAnim.h +++ b/panda/src/egg/eggXfmSAnim.h @@ -35,7 +35,7 @@ class EggXfmAnimData; // any number of EggSAnimData children. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG EggXfmSAnim : public EggGroupNode { -public: +PUBLISHED: INLINE EggXfmSAnim(const string &name = "", CoordinateSystem cs = CS_default); EggXfmSAnim(const EggXfmAnimData &convert_from); diff --git a/panda/src/egg2pg/Sources.pp b/panda/src/egg2pg/Sources.pp index 75378f0033..134b18fa98 100644 --- a/panda/src/egg2pg/Sources.pp +++ b/panda/src/egg2pg/Sources.pp @@ -42,4 +42,6 @@ #define INSTALL_HEADERS \ load_egg_file.h config_egg2pg.h + #define IGATESCAN load_egg_file.h + #end lib_target diff --git a/panda/src/egg2pg/characterMaker.h b/panda/src/egg2pg/characterMaker.h index a66f74ebaf..fedcacd78a 100644 --- a/panda/src/egg2pg/characterMaker.h +++ b/panda/src/egg2pg/characterMaker.h @@ -36,8 +36,8 @@ class CharacterJointBundle; class Character; class CharacterSlider; class MovingPartBase; -class NamedNode; class EggLoader; +class PandaNode; /////////////////////////////////////////////////////////////////// // Class : CharacterMaker diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index 3209c195a6..4a74ed688d 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -22,7 +22,6 @@ #include "sceneGraphReducer.h" #include "virtualFileSystem.h" #include "config_util.h" -#include "config_express.h" static PT(PandaNode) load_from_loader(EggLoader &loader) { @@ -80,32 +79,18 @@ load_egg_file(const string &filename, CoordinateSystem cs) { EggLoader loader; loader._data.set_egg_filename(egg_filename); loader._data.set_auto_resolve_externals(true); - if (cs != CS_default) { - loader._data.set_coordinate_system(cs); - } + loader._data.set_coordinate_system(cs); + bool okflag; - - if (use_vfs) { - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *istr = vfs->open_read_file(egg_filename); - if (istr == (istream *)NULL) { - egg2pg_cat.error() - << "Could not open " << egg_filename << " for reading.\n"; - return NULL; - } - okflag = loader._data.read(*istr); - delete istr; - - } else { - ifstream file; - - if (!egg_filename.open_read(file)) { - egg2pg_cat.error() - << "Could not open " << egg_filename << " for reading.\n"; - return NULL; - } - okflag = loader._data.read(file); + VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); + istream *istr = vfs->open_read_file(egg_filename); + if (istr == (istream *)NULL) { + egg2pg_cat.error() + << "Could not open " << egg_filename << " for reading.\n"; + return NULL; } + okflag = loader._data.read(*istr); + delete istr; if (!okflag) { egg2pg_cat.error() @@ -124,7 +109,7 @@ load_egg_file(const string &filename, CoordinateSystem cs) { // loading. //////////////////////////////////////////////////////////////////// PT(PandaNode) -load_egg_data(EggData &data) { +load_egg_data(EggData &data, CoordinateSystem cs) { // We temporarily shuttle the children to a holding node so we can // copy them into the EggLoader's structure without it complaining. EggGroupNode children_holder; @@ -133,5 +118,8 @@ load_egg_data(EggData &data) { EggLoader loader(data); loader._data.steal_children(children_holder); + loader._data.set_auto_resolve_externals(true); + loader._data.set_coordinate_system(cs); + return load_from_loader(loader); } diff --git a/panda/src/egg2pg/load_egg_file.h b/panda/src/egg2pg/load_egg_file.h index 372a601613..8addf19f05 100644 --- a/panda/src/egg2pg/load_egg_file.h +++ b/panda/src/egg2pg/load_egg_file.h @@ -26,6 +26,7 @@ class EggData; +BEGIN_PUBLISH //////////////////////////////////////////////////////////////////// // Function: load_egg_file // Description: A convenience function; the primary interface to this @@ -47,6 +48,7 @@ load_egg_file(const string &filename, CoordinateSystem cs = CS_default); // loading. //////////////////////////////////////////////////////////////////// EXPCL_PANDAEGG PT(PandaNode) -load_egg_data(EggData &data); +load_egg_data(EggData &data, CoordinateSystem cs = CS_default); +END_PUBLISH #endif