00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
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