Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg2pg/computedVerticesMaker.h

Go to the documentation of this file.
00001 // Filename: computedVerticesMaker.h
00002 // Created by:  drose (01Mar99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef COMPUTEDVERTICESMAKER_H
00020 #define COMPUTEDVERTICESMAKER_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "computedVerticesMakerEntity.h"
00025 
00026 #include "computedVerticesMorph.h"
00027 #include "pointerToArray.h"
00028 #include "luse.h"
00029 #include "typedef.h"
00030 #include "eggMorphList.h"
00031 #include "pta_Vertexf.h"
00032 #include "pta_Normalf.h"
00033 #include "pta_Colorf.h"
00034 #include "pta_TexCoordf.h"
00035 
00036 #include "pset.h"
00037 #include "pmap.h"
00038 
00039 class ComputedVertices;
00040 class CharacterMaker;
00041 class EggNode;
00042 class EggVertex;
00043 
00044 ///////////////////////////////////////////////////////////////////
00045 //       Class : ComputedVerticesMaker
00046 // Description : An object to collect together all the vertices of a
00047 //               character, indicate what the transform space of each
00048 //               vertex is (which may be a soft-skinned combination of
00049 //               one or more joints), and identify which vertices may
00050 //               be shared together.
00051 //
00052 //               Generally, you use a ComputedVerticesMaker by first
00053 //               defining a transform space via begin_new_space(),
00054 //               repeated calls to add_joint() (or
00055 //               add_vertex_joints()), and then mark_space().  Having
00056 //               done that, you can then add any number of vertices to
00057 //               the space via add_vertex(), add_normal(), etc., and
00058 //               it will return an index number for each vertex,
00059 //               collapsing duplicate vertices together properly.
00060 //               When you are ready to define a new space, simply
00061 //               repeat the process from begin_new_space().
00062 ////////////////////////////////////////////////////////////////////
00063 class EXPCL_PANDAEGG ComputedVerticesMaker {
00064 public:
00065   ComputedVerticesMaker();
00066 
00067   void begin_new_space();
00068   void add_joint(EggNode *joint, double membership);
00069   void add_vertex_joints(EggVertex *vertex, EggNode *object);
00070   void mark_space();
00071 
00072   int add_vertex(const Vertexd &vertex, const EggMorphVertexList &morphs,
00073                  const LMatrix4d &transform);
00074   int add_normal(const Normald &normal, const EggMorphNormalList &morphs,
00075                  const LMatrix4d &transform);
00076   int add_texcoord(const TexCoordd &texcoord,
00077                    const EggMorphTexCoordList &morphs,
00078                    const LMatrix3d &transform);
00079   int add_color(const Colorf &color, const EggMorphColorList &morphs);
00080 
00081   ComputedVertices *make_computed_vertices(Character *character,
00082                                            CharacterMaker &char_maker);
00083 
00084   void write(ostream &out) const;
00085 
00086 public:
00087   PTA_Vertexf _coords;
00088   PTA_Normalf _norms;
00089   PTA_Colorf _colors;
00090   PTA_TexCoordf _texcoords;
00091 
00092 protected:
00093   typedef pmap<int, LVector3f> VertexMorphList;
00094   typedef pmap<int, LVector3f> NormalMorphList;
00095   typedef pmap<int, LVector2f> TexCoordMorphList;
00096   typedef pmap<int, LVector4f> ColorMorphList;
00097   class MorphList {
00098   public:
00099     VertexMorphList _vmorphs;
00100     NormalMorphList _nmorphs;
00101     TexCoordMorphList _tmorphs;
00102     ColorMorphList _cmorphs;
00103   };
00104 
00105   typedef pmap<string, MorphList> Morphs;
00106   Morphs _morphs;
00107 
00108   typedef pset<int> Vertices;
00109 
00110   Vertices _cindex;
00111   Vertices _tindex;
00112 
00113   ComputedVerticesMakerTexCoordMap _tmap;
00114   ComputedVerticesMakerColorMap _cmap;
00115 
00116 #ifdef WIN32_VC
00117 public:
00118 #endif
00119 
00120   class JointWeights: public pmap<EggNode *, double> {
00121   public:
00122     bool operator < (const JointWeights &other) const;
00123     void normalize_weights();
00124 
00125     void output(ostream &out) const;
00126   };
00127 
00128 protected:
00129   class VertexCollection {
00130   public:
00131     Vertices _vindex;
00132     Vertices _nindex;
00133 
00134     ComputedVerticesMakerVertexMap _vmap;
00135     ComputedVerticesMakerNormalMap _nmap;
00136   };
00137 
00138   typedef pmap<JointWeights, VertexCollection> TransformSpaces;
00139   TransformSpaces _transforms;
00140 
00141   class VertexTransform {
00142   public:
00143     EggNode *_joint;
00144     float _effect;
00145   };
00146 
00147   JointWeights _current_jw;
00148   VertexCollection *_current_vc;
00149 
00150   friend inline ostream &operator << (ostream &, const JointWeights &);
00151 };
00152 
00153 inline ostream &
00154 operator << (ostream &out, const ComputedVerticesMaker::JointWeights &jw) {
00155   jw.output(out);
00156   return out;
00157 }
00158 
00159 #include "computedVerticesMaker.I"
00160 
00161 #endif
00162 

Generated on Fri May 2 00:38:09 2003 for Panda by doxygen1.3