00001 // Filename: eggData.h 00002 // Created by: drose (20Jan99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef EGGDATA_H 00020 #define EGGDATA_H 00021 00022 #include <pandabase.h> 00023 00024 #include "eggGroupNode.h" 00025 #include <filename.h> 00026 #include <coordinateSystem.h> 00027 #include <notify.h> 00028 #include <dSearchPath.h> 00029 00030 #include <string> 00031 00032 00033 /////////////////////////////////////////////////////////////////// 00034 // Class : EggData 00035 // Description : This is the primary interface into all the egg data, 00036 // and the root of the egg file structure. An EggData 00037 // structure corresponds exactly with an egg file on the 00038 // disk. 00039 // 00040 // The EggData class inherits from EggGroupNode its 00041 // collection of children, which are accessed by using 00042 // the EggData itself as an STL container with begin() 00043 // and end() calls. The children of the EggData class 00044 // are the toplevel nodes in the egg file. 00045 //////////////////////////////////////////////////////////////////// 00046 class EXPCL_PANDAEGG EggData : public EggGroupNode { 00047 public: 00048 INLINE EggData(); 00049 INLINE EggData(const EggData ©); 00050 INLINE EggData &operator = (const EggData ©); 00051 00052 static bool resolve_egg_filename(Filename &egg_filename, 00053 const DSearchPath &searchpath = DSearchPath()); 00054 00055 bool read(Filename filename); 00056 bool read(istream &in); 00057 void merge(EggData &other); 00058 00059 bool load_externals(const DSearchPath &searchpath = DSearchPath()); 00060 int collapse_equivalent_textures(); 00061 int collapse_equivalent_materials(); 00062 00063 bool write_egg(Filename filename); 00064 bool write_egg(ostream &out); 00065 00066 INLINE void set_auto_resolve_externals(bool resolve); 00067 INLINE bool get_auto_resolve_externals() const; 00068 00069 void set_coordinate_system(CoordinateSystem coordsys); 00070 INLINE CoordinateSystem get_coordinate_system() const; 00071 00072 INLINE void set_egg_filename(const Filename &egg_filenamea); 00073 INLINE const Filename &get_egg_filename() const; 00074 00075 INLINE void recompute_vertex_normals(double threshold); 00076 INLINE void recompute_polygon_normals(); 00077 INLINE void strip_normals(); 00078 00079 protected: 00080 virtual void write(ostream &out, int indent_level = 0) const; 00081 00082 private: 00083 void post_read(); 00084 void pre_write(); 00085 00086 bool _auto_resolve_externals; 00087 CoordinateSystem _coordsys; 00088 Filename _egg_filename; 00089 00090 public: 00091 static TypeHandle get_class_type() { 00092 return _type_handle; 00093 } 00094 static void init_type() { 00095 EggGroupNode::init_type(); 00096 register_type(_type_handle, "EggData", 00097 EggGroupNode::get_class_type()); 00098 } 00099 virtual TypeHandle get_type() const { 00100 return get_class_type(); 00101 } 00102 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00103 00104 private: 00105 static TypeHandle _type_handle; 00106 }; 00107 00108 #include "eggData.I" 00109 00110 #endif