Panda3D
save_egg_file.cxx
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 save_egg_file.cxx
10  * @author drose
11  * @date 2002-02-26
12  */
13 
14 #include "save_egg_file.h"
15 #include "eggSaver.h"
16 #include "config_egg2pg.h"
17 #include "modelRoot.h"
18 #include "sceneGraphReducer.h"
19 #include "virtualFileSystem.h"
20 #include "config_putil.h"
21 
22 /**
23  * A convenience function; converts the indicated scene graph to an egg file
24  * and writes it to disk.
25  */
26 bool
27 save_egg_file(const Filename &filename, PandaNode *node, CoordinateSystem cs) {
28  PT(EggData) data = new EggData;
29  if (cs == CS_default) {
30  cs = get_default_coordinate_system();
31  }
32  data->set_coordinate_system(cs);
33 
34  EggSaver saver(data);
35  if (node->is_of_type(ModelRoot::get_class_type())) {
36  // If this is a ModelRoot, only write the nodes below it. Otherwise we
37  // end up inserting a node when we do a bam2egg.
38  saver.add_subgraph(node);
39  } else {
40  saver.add_node(node);
41  }
42 
43  return data->write_egg(filename);
44 }
45 
46 /**
47  * Another convenience function; works like save_egg_file() but populates an
48  * EggData instead of writing the results to disk.
49  */
50 bool
52  EggSaver saver(data);
53  if (node->is_of_type(ModelRoot::get_class_type())) {
54  // If this is a ModelRoot, only write the nodes below it. Otherwise we
55  // end up inserting a node when we do a bam2egg.
56  saver.add_subgraph(node);
57  } else {
58  saver.add_node(node);
59  }
60  return true;
61 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool save_egg_file(const Filename &filename, PandaNode *node, CoordinateSystem cs)
A convenience function; converts the indicated scene graph to an egg file and writes it to disk.
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
Converts the scene graph beginning at the indicated node into an EggData structure,...
Definition: eggSaver.h:53
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool save_egg_data(EggData *data, PandaNode *node)
Another convenience function; works like save_egg_file() but populates an EggData instead of writing ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
void add_subgraph(PandaNode *root)
Adds the scene graph rooted at the indicated node (but without the node itself) to the accumulated eg...
Definition: eggSaver.cxx:117
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
void add_node(PandaNode *node)
Adds the scene graph rooted at the indicated node to the accumulated egg data within this object.
Definition: eggSaver.cxx:97