32 extern int eggyyparse();
54 return vfs->
exists(egg_filename);
69 if (display_name.empty()) {
70 display_name = filename;
76 if (vfile ==
nullptr) {
77 egg_cat.error() <<
"Could not find " << display_name <<
"\n";
82 istream *file = vfile->open_read_file(
true);
83 if (file ==
nullptr) {
84 egg_cat.error() <<
"Unable to open " << display_name <<
"\n";
89 <<
"Reading " << display_name <<
"\n";
91 bool read_ok =
read(*file);
92 vfile->close_read_file(file);
122 egg_cleanup_parser();
123 error_count = egg_error_count();
131 return (error_count == 0);
217 if (file ==
nullptr) {
218 egg_cat.error() <<
"Unable to open " << filename <<
" for writing.\n";
234 if (egg_precision > 0) {
236 std::streamsize orig_precision = out.precision();
237 out.precision((std::streamsize)egg_precision);
239 out.precision(orig_precision);
254 if (new_coordsys == CS_default) {
255 new_coordsys = get_default_coordinate_system();
257 if (new_coordsys != _coordsys &&
258 (_coordsys != CS_default && _coordsys != CS_invalid)) {
260 LMatrix4d mat = LMatrix4d::convert_mat(_coordsys, new_coordsys);
261 LMatrix4d inv = LMatrix4d::convert_mat(new_coordsys, _coordsys);
263 r_transform(mat, inv, new_coordsys);
264 r_transform_vertices(mat);
271 _coordsys = new_coordsys;
278 write(ostream &out,
int indent_level)
const {
280 ecs->write(out, indent_level);
292 CoordinateSystem old_coordsys = _coordsys;
293 _coordsys = find_coordsys_entry();
295 if (_coordsys == CS_default) {
298 _coordsys = CS_yup_right;
300 }
else if (_coordsys == CS_invalid) {
302 <<
"Contradictory <CoordinateSystem> entries encountered.\n";
303 _coordsys = CS_yup_right;
306 r_mark_coordsys(_coordsys);
308 if (old_coordsys != CS_default) {
359 iterator ci = begin();
360 while (ci != end() && (*ci)->is_of_type(EggComment::get_class_type())) {
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.
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.
The <CoordinateSystem> entry at the top of an egg file.
This is the primary interface into all the egg data, and the root of the egg file structure.
bool write_egg(Filename filename)
The main interface for writing complete egg files.
get_auto_resolve_externals
Indicates whether the EggData object will automatically resolve any external references when read() i...
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...
set_egg_timestamp
Sets the timestamp of the egg file on disk, at the time it was opened for reading.
get_coordinate_system
Returns the coordinate system in which the egg file is defined.
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...
set_coordinate_system
Changes the coordinate system of the EggData.
int collapse_equivalent_materials()
Removes duplicate references to the same material with the same properties.
int collapse_equivalent_textures()
Removes duplicate references to the same texture image with the same properties.
set_egg_filename
Sets the filename–especially the directory part–in which the egg file is considered to reside.
void merge(EggData &other)
Appends the other egg structure to the end of this one.
get_egg_filename
Returns the directory in which the egg file is considered to reside.
bool read(Filename filename, std::string display_name=std::string())
Opens the indicated filename and reads the egg data contents from it.
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.
void resolve_filenames(const DSearchPath &searchpath)
Walks the tree and attempts to resolve any filenames encountered.
bool has_absolute_pathnames() const
Returns true if any nodes at this level and below include a reference to a file via an absolute pathn...
void steal_children(EggGroupNode &other)
Moves all the children from the other node to this one.
This is a collection of materials by MRef name.
void uniquify_mrefs()
Guarantees that each material in the collection has a unique MRef name.
int find_used_materials(EggNode *node)
Walks the egg hierarchy beginning at the indicated node, looking for materials that are referenced by...
int collapse_equivalent_materials(int eq, EggGroupNode *node)
Walks through the collection and collapses together any separate materials that are equivalent accord...
int extract_materials(EggGroupNode *node)
Walks the egg hierarchy beginning at the indicated node, and removes any EggMaterials encountered in ...
EggGroupNode::iterator insert_materials(EggGroupNode *node)
Adds a series of EggMaterial nodes to the beginning of the indicated node to reflect each of the mate...
void sort_by_mref()
Sorts all the materials into alphabetical order by MRef name.
void remove_unused_materials(EggNode *node)
Removes any materials from the collection that aren't referenced by any primitives in the indicated e...
void uniquify(EggNode *node)
Begins the traversal from the indicated node.
This is a specialization of EggNameUniquifier to generate unique names for textures,...
This is a collection of textures by TRef name.
void sort_by_tref()
Sorts all the textures into alphabetical order by TRef name.
int find_used_textures(EggNode *node)
Walks the egg hierarchy beginning at the indicated node, looking for textures that are referenced by ...
int collapse_equivalent_textures(int eq, EggGroupNode *node)
Walks through the collection and collapses together any separate textures that are equivalent accordi...
int extract_textures(EggGroupNode *node)
Walks the egg hierarchy beginning at the indicated node, and removes any EggTextures encountered in t...
void uniquify_trefs()
Guarantees that each texture in the collection has a unique TRef name.
EggGroupNode::iterator insert_textures(EggGroupNode *node)
Adds a series of EggTexture nodes to the beginning of the indicated node to reflect each of the textu...
void remove_unused_textures(EggNode *node)
Removes any textures from the collection that aren't referenced by any primitives in the indicated eg...
The name of a file, such as a texture file or an Egg file.
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
void set_text()
Indicates that the filename represents a text file.
Similar to MutexHolder, but for a light mutex.
TypeHandle is the identifier used to differentiate C++ class types.
A hierarchy of directories and files that appears to be one continuous file system,...
static void close_write_file(std::ostream *stream)
Closes a file opened by a previous call to open_write_file().
bool exists(const Filename &filename) const
Convenience function; returns true if the named file exists.
bool resolve_filename(Filename &filename, const DSearchPath &searchpath, const std::string &default_extension=std::string()) const
Searches the given search path for the filename.
std::ostream * open_write_file(const Filename &filename, bool auto_wrap, bool truncate)
Convenience function; returns a newly allocated ostream if the file exists and can be written,...
PointerTo< VirtualFile > get_file(const Filename &filename, bool status_only=false) const
Looks up the file by the indicated name in the file system.
bool delete_file(const Filename &filename)
Attempts to delete the indicated file or directory.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
The abstract base class for a file or directory within the VirtualFileSystem.
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.
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.