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_collision_node(CollisionNode *node, const WorkingNodePath &node_path,
82  EggGroupNode *egg_parent, bool has_decal,
83  CharacterJointMap *joint_map);
84  void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path,
85  EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=nullptr);
86  void convert_primitive(const GeomVertexData *vertex_data,
87  const GeomPrimitive *primitive,
88  const RenderState *geom_state,
89  const RenderState *net_state,
90  const LMatrix4 &net_mat, EggGroupNode *egg_parent,
91  CharacterJointMap *jointMap);
92 
93  void recurse_nodes(const WorkingNodePath &node_path, EggGroupNode *egg_parent,
94  bool has_decal, CharacterJointMap *joint_map);
95  bool apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage = true);
96  bool apply_state_properties(EggRenderMode *egg_render_mode, const RenderState *state);
97  bool apply_tags(EggGroup *egg_group, PandaNode *node);
98  bool apply_tag(EggGroup *egg_group, PandaNode *node, const std::string &tag);
99 
100  EggMaterial *get_egg_material(Material *tex);
101  EggTexture *get_egg_texture(Texture *tex);
102 
103  PT(EggData) _data;
104 
105  PT(EggVertexPool) _vpool;
106  EggMaterialCollection _materials;
107  EggTextureCollection _textures;
108 };
109 
110 #include "eggSaver.I"
111 
112 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
This is our own Panda specialization on the default STL map.
Definition: pmap.h:49
An animated character, with skeleton-morph animation and either soft- skinned or hard-skinned vertice...
Definition: character.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
This is a collection of materials by MRef name.
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:56
A node that automatically cycles through rendering each one of its children according to its frame ra...
Definition: sequenceNode.h:27
This is a collection of textures by TRef name.
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
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,...
Definition: eggSaver.h:53
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:34
This class stores miscellaneous rendering properties that is associated with geometry,...
Definition: eggRenderMode.h:31
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:33
A Level-of-Detail node.
Definition: lodNode.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition: eggVertex.h:39
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:43
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
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:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a node that contains a pointer to an AnimBundle.
A collection of vertices.
Definition: eggVertexPool.h:41
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:34
A node that renders only one of its children, according to the user's indication.
Definition: switchNode.h:25
This is the base class for PartRoot and MovingPart.
Definition: partGroup.h:43