source: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp @ 2085

Revision 2085, 18.4 KB checked in by gumbau, 17 years ago (diff)
RevLine 
[2085]1/*========================================================================
[774]2 *      (C) 2005 Universitat Jaume I
[2085]3 *========================================================================
[774]4 *      PROYECT:        GAME TOOLS
[2085]5 *========================================================================
[1009]6 *      CONTENT:
7 *
8 *
9 *      @file   GeoLodStripsLibrary.cpp
[2085]10 *=======================================================================*/
[774]11
12#include "GeoLodStripsLibrary.h"
13
14using namespace Geometry;
[1541]15using   namespace       std;
[774]16
[2085]17//-------------------------------------------------------------------------
[1526]18//      Constructor.
[2085]19//-------------------------------------------------------------------------
20LodStripsLibrary::LodStripsLibrary(
21                                                                                                                const LodStripsLibraryData      *lodstripsdata,
22                                                                                                                Mesh                                                                                            *geomesh,
23                                                                                                                IndexData                                                                               *userindexdata)
[774]24{
25        //      Sets the current lod.
26        mCurrentLod     =       0;
27
28        //      Sets the global mesh.
29        mGeoMesh = geomesh;
[1018]30
[1560]31        delete_indexdata                                =       false;
32        dataRetrievalInterface  =       userindexdata;
33        indices_x_submesh                               =       NULL;
34        offsets_x_submesh                               =       NULL;
35        mStripsSubmesh                                  =       NULL;
36        submesh_x_strip                                 =       NULL;
37        lodFactor                                                               =       1.0f;
38        current_triangle_count  =       0;
[1526]39       
[774]40        //      Loads the Level Of Detail file.
[1078]41        LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh);
[1058]42
[1560]43        GoToLod(0.0f);
44
45        minFaces        =       0;
46
[1058]47        for (unsigned int strip = 0; strip < mTotalStrips; strip++)
[1560]48        {
49                minFaces        +=      int(mStrips[strip].size() - 2);
50        }
[1058]51
52        GoToLod(1.0f);
[1560]53
54        maxFaces        =       0;
55
[1058]56        for (unsigned int strip = 0; strip < mTotalStrips; strip++)
[1560]57        {
58                maxFaces        +=      int(mStrips[strip].size() - 2);
59        }
[774]60}
61
[2085]62//-------------------------------------------------------------------------
[1526]63//      Destructor
[2085]64//-------------------------------------------------------------------------
[774]65LodStripsLibrary::~LodStripsLibrary()
66{
[1014]67        delete  [] mStrips;
[1526]68        if (delete_indexdata)
[1018]69                delete dataRetrievalInterface;
[1078]70        if (indices_x_submesh)
71                delete[] indices_x_submesh;
[1083]72        if (offsets_x_submesh)
73                delete[] offsets_x_submesh;
[1090]74        if (mStripsSubmesh)
75                delete[] mStripsSubmesh;
[1526]76        if (submesh_x_strip)
77                delete[] submesh_x_strip;
[774]78}
79
[2085]80//-------------------------------------------------------------------------
[774]81//      Public.
[2085]82//-------------------------------------------------------------------------
[774]83
[2085]84//-------------------------------------------------------------------------
[1009]85//      Go to the level of detail.
[2085]86//-------------------------------------------------------------------------
[1058]87void LodStripsLibrary::GoToLod(float lodfactor)
[774]88{
[1541]89        register        int                     j;
90        register        int                     offset;
[1526]91        long                    int                     i;
92        long                    int                     k;
93        long                    int                     b_change_ok     =       1;
[1541]94        unsigned long   int     lod;
[1526]95        long                    int                     t;
96        long                    int                     r;
97        long                    int                     next;
98        long                    int                     el1;
99        long                    int                     el2;
100        long                    int                     total_changes;
101        long                    int                     totalR;
[1541]102        SmallIntVector                                          *strip;
[774]103        SmallIntVector::iterator        start;
104
[1526]105        if (lodfactor<0.0f) lodfactor=0.0f;
106        if (lodfactor>1.0f) lodfactor=1.0f;
107
[1070]108        uint32 newLOD = (uint32)((1.0f - lodfactor) * mLods);
[1526]109
110        lodFactor=lodfactor;
[1058]111   
[774]112        if (newLOD != mCurrentLod)
113        {
114                if (newLOD > mCurrentLod)
115                {
[1014]116                        //      Forwards.
[1530]117                        //      Increments LOD (decreases level of detail)
[1541]118                        for (   lod     =       mCurrentLod;
119                                                (lod < newLOD)
120                                                ||
121                                                ((mCurrentRegLOD->obligatory == 1) && (lod < (mLods - 1)));
122                                                lod++)
[774]123                        {
[1541]124                                next                                    =       mVertex[lod];
[774]125                                total_changes   =       mPChanges[lod];
126
127                                for (i = 0; i < total_changes; i++)
128                                {
[1014]129                                        //      Strip change.
[1541]130                                        t                       =       mCurrentRegLOD->strip;
[774]131                                        strip   =       &(mStrips[t]);
[1541]132                                        start   =       strip->begin();
133
[1526]134                                        int stripsize_ini = strip->size();
[774]135                               
136                                        //      Position.
137                                        totalR  =       mCurrentRegLOD->position;
138
139                                        for (j = totalR - 1; j >= 0; j--)
140                                        {
[1526]141                                                start[*mCurrentData]    =       next;                                           
[774]142                                                ++mCurrentData;
143                                        }
144                                       
145                                        //      L1.
146                                        totalR  =       mCurrentRegLOD->vertexRepetition;
147                                       
148                                        for (j = totalR - 1; j >= 0; j--)
149                                        {
150                                                offset  =       *mCurrentData + 1;
151
152                                                strip->erase(   start + offset,
153                                                                                                        start
154                                                                                                        +
155                                                                                                        offset
156                                                                                                        +
157                                                                                                        (*(mCurrentData + 1)));
158
159                                                ++mCurrentData;
160                                                ++mCurrentData;
161                                        }
162                                       
163                                        //      L2
164                                        totalR  =       mCurrentRegLOD->edgeRepetition;
165                                       
166                                        for (j = totalR - 1; j >= 0; j--)
167                                        {
168                                                offset  =       *mCurrentData + 2;
169                                                strip->erase(   start   +       offset,
170                                                                                                        start
171                                                                                                        +
172                                                                                                        offset
173                                                                                                        +
174                                                                                                        2*(*(mCurrentData + 1)));
175
[1014]176                                                mCurrentData++;
177                                                mCurrentData++;
[774]178                                        }
179
[1530]180//                                      lastLOD = mCurrentRegLOD;
[1014]181                                        mCurrentRegLOD++;
[774]182                                       
183                                        mStripsChanges[t]       =       1;
[1526]184
185                                        int stripsize_end = strip->size();
186                                        indices_x_submesh[submesh_x_strip[t]] -= (stripsize_ini - stripsize_end);
[774]187                               
188                                }
189                               
190                                mCurrentLod     =       lod + 1;
191                        }
192
193                }
[1014]194                //      If LOD is less than actual.
[774]195                else
196                {
[1014]197                        mCurrentRegLOD--;
198                        mCurrentData--;
[1541]199
200
[1014]201                        //      Decrements LOD.
[1541]202                        for (   lod     =       mCurrentLod;
203                                                (lod > newLOD)
204                                                ||
205                                                ((mCurrentRegLOD->obligatory == 1) && (lod > 0))
206                                                ||
207                                                ((mCurrentRegLOD[1].obligatory == 1) && (lod > 0));
208                                                lod--)
[774]209                        {
[1541]210
[774]211                                total_changes   =       mPChanges[lod - 1];
212                               
213                                for (i = 0; i < total_changes; i++)
214                                {
215                                        t                       =       mCurrentRegLOD->strip;
216                                        strip   =       &(mStrips[t]);
217                                        start   =       mStrips[t].begin();
[1526]218                                        int stripsize_ini = strip->size();
[774]219
220                                        //      L2.
221                                        totalR  =       mCurrentRegLOD->edgeRepetition;
222                                       
223                                        for (j = 0; j < totalR; j++)
224                                        {
225                                                el1     =       (*strip)[*(mCurrentData - 1)];
226                                                el2     =       (*strip)[*(mCurrentData - 1) + 1];
227                                                r               =       *(mCurrentData);
228                                               
229                                                for (k = 0; k < r; k++)
230                                                {
231                                                        (*strip).insert(start+*(mCurrentData - 1),el2);
232                                                        (*strip).insert(start+*(mCurrentData - 1),el1);
233                                                }
234                                               
[1014]235                                                mCurrentData--;
236                                                mCurrentData--;
[774]237                                        }
238
239                                        //      Vertex Repetition.
240                                        totalR  =       mCurrentRegLOD->vertexRepetition;
241                                       
242                                        for (j = 0; j < totalR; j++)
243                                        {
244                                                el1     =       (*strip)[*(mCurrentData-1)];
245                                                r               =       *(mCurrentData);
246                                               
247                                                for (k = 0; k < r; k++)
248                                                {
249                                                        (*strip).insert(start+*(mCurrentData-1),el1);
250                                                }
251
[1014]252                                                mCurrentData--;
253                                                mCurrentData--;
[774]254                                        }
255                                       
256                                        //      POS.
257                                        totalR  =       mCurrentRegLOD->position;
258                                       
259                                        for (j = 0; j < totalR; j++)
260                                        {
261                                                (*strip)[*mCurrentData] =       lod - 1;
[1014]262                                                mCurrentData--;
[774]263                                        }
264                                       
[1530]265        //                              lastLOD = mCurrentRegLOD;
[1014]266                                        mCurrentRegLOD--;
[774]267                                        mStripsChanges[t]       =       1;
[1526]268
269                                        int stripsize_end = strip->size();
270                                        indices_x_submesh[submesh_x_strip[t]] += (stripsize_end - stripsize_ini);
[774]271                                }                       
272                               
[1541]273                                //      Update LOD.
[774]274                                mCurrentLod     =       lod - 1;
[1541]275
276                                //      Debug.
277                                cout    <<      "Obligatory: "
278                                                        <<      (int)mCurrentRegLOD->obligatory
279                                                        <<      endl;
[774]280                        }
281                       
[1014]282                        mCurrentData++;
283                        mCurrentRegLOD++;
[774]284                }
285        }
286
[1552]287/*      // debug!
288        FILE *f = fopen("lodstrips_lodinfo.txt","wt");
289        fprintf(f,"mCurrentLOD: %d",mCurrentLod);
290        fprintf(f,"mLods: %d",mLods);
291        for (int i=0; i<mTotalStrips; i++)
292        {
293                fprintf(f,"\nstrip: %d - ",i);
294                for (int j=0; j<mStrips[i].size(); j++)
295                {
296                        int ind = mStrips[i][j];
297                        fprintf(f,"%d ",ind);
298                }
299        }
300        fclose(f);*/
301
[1018]302        UpdateDataRetrievalInterface();
[1058]303//      return  return_value;
[774]304}
305
[2085]306//-------------------------------------------------------------------------
[1009]307//      Returns the number of vertices of the highest LOD.
[2085]308//-------------------------------------------------------------------------
[774]309uint32  LodStripsLibrary::MaxVertices()
310{
[1007]311        return  mMaxVerticesLOD;
[774]312}
313
[2085]314//-------------------------------------------------------------------------
[1009]315//      Returns the number of vertices of the lowest LOD.
[2085]316//-------------------------------------------------------------------------
[774]317uint32  LodStripsLibrary::MinVertices()
318{
319        uint32  number_of_vertices;
320
[1014]321        //      Total vertices of minimum lod.
[1007]322        number_of_vertices      =       mMaxVerticesLOD - (mMinLod + 1);
[774]323
324        return  number_of_vertices;
325}
326
[2085]327//-------------------------------------------------------------------------
[1009]328//      Returns the number of triangles of the highest LOD.
[2085]329//-------------------------------------------------------------------------
[774]330uint32  LodStripsLibrary::MaxFaces()
331{
[1058]332/*      uint32  number_of_faces;
[774]333
334        uint32  current_lod;
335
336        current_lod     =       GoToLod(MaxLod());
337
338        //      Initialize number of faces count.
339        number_of_faces =       0;
340
341        //      For each strip.
[985]342        for (unsigned int strip =       0; strip < mTotalStrips; strip++)
[774]343        {
[985]344                number_of_faces +=      int(mStrips[strip].size() - 2);
[774]345        }
346
347        GoToLod(current_lod);
348
[1058]349        return  number_of_faces;*/
350
351        return maxFaces;
[774]352}
353
[2085]354//-------------------------------------------------------------------------
[1009]355//      Returns the number of triangles of the lowest LOD.
[2085]356//-------------------------------------------------------------------------
[774]357uint32  LodStripsLibrary::MinFaces()
358{
[1058]359/*      uint32  current_lod;
[774]360        uint32  number_of_faces;
361
362        current_lod     =       GoToLod(MinLod());
363
364        //      Initialize number of faces count.
365        number_of_faces =       0;
366
367        //      For each strip.
[985]368        for (unsigned int strip =       0; strip < mTotalStrips; strip++)
[774]369        {
[985]370                number_of_faces +=      int(mStrips[strip].size() - 2);
[774]371        }
372
373        GoToLod(current_lod);
374
[1058]375        return  number_of_faces;*/
376
377        return minFaces;
[774]378}
379
[2085]380//-------------------------------------------------------------------------
[1009]381//      Establishes the new LOD range.
382//      Only the LODs in that range are stored and used.
[2085]383//-------------------------------------------------------------------------
[774]384void            LodStripsLibrary::TrimByLod(uint32 minLod, uint32 maxLod)
385{
[1007]386        //      Refresh number of vercies of the max lod.
387        mMaxVerticesLOD +=      mMaxLod - maxLod;
388       
[774]389        mMinLod =       minLod;
390        mMaxLod =       maxLod;
391}
[1018]392/*
[2085]393//-------------------------------------------------------------------------
[1009]394//      Get strip count.
[2085]395//-------------------------------------------------------------------------
[829]396uint32  LodStripsLibrary::GetStripCount() const
[774]397{
398        return  (uint32)        mTotalStrips;
399}
400
[2085]401//-------------------------------------------------------------------------
[1009]402//      Get Index by strip.
[2085]403//-------------------------------------------------------------------------
[829]404uint32  LodStripsLibrary::GetIndexCountByStrip(uint32 istrip) const
405{
406        return (uint32) mStrips[istrip].size();
407}
[1018]408*/
[2085]409//-------------------------------------------------------------------------
[774]410//      Private.
[2085]411//-------------------------------------------------------------------------
[774]412
[2085]413//-------------------------------------------------------------------------
[1009]414//      Copy a STL vector to a C array.
[2085]415//-------------------------------------------------------------------------
[1526]416void LodStripsLibrary::CopyVectors2Arrays(void)
[774]417{
418        SmallInt                                        max;
419        SmallInt                                        t;
420        SmallInt                                        *data_array;
421        SmallIntVector          tira;
422        LODRegisterType         *changes_array;
423        LODRegisterVector       list_changes;
424
[985]425        mTotalStrips            =       int(mFileStrips.size());
[774]426        mVertex                                 =       new SmallInt[mTotalVertices];
427        mStripsChanges  =       new SmallInt[mTotalChanges];
428        mStrips                                 =       new SmallIntVector[mTotalStrips];
429        data_array                      =       new SmallInt[mData.size()];
430       
431        max                                     =       0;
432        mTotalFaces     =       0;
[1018]433
[1069]434//      unsigned int * strip_sizes = new unsigned int[mFileStrips.size()];
435        unsigned int total_strip_size = 0;
[1070]436       
437        for (unsigned   int     i = 0; i < mFileStrips.size(); i++)
[774]438        {
[1069]439                total_strip_size += t = int(mFileStrips[i].size());
[774]440                if (t>max)
441                        max     =       t;
442                mTotalFaces     +=      t - 2;
443        }
444
445        changes_array   =       new LODRegisterType[mFileChangesLOD.size()];
446       
[1014]447        //      Fill up changes array.
[1070]448        for (unsigned   int     i = 0; i < mFileChangesLOD.size(); ++i)
[774]449        {
450                changes_array[i]        =       mFileChangesLOD[i];
451        }
452
453        mCurrentRegLOD  =       changes_array;
454       
[2085]455//      Copy strips.
[1325]456//      unsigned int numDegenerated = 2*mTotalStrips - 2;
[1526]457//      dataRetrievalInterface=create_index_data_func(total_strip_size,indexdata_user_data); // temporal!
[1070]458
[1526]459//      dataRetrievalInterface->Init(total_strip_size);
460/*      dataRetrievalInterface->numinds=total_strip_size;
461        dataRetrievalInterface->numvalidinds=total_strip_size;*/
462//      dataRetrievalInterface->Begin();
463
[1070]464        unsigned        int     ii = 0;
465
466        for (unsigned   int     i = 0; i < mFileStrips.size(); i++)
[774]467        {
[1070]468                for (unsigned   int     j = 0; j < mFileStrips[i].size(); j++,ii++)
[774]469                {
470                        mStrips[i].push_back(mFileStrips[i][j]);
[1526]471//                      dataRetrievalInterface->SetIndex(ii,mFileStrips[i][j]);
[774]472                }
473               
[1014]474                //      Reset flags of strips changed.
[774]475                mStripsChanges[i]       =       0;
476        }
[1552]477
[1526]478//      dataRetrievalInterface->End();
[774]479
[1070]480        for (unsigned   int     i = 0; i < mData.size(); i++)
[774]481        {
482                data_array[i]   =       mData[i];
483        }
484       
485        mCurrentData    =       data_array;
486
[1014]487        //      Fill up mVertex.
[1070]488        for(unsigned    int     i = 0; i < mFileVertices.size(); i++)
[774]489        {
490                mVertex[i]      =       mFileVertices[i];
491        }
[1018]492
[1069]493//      delete[] strip_sizes;
[774]494}
495
[2085]496//-------------------------------------------------------------------------
[1009]497//      LoadStripMesh
[2085]498//-------------------------------------------------------------------------
499void LodStripsLibrary::LoadStripMesh(
500                                                                                                                const LodStripsLibraryData *lodstripsdata,
501                                                                                                                Mesh *geomesh)
[774]502{
503        SmallIntVector                                                                          strip_aux;
504        std::vector                     <LODRegisterType>       list_pos;
505        std::vector                     <unsigned int>          p_changes;
[1014]506        int                                                                                                                             v                       =       0;
507        int                                                                                                                             t                       =       -1;
508        int                                                                                                                             s                       =       0;
509        int                                                                                                                             next    =       0;
510        int                                                                                                                             c                       =       -1;
[774]511        Index                                                                                                                   *index;
512        Index                                                                                                                   *indexBegin;
513        Index                                                                                                                   *indexEnd;
514        SubMesh                                                                                                         *geoSubMesh;
515
516        //      For each one of the submeshes.
[1078]517        indices_x_submesh = new int[geomesh->mSubMeshCount];
[1083]518        offsets_x_submesh = new int[geomesh->mSubMeshCount];
[1526]519
520        int totaltiras = 0;
[2085]521
522        for (   unsigned int submesh = 0;
523                                submesh < geomesh->mSubMeshCount;
524                                submesh++)
525        {
526                for (   unsigned int strip = 0;
527                                        strip < geomesh->mSubMesh[submesh].mStripCount;
528                                        strip++)
529                {
[1526]530                        totaltiras++;
[2085]531                }
532        }
[1526]533
534        submesh_x_strip = new int[totaltiras];
535
536        int istrip = 0;
[2085]537       
538        for (   size_t  submesh =       0;      submesh < geomesh->mSubMeshCount;       submesh++)
[774]539        {
540                geoSubMesh      =       &geomesh->mSubMesh[submesh];
[1526]541                indices_x_submesh[submesh] = 0;
[774]542
543                //      For each one of the strips.
[2085]544                for (   unsigned int strip = 0;
545                                        strip < geoSubMesh->mStripCount;
546                                        strip++, istrip++)
[774]547                {
548                        // Insert an empty strip.
[1526]549                        submesh_x_strip[istrip] = submesh;
[774]550                        t++;
551                        strip_aux.clear();
552                        mFileStrips.push_back(strip_aux);
553
554                        //      First index of the strip.
555                        indexBegin      =       geoSubMesh->mStrip[strip];
556
[1552]557                        //      If the strips is not the first. (DEG!)
558                        if (strip != 0)
[2085]559                        {
[774]560                                indexBegin++;
[2085]561                        }
[774]562
563                        //      If is the final strip
564                        if (strip       == (geoSubMesh->mStripCount - 1))
565                        {
566                                //      The end of the index array.
567                                indexEnd        = &geoSubMesh->mIndex[geoSubMesh->mIndexCount];
568                        }
569                        else
570                        {
571                                //      The beginning of the next strip.
572                                indexEnd        = geoSubMesh->mStrip[strip + 1];
573
[1552]574                                //      Remove degenerated (DEG!)
575                                indexEnd--;
[774]576                        }
577                       
578                        int i;
579                        i       = 0;
[1526]580                       
[1083]581                        if (submesh==0)
[2085]582                        {
[1083]583                                offsets_x_submesh[submesh] = 0;
[2085]584                        }
[1083]585                        else
[2085]586                        {
[1083]587                                offsets_x_submesh[submesh] = indices_x_submesh[submesh-1];
[2085]588                        }
[1083]589
[774]590                        //      For each index of the strip.
591                        for (index = indexBegin; index < indexEnd; index++)
592                        {
593                                mFileStrips[t].push_back(indexBegin[i]);
[1078]594                                indices_x_submesh[submesh]++;
[774]595                                i++;
[2085]596                        }
[774]597                }
598        }
599
[2085]600        mFileVertices           = lodstripsdata->mFileVertices;
601        mFileChangesLOD = lodstripsdata->mFileChangesLOD;
602        mData                                           = lodstripsdata->mData;
603        p_changes                               = lodstripsdata->p_changes;
[1078]604
[2085]605        mStripsSubmesh  = new int [geomesh->mSubMeshCount];
[774]606
[1136]607        for (size_t     submesh = 0; submesh < geomesh->mSubMeshCount; submesh++)
[2085]608        {
609                mStripsSubmesh[submesh] =       0;
[1090]610        }
[774]611
[1090]612        //      Max / Min values for LOD.
613        mLods                                                                                   =       int(p_changes.size());
614        mMaxLod                                                                         =       0;
615        mMinLod                                                                         =       mLods;
[774]616
[1090]617        mPChanges                       =       new SmallInt[mLods];
618       
619        for (unsigned int i = 0; i < mLods; i++)
[2085]620        {
[1090]621                mPChanges[i] = p_changes[i];
[2085]622        }
[1090]623
624        mTotalVertices          =       int(mFileVertices.size());
625        mMaxVerticesLOD         =       mTotalVertices;
626        mTotalStrips                    =       int(mFileStrips.size());
627        mTotalChanges                   =       int(mFileChangesLOD.size());
628
629        //Copy the data to the structure we will use
630        CopyVectors2Arrays();
[774]631}
632
[1018]633void LodStripsLibrary::UpdateDataRetrievalInterface(void)
634{
[1560]635        int                                             target_submesh  =       0;
636        size_t                          strip_count                     =       0;
637        unsigned int    ii_submesh                      =       0;
[2085]638        uint32                          numdeg                                  =       0;
[1560]639
[1552]640        current_triangle_count = 0;
[1078]641
[1552]642        // indices_x_submesh is calculated without degenerates,
643        // we must add the degenerate indices added here
[2085]644        if (mGeoMesh->mSubMesh[target_submesh].mStripCount > 0)
645        {
646                numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount * 2 - 2;
647        }
[1325]648
[1560]649        dataRetrievalInterface->Begin(target_submesh,
650                                                                                                                                indices_x_submesh[target_submesh] + numdeg);
[1526]651
[1560]652        current_triangle_count  +=      indices_x_submesh[target_submesh] + numdeg;
653
654        //      For each strip.
[1552]655        for (unsigned int i = 0; i < mTotalStrips; i++, strip_count++)
[1018]656        {
[1078]657                if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount)
658                {
[1560]659                        if (target_submesh == 0)
660                        {
[1083]661                                offsets_x_submesh[target_submesh] = 0;
[1560]662                        }
[1083]663                        else
[1560]664                        {
[2085]665                                offsets_x_submesh[target_submesh] =
666                                                                        indices_x_submesh[target_submesh-1]
667                                                                        +
668                                                                        offsets_x_submesh[target_submesh-1];
[1560]669                        }
[1083]670
[1136]671                        mStripsSubmesh[target_submesh]  =       (int)strip_count;
[1325]672                        strip_count     =       0;
[1136]673
[1078]674                        target_submesh++;
[1526]675                        ii_submesh = 0;
676                        dataRetrievalInterface->End();
[1560]677
[2085]678                        if (mGeoMesh->mSubMesh[target_submesh].mStripCount > 0)
679                        {
680                                numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2;
681                        }
[1560]682
683                        dataRetrievalInterface->Begin(target_submesh,
[2085]684                                                                                                                                                indices_x_submesh[target_submesh]
685                                                                                                                                                +
686                                                                                                                                                numdeg);
[1552]687                       
[2085]688                        current_triangle_count  +=      indices_x_submesh[target_submesh]
689                                                                                                                                        +
690                                                                                                                                        numdeg;
[1078]691                }
[1560]692
[1087]693                int lastindex = -1;
[1560]694
695                for (   SmallIntVector::iterator it     =       mStrips[i].begin();
696                                        it != mStrips[i].end();
697                                        it++, ii_submesh++)
[1078]698                {
[1552]699                        // repeat the first index of the strip: degenerate (DEG!)
700                        // except for the first strip in a mesh
[1560]701                        if ((lastindex == -1) && (strip_count > 0))
[1087]702                        {
[1560]703                                lastindex       =       *it;
704
[2085]705                                dataRetrievalInterface->SetIndex(ii_submesh,*it);
[1552]706                                ii_submesh++;
707                        }
[1560]708
709                        lastindex       =       *it;
[1526]710                        dataRetrievalInterface->SetIndex(ii_submesh,*it);
[1078]711                }
[1087]712
[1552]713                // repeat last vertex of the strip: degenerate (DEG!)
714                // except for the last strip in a mesh
[1560]715                if (strip_count < mGeoMesh->mSubMesh[target_submesh].mStripCount-1)
[1552]716                {
717                        dataRetrievalInterface->SetIndex(ii_submesh,lastindex);
718                        ii_submesh++;
719                }
[1018]720        }
[1078]721
722        if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount)
723        {
[1560]724                if (target_submesh == 0)
725                {
[1083]726                        offsets_x_submesh[target_submesh] = 0;
[1560]727                }
[1083]728                else
[1560]729                {
[2085]730                        offsets_x_submesh[target_submesh] =
731                                                                        indices_x_submesh[target_submesh - 1]
732                                                                        +
733                                                                        offsets_x_submesh[target_submesh - 1];
[1560]734                }
[1083]735
[1560]736                mStripsSubmesh[target_submesh]  =       (int)strip_count;
737                strip_count                                                                                     =       0;
738
[1078]739                target_submesh++;
740        }
741
[1018]742        dataRetrievalInterface->End();
[1070]743}
[1560]744
Note: See TracBrowser for help on using the repository browser.