Panda3D
 All Classes Functions Variables Enumerations
softNodeDesc.h
1 // Filename: softNodeDesc.h
2 // Created by: masad (03Oct03)
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 SOFTNODEDESC_H
16 #define SOFTNODEDESC_H
17 
18 #ifdef _MIN
19 #undef _MIN
20 #endif
21 #ifdef _MAX
22 #undef _MAX
23 #endif
24 
25 #include "pandatoolbase.h"
26 
27 #include "eggVertex.h"
28 #include "eggVertexPool.h"
29 #include "referenceCount.h"
30 #include "pointerTo.h"
31 #include "namable.h"
32 
33 #include <SAA.h>
34 
35 class EggGroup;
36 class EggTable;
37 class EggXfmSAnim;
38 
39 ////////////////////////////////////////////////////////////////////
40 // Class : SoftNodeDesc
41 // Description : Describes a single instance of a node aka element in the Soft
42 // scene graph, relating it to the corresponding egg
43 // structures (e.g. node, group, or table entry) that
44 // will be created.
45 ////////////////////////////////////////////////////////////////////
46 class SoftNodeDesc : public ReferenceCount, public Namable {
47 public:
48  SoftNodeDesc(SoftNodeDesc *parent=NULL, const string &name = string());
49  ~SoftNodeDesc();
50 
51  void set_parent(SoftNodeDesc *parent);
52  void force_set_parent(SoftNodeDesc *parent);
53  void set_model(SAA_Elem *model);
54  bool has_model() const;
55  SAA_Elem *get_model() const;
56 
57  bool is_joint() const;
58  bool is_junk() const;
59  void set_joint();
60  bool is_joint_parent() const;
61  bool is_partial(char *search_prefix);
62 
63  SoftNodeDesc *_parent;
64  SoftNodeDesc *_parentJoint; // keep track of who is your parent joint
66  Children _children;
67 
68 private:
69  void clear_egg();
70  void mark_joint_parent();
71  void check_joint_parent();
72  void check_junk(bool parent_junk);
73  void check_pseudo_joints(bool joint_above);
74 
75  void set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint);
76 
77  SAA_ModelType type;
78 
79  SAA_Elem *_model;
80 
81  EggGroup *_egg_group;
82  EggTable *_egg_table;
83  EggXfmSAnim *_anim;
84 
85  enum JointType {
86  JT_none, // Not a joint.
87  JT_joint, // An actual joint in Soft.
88  JT_pseudo_joint, // Not a joint in Soft, but treated just like a
89  // joint for the purposes of the converter.
90  JT_joint_parent, // A parent or ancestor of a joint or pseudo joint.
91  JT_junk, // originated from con-/fly-/car_rig/bars etc.
92  };
93  JointType _joint_type;
94 
95 public:
96 
97  char **texNameArray;
98  int *uRepeat, *vRepeat;
99  PN_stdfloat matrix[4][4];
100 
101  const char *fullname;
102 
103  int numTri;
104  // int numShapes;
105  int numTexLoc;
106  int numTexGlb;
107  int *numTexTri;
108 
109  // if the node is a MNSRF
110  int numNurbTexLoc;
111  int numNurbTexGlb;
112  int numNurbMats;
113 
114  PN_stdfloat *uScale;
115  PN_stdfloat *vScale;
116  PN_stdfloat *uOffset;
117  PN_stdfloat *vOffset;
118 
119  SAA_Boolean valid;
120  SAA_Boolean uv_swap;
121  // SAA_Boolean visible;
122  SAA_Elem *textures;
123  SAA_Elem *materials;
124  SAA_SubElem *triangles;
125  SAA_GeomType gtype;
126 
127  EggGroup *get_egg_group()const {return _egg_group;}
128 
129  void get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global);
130  void get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global);
131  void load_poly_model(SAA_Scene *scene, SAA_ModelType type);
132  void load_nurbs_model(SAA_Scene *scene, SAA_ModelType type);
133 
134  void make_morph_table(PN_stdfloat time);
135  void make_linear_morph_table(int numShapes, PN_stdfloat time);
136  void make_weighted_morph_table(int numShapes, PN_stdfloat time);
137  void make_expression_morph_table(int numShapes, PN_stdfloat time);
138 
139  void make_vertex_offsets(int numShapes);
140  int find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert);
141 
142  static TypeHandle get_class_type() {
143  return _type_handle;
144  }
145  static void init_type() {
146  ReferenceCount::init_type();
147  Namable::init_type();
148  register_type(_type_handle, "SoftNodeDesc",
149  ReferenceCount::get_class_type(),
150  Namable::get_class_type());
151  }
152 
153 private:
154  static TypeHandle _type_handle;
155 
156  friend class SoftNodeTree;
157 };
158 
159 class SoftToEggConverter;
160 extern SoftToEggConverter stec;
161 
162 #endif
bool has_model() const
Returns true if a Soft dag path has been associated with this node, false otherwise.
void get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global)
Extracts the transform on the indicated Soft node, as appropriate for a joint in an animated characte...
void force_set_parent(SoftNodeDesc *parent)
Sometimes, parent is not known at node creation As soon as it is known, set the parent.
void make_linear_morph_table(int numShapes, PN_stdfloat time)
Given a scene, a model, its name, and the time, get the shape fcurve for the model and determine the ...
void make_expression_morph_table(int numShapes, PN_stdfloat time)
Given a scene, a model and its number of key shapes generate a morph table describing transitions btw...
Describes a complete tree of soft nodes for conversion.
Definition: softNodeTree.h:35
SAA_Elem * get_model() const
Returns the SAA_Elem * associated with this node.
bool is_joint_parent() const
Returns true if the node is the parent or ancestor of a joint.
The main glue of the egg hierarchy, this corresponds to the &lt;Group&gt;, &lt;Instance&gt;, and &lt;Joint&gt; type nod...
Definition: eggGroup.h:36
A base class for all things which can have a name.
Definition: namable.h:29
bool is_joint() const
Returns true if the node should be treated as a joint by the converter.
bool is_partial(char *search_prefix)
check to see if this is a selected branch we want to descend - this will prevent creating geometry fo...
This corresponds to an &lt;Xfm$Anim_S$&gt; entry, which is a collection of up to nine &lt;S$Anim&gt; entries that...
Definition: eggXfmSAnim.h:33
void make_vertex_offsets(int numShapes)
Given a scene, a model , the vertices of its original shape and its name find the difference between ...
Describes a single instance of a node aka element in the Soft scene graph, relating it to the corresp...
Definition: softNodeDesc.h:46
void set_joint()
sets the _joint_type to JT_joint
void make_weighted_morph_table(int numShapes, PN_stdfloat time)
Given a scene, a model, a list of all models in the scene, the number of models in the scece...
bool is_junk() const
Returns true if the node should be treated as a junk by the converter.
This corresponds to a.
Definition: eggTable.h:31
void load_nurbs_model(SAA_Scene *scene, SAA_ModelType type)
Converts the indicated Soft polyset to a bunch of EggPolygons and parents them to the indicated egg g...
This class supervises the construction of an EggData structure from a single Softimage file...
A base class for all things that want to be reference-counted.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:531
void set_parent(SoftNodeDesc *parent)
Sometimes, parent is not known at node creation As soon as it is known, set the parent.
int find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert)
given a vertex, find its corresponding shape vertex and return its index.
void get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global)
Extracts the transform on the indicated Soft node, and applies it to the corresponding Egg node...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void set_model(SAA_Elem *model)
Indicates an associated between the SoftNodeDesc and some SAA_Elem instance.
void load_poly_model(SAA_Scene *scene, SAA_ModelType type)
Converts the indicated Soft polyset to a bunch of EggPolygons and parents them to the indicated egg g...
void make_morph_table(PN_stdfloat time)
Given a scene, a model, a name and a frame time, determine what type of shape interpolation is used a...