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
51 save_egg_data(EggData *data, PandaNode *node) {
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 }
EggData
This is the primary interface into all the egg data, and the root of the egg file structure.
Definition: eggData.h:37
EggSaver
Converts the scene graph beginning at the indicated node into an EggData structure,...
Definition: eggSaver.h:53
EggSaver::add_node
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
EggSaver::add_subgraph
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
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
TypedObject::is_of_type
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
config_egg2pg.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
config_putil.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggSaver.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
modelRoot.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
save_egg_data
bool save_egg_data(EggData *data, PandaNode *node)
Another convenience function; works like save_egg_file() but populates an EggData instead of writing ...
Definition: save_egg_file.cxx:51
save_egg_file
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.
Definition: save_egg_file.cxx:27
save_egg_file.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
sceneGraphReducer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtualFileSystem.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.