Panda3D

Loading...
Searching...
No Matches
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 {
38PUBLISHED:
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
BamCacheRecord
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
Definition bamCacheRecord.h:36
DSearchPath
This class stores a list of directories that can be searched, in order, to locate a particular file.
Definition dSearchPath.h:28
EggData::write_egg
bool write_egg(Filename filename)
The main interface for writing complete egg files.
Definition eggData.cxx:212
EggData::original_had_absolute_pathnames
bool original_had_absolute_pathnames() const
Returns true if the data processed in the last call to read() contained absolute pathnames,...
Definition eggData.I:82
EggData::get_auto_resolve_externals
get_auto_resolve_externals
Indicates whether the EggData object will automatically resolve any external references when read() i...
Definition eggData.h:72
EggData::resolve_egg_filename
static bool resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath=DSearchPath())
Looks for the indicated filename, first along the indicated searchpath, and then along the model_path...
Definition eggData.cxx:44
EggData::set_egg_timestamp
set_egg_timestamp
Sets the timestamp of the egg file on disk, at the time it was opened for reading.
Definition eggData.h:75
EggData::get_coordinate_system
get_coordinate_system
Returns the coordinate system in which the egg file is defined.
Definition eggData.h:73
EggData::get_egg_timestamp
get_egg_timestamp
Returns the timestamp of the egg file on disk, at the time it was opened for reading,...
Definition eggData.h:75
EggData::set_auto_resolve_externals
set_auto_resolve_externals
Indicates whether the EggData object will automatically resolve any external references when read() i...
Definition eggData.h:72
EggData::load_externals
bool load_externals(const DSearchPath &searchpath=DSearchPath())
Loads up all the egg files referenced by <File> entries within the egg structure, and inserts their c...
Definition eggData.cxx:162
EggData::set_coordinate_system
set_coordinate_system
Changes the coordinate system of the EggData.
Definition eggData.h:73
EggData::collapse_equivalent_materials
int collapse_equivalent_materials()
Removes duplicate references to the same material with the same properties.
Definition eggData.cxx:201
EggData::collapse_equivalent_textures
int collapse_equivalent_textures()
Removes duplicate references to the same texture image with the same properties.
Definition eggData.cxx:187
EggData::set_egg_filename
set_egg_filename
Sets the filename–especially the directory part–in which the egg file is considered to reside.
Definition eggData.h:74
EggData::merge
void merge(EggData &other)
Appends the other egg structure to the end of this one.
Definition eggData.cxx:139
EggData::get_egg_filename
get_egg_filename
Returns the directory in which the egg file is considered to reside.
Definition eggData.h:74
EggData::read
bool read(Filename filename, std::string display_name=std::string())
Opens the indicated filename and reads the egg data contents from it.
Definition eggData.cxx:65
EggGroupNode::write
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.
Definition eggGroupNode.cxx:84
EggGroupNode::strip_normals
void strip_normals()
Removes all normals from primitives, and the vertices they reference, at this node and below.
Definition eggGroupNode.cxx:592
EggGroupNode::recompute_polygon_normals
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...
Definition eggGroupNode.cxx:541
EggGroupNode::recompute_vertex_normals
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...
Definition eggGroupNode.cxx:475
Filename
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
coordinateSystem.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dSearchPath.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggData.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggGroupNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
filename.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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