source: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp @ 1541

Revision 1541, 33.8 KB checked in by gumbau, 18 years ago (diff)
Line 
1#include <iostream>
2#include <fstream>
3#include <time.h>
4#include "GeoLodStripsConstructor.h"
5#include "GeoMeshLoader.h"
6
7using namespace Geometry;
8
9//---------------------------------------------------------------------------
10//      Call GenerarModeloV and CopiarVectorsArraysNUEVAED to make changes.
11//---------------------------------------------------------------------------
12void LodStripsConstructor::GenerarModeloCompleto(TIPOFUNC       upb)
13{       
14        float   percent;
15
16        this->GenerarModeloV(upb);
17        this->CopiarVectors2ArraysNUEVAED();
18
19        //      Last updtate of the progress bar.
20        percent =       100.0;
21        upb(percent);
22}
23
24//---------------------------------------------------------------------------
25//      It makes Lods changes and count them.
26//---------------------------------------------------------------------------
27void LodStripsConstructor::CalcularCambiosLODsVNuevaED(TIPOFUNC upb)
28{
29        long            int                                     k;
30        long            int                                     i;
31        unsigned long           int                     t;
32        long            int                                     r;
33        unsigned long           int                     v;
34        long            int                                     p0;
35        long            int                                     lod     =       0;
36        long            int                                     sigue;
37        long            int                                     ac[3]   =       {0,0,0};
38        long            int                                     totalRegs       =       0;
39        long            int                                     RegsCambios;
40        std::vector<std::vector<int> >  TiraOriginal;
41        LODData                                                 regLOD;
42        std::vector<LODData>                    listaCambios;
43        float                                                   percent;
44        float                                                   increment;
45        long            int                                     update;
46
47        //      Saves original copy.
48        TiraOriginal                    =       this->cStrips;
49
50        this->MARCAVACIO        =       int(10 * this->cVerts.size());
51       
52        listaCambios.clear();
53
54        //      Initialize increment.
55        increment       =       0.0;
56       
57        for     (lod = 0; ((this->cVerts[lod].Next) != -1); lod++)
58        {
59                increment       +=      1.0;
60        }
61
62        update          =       -1;
63        increment       =       (float)30.0     /       increment;
64        percent         =       1.0;
65       
66        this->LodsDisp  =       this->TOTALCAMBIOS      =       lod;
67        pCambios                =       new uint32[this->TOTALCAMBIOS];
68        pCambios[0]             =       0;
69       
70        for     (lod = 0; ((this->cVerts[lod].Next) != -1); lod++)
71        {
72                tipoVertice & cVertsLOD = this->cVerts[lod];
73               
74                RegsCambios                             =       0;
75                regLOD.obligatory       =       this->Ordenacion[lod].obligatory;
76               
77                for(t = 0; t < this->cStrips.size(); t++)
78                {
79                        std::vector<int> & cStripsT = this->cStrips[t];
80
81                        //      Initialize.
82                        regLOD.strip    =       this->MARCAVACIO;
83
84                        //      Change vertices.
85                        totalRegs               =       0;
86                       
87                        for (v = 0; v < cStripsT.size(); v++)
88                        {
89                                if (cStripsT[v] == lod)
90                                {
91                                        //      Strips.
92                                        if (regLOD.strip == this->MARCAVACIO)
93                                                regLOD.strip = t;
94                                       
95                                        ++totalRegs;
96
97                                        cDatos.push_back(v);
98
99                                        cStripsT[v]     =       cVertsLOD.Next;
100                                }
101                        }
102                       
103                        regLOD.nP       =       char(totalRegs);
104
105                        //      Simplifications length 1.
106                        //      Changes for simplification of level 1 to greater than 2.
107                        totalRegs       =       0;
108                        i                       =       0;
109                        r                       =       0;
110                        sigue           =       0;
111                        k                       =       long(cStripsT.size()-3);
112                       
113                        while (i < k)
114                        {
115                                if (    (cStripsT[i] == cStripsT[i+1])
116                                                        &&
117                                                        (cStripsT[i+1] == cStripsT[i+2])
118                                                )
119                                {
120                                        //      Saves beginning of repetition.
121                                        if (!r)
122                                        {
123                                                p0      =       i;
124                                        }
125                                       
126                                        //cStripsT.eraseAtPos(i);
127                                        cStripsT.erase(cStripsT.begin()+i);
128                                        i--;
129                                        r++;
130                                       
131                                        if ((i+1) != cStripsT.size()-1)
132                                        {
133                                                sigue   =       1;
134                                        }
135                                        else
136                                        {
137                                                sigue   =       0;
138                                        }
139                                       
140                                }
141                                else
142                                {
143                                        sigue   =       0;
144                                }
145
146                                if (!sigue && r)
147                                {
148                                       
149
150                                        /*
151                                        cDatos.push_back(p0);
152                                        cDatos.push_back(r);
153
154                                        r       =       0;
155                                        k       =       long(cStripsT.size()-r-3);
156                                        */
157                                        long auxp0, auxr;
158                                        //regLOD.strip= t;
159                                        auxp0= p0;
160                                        auxr= r;
161                                               
162                                        if (r==1)
163                                        {
164                                                while(r>0)
165                                                {
166                                                        cStripsT.insert(cStripsT.begin()+p0,cStripsT[p0]);
167                                                        r--;
168                                                }
169                                                i=p0;
170                                        }                                       
171                                        else
172                                        {
173                                                if (r%2) //If r is odd the changes are undone
174                                                {
175                                                        cStripsT.insert(cStripsT.begin()+p0,cStripsT[p0]);
176                                                        r--;
177                                                        auxr=r;
178                                                }
179                                                //listaPos.push_back(pos);
180                                                cDatos.push_back(auxp0);
181                                                cDatos.push_back(auxr);
182                                        if (regLOD.strip == this->MARCAVACIO)
183                                        {
184                                                regLOD.strip    =       t;
185                                        }
186
187                                        ++totalRegs;
188                                        }
189
190
191                                        r       =       0;
192
193                                        k       =       (long)(cStripsT.size() - 3);
194
195                                }
196
197                                i++;
198                        }
199                       
200                        regLOD.nL1      =       char(totalRegs);
201
202                        //TERCERO: Simplificaciones de Longitud 2 tipo V1 V2 V1 V2 -> V1 V2
203                        totalRegs       =       0;
204                        i                                       =       0;
205                        r                                       =       0;
206                        sigue                   =       0;
207                        k                                       =       long(cStripsT.size() - 4);
208                       
209                        while   (i < k)
210                        {
211                                if (    (cStripsT[i] == cStripsT[i+2])
212                                                        &&
213                                                        (cStripsT[i+1] == cStripsT[i+3])
214                                                )
215                                {
216                                        if (!r)
217                                        {
218                                                p0      =       i;
219                                        }
220                                       
221                                        //cStripsT.eraseAtPos(i);
222                                        cStripsT.erase(this->cStrips[t].begin()+i);
223                                        //cStripsT.eraseAtPos(i);
224                                        cStripsT.erase(this->cStrips[t].begin()+i);
225                                        r++;
226                                       
227                                        i       -=      2;
228                                       
229                                        if ((i+1) != cStripsT.size()-3)
230                                        {
231                                                sigue   =       1;
232                                        }
233                                        else
234                                        {
235                                                sigue   =       0;
236                                        }
237                                       
238                                }
239                                else
240                                {
241                                        sigue   =       0;
242                                }
243
244                                if (!sigue && r)
245                                {
246                                        if (regLOD.strip == this->MARCAVACIO)
247                                        {
248                                                regLOD.strip    =       t;
249                                        }
250                                       
251                                        ++totalRegs;
252
253                                        cDatos.push_back(p0);
254                                        cDatos.push_back(r);
255                                       
256                                        r       =       0;
257                                        k       =       long((cStripsT.size()-4-2*r));
258                                }
259
260                                i++;
261                        }
262                       
263                        regLOD.nL2      =       char(totalRegs);
264                       
265                        if (regLOD.strip != this->MARCAVACIO)
266                        {
267                                RegsCambios++;
268                                listaCambios.push_back(regLOD);
269                        }
270                }//     End for t.
271               
272                pCambios[lod]   =       RegsCambios;
273        }//     End for lod.
274
275        this->cCambios  =       listaCambios;
276
277        //      Guardar el numero de LODS disponibles.
278        this->TOTALCAMBIOS      =       this->LodsDisp=lod;
279
280        //Retornar a la lista original
281        this->cStrips   =       TiraOriginal;
282}
283
284//---------------------------------------------------------------------------
285//Put in order vertex of Mesh from simplification sequence
286//---------------------------------------------------------------------------
287void LodStripsConstructor::OrdenarModeloVQSLIM(TIPOFUNC upb)
288{
289        unsigned long int i;
290        unsigned long int j;
291        unsigned long int t;
292        unsigned long int v;
293        long int vSig;
294        long int k;
295        VECTORVERTEX                    Vertices;
296        std::vector<tipoVertice>                NuevosVerts;
297        std::vector<std::vector<int> >  NuevasTiras;
298        std::vector<int>                tira;
299        tipoOrden                               Orden;
300        tipoOrden                               *Ord;
301        bool                                    bEncontrado;
302
303
304        //      Progress bar
305        float                   percent;
306        float                   increment;
307        long    int     update;
308
309        bEncontrado = false;
310
311        size_t  mStepsSize = mGeoMeshSQ->mSteps.size();
312
313        update                  =       -1;
314        percent                 =       1.0;
315        increment               =       (float)(10.0) / (float)mStepsSize;
316       
317        for     (i = 0; i < mStepsSize; i++)
318        {
319                if (update      != (int)(i * increment))
320                {
321                        update  =       (int)(i * increment);
322                        upb(percent);
323                }
324               
325                const MeshSimplificationSequence::Step & theStep = this->mGeoMeshSQ->mSteps[i];
326
327                Orden.vQslimNext        =       theStep.mV0;
328                Orden.vQslim                    =       theStep.mV1;
329                Orden.obligatory        =       theStep.obligatory;
330                Orden.vLS                                       =       i;
331
332                Orden.x                                 =       theStep.x;
333                Orden.vLSNext           =       -1;
334                Orden.cambio            =       "n";
335
336                Ordenacion.push_back(Orden);
337        }
338       
339        update          =       -1;
340        increment       =       (float)(10.0) / (float)(Ordenacion.size());
341        percent         =       1.0;
342
343        update          =       -1;
344        increment       =       (float)(10.0) / (float)(Ordenacion.size());
345        percent         =       1.0;
346
347        //      3 seg.
348        //Ordenacion de los vertices
349        for(i = 0; i < Ordenacion.size(); i++)
350        {
351                if (update      !=      (int)(i * increment))
352                {
353                        update  =       (int)(i * increment);
354                        upb(percent);
355                }
356
357                int OrdvQslim = Ordenacion[i].vQslim;
358                int OrdvQslimNext = Ordenacion[i].vQslimNext;
359
360                NuevosVerts.push_back(this->cVerts[OrdvQslim]);
361
362                cVerts[OrdvQslim].Next  =       -1;
363        }
364
365        //      Añadir aquellos vertices que no estaban en NuevosVerts
366        //      y no se simplificaban.
367        int cont                =       0;
368        int contestaban =       0;
369
370        size_t  cVertsSize = this->cVerts.size();
371        for(i = 0; i < cVertsSize; i++)
372        {
373                if (this->cVerts[i].Next != -1)
374                {
375                        cont++;
376                        NuevosVerts.push_back(this->cVerts[i]);
377                        Orden.vLS                       =       int(Ordenacion.size());
378                        Orden.obligatory        = 0;
379                        Orden.vLSNext           =       -1;
380                        Orden.vQslim            =       i;
381                        Orden.vQslimNext        =       -1;
382
383                        Ordenacion.push_back(Orden);
384                }
385                else
386                {
387                        contestaban++;
388                }
389        }
390
391        update          =       -1;
392        increment       =       (float)(10.0)   /       (float)(Ordenacion.size());
393        percent         =       1.0;
394       
395        //      2 min.
396        //      Calcular los siguiente teniendo en cuenta el simplif.
397        for (i = 0; i < Ordenacion.size(); i++)
398        {
399                if (update      !=      (int)(i * increment))
400                {
401                        update  =       (int)(i * increment);
402                        upb(percent);
403                }
404               
405                v       =       Ordenacion[i].vQslimNext;
406
407                //Buscar ese vertice v cual es ahora
408                vSig    =       0;
409
410                for (t = 0; t < Ordenacion.size() && !vSig;t++)
411                {
412                        if (Ordenacion[t].vQslim == v)
413                        {
414                                vSig    =       Ordenacion[t].vLS;
415                        }
416                }
417
418                if (vSig != 0)
419                {
420                        Ordenacion[i].vLSNext   =       vSig;
421                }
422        }
423
424        //Creacion de nuevas tiras con las mismas dimensiones
425        size_t  cStripsSize = this->cStrips.size();
426        for(t = 0; t < cStripsSize; t++)
427        {
428                tira.clear();
429
430                size_t  cStripsSizeT = this->cStrips[t].size();
431
432                for(i = 0; i < cStripsSizeT; i++)
433                {
434                        tira.push_back(0);
435                }
436
437                NuevasTiras.push_back(tira);
438        }
439
440        update          =       -1;
441        increment       =       (float)(20.0) / (float)(NuevosVerts.size());
442        percent         =       1.0;
443
444        k       =       0;
445
446        //      2 min.
447        //Cambiar los vertices de las tiras
448        size_t  NuevosVertsSize = NuevosVerts.size();
449
450        for(v = 0; v < NuevosVertsSize; v++)
451        {
452                if (update != (int)(v * increment))
453                {
454                        update  =       (int)(v * increment);
455                        upb(percent);
456                }               
457
458                const tipoOrden & OrdenacionV = Ordenacion[v];
459
460                for(t = 0; t < cStrips.size(); t++)
461                {
462                        std::vector<int> & thisStrip = cStrips[t];                     
463                        std::vector<int> & NuevasTirasT = NuevasTiras[t];
464                        size_t  cStripsSizeT = thisStrip.size();
465
466                        for(i = 0; i < cStripsSizeT; i++)
467                        {
468                                if (thisStrip[i] == OrdenacionV.vQslim)
469                                {
470                                        k++;
471                                        NuevasTirasT[i] =       v;
472                                }
473                        }
474                }
475        }
476
477        //Cambiar a Tiras Nuevas
478        this->cStrips   =       NuevasTiras;
479
480        //NuevosVerts y Ordenacion = tamaño.
481        NuevosVertsSize = NuevosVerts.size();
482
483        for(i = 0; i < NuevosVertsSize; i++)
484        {
485                NuevosVerts[i].Next     =       Ordenacion[i].vLSNext;
486        }
487
488        //Cambiar cVerts por nuevosVerts.
489        this->cVerts    =       NuevosVerts;
490
491        //percent       =       100.0;
492        //upb(percent);
493}
494
495//---------------------------------------------------------------------------
496//      Constructor of LodStripsConstructor object from
497//      a Mesh and MeshSimplificationSequence.
498//---------------------------------------------------------------------------
499LodStripsConstructor::LodStripsConstructor(const Mesh                                           *m,
500                                                                                                                const MeshSimplificationSequence        *ms,
501                                                                                                                        size_t                                                                                                          submesh,
502                                                                                                                        TIPOFUNC                                                                                                        upb)
503{
504        MARCA   =       TOTALTIRAS      =       TOTALVERTS      =       TOTALCAMBIOS    =       0;
505       
506        meshoriginal    =       m;
507       
508        mGeoMesh                        =       new Mesh();
509        *mGeoMesh                       =       *m;
510       
511        mInitialMesh    =       new Mesh();
512        *mInitialMesh   =       *m;
513       
514        this->mGeoMeshSQ        =       const_cast<MeshSimplificationSequence*>(ms);
515
516        //      Add new vertices to mesh.
517        AddNewVertices();
518
519        //      Set the leaves submesh.
520        mSubMeshLeaves  =       submesh;
521       
522        this->GenerarModeloCompleto(upb);
523
524        //      Sort submesh bones.
525        this->sortBones();
526}
527
528//---------------------------------------------------------------------------
529//      Destructor LodStripsConstructor object
530//---------------------------------------------------------------------------
531LodStripsConstructor::~LodStripsConstructor()
532{
533        delete [] vDatos;
534        delete [] vCambios;
535/*      vector <LODData> cCambiosTemp;
536        cCambios.swap(cCambiosTemp);*/
537        cCambios.clear();
538
539/*      VECTORUNINT cDatosTemp;
540        cDatos.swap(cDatosTemp);*/
541        cDatos.clear();
542
543        delete [] vStrips;
544
545        delete [] vVerts;
546
547//      vector <VECTORINT> cStripsTemp;
548//      cStrips.swap(cStripsTemp);;
549        cStrips.clear();
550
551//      VECTORVERTEX cVertsTemp;
552//      cVerts.swap(cVertsTemp);
553        cVerts.clear();
554
555        delete [] pCambios;
556
557        delete  mInitialMesh;
558        delete  mGeoMesh;
559}
560
561//---------------------------------------------------------------------------
562//      Build lod file with necessary information and save all changes at
563//      lodStripConstructor object.
564//---------------------------------------------------------------------------
565void LodStripsConstructor::Save(std::string filename)
566{
567        int vertexCount         =       (int)this->cVerts.size();
568        int changesCount        =       (int)this->cCambios.size();
569        int dataCount                   =       (int)this->cDatos.size();
570        int cambiosCount        =       this->TOTALCAMBIOS;
571        int size                                        =       changesCount*sizeof(LODData)
572                                                                                        +
573                                                                                        (vertexCount + dataCount + cambiosCount + 4)
574                                                                                        *
575                                                                                        sizeof(int)
576                                                                                        +
577                                                                                        CHUNK_OVERHEAD_SIZE;
578
579        FILE *f =       fopen(filename.c_str(),"ab");
580
581        unsigned short chunkid  =       0xabcd;
582
583        fwrite(&chunkid,sizeof(unsigned short),1,f);
584        fwrite(&size,sizeof(unsigned long),1,f);
585
586        // VERTICES.
587        fwrite(&vertexCount, sizeof(int), 1, f);
588
589        for (size_t     i = 0; i < this->cVerts.size(); i++)
590        {
591                int auxv        =       cVerts[i].Next;
592                fwrite(&auxv, sizeof(int), 1, f);
593        }
594
595        //      CSTRIPS.
596        this->TOTALINDICES      =       0;
597       
598        for(size_t      i = 0; i < this->cStrips.size(); i++)
599        {
600                this->TOTALINDICES += int(this->cStrips[i].size());
601        }
602
603        //      lines starting with a d.
604        //      Changes
605        fwrite(&changesCount, sizeof(int), 1, f);
606        for(size_t      i = 0; i < this->cCambios.size(); i++)
607        {
608                LODData change= cCambios[i];
609                fwrite(&change, sizeof(LODData), 1, f);
610        }
611
612        //      Data.
613        fwrite(&dataCount, sizeof(int), 1, f);
614        for(size_t      i = 0; i < this->cDatos.size(); i++)
615        {
616                int data= cDatos[i];
617                fwrite(&data, sizeof(int), 1, f);
618        }
619
620        //      lines starting with a p.
621        //      Chages made in a LOD.
622        fwrite(&cambiosCount, sizeof(int), 1, f);
623
624        for(size_t      i = 0; i < this->TOTALCAMBIOS; i++)
625        {
626                int cambio= pCambios[i];
627                fwrite(&cambio, sizeof(int), 1, f);
628        }
629
630        fclose(f);
631}
632
633int LodStripsConstructor::igual(Geometry::Vector3 vo,Geometry::Vector3 vc)
634{
635        if (vo.x==vc.x && vo.y==vc.y && vo.z==vc.z)
636                return 1;
637        else
638                return 0;
639}
640
641int LodStripsConstructor::igual(Geometry::Vector2 vo,Geometry::Vector2 vc)
642{
643        if (vo.x==vc.x && vo.y==vc.y)
644                return 1;
645        else
646                return 0;
647}
648
649/*void LodStripsConstructor::Load(Serializer &oSerializer)
650{
651}*/
652
653//---------------------------------------------------------------------------
654//      Call leeVerticesyTirasDeMesh, OrdenarModeloVQSLIM
655//      and CalcularCambiosLODsVNuevaED to make changes at vertex
656//      and index strutures.
657//---------------------------------------------------------------------------
658void LodStripsConstructor::GenerarModeloV(TIPOFUNC      upb)
659{
660        long int        max;
661        long int        t;
662        unsigned long int       i;
663        float                   percent;
664
665        percent =       10;
666
667        this->leeVerticesyTirasDeMesh();
668
669        upb(percent);
670
671        //      6 min. 
672        this->OrdenarModeloVQSLIM(upb);
673
674        //Calcular el tamaño maximo de tira
675        max     =       0;
676
677        for(i = 0; i < this->TOTALTIRAS; i++)
678        {
679                t = long(this->cStrips[i].size());
680               
681                if (t > max)
682                        max     = t;
683        }
684
685        this->MARCA     =       max + 1;
686        this->CalcularCambiosLODsVNuevaED(upb);
687}
688
689//---------------------------------------------------------------------------
690//      It fills structs with vertex and index information.
691//---------------------------------------------------------------------------
692void LodStripsConstructor::CopiarVectors2ArraysNUEVAED()
693{
694        unsigned int            i;
695        unsigned int            j;
696        uint32                  max;
697        uint32                  t;
698        VECTORINT               tira;
699        LODChanges      listaCambios;
700
701        //      ALLOCATE----------------
702        this->TOTALVERTS        =       int(this->cVerts.size());
703        this->TOTALTIRAS        =       int(this->cStrips.size());
704        this->vVerts                    =       new tipoVertice[this->TOTALVERTS];
705        this->lStripsV          =       new VECTORINT[this->TOTALTIRAS];
706        this->vDatos                    =       new uint32[cDatos.size()];
707       
708        //      Calcular el tamaño maximo de tira y el numero de caras total.
709        max                                                             =       0;
710        this->TOTALCARAS        =       0;
711
712        for     (i = 0; i < this->cStrips.size(); i++)
713        {
714                t       =       int(this->cStrips[i].size());
715               
716                if (t > max)
717                {
718                        max     =       t;
719                }
720
721                this->TOTALCARAS        +=      (t-2);
722        }
723       
724        this->vStrips   =       Allocate2DArrayINT(this->TOTALTIRAS,max+1);
725        this->MARCA             =       int(this->cVerts.size());
726        vCambios                        =       new LODData[this->cCambios.size()];
727       
728        //      Rellenar vChanges.
729        for     (i = 0; i < this->cCambios.size();++i)
730        {
731                vCambios[i]     =       cCambios[i];
732        }
733       
734        for (i = 0; i < this->cStrips.size(); i++)
735        {
736                for (j = 0; j < this->cStrips[i].size(); j++)
737                {
738                        //      Rellenar el array vStrips.
739                        this->vStrips[i][j]     = this->cStrips[i][j];
740                       
741                        //      Rellenar el vVector.
742                        this->lStripsV[i].push_back(this->cStrips[i][j]);
743                }
744               
745                this->vStrips[i][j]     =       this->MARCA;
746        }
747
748        for (i = 0; i < cDatos.size(); i++)
749        {
750                vDatos[i]       =       cDatos[i];
751        }
752       
753        pCurrentData    =       vDatos;
754
755        //      Meter los vertices en vVerts.
756        for     (i = 0; i < this->cVerts.size(); i++)
757        {
758                this->vVerts[i] =       this->cVerts[i];
759        }
760
761}
762
763//---------------------------------------------------------------------------
764//      It fills cVerts and cStrips with original Mesh vertex and strips
765//      information.
766//---------------------------------------------------------------------------
767void LodStripsConstructor::leeVerticesyTirasDeMesh()
768{
769        tipoVertice     vAux;
770        std::vector<int>                tira;
771        size_t                  i;
772        size_t                  j;
773        bool                            error;
774
775        error   =       false;
776       
777        if(this->mGeoMesh->mSubMeshCount == 1)
778        {
779                error   =       false;
780        }
781        else
782        {
783                for     (i = 0; i < this->mGeoMesh->mSubMeshCount;i++)
784                {
785                        if      (this->mGeoMesh->mSubMesh[i].mSharedVertexBuffer == true)
786                        {
787                                error   =       false;
788                        }
789                        else
790                        {
791                                error   =       true;
792                                break;
793                        }
794                }
795        }
796       
797        if(!error)
798        {
799                if      (       (this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true)
800                                        &&
801                                        (this->mGeoMesh->mSubMeshCount > 1)
802                                )
803                {
804                        for     (j = 0; j < this->mGeoMesh->mVertexBuffer->mVertexCount; j++)
805                        {
806                                //      Si hay mas de un submesh ListaIndices no se rellena correctamente
807                                vAux.Vertex[0] = this->mGeoMesh->mVertexBuffer->mPosition[j].x;
808                                vAux.Vertex[1] = this->mGeoMesh->mVertexBuffer->mPosition[j].y;
809                                vAux.Vertex[2] = this->mGeoMesh->mVertexBuffer->mPosition[j].z;
810
811                                //      Añadimos las normales en cVerts.
812                                if      (       this->mGeoMesh->mVertexBuffer->mVertexInfo
813                                                        &
814                                                        Geometry::VERTEX_NORMAL
815                                                )
816                                {
817                                        vAux.Normal[0] = this->mGeoMesh->mVertexBuffer->mNormal[j].x;
818                                        vAux.Normal[1] = this->mGeoMesh->mVertexBuffer->mNormal[j].y;
819                                        vAux.Normal[2] = this->mGeoMesh->mVertexBuffer->mNormal[j].z;
820                                }
821
822                                //      Añadimos las coordenadas de textura a cVerts.
823                                if      (       this->mGeoMesh->mVertexBuffer->mVertexInfo
824                                                        &
825                                                        Geometry::VERTEX_TEXCOORDS
826                                                )
827                                {
828                                        vAux.TexCoords[0] = this->mGeoMesh->mVertexBuffer->mTexCoords[j].x;
829                                        vAux.TexCoords[1] = this->mGeoMesh->mVertexBuffer->mTexCoords[j].y;
830                                }
831
832                                vAux.Next               =       -10;
833                                vAux.numMesh    =       0;                     
834                                vAux.obligatory =       0;
835                               
836                                this->cVerts.push_back(vAux);
837                        }
838                }
839                else
840                {
841                        for     (i = 0; i < this->mGeoMesh->mSubMeshCount; i++)
842                        {
843                                for     (       j = 0;
844                                                j < this->mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount;
845                                                j++)
846                                {
847                                        //      Si hay mas de un submesh ListaIndices
848                                        //      no se rellena correctamente.
849                                        vAux.Vertex[0] = this->mGeoMesh->mSubMesh[i].
850                                                mVertexBuffer->mPosition[j].x;
851                                        vAux.Vertex[1] = this->mGeoMesh->mSubMesh[i].
852                                                mVertexBuffer->mPosition[j].y;
853                                        vAux.Vertex[2] = this->mGeoMesh->mSubMesh[i].
854                                                mVertexBuffer->mPosition[j].z;
855                                        //      Añadimos las normales en cVerts.
856                                        vAux.Normal[0] = this->mGeoMesh->mSubMesh[i].
857                                                mVertexBuffer->mNormal[j].x;
858                                        vAux.Normal[1] = this->mGeoMesh->mSubMesh[i].
859                                                mVertexBuffer->mNormal[j].y;
860                                        vAux.Normal[2] = this->mGeoMesh->mSubMesh[i].
861                                                mVertexBuffer->mNormal[j].z;
862
863                                        //      Añadimos las coordenadas de textura a cVerts.
864                                        vAux.TexCoords[0]       =       this->mGeoMesh->mSubMesh[i].
865                                                mVertexBuffer->mTexCoords[j].x;
866                                        vAux.TexCoords[1] = this->mGeoMesh->mSubMesh[i].
867                                                mVertexBuffer->mTexCoords[j].y;
868
869                                        vAux.Next                       =       -10;
870                                        vAux.numMesh    =       int(i);
871
872                                        this->cVerts.push_back(vAux);
873                                }
874                        }
875                }       
876
877                Index   indice_acum;
878                Index   num_vert;
879
880                num_vert        =       0;
881               
882                for     (i = 0; i < this->mGeoMesh->mSubMeshCount; i++)
883                {
884                        //      If is not the leaves submesh.
885                        if (mSubMeshLeaves != i)
886                        {
887                                indice_acum     =       0;
888
889                                for     (j = 0; j < this->mGeoMesh->mSubMesh[i].mStripCount; j++)
890                                {
891                                        Index   *aux    =       this->mGeoMesh->mSubMesh[i].mStrip[j];
892
893                                        /*
894                                        if (j != 0)
895                                        {
896                                                // La primera tira no empieza por índices repetidos.
897                                                aux     =       aux+1;
898
899                                                indice_acum++;
900                                        }
901                                        */
902
903                                        if (j+1 < this->mGeoMesh->mSubMesh[i].mStripCount)
904                                        {
905                                                Index   *siguiente      =       this->mGeoMesh->mSubMesh[i].mStrip[j+1];
906
907                                                tira.clear();
908
909                                                while (aux != siguiente)
910                                                {
911                                                        tira.push_back(*aux);
912                                                        indice_acum++;
913
914                                                        aux     =       aux + 1;
915                                                }
916
917                                                //tira.pop_back();
918
919                                                this->cStrips.push_back(tira);
920                                        }
921                                        else
922                                        {
923                                                // Insertar los indices de la última tira en el cStrips
924                                                tira.clear();
925
926                                                for     (       unsigned int k = indice_acum;
927                                                                k < this->mGeoMesh->mSubMesh[i].mIndexCount;
928                                                                k++)
929                                                {
930                                                        tira.push_back(this->mGeoMesh->mSubMesh[i].mIndex[k]);
931                                                }
932
933                                                this->cStrips.push_back(tira);
934                                        }
935                                }
936
937                                num_vert        +=      int(this->mGeoMesh->mSubMesh[i].
938                                        mVertexBuffer->mVertexCount);
939                        }
940                }
941
942                this->TOTALVERTS        =       int(cVerts.size());
943                this->TOTALTIRAS        =       int(cStrips.size());
944        }
945        else
946        {
947                //      Error.
948        }
949}
950
951//---------------------------------------------------------------------------
952//      GetMesh: Return de current Mesh.
953//---------------------------------------------------------------------------
954Mesh    *       LodStripsConstructor::GetMesh()
955{
956        Mesh            *mesh_built;
957
958        mesh_built              =       new Mesh();
959        *mesh_built             =       *mGeoMesh;
960
961        return  mesh_built;
962}
963
964//---------------------------------------------------------------------------
965// Sets what is the submesh that stores the leaves.
966//---------------------------------------------------------------------------
967void LodStripsConstructor::SetSubMeshLeaves(size_t      submesh)
968{
969        mSubMeshLeaves  =       submesh;
970}
971
972//---------------------------------------------------------------------------
973//      Sort submesh bones.
974//---------------------------------------------------------------------------
975void LodStripsConstructor::sortBones()
976{
977        bool                                                                    shared_found;
978        int                                                                             n;
979        int                                                                             o;
980        int                                                                             p;
981        VertexBoneAssignment    assign;
982        SubMesh                                                         *submesh;
983        SubMesh                                                         *copysubmesh;
984        VertexBuffer                                    *mesh_vb;
985        VertexBuffer                                    *copy_vb;
986
987        std::vector<VertexBoneAssignment>       *mesh_bones;
988        std::vector<VertexBoneAssignment>       *copy_bones;
989
990        //      Initialize shared vertex flag.
991        shared_found    =       false;
992
993        //      For each submesh.
994        for (size_t     i = 0;  i       <       mGeoMesh->mSubMeshCount;        i++)
995        {
996                submesh                 =       &mGeoMesh->mSubMesh[i];
997                copysubmesh     =       &mInitialMesh->mSubMesh[i];
998
999                //      If submesh has shared vertex.
1000                if (submesh->mSharedVertexBuffer)
1001                {
1002                        if (shared_found)
1003                        {
1004                                continue;
1005                        }
1006
1007                        shared_found    =       true;
1008                       
1009                        //      Vertex buffers.
1010                        mesh_vb =       mGeoMesh->mVertexBuffer;
1011                        copy_vb =       mInitialMesh->mVertexBuffer;
1012
1013                        //      Bones.
1014                        mesh_bones      =       &mGeoMesh->mBones;
1015                        copy_bones      =       &mInitialMesh->mBones;
1016                }
1017                else
1018                {
1019                        //      Vertex buffers.
1020                        mesh_vb =       submesh->mVertexBuffer;
1021                        copy_vb =       copysubmesh->mVertexBuffer;
1022
1023                        //      Bones.
1024                        mesh_bones      =       &submesh->mBones;
1025                        copy_bones      =       &copysubmesh->mBones;
1026                }
1027               
1028                if (!mesh_bones->empty())
1029                {
1030                        assign.boneIndex        =       0;
1031                        assign.weight           =       1;
1032
1033                        for (size_t     m = copy_vb->mVertexCount;
1034                                                m < mesh_vb->mVertexCount;
1035                                                m++)
1036                        {
1037                                assign.vertexIndex      =       (unsigned int)m;
1038                                mesh_bones->push_back(assign);
1039                        }
1040
1041                        //      Change bones.
1042                        for (size_t     m = 0;  m < mesh_bones->size(); m++)
1043                        {
1044                                n       =       (*mesh_bones)[m].vertexIndex;
1045                                o       =       0;
1046                               
1047                                while (!(       (mesh_vb->mPosition[n].x == copy_vb->mPosition[o].x)    &&
1048                                                        (mesh_vb->mPosition[n].y == copy_vb->mPosition[o].y)    &&
1049                                                        (mesh_vb->mPosition[n].z == copy_vb->mPosition[o].z)))
1050                                {
1051                                        o++;
1052                                }
1053
1054                                p = 0;
1055                               
1056                                while ((*copy_bones)[p].vertexIndex != o)
1057                                        p++;
1058
1059                                //      Same bone for 'm' and 'p'.
1060                                (*mesh_bones)[m].boneIndex      =       (*copy_bones)[p].boneIndex;
1061                        }
1062
1063                        //      Look for repeated bones.
1064                        for (size_t     m       =       0;      m < mesh_vb->mVertexCount;      m++)
1065                        {
1066                                for (size_t     n       =       m + 1;  n < mesh_vb->mVertexCount;      n++)
1067                                {
1068                                        if ((mesh_vb->mPosition[m].x == mesh_vb->mPosition[n].x)
1069                                                        &&
1070                                                        (mesh_vb->mPosition[m].y == mesh_vb->mPosition[n].y)
1071                                                        &&
1072                                                        (mesh_vb->mPosition[m].z == mesh_vb->mPosition[n].z))
1073                                        {
1074                                                o       =       0;
1075                                               
1076                                                while ((*mesh_bones)[o].vertexIndex != m)
1077                                                {
1078                                                        o++;
1079                                                }
1080
1081                                                p       =       0;
1082                                               
1083                                                while ((*mesh_bones)[p].vertexIndex != n)
1084                                                {
1085                                                        p++;
1086                                                }
1087
1088                                                if ((*mesh_bones)[o].boneIndex != (*mesh_bones)[p].boneIndex)
1089                                                {
1090                                                        printf("-->Error en los vertices %d y %d\n",m,n);
1091                                                }
1092                                        }
1093                                }
1094                        }
1095                }
1096        }
1097}
1098
1099void LodStripsConstructor::UpdateMesh(void)
1100{
1101        int num_no      =       0;
1102        //int i=0,j=0;
1103
1104        if(this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true)
1105        {
1106                //mPosition
1107                delete[] this->mGeoMesh->mVertexBuffer->mPosition;
1108                this->mGeoMesh->mVertexBuffer->mPosition = new Vector3[this->cVerts.size()];
1109
1110                //mNormal
1111                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
1112                {
1113                        delete[] this->mGeoMesh->mVertexBuffer->mNormal;
1114                        this->mGeoMesh->mVertexBuffer->mNormal = new Vector3[this->cVerts.size()];
1115                }
1116
1117                //mTexCoords
1118                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS)
1119                {
1120                        delete[] this->mGeoMesh->mVertexBuffer->mTexCoords;
1121                        this->mGeoMesh->mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()];
1122                }
1123
1124                this->mGeoMesh->mVertexBuffer->mVertexCount     =       this->cVerts.size();
1125                this->mGeoMesh->mVertexBuffer->mVertexInfo              =       this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo;
1126
1127                for(size_t      i = 0; i < this->mGeoMesh->mSubMeshCount; i++)
1128                {
1129                        this->mGeoMesh->mSubMesh[i].mVertexBuffer       =       this->mGeoMesh->mVertexBuffer;
1130                        this->mGeoMesh->mSubMesh[i].mSharedVertexBuffer =       true;
1131                }
1132
1133                int     indice  =       0;
1134
1135                for (size_t     j       =       0;      j < this->cVerts.size();        j++)
1136                {
1137                        //Copiamos las coordeandas de posicion
1138                        this->mGeoMesh->mVertexBuffer->mPosition[indice].x      =       this->cVerts[j].Vertex[0];
1139                        this->mGeoMesh->mVertexBuffer->mPosition[indice].y      =       this->cVerts[j].Vertex[1];
1140                        this->mGeoMesh->mVertexBuffer->mPosition[indice].z      =       this->cVerts[j].Vertex[2];
1141
1142                        //Copiamos las normales
1143                        if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
1144                        {
1145                                this->mGeoMesh->mVertexBuffer->mNormal[indice].x        =       this->cVerts[j].Normal[0];
1146                                this->mGeoMesh->mVertexBuffer->mNormal[indice].y        =       this->cVerts[j].Normal[1];
1147                                this->mGeoMesh->mVertexBuffer->mNormal[indice].z        =       this->cVerts[j].Normal[2];
1148                        }
1149
1150                        //Copiamos las coordenadas de textura
1151                        if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS)
1152                        {
1153                                this->mGeoMesh->mVertexBuffer->mTexCoords[indice].x     =       this->cVerts[j].TexCoords[0];
1154                                this->mGeoMesh->mVertexBuffer->mTexCoords[indice].y     =       this->cVerts[j].TexCoords[1];
1155                        }
1156
1157                        indice++;
1158                }
1159
1160                this->mGeoMesh->mVertexBuffer->mVertexCount     =       indice;
1161        }
1162        else    //OSCAR
1163        {
1164                //Supondre que solo tengo un submesh con vertices no compartidos
1165                //mPosition
1166                delete[]        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition;
1167               
1168                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition    =       new Vector3[this->cVerts.size()];
1169
1170                //mNormal
1171                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
1172                {
1173                        delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal;
1174                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal = new Vector3[this->cVerts.size()];
1175                }
1176
1177                //mTexCoords
1178                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS)
1179                {
1180                        delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords;
1181                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()];
1182                }
1183
1184                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =this->cVerts.size();
1185                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexInfo = this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo;
1186
1187                this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer=false;
1188
1189                int     indice  =       0;
1190
1191                for (size_t     j       =       0;      j < this->cVerts.size();        j++)
1192                {
1193                        //Copiamos las coordeandas de posicion
1194                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].x=this->cVerts[j].Vertex[0];
1195                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].y=this->cVerts[j].Vertex[1];
1196                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].z=this->cVerts[j].Vertex[2];
1197
1198                        //Copiamos las normales
1199                        if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
1200                        {
1201                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].x=this->cVerts[j].Normal[0];
1202                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].y=this->cVerts[j].Normal[1];
1203                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].z=this->cVerts[j].Normal[2];
1204                        }
1205
1206                        //Copiamos las coordenadas de textura
1207                        if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS)
1208                        {
1209                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].x=this->cVerts[j].TexCoords[0];
1210                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].y=this->cVerts[j].TexCoords[1];
1211                        }
1212                        indice++;
1213                }
1214                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =indice;
1215        }
1216       
1217        int indice_acum = 0;
1218
1219        for(size_t      i = 0;  i < this->mGeoMesh->mSubMeshCount;      i++)
1220        {
1221                Geometry::SubMesh & subMesh = meshoriginal->mSubMesh[i];
1222                Geometry::SubMesh & mGeoMeshSubMesh = this->mGeoMesh->mSubMesh[i];
1223
1224                for (size_t ind=0; ind < subMesh.mIndexCount; ind++)
1225                {
1226                        Index indIndex = subMesh.mIndex[ind];
1227                        if (subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS)
1228                        {
1229                                //Hay coordenadas de textura y normales
1230                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
1231                                {
1232                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++)
1233                                        {
1234                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo]))
1235                                                {
1236                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo]))
1237                                                        {
1238                                                                if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo]))
1239                                                                {
1240                                                                        mGeoMeshSubMesh.mIndex[ind]= int(indvo);//+indice_acum;
1241                                                                }
1242                                                        }
1243                                                }
1244                                        }
1245                                }
1246                                else            //Hay coordenadas de textura pero no hay normales
1247                                {
1248                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++)
1249                                        {
1250                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo]))
1251                                                {
1252                                                        if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo]))
1253                                                        {
1254                                                                mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum;
1255                                                        }
1256                                                }
1257                                        }
1258                                }
1259                        }
1260                        else
1261                        {
1262                                // No hay coordenadas de textura pero si normales
1263                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL)
1264                                {
1265                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++)
1266                                        {
1267                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo]))
1268                                                {
1269                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo]))
1270                                                        {
1271                                                                mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum;
1272                                                        }
1273                                                }
1274                                        }
1275                                }
1276                                else            //No hay coordenadas de texturas ni normales
1277                                {
1278                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++)
1279                                        {
1280                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo]))
1281                                                {
1282                                                        mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum;
1283                                                }
1284                                        }
1285                                }
1286                        }
1287                }
1288        }
1289}
1290
1291//---------------------------------------------------------------------------
1292//      Add new vertices to mesh.
1293//---------------------------------------------------------------------------
1294void LodStripsConstructor::AddNewVertices()
1295{
1296        int                             num_vertices;
1297        SubMesh                 *geosubmesh;
1298        VertexBuffer    *vertex_buffer;
1299        VertexBuffer    *new_vertex_buffer;
1300
1301        //      Gets old vertex buffer.
1302        vertex_buffer   =       mGeoMesh->mVertexBuffer;
1303       
1304        num_vertices    =       vertex_buffer->mVertexCount
1305                                                                        +
1306                                                mGeoMeshSQ->mNewVertices.size();
1307
1308        //      Initialize auxiliar vertex buffer.
1309        new_vertex_buffer       =       new     VertexBuffer();
1310
1311        new_vertex_buffer->mVertexCount =       num_vertices;
1312       
1313        new_vertex_buffer->mPosition            =       new     Vector3[num_vertices];
1314        new_vertex_buffer->mNormal                      =       new     Vector3[num_vertices];
1315        new_vertex_buffer->mTexCoords           =       new     Vector2[num_vertices];
1316
1317        new_vertex_buffer->mVertexInfo  =       vertex_buffer->mVertexInfo;
1318
1319        //      Num old vertices.
1320        num_vertices    =       vertex_buffer->mVertexCount;
1321
1322        //      Copy the old vertex buffer.
1323        for     (unsigned       int     i       =       0;      i < num_vertices;       i++)
1324        {
1325                new_vertex_buffer->mPosition[i] =       vertex_buffer->mPosition[i];
1326                new_vertex_buffer->mNormal[i]   =       vertex_buffer->mNormal[i];
1327                new_vertex_buffer->mTexCoords[i]=       vertex_buffer->mTexCoords[i];
1328        }
1329
1330
1331        //      Copy new vertices.
1332        for (unsigned   int     i       =       0;      i < mGeoMeshSQ->mNewVertices.size();    i++)
1333        {
1334                new_vertex_buffer->mPosition[num_vertices + i] = mGeoMeshSQ->mNewVertices[i].position;
1335                new_vertex_buffer->mTexCoords[num_vertices + i] = mGeoMeshSQ->mNewVertices[i].texcoord;
1336                new_vertex_buffer->mNormal[num_vertices + i] = mGeoMeshSQ->mNewVertices[i].normal;
1337
1338                // check if my twin-vertex-bone has a bone assignment
1339                // we check only the GeoMesh bones because the lodstrips only works for sharedvertex bones
1340                for (std::vector<VertexBoneAssignment>::iterator it = mGeoMesh->mBones.begin(); it != mGeoMesh->mBones.end(); it ++)
1341                {
1342                        if (it->vertexIndex == mGeoMeshSQ->mNewVertices[i].bonefrom)
1343                        {
1344                                VertexBoneAssignment vba;
1345                                vba.boneIndex = it->boneIndex;
1346                                vba.vertexIndex = mGeoMeshSQ->mNewVertices[i].id;
1347                                vba.weight = it->weight;
1348                                mGeoMesh->mBones.push_back(vba);
1349                        }
1350                }
1351        }
1352
1353        //      For each submesh.
1354        for (unsigned int submesh       =       0; submesh < mGeoMesh->mSubMeshCount; submesh++)
1355        {
1356                geosubmesh      =       &mGeoMesh->mSubMesh[submesh];
1357
1358                geosubmesh->mVertexBuffer       =       new_vertex_buffer;
1359        }
1360
1361        delete  vertex_buffer;
1362       
1363        mGeoMesh->mVertexBuffer =       new_vertex_buffer;
1364}
1365
Note: See TracBrowser for help on using the repository browser.