Panda3D
 All Classes Functions Variables Enumerations
softNodeDesc.h
00001 // Filename: softNodeDesc.h
00002 // Created by:  masad (03Oct03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef SOFTNODEDESC_H
00016 #define SOFTNODEDESC_H
00017 
00018 #ifdef _MIN
00019 #undef _MIN
00020 #endif
00021 #ifdef _MAX
00022 #undef _MAX
00023 #endif
00024 
00025 #include "pandatoolbase.h"
00026 
00027 #include "eggVertex.h"
00028 #include "eggVertexPool.h"
00029 #include "referenceCount.h"
00030 #include "pointerTo.h"
00031 #include "namable.h"
00032 
00033 #include <SAA.h>
00034 
00035 class EggGroup;
00036 class EggTable;
00037 class EggXfmSAnim;
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //       Class : SoftNodeDesc
00041 // Description : Describes a single instance of a node aka element in the Soft
00042 //               scene graph, relating it to the corresponding egg
00043 //               structures (e.g. node, group, or table entry) that
00044 //               will be created.
00045 ////////////////////////////////////////////////////////////////////
00046 class SoftNodeDesc : public ReferenceCount, public Namable {
00047 public:
00048   SoftNodeDesc(SoftNodeDesc *parent=NULL, const string &name = string());
00049   ~SoftNodeDesc();
00050 
00051   void set_parent(SoftNodeDesc *parent);
00052   void force_set_parent(SoftNodeDesc *parent);
00053   void set_model(SAA_Elem *model);
00054   bool has_model() const;
00055   SAA_Elem *get_model() const;
00056 
00057   bool is_joint() const;
00058   bool is_junk() const;
00059   void set_joint();
00060   bool is_joint_parent() const;
00061   bool is_partial(char *search_prefix);
00062 
00063   SoftNodeDesc *_parent;
00064   SoftNodeDesc *_parentJoint; // keep track of who is your parent joint
00065   typedef pvector< PT(SoftNodeDesc) > Children;
00066   Children _children;
00067 
00068 private:
00069   void clear_egg();
00070   void mark_joint_parent();
00071   void check_joint_parent();
00072   void check_junk(bool parent_junk);
00073   void check_pseudo_joints(bool joint_above);
00074 
00075   void set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint);
00076 
00077   SAA_ModelType type;
00078 
00079   SAA_Elem *_model;
00080 
00081   EggGroup *_egg_group;
00082   EggTable *_egg_table;
00083   EggXfmSAnim *_anim;
00084 
00085   enum JointType {
00086     JT_none,         // Not a joint.
00087     JT_joint,        // An actual joint in Soft.
00088     JT_pseudo_joint, // Not a joint in Soft, but treated just like a
00089                      // joint for the purposes of the converter.
00090     JT_joint_parent, // A parent or ancestor of a joint or pseudo joint.
00091     JT_junk,         // originated from con-/fly-/car_rig/bars etc.
00092   };
00093   JointType _joint_type;
00094 
00095 public:
00096 
00097   char **texNameArray;
00098   int *uRepeat, *vRepeat;
00099   PN_stdfloat matrix[4][4];
00100 
00101   const char *fullname;
00102 
00103   int numTri;
00104   //  int numShapes;
00105   int numTexLoc;
00106   int numTexGlb;
00107   int *numTexTri;
00108 
00109   // if the node is a MNSRF
00110   int numNurbTexLoc;
00111   int numNurbTexGlb;
00112   int numNurbMats;
00113 
00114   PN_stdfloat *uScale;
00115   PN_stdfloat *vScale;
00116   PN_stdfloat *uOffset;
00117   PN_stdfloat *vOffset;
00118   
00119   SAA_Boolean valid;
00120   SAA_Boolean uv_swap;
00121   //  SAA_Boolean visible;
00122   SAA_Elem *textures;
00123   SAA_Elem *materials;
00124   SAA_SubElem *triangles;
00125   SAA_GeomType gtype;
00126 
00127   EggGroup *get_egg_group()const {return _egg_group;}
00128 
00129   void get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global);
00130   void get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global);
00131   void load_poly_model(SAA_Scene *scene, SAA_ModelType type);
00132   void load_nurbs_model(SAA_Scene *scene, SAA_ModelType type);
00133 
00134   void make_morph_table(PN_stdfloat time);
00135   void make_linear_morph_table(int numShapes, PN_stdfloat time);
00136   void make_weighted_morph_table(int numShapes, PN_stdfloat time);
00137   void make_expression_morph_table(int numShapes, PN_stdfloat time);
00138 
00139   void make_vertex_offsets(int numShapes);
00140   int find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert);
00141 
00142   static TypeHandle get_class_type() {
00143     return _type_handle;
00144   }
00145   static void init_type() {
00146     ReferenceCount::init_type();
00147     Namable::init_type();
00148     register_type(_type_handle, "SoftNodeDesc",
00149                   ReferenceCount::get_class_type(),
00150                   Namable::get_class_type());
00151   }
00152 
00153 private:
00154   static TypeHandle _type_handle;
00155 
00156   friend class SoftNodeTree;
00157 };
00158 
00159 class SoftToEggConverter;
00160 extern SoftToEggConverter stec;
00161 
00162 #endif
 All Classes Functions Variables Enumerations