Panda3D
 All Classes Functions Variables Enumerations
eggData.h
1 // Filename: eggData.h
2 // Created by: drose (20Jan99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGDATA_H
16 #define EGGDATA_H
17 
18 #include "pandabase.h"
19 
20 #include "eggGroupNode.h"
21 #include "filename.h"
22 #include "coordinateSystem.h"
23 #include "pnotify.h"
24 #include "dSearchPath.h"
25 
26 class BamCacheRecord;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : EggData
30 // Description : This is the primary interface into all the egg data,
31 // and the root of the egg file structure. An EggData
32 // structure corresponds exactly with an egg file on the
33 // disk.
34 //
35 // The EggData class inherits from EggGroupNode its
36 // collection of children, which are accessed by using
37 // the EggData itself as an STL container with begin()
38 // and end() calls. The children of the EggData class
39 // are the toplevel nodes in the egg file.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDAEGG EggData : public EggGroupNode {
42 PUBLISHED:
43  INLINE EggData();
44  INLINE EggData(const EggData &copy);
45  INLINE EggData &operator = (const EggData &copy);
46 
47  static bool resolve_egg_filename(Filename &egg_filename,
48  const DSearchPath &searchpath = DSearchPath());
49 
50  bool read(Filename filename, string display_name = string());
51  bool read(istream &in);
52  void merge(EggData &other);
53 
54  bool load_externals(const DSearchPath &searchpath = DSearchPath());
55  bool load_externals(const DSearchPath &searchpath, BamCacheRecord *record);
56  int collapse_equivalent_textures();
57  int collapse_equivalent_materials();
58 
59  bool write_egg(Filename filename);
60  bool write_egg(ostream &out);
61 
62  INLINE void set_auto_resolve_externals(bool resolve);
63  INLINE bool get_auto_resolve_externals() const;
64  INLINE bool original_had_absolute_pathnames() const;
65 
66  void set_coordinate_system(CoordinateSystem coordsys);
67  INLINE CoordinateSystem get_coordinate_system() const;
68 
69  INLINE void set_egg_filename(const Filename &egg_filename);
70  INLINE const Filename &get_egg_filename() const;
71 
72  INLINE void set_egg_timestamp(time_t egg_timestamp);
73  INLINE time_t get_egg_timestamp() const;
74 
75  INLINE void recompute_vertex_normals(double threshold);
76  INLINE void recompute_polygon_normals();
77  INLINE void strip_normals();
78 
79 protected:
80  virtual void write(ostream &out, int indent_level = 0) const;
81 
82 private:
83  void post_read();
84  void pre_write();
85 
86  bool _auto_resolve_externals;
87  bool _had_absolute_pathnames;
88  CoordinateSystem _coordsys;
89  Filename _egg_filename;
90  time_t _egg_timestamp;
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  EggGroupNode::init_type();
98  register_type(_type_handle, "EggData",
99  EggGroupNode::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105 
106 private:
107  static TypeHandle _type_handle;
108 };
109 
110 #include "eggData.I"
111 
112 #endif
void strip_normals()
Removes all normals from primitives, and the vertices they reference, at this node and below...
virtual void write(ostream &out, int indent_level) const
Writes the group and all of its children to the indicated output stream in Egg format.
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
void recompute_polygon_normals(CoordinateSystem cs=CS_default)
Recomputes all the polygon normals for polygon geometry at this group node and below so that they acc...
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This class stores a list of directories that can be searched, in order, to locate a particular file...
Definition: dSearchPath.h:32
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void recompute_vertex_normals(double threshold, CoordinateSystem cs=CS_default)
Recomputes all the vertex normals for polygon geometry at this group node and below so that they accu...