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