Panda3D
 All Classes Functions Variables Enumerations
eggSaver.h
1 // Filename: eggSaver.h
2 // Created by: drose (19Dec12)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGSAVER_H
16 #define EGGSAVER_H
17 
18 #include "pandabase.h"
19 
20 #include "luse.h"
21 #include "eggData.h"
22 #include "eggTextureCollection.h"
23 #include "eggMaterialCollection.h"
24 
25 class WorkingNodePath;
26 class EggGroup;
27 class EggGroupNode;
28 class EggVertexPool;
29 class EggTexture;
30 class LODNode;
31 class SequenceNode;
32 class SwitchNode;
33 class AnimBundleNode;
34 class AnimGroup;
35 class Character;
36 class PartGroup;
37 class CollisionNode;
38 class GeomNode;
39 class GeomVertexData;
40 class GeomPrimitive;
41 class PandaNode;
42 class RenderState;
43 class Material;
44 class Texture;
45 class CharacterJoint;
46 class EggVertex;
47 
48 ////////////////////////////////////////////////////////////////////
49 // Class : EggSaver
50 // Description : Converts the scene graph beginning at the indicated
51 // node into an EggData structure, for writing to an egg
52 // file. The conversion is not necessarily complete
53 // (some Panda or egg constructs are not fully supported
54 // by this class).
55 ////////////////////////////////////////////////////////////////////
56 class EggSaver {
57 PUBLISHED:
58  EggSaver(EggData *data = NULL);
59 
60  void add_node(PandaNode *node);
61  INLINE EggData *get_egg_data() const;
62 
63 private:
65 
66  void convert_node(const WorkingNodePath &node_path, EggGroupNode *egg_parent,
67  bool has_decal);
68  void convert_lod_node(LODNode *node, const WorkingNodePath &node_path,
69  EggGroupNode *egg_parent, bool has_decal);
70  void convert_sequence_node(SequenceNode *node, const WorkingNodePath &node_path,
71  EggGroupNode *egg_parent, bool has_decal);
72  void convert_switch_node(SwitchNode *node, const WorkingNodePath &node_path,
73  EggGroupNode *egg_parent, bool has_decal);
74  EggGroupNode *convert_animGroup_node(AnimGroup *animGroup, double fps );
75  void convert_anim_node(AnimBundleNode *node, const WorkingNodePath &node_path,
76  EggGroupNode *egg_parent, bool has_decal);
77  void convert_character_node(Character *node, const WorkingNodePath &node_path,
78  EggGroupNode *egg_parent, bool has_decal);
79  void convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, CharacterJointMap *jointMap);
80  void convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path,
81  EggGroupNode *egg_parent, bool has_decal);
82  void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path,
83  EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=NULL);
84  void convert_primitive(const GeomVertexData *vertex_data,
85  const GeomPrimitive *primitive,
86  const RenderState *net_state,
87  const LMatrix4 &net_mat, EggGroupNode *egg_parent,
88  CharacterJointMap *jointMap);
89 
90  void recurse_nodes(const WorkingNodePath &node_path, EggGroupNode *egg_parent,
91  bool has_decal);
92  bool apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage = true);
93  bool apply_tags(EggGroup *egg_group, PandaNode *node);
94  bool apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag);
95 
96  EggMaterial *get_egg_material(Material *tex);
97  EggTexture *get_egg_texture(Texture *tex);
98 
99  static EggPrimitive *make_egg_polygon();
100  static EggPrimitive *make_egg_patch();
101  static EggPrimitive *make_egg_point();
102  static EggPrimitive *make_egg_line();
103 
104  PT(EggData) _data;
105 
106  PT(EggVertexPool) _vpool;
107  EggMaterialCollection _materials;
108  EggTextureCollection _textures;
109 };
110 
111 #include "eggSaver.I"
112 
113 #endif
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
EggData * get_egg_data() const
Returns the EggData populated within this class.
Definition: eggSaver.I:22
An animated character, with skeleton-morph animation and either soft-skinned or hard-skinned vertices...
Definition: character.h:41
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
This is a collection of materials by MRef name.
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:33
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:63
A node that automatically cycles through rendering each one of its children according to its frame ra...
Definition: sequenceNode.h:29
This is a collection of textures by TRef name.
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
This is a class designed to support low-overhead traversals of the complete scene graph...
Converts the scene graph beginning at the indicated node into an EggData structure, for writing to an egg file.
Definition: eggSaver.h:56
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:36
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
A Level-of-Detail node.
Definition: lodNode.h:31
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
Definition: eggVertex.h:41
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
Defines the way an object appears in the presence of lighting.
Definition: material.h:34
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This represents one joint of the character's animation, containing an animating transform matrix...
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:33
This is a node that contains a pointer to an AnimBundle.
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:96
A collection of vertices.
Definition: eggVertexPool.h:46
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37
A node that renders only one of its children, according to the user's indication. ...
Definition: switchNode.h:27
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:45