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

Revision 1552, 33.9 KB checked in by gumbau, 18 years ago (diff)

Fixed degenerates in LodStripsFixed?

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