source: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp @ 986

Revision 986, 17.3 KB checked in by gumbau, 18 years ago (diff)
Line 
1#include "GeoMesh.h"
2
3using namespace Geometry;
4using namespace std;
5
6//---------------------------------------------------------------------------
7//      Cosntructor.
8//---------------------------------------------------------------------------
9Mesh::Mesh():
10        mVertexBuffer(0), mSubMeshCount(0), mSubMesh(0), hasSkeleton(false)
11{
12        mMeshBounds.maxX                                        =       0.0;
13        mMeshBounds.maxY                                        =       0.0;
14        mMeshBounds.maxZ                                        =       0.0;
15        mMeshBounds.minX                                        =       0.0;
16        mMeshBounds.minY                                        =       0.0;
17        mMeshBounds.minZ                                        =       0.0;
18        mMeshBounds.scaleFactor =       0.0;
19}
20
21//---------------------------------------------------------------------------
22//      Destroyer.
23//---------------------------------------------------------------------------
24Mesh::~Mesh()
25{
26        delete[] mSubMesh;
27        delete mVertexBuffer;
28}
29
30
31//---------------------------------------------------------------------------
32//      Copy constructor.
33//---------------------------------------------------------------------------
34Mesh::Mesh(const Mesh &objmesh)
35{
36        // constructor copia
37        mVertexBuffer   =       new VertexBuffer();
38        mSubMeshCount   =       objmesh.mSubMeshCount;
39        mSubMesh                        =       new SubMesh[objmesh.mSubMeshCount];
40
41        //      Fill up bounding box settings.
42        mMeshBounds.maxX                                        =       objmesh.mMeshBounds.maxX;
43        mMeshBounds.maxY                                        =       objmesh.mMeshBounds.maxY;
44        mMeshBounds.maxZ                                        =       objmesh.mMeshBounds.maxZ;
45        mMeshBounds.minX                                        =       objmesh.mMeshBounds.minX;
46        mMeshBounds.minY                                        =       objmesh.mMeshBounds.minY;
47        mMeshBounds.minZ                                        =       objmesh.mMeshBounds.minZ;
48        mMeshBounds.radius                              =       objmesh.mMeshBounds.radius;
49        mMeshBounds.scaleFactor         =       objmesh.mMeshBounds.scaleFactor;
50       
51        //      For each submesh.
52        for(size_t i = 0; i < objmesh.mSubMeshCount; i++)
53        {
54                mSubMesh[i].mSharedVertexBuffer                                 =       false;
55                mSubMesh[i].mVertexBuffer                                                               =       new VertexBuffer();
56                mSubMesh[i].mVertexBuffer->mPosition            =       new Vector3[objmesh.mSubMesh[i].mVertexBuffer->mVertexCount];
57                mSubMesh[i].mVertexBuffer->mNormal                      =       new Vector3[objmesh.mSubMesh[i].mVertexBuffer->mVertexCount];
58                mSubMesh[i].mVertexBuffer->mTexCoords   = new Vector2[objmesh.mSubMesh[i].mVertexBuffer->mVertexCount];
59                mSubMesh[i].mVertexBuffer->mVertexCount =       objmesh.mSubMesh[i].mVertexBuffer->mVertexCount;
60                mSubMesh[i].mVertexBuffer->mVertexInfo  =       objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo;
61                mSubMesh[i].mType                                                                                               =       objmesh.mSubMesh[i].mType;
62                strcpy(mSubMesh[i].mMaterialName,objmesh.mSubMesh[i].mMaterialName);
63               
64                if(objmesh.mSubMesh[i].mSharedVertexBuffer)
65                {
66                        for(size_t s    =       0;
67                                        s<objmesh.mSubMesh[i].mVertexBuffer->mVertexCount;
68                                        s++)
69                        {
70                                //      Copy mPosition.
71                                if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_POSITION)
72                                {
73                                        mSubMesh[i].mVertexBuffer->mPosition[s].x = objmesh.mVertexBuffer->mPosition[s].x;
74                                        mSubMesh[i].mVertexBuffer->mPosition[s].y = objmesh.mVertexBuffer->mPosition[s].y;
75                                        mSubMesh[i].mVertexBuffer->mPosition[s].z = objmesh.mVertexBuffer->mPosition[s].z;
76                                }
77                               
78                                //      Copy mNormal.
79                                if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_NORMAL)
80                                {
81                                        mSubMesh[i].mVertexBuffer->mNormal[s].x = objmesh.mVertexBuffer->mNormal[s].x;
82                                        mSubMesh[i].mVertexBuffer->mNormal[s].y = objmesh.mVertexBuffer->mNormal[s].y;
83                                        mSubMesh[i].mVertexBuffer->mNormal[s].z = objmesh.mVertexBuffer->mNormal[s].z;
84                                }
85
86                                //      Copy mTexCoords.
87                                if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_TEXCOORDS)
88                                {
89                                        mSubMesh[i].mVertexBuffer->mTexCoords[s].x = objmesh.mVertexBuffer->mTexCoords[s].x;
90                                        mSubMesh[i].mVertexBuffer->mTexCoords[s].y = objmesh.mVertexBuffer->mTexCoords[s].y;
91                                }
92                        }
93                        objmesh.mSubMesh[i].mSharedVertexBuffer = false;
94                }
95                else
96                {
97                        for(size_t s = 0; s < objmesh.mSubMesh[i].mVertexBuffer->mVertexCount; s++)
98                        {
99                                //      Copy mPosition.
100                                if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_POSITION)
101                                {
102                                        mSubMesh[i].mVertexBuffer->mPosition[s].x = objmesh.mSubMesh[i].mVertexBuffer->mPosition[s].x;
103                                        mSubMesh[i].mVertexBuffer->mPosition[s].y = objmesh.mSubMesh[i].mVertexBuffer->mPosition[s].y;
104                                        mSubMesh[i].mVertexBuffer->mPosition[s].z = objmesh.mSubMesh[i].mVertexBuffer->mPosition[s].z;
105                                }
106                               
107                                //Copiamos mNormal
108                                if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_NORMAL)
109                                {
110                                        mSubMesh[i].mVertexBuffer->mNormal[s].x = objmesh.mSubMesh[i].mVertexBuffer->mNormal[s].x;
111                                        mSubMesh[i].mVertexBuffer->mNormal[s].y = objmesh.mSubMesh[i].mVertexBuffer->mNormal[s].y;
112                                        mSubMesh[i].mVertexBuffer->mNormal[s].z = objmesh.mSubMesh[i].mVertexBuffer->mNormal[s].z;
113                                }
114
115                                //Copiamos mTexCoords
116                                if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_TEXCOORDS)
117                                {
118                                        mSubMesh[i].mVertexBuffer->mTexCoords[s].x = objmesh.mSubMesh[i].mVertexBuffer->mTexCoords[s].x;
119                                        mSubMesh[i].mVertexBuffer->mTexCoords[s].y = objmesh.mSubMesh[i].mVertexBuffer->mTexCoords[s].y;
120                                }
121                        }
122
123                }
124               
125                // Copy indices.
126                mSubMesh[i].mIndexCount =       objmesh.mSubMesh[i].mIndexCount;
127                mSubMesh[i].mIndex                      =       new Index[mSubMesh[i].mIndexCount];
128               
129                memcpy(mSubMesh[i].mIndex,objmesh.mSubMesh[i].mIndex,objmesh.mSubMesh[i].mIndexCount*sizeof(Index));
130
131                // Copy strips.
132                __w64 int offset        =       0; // offset between memory positions.
133                mSubMesh[i].mStripCount=objmesh.mSubMesh[i].mStripCount;
134                if (objmesh.mSubMesh[i].mStripCount>0)
135                {
136                        mSubMesh[i].mStrip = new Index*[objmesh.mSubMesh[i].mStripCount];
137
138                        offset  = &(mSubMesh[i].mIndex[0]) - &(objmesh.mSubMesh[i].mIndex[0]);
139                        for (size_t j=0;j<objmesh.mSubMesh[i].mStripCount;j++)
140                        {
141                                mSubMesh[i].mStrip[j]=objmesh.mSubMesh[i].mStrip[j] + offset;
142                        }
143                }
144
145                //      Copy submesh bones.
146                if (!objmesh.mSubMesh[i].mBones.empty())
147                {
148                        for (unsigned int j = 0; j < objmesh.mSubMesh[i].mBones.size(); j++)
149                        {
150                                mSubMesh[i].mBones.push_back(objmesh.mSubMesh[i].mBones[j]);
151                        }
152                }
153        }
154       
155        //      Copy skeleton name.
156        if (objmesh.hasSkeleton)
157        {
158                hasSkeleton     =       true;
159               
160                strcpy(mSkeletonName,objmesh.mSkeletonName);
161        }
162
163        //      Copy mesh bones.
164        if (!objmesh.mBones.empty())
165        {
166                for (unsigned int j = 0; j < objmesh.mBones.size(); j++)
167                {
168                        mBones.push_back(objmesh.mBones[j]);
169                }
170        }
171
172}
173
174//---------------------------------------------------------------------------
175//      Assignment operator.
176//---------------------------------------------------------------------------
177Mesh &Mesh::operator =(const Geometry::Mesh &objmesh)
178{
179        // Operador de asignación
180        bool copiados   =       false; // indica si los vértices compartidos han sido copiados
181        mVertexBuffer   =       new VertexBuffer();
182        mSubMeshCount   =       objmesh.mSubMeshCount;
183        mSubMesh                        =       new Geometry::SubMesh[objmesh.mSubMeshCount];
184       
185        //      Fill up bounding box settings.
186        mMeshBounds.maxX                                        =       objmesh.mMeshBounds.maxX;
187        mMeshBounds.maxY                                        =       objmesh.mMeshBounds.maxY;
188        mMeshBounds.maxZ                                        =       objmesh.mMeshBounds.maxZ;
189        mMeshBounds.minX                                        =       objmesh.mMeshBounds.minX;
190        mMeshBounds.minY                                        =       objmesh.mMeshBounds.minY;
191        mMeshBounds.minZ                                        =       objmesh.mMeshBounds.minZ;
192        mMeshBounds.radius                              =       objmesh.mMeshBounds.radius;
193        mMeshBounds.scaleFactor         =       objmesh.mMeshBounds.scaleFactor;
194
195        //      For each submesh.
196        for(size_t i = 0; i < objmesh.mSubMeshCount; i++)
197        {
198                mSubMesh[i].mSharedVertexBuffer                                 =       objmesh.mSubMesh[i].mSharedVertexBuffer; //.false;
199                mSubMesh[i].mVertexBuffer                                                               =       new Geometry::VertexBuffer();
200                mSubMesh[i].mVertexBuffer->mPosition            =       new Geometry::Vector3[objmesh.mSubMesh[i].mVertexBuffer->mVertexCount];
201                mSubMesh[i].mVertexBuffer->mNormal                      =       new Geometry::Vector3[objmesh.mSubMesh[i].mVertexBuffer->mVertexCount];
202                mSubMesh[i].mVertexBuffer->mTexCoords           =       new Geometry::Vector2[objmesh.mSubMesh[i].mVertexBuffer->mVertexCount];
203                mSubMesh[i].mVertexBuffer->mVertexCount =       objmesh.mSubMesh[i].mVertexBuffer->mVertexCount;
204                mSubMesh[i].mVertexBuffer->mVertexInfo  =       objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo;
205                mSubMesh[i].mType                                       =       objmesh.mSubMesh[i].mType;
206                strcpy(mSubMesh[i].mMaterialName,objmesh.mSubMesh[i].mMaterialName);
207
208                if (objmesh.mSubMesh[i].mSharedVertexBuffer && !copiados)
209                {
210                        mVertexBuffer   =       mSubMesh[i].mVertexBuffer;
211                        copiados                        =       true;
212                }
213
214                for(size_t s = 0; s < objmesh.mSubMesh[i].mVertexBuffer->mVertexCount; s++)
215                {
216                        //Copiamos mPosition
217                        //if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_POSITION)
218                        //{
219                                mSubMesh[i].mVertexBuffer->mPosition[s].x = objmesh.mSubMesh[i].mVertexBuffer->mPosition[s].x;
220                                mSubMesh[i].mVertexBuffer->mPosition[s].y = objmesh.mSubMesh[i].mVertexBuffer->mPosition[s].y;
221                                mSubMesh[i].mVertexBuffer->mPosition[s].z = objmesh.mSubMesh[i].mVertexBuffer->mPosition[s].z;
222                        //}
223                        //Copiamos mNormal
224                        if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
225                        {
226                                mSubMesh[i].mVertexBuffer->mNormal[s].x = objmesh.mSubMesh[i].mVertexBuffer->mNormal[s].x;
227                                mSubMesh[i].mVertexBuffer->mNormal[s].y = objmesh.mSubMesh[i].mVertexBuffer->mNormal[s].y;
228                                mSubMesh[i].mVertexBuffer->mNormal[s].z = objmesh.mSubMesh[i].mVertexBuffer->mNormal[s].z;
229                        }
230
231                        //Copiamos mTexCoords
232                        if (objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS)
233                        {
234                                mSubMesh[i].mVertexBuffer->mTexCoords[s].x = objmesh.mSubMesh[i].mVertexBuffer->mTexCoords[s].x;
235                                mSubMesh[i].mVertexBuffer->mTexCoords[s].y = objmesh.mSubMesh[i].mVertexBuffer->mTexCoords[s].y;
236                        }
237                }
238
239                // Copiar los indices
240                mSubMesh[i].mIndexCount =       objmesh.mSubMesh[i].mIndexCount;
241                mSubMesh[i].mIndex                      =       new Index[mSubMesh[i].mIndexCount];
242
243                memcpy( mSubMesh[i].mIndex,
244                                                objmesh.mSubMesh[i].mIndex,
245                                                objmesh.mSubMesh[i].mIndexCount*sizeof(Geometry::Index));
246
247                // Copiar las tiras
248                __w64 offset    =       0; // desplazamiento entre posiciones de memoria.
249                mSubMesh[i].mStripCount =       objmesh.mSubMesh[i].mStripCount;
250
251                if (objmesh.mSubMesh[i].mStripCount>0)
252                {
253                        mSubMesh[i].mStrip      =       new Index*[objmesh.mSubMesh[i].mStripCount];
254                        offset  =       &(mSubMesh[i].mIndex[0]) - &(objmesh.mSubMesh[i].mIndex[0]);
255                       
256                        for (size_t j = 0; j < objmesh.mSubMesh[i].mStripCount; j++)
257                        {
258                                mSubMesh[i].mStrip[j]   =       objmesh.mSubMesh[i].mStrip[j] + offset;
259                        }
260                }
261               
262                //      Copy submesh bones.
263                if (!objmesh.mSubMesh[i].mBones.empty())
264                {
265                        for (unsigned int j = 0; j < objmesh.mSubMesh[i].mBones.size(); j++)
266                        {
267                                mSubMesh[i].mBones.push_back(objmesh.mSubMesh[i].mBones[j]);
268                        }
269                }
270        }
271
272        //      Copy skeleton name.
273        if (objmesh.hasSkeleton)
274        {
275                hasSkeleton     =       true;
276               
277                strcpy(mSkeletonName,objmesh.mSkeletonName);
278        }
279
280        //      Copy mesh bones.
281        if (!objmesh.mBones.empty())
282        {
283                for (unsigned int j = 0; j < objmesh.mBones.size(); j++)
284                {
285                        mBones.push_back(objmesh.mBones[j]);
286                }
287        }
288
289        return  *this;
290}
291
292//---------------------------------------------------------------------------
293//      Load mesh.
294//---------------------------------------------------------------------------
295void Mesh::Load(Serializer &s)
296{
297        bool sharedVertexBuffer = false;
298
299        //Clear Data
300        delete[] mSubMesh;  mSubMesh = 0;
301        delete   mVertexBuffer; mVertexBuffer = 0;
302        mSubMeshCount = 0;
303       
304        s.ReadArray(&sharedVertexBuffer,1);
305        if (sharedVertexBuffer)
306        {
307                mVertexBuffer = new VertexBuffer;
308                mVertexBuffer->Load(s);
309        }
310        s.ReadArray(&mSubMeshCount,1);
311        mSubMesh = new SubMesh[mSubMeshCount];
312        for(size_t i = 0; i < mSubMeshCount; ++i)
313        {
314                mSubMesh[i].Load(s);
315                if (mSubMesh[i].mSharedVertexBuffer && sharedVertexBuffer)
316                {
317                        mSubMesh[i].mVertexBuffer = mVertexBuffer;
318                }
319        }
320}
321
322//---------------------------------------------------------------------------
323//      Save mesh.
324//---------------------------------------------------------------------------
325void Mesh::Save(Serializer &s)
326{
327        bool sharedVertexBuffer = (mVertexBuffer != 0);
328        s.WriteArray(&sharedVertexBuffer, 1);
329        if (sharedVertexBuffer)
330        {
331                mVertexBuffer->Save(s);
332        }
333        s.WriteArray(&mSubMeshCount,1);
334        for(size_t i = 0; i < mSubMeshCount; ++i)
335        {
336                mSubMesh[i].Save(s);
337        }
338}
339
340//---------------------------------------------------------------------------
341//      Export to obj mesh.
342//---------------------------------------------------------------------------
343void Mesh::exportToOBJ(char *nomfich)
344{
345        // Genera un fichero obj con vértices, triángulos
346
347        std::ofstream obj(nomfich);
348        obj << "begin" << std::endl;
349        // Vértices
350        for (size_t i=0; i < mSubMeshCount; i++)
351        {
352                for (size_t j=0; j < mSubMesh[i].mVertexBuffer->mVertexCount; j++)
353                {       
354                        obj << "v " <<  mSubMesh[i].mVertexBuffer->mPosition[j].x << " " <<
355                                mSubMesh[i].mVertexBuffer->mPosition[j].y << " " <<
356                                mSubMesh[i].mVertexBuffer->mPosition[j].z << " " << std::endl;
357                }
358        }
359
360
361        // Caras
362        for (size_t i=0; i < mSubMeshCount; i++)
363        {
364                for (size_t j=0; j < mSubMesh[i].mIndexCount; j=j+3)
365                {       
366                        obj << "f " <<  mSubMesh[i].mIndex[j]+1 << " " <<
367                                mSubMesh[i].mIndex[j+1]+1 << " " <<
368                                mSubMesh[i].mIndex[j+2]+1 << std::endl;
369                }
370        }
371
372        obj << "end" << std::endl;
373        obj.close();
374}
375
376//---------------------------------------------------------------------------
377// Transform to shared vertex mesh.
378//---------------------------------------------------------------------------
379Mesh *Mesh::toSharedVertex()
380{
381        // Move all vertex to the shared vertex buffer.
382        Mesh *mesh = new Mesh();
383
384        if (mSubMesh[0].mSharedVertexBuffer)
385        {
386                *mesh   =       *this;
387               
388                return  mesh;
389        }
390       
391        mesh->mVertexBuffer     =       new VertexBuffer();
392        mesh->mSubMeshCount =   mSubMeshCount;
393       
394        // Reserva memoria para los submeshes
395        mesh->mSubMesh  =       new SubMesh[mSubMeshCount];
396
397        //      Fill up bounding box settings.
398        mesh->mMeshBounds.maxX                                  =       mMeshBounds.maxX;
399        mesh->mMeshBounds.maxY                                  =       mMeshBounds.maxY;
400        mesh->mMeshBounds.maxZ                                  =       mMeshBounds.maxZ;
401        mesh->mMeshBounds.minX                                  =       mMeshBounds.minX;
402        mesh->mMeshBounds.minY                                  =       mMeshBounds.minY;
403        mesh->mMeshBounds.minZ                                  =       mMeshBounds.minZ;
404        mesh->mMeshBounds.radius                                =       mMeshBounds.radius;
405        mesh->mMeshBounds.scaleFactor           =       mMeshBounds.scaleFactor;
406       
407// construcción de los submeshes
408        long int acumVerts      =       0;
409       
410        for (size_t i = 0; i < mesh->mSubMeshCount; i++)
411        {
412                mesh->mSubMesh[i].mSharedVertexBuffer   =       true;
413                mesh->mSubMesh[i].mVertexBuffer                         =       mesh->mVertexBuffer;
414                mesh->mSubMesh[i].mStripCount                                   =       0;
415                mesh->mSubMesh[i].mStrip                                                        =       NULL;
416                mesh->mSubMesh[i].mType                                                         =       mSubMesh[i].mType;
417               
418                strcpy(mesh->mSubMesh[i].mMaterialName,mSubMesh[i].mMaterialName);
419               
420                // copiar los índices
421                mesh->mSubMesh[i].mIndexCount   =       mSubMesh[i].mIndexCount;
422                mesh->mSubMesh[i].mIndex                        =       new Index[mSubMesh[i].mIndexCount];
423
424                for (size_t j = 0;      j < mSubMesh[i].mIndexCount;    j++)
425                {
426                        mesh->mSubMesh[i].mIndex[j]     =       mSubMesh[i].mIndex[j]+acumVerts;
427                }
428
429                acumVerts       +=      long(mSubMesh[i].mVertexBuffer->mVertexCount);
430
431                // Copiar las tiras
432                int offset      =       0; // desplazamiento entre posiciones de memoria.
433               
434                mesh->mSubMesh[i].mStripCount   =       mSubMesh[i].mStripCount;
435               
436                if (mSubMesh[i].mStripCount > 0)
437                {
438                        mesh->mSubMesh[i].mStrip        =       new Index*[mSubMesh[i].mStripCount];
439
440                        offset  =       int(&(mesh->mSubMesh[i].mIndex[0]) - &(mSubMesh[i].mIndex[0]));
441                       
442                        for (size_t j = 0;      j < mSubMesh[i].mStripCount;    j++)
443                        {
444                                mesh->mSubMesh[i].mStrip[j] = mSubMesh[i].mStrip[j] + offset;
445                        }
446                }
447        }
448       
449        mesh->mVertexBuffer->mVertexCount       =       acumVerts;
450        mesh->mVertexBuffer->mVertexInfo        =       mSubMesh[0].mVertexBuffer->mVertexInfo;
451       
452        mesh->mVertexBuffer->mPosition          =       new Vector3[mesh->mVertexBuffer->mVertexCount];
453        mesh->mVertexBuffer->mNormal                    =       new Vector3[mesh->mVertexBuffer->mVertexCount];
454        mesh->mVertexBuffer->mTexCoords         =       new Vector2[mesh->mVertexBuffer->mVertexCount];
455
456        // copiar los vértices
457        acumVerts       =       0;
458       
459        size_t  newIndex;
460       
461        for (size_t i = 0; i < mSubMeshCount;   i++)
462        {
463                for(size_t j = 0; j < mSubMesh[i].mVertexBuffer->mVertexCount; j++)
464                {
465                        newIndex        =       acumVerts + j;
466                       
467                        mesh->mVertexBuffer->
468                                                mPosition[newIndex].x   =       mSubMesh[i].mVertexBuffer->
469                                                                                                                                                                                                mPosition[j].x;
470                       
471                        mesh->mVertexBuffer->
472                                                mPosition[newIndex].y   =       mSubMesh[i].mVertexBuffer->
473                                                                                                                                                                                                mPosition[j].y;
474                       
475                        mesh->mVertexBuffer->
476                                                mPosition[newIndex].z   =       mSubMesh[i].mVertexBuffer->
477                                                                                                                                                                                                mPosition[j].z;
478
479                        mesh->mVertexBuffer->
480                                                mNormal[newIndex].x     =       mSubMesh[i].mVertexBuffer->
481                                                                                                                                                                                        mNormal[j].x;
482                       
483                        mesh->mVertexBuffer->
484                                                mNormal[newIndex].y     =       mSubMesh[i].mVertexBuffer->
485                                                                                                                                                                                        mNormal[j].y;
486                       
487                        mesh->mVertexBuffer->
488                                                mNormal[newIndex].z     =       mSubMesh[i].mVertexBuffer->
489                                                                                                                                                                                        mNormal[j].z;
490
491                        mesh->mVertexBuffer->
492                                                mTexCoords[newIndex].x  =       mSubMesh[i].mVertexBuffer->
493                                                                                                                                                                                                        mTexCoords[j].x;
494                       
495                        mesh->mVertexBuffer->
496                                                mTexCoords[newIndex].y  =       mSubMesh[i].mVertexBuffer->
497                                                                                                                                                                                                        mTexCoords[j].y;
498                }
499               
500                acumVerts       +=      long(mSubMesh[i].mVertexBuffer->mVertexCount);
501
502                //      Copy submesh bones.
503                if (!mSubMesh[i].mBones.empty())
504                {
505                        for (unsigned int j = 0; j < mSubMesh[i].mBones.size(); j++)
506                        {
507                                mesh->mSubMesh[i].mBones.push_back(mSubMesh[i].mBones[j]);
508                        }
509                }
510
511        }
512
513        //      Copy skeleton name.
514        if (hasSkeleton)
515        {
516                mesh->hasSkeleton       =       true;
517               
518                strcpy(mesh->mSkeletonName,mSkeletonName);
519        }
520
521        //      Copy mesh bones.
522        if (!mBones.empty())
523        {
524                for (unsigned int j = 0; j < mBones.size(); j++)
525                {
526                        mesh->mBones.push_back(mBones[j]);
527                }
528        }
529
530        return mesh;
531}
532
Note: See TracBrowser for help on using the repository browser.