Panda3D
Loading...
Searching...
No Matches
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"
23
24class WorkingNodePath;
25class EggGroup;
26class EggGroupNode;
27class EggVertexPool;
28class EggTexture;
29class LODNode;
30class SequenceNode;
31class SwitchNode;
32class AnimBundleNode;
33class AnimGroup;
34class Character;
35class PartGroup;
36class CollisionNode;
37class GeomNode;
38class GeomVertexData;
39class GeomPrimitive;
40class PandaNode;
41class RenderState;
42class Material;
43class Texture;
44class CharacterJoint;
45class 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 */
53class EXPCL_PANDA_EGG2PG EggSaver {
54PUBLISHED:
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
61private:
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
This is a node that contains a pointer to an AnimBundle.
This is the base class for AnimChannel and AnimBundle.
Definition animGroup.h:33
This represents one joint of the character's animation, containing an animating transform matrix.
An animated character, with skeleton-morph animation and either soft- skinned or hard-skinned vertice...
Definition character.h:38
A node in the scene graph that can hold any number of CollisionSolids.
This is the primary interface into all the egg data, and the root of the egg file structure.
Definition eggData.h:37
A base class for nodes in the hierarchy that are not leaf nodes.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition eggGroup.h:34
This is a collection of materials by MRef name.
This class stores miscellaneous rendering properties that is associated with geometry,...
Converts the scene graph beginning at the indicated node into an EggData structure,...
Definition eggSaver.h:53
This is a collection of textures by TRef name.
Defines a texture map that may be applied to geometry.
Definition eggTexture.h:30
A collection of vertices.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition eggVertex.h:39
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A Level-of-Detail node.
Definition lodNode.h:28
Defines the way an object appears in the presence of lighting.
Definition material.h:43
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
This is the base class for PartRoot and MovingPart.
Definition partGroup.h:43
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
A node that automatically cycles through rendering each one of its children according to its frame ra...
A node that renders only one of its children, according to the user's indication.
Definition switchNode.h:25
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
This is a class designed to support low-overhead traversals of the complete scene graph,...
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.