Panda3D
|
This is the primary interface into all the egg data, and the root of the egg file structure. More...
#include "eggData.h"
Public Member Functions | |
EggData (const 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. | |
virtual TypeHandle | force_init_type () |
bool | get_auto_resolve_externals () const |
Indicates whether the EggData object will automatically resolve any external references when read() is called. | |
CoordinateSystem | get_coordinate_system () const |
Returns the coordinate system in which the egg file is defined. | |
const Filename & | get_egg_filename () const |
Returns the directory in which the egg file is considered to reside. | |
virtual TypeHandle | get_type () const |
bool | load_externals (const DSearchPath &searchpath=DSearchPath()) |
Loads up all the egg files referenced by <File> entries within the egg structure, and inserts their contents in place of the <File> entries. | |
bool | load_externals (const DSearchPath &searchpath, BamCacheRecord *record) |
Loads up all the egg files referenced by <File> entries within the egg structure, and inserts their contents in place of the <File> entries. | |
void | merge (EggData &other) |
Appends the other egg structure to the end of this one. | |
EggData & | operator= (const EggData ©) |
bool | original_had_absolute_pathnames () const |
Returns true if the data processed in the last call to read() contained absolute pathnames, or false if those pathnames were all relative. | |
bool | read (Filename filename, string display_name=string()) |
Opens the indicated filename and reads the egg data contents from it. | |
bool | read (istream &in) |
Parses the egg syntax contained in the indicated input stream. | |
void | recompute_polygon_normals () |
Recomputes all the polygon normals for polygon geometry at this group node and below so that they accurately reflect the vertex positions. | |
void | recompute_vertex_normals (double threshold) |
Recomputes all the vertex normals for polygon geometry at this group node and below so that they accurately reflect the vertex positions. | |
void | set_auto_resolve_externals (bool resolve) |
Indicates whether the EggData object will automatically resolve any external references when read() is called. | |
void | set_coordinate_system (CoordinateSystem coordsys) |
Changes the coordinate system of the EggData. | |
void | set_egg_filename (const Filename &egg_filename) |
Sets the filename--especially the directory part--in which the egg file is considered to reside. | |
void | strip_normals () |
Removes all normals from primitives, and the vertices they reference, at this node and below. | |
bool | write_egg (Filename filename) |
The main interface for writing complete egg files. | |
bool | write_egg (ostream &out) |
The main interface for writing complete egg files. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
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. | |
Protected Member Functions | |
virtual void | write (ostream &out, int indent_level=0) const |
Writes the egg data out to the indicated output stream. |
This is the primary interface into all the egg data, and the root of the egg file structure.
An EggData structure corresponds exactly with an egg file on the disk.
The EggData class inherits from EggGroupNode its collection of children, which are accessed by using the EggData itself as an STL container with begin() and end() calls. The children of the EggData class are the toplevel nodes in the egg file.
Removes duplicate references to the same material with the same properties.
Considers two material references with identical properties, but different mref names, to be equivalent, and collapses them, choosing one mref name to keep arbitrarily. Returns the number of materials removed.
Definition at line 223 of file eggData.cxx.
References EggMaterialCollection::collapse_equivalent_materials(), and EggMaterialCollection::find_used_materials().
Removes duplicate references to the same texture image with the same properties.
Considers two texture references with identical properties, but different tref names, to be equivalent, and collapses them, choosing one tref name to keep arbitrarily. Returns the number of textures removed.
Definition at line 205 of file eggData.cxx.
References EggTextureCollection::collapse_equivalent_textures(), and EggTextureCollection::find_used_textures().
bool EggData::get_auto_resolve_externals | ( | ) | const [inline] |
CoordinateSystem EggData::get_coordinate_system | ( | ) | const [inline] |
Returns the coordinate system in which the egg file is defined.
Definition at line 108 of file eggData.I.
Referenced by MaxNodeTree::get_egg_table(), SoftNodeTree::get_egg_table(), MayaNodeTree::get_egg_table(), load_externals(), and merge().
const Filename & EggData::get_egg_filename | ( | ) | const [inline] |
Returns the directory in which the egg file is considered to reside.
Definition at line 132 of file eggData.I.
Referenced by EggCharacterCollection::check_errors(), EggCharacterFilter::post_command_line(), read(), and EggMultiFilter::write_eggs().
static void EggData::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from EggGroupNode.
Definition at line 92 of file eggData.h.
References EggGroupNode::init_type().
bool EggData::load_externals | ( | const DSearchPath & | searchpath = DSearchPath() | ) |
Loads up all the egg files referenced by <File> entries within the egg structure, and inserts their contents in place of the <File> entries.
Searches for files in the searchpath, if not found directly, and writes error messages to the indicated output stream. Returns true if all externals were loaded successfully, false otherwise.
Definition at line 172 of file eggData.cxx.
References get_coordinate_system(), and EggGroupNode::r_load_externals().
Referenced by EggReader::handle_args(), and EggGroupNode::r_load_externals().
bool EggData::load_externals | ( | const DSearchPath & | searchpath, |
BamCacheRecord * | record | ||
) |
Loads up all the egg files referenced by <File> entries within the egg structure, and inserts their contents in place of the <File> entries.
Searches for files in the searchpath, if not found directly, and writes error messages to the indicated output stream. Returns true if all externals were loaded successfully, false otherwise.
Definition at line 189 of file eggData.cxx.
References get_coordinate_system(), and EggGroupNode::r_load_externals().
void EggData::merge | ( | EggData & | other | ) |
Appends the other egg structure to the end of this one.
The other egg structure is invalidated.
Definition at line 145 of file eggData.cxx.
References get_coordinate_system(), set_coordinate_system(), and EggGroupNode::steal_children().
bool EggData::original_had_absolute_pathnames | ( | ) | const [inline] |
Returns true if the data processed in the last call to read() contained absolute pathnames, or false if those pathnames were all relative.
This method is necessary because if auto_resolve_externals() is in effect, it may modify the pathnames to be absolute whether or not they were as loaded from disk. This method can be used to query the state of the original egg file from disk.
Definition at line 97 of file eggData.I.
Referenced by EggReader::handle_args().
bool EggData::read | ( | Filename | filename, |
string | display_name = string() |
||
) |
Opens the indicated filename and reads the egg data contents from it.
Returns true if the file was successfully opened and read, false if there were some errors, in which case the data may be partially read.
error is the output stream to which to write error messages.
Definition at line 71 of file eggData.cxx.
References VirtualFileSystem::close_read_file(), VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), set_egg_filename(), and Filename::set_text().
Referenced by EggReader::handle_args(), and EggGroupNode::r_load_externals().
bool EggData::read | ( | istream & | in | ) |
Parses the egg syntax contained in the indicated input stream.
Returns true if the stream was a completely valid egg file, false if there were some errors, in which case the data may be partially read.
Before you call this routine, you should probably call set_egg_filename() to set the name of the egg file we're processing, if at all possible. If there is no such filename, you may set it to the empty string.
Definition at line 111 of file eggData.cxx.
References get_egg_filename(), and EggGroupNode::steal_children().
void EggData::recompute_polygon_normals | ( | ) | [inline] |
Recomputes all the polygon normals for polygon geometry at this group node and below so that they accurately reflect the vertex positions.
Normals are removed from the vertices and defined only on polygons, giving the geometry a faceted appearance.
This function also removes degenerate polygons that do not have enough vertices to define a normal. It does not affect normals for other kinds of primitives like Nurbs or Points.
This function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the normals removed. Thus, it is a good idea to call remove_unused_vertices() after calling this.
void EggData::recompute_vertex_normals | ( | double | threshold | ) | [inline] |
Recomputes all the vertex normals for polygon geometry at this group node and below so that they accurately reflect the vertex positions.
A shared edge between two polygons (even in different groups) is considered smooth if the angle between the two edges is less than threshold degrees.
This function also removes degenerate polygons that do not have enough vertices to define a normal. It does not affect normals for other kinds of primitives like Nurbs or Points.
This function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the correct normals. Thus, it is a good idea to call remove_unused_vertices() after calling this.
bool EggData::resolve_egg_filename | ( | Filename & | egg_filename, |
const DSearchPath & | searchpath = DSearchPath() |
||
) | [static] |
Looks for the indicated filename, first along the indicated searchpath, and then along the model_path.
If found, updates the filename to the full path and returns true; otherwise, returns false.
Definition at line 45 of file eggData.cxx.
References VirtualFileSystem::exists(), VirtualFileSystem::get_global_ptr(), Filename::is_fully_qualified(), and VirtualFileSystem::resolve_filename().
Referenced by EggGroupNode::r_load_externals().
void EggData::set_auto_resolve_externals | ( | bool | resolve | ) | [inline] |
Indicates whether the EggData object will automatically resolve any external references when read() is called.
The default is false.
Definition at line 67 of file eggData.I.
Referenced by EggGroupNode::r_load_externals().
void EggData::set_coordinate_system | ( | CoordinateSystem | new_coordsys | ) |
Changes the coordinate system of the EggData.
If the coordinate system was previously different, this may result in a conversion of the data.
Definition at line 272 of file eggData.cxx.
References LMatrix4d::convert_mat(), EggGroupNode::r_transform(), EggGroupNode::r_transform_vertices(), and EggGroupNode::update_under().
Referenced by MaxToEggConverter::convert(), SomethingToEggConverter::handle_external_reference(), merge(), EggMultiFilter::post_command_line(), and EggGroupNode::r_load_externals().
void EggData::set_egg_filename | ( | const Filename & | egg_filename | ) | [inline] |
void EggData::strip_normals | ( | ) | [inline] |
Removes all normals from primitives, and the vertices they reference, at this node and below.
This function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the normal removed. Thus, it is a good idea to call remove_unused_vertices() after calling this.
Reimplemented from EggGroupNode.
void EggData::write | ( | ostream & | out, |
int | indent_level = 0 |
||
) | const [protected, virtual] |
Writes the egg data out to the indicated output stream.
Reimplemented from EggGroupNode.
Definition at line 300 of file eggData.cxx.
Referenced by write_egg().
bool EggData::write_egg | ( | Filename | filename | ) |
The main interface for writing complete egg files.
Definition at line 236 of file eggData.cxx.
References VirtualFileSystem::close_write_file(), VirtualFileSystem::delete_file(), VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_write_file(), and Filename::set_text().
Referenced by EggMultiFilter::write_eggs().
bool EggData::write_egg | ( | ostream & | out | ) |
The main interface for writing complete egg files.
Definition at line 257 of file eggData.cxx.
References write().