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