source: trunk/UPV/GTGeometry/src/GeoMesh.cpp @ 138

Revision 138, 1.2 KB checked in by hidalgo, 19 years ago (diff)

Uploaded WP4 Dummy code(Geometry)

Line 
1#include "GeoMesh.h"
2
3using namespace Geometry;
4
5//----------------------------------------------------------------------------
6Mesh::Mesh():
7        mVertexBuffer(0), mSubMeshCount(0), mSubMesh(0), mType(GEO_TRIANGLE_LIST)
8{
9}
10
11Mesh::~Mesh()
12{
13        delete[] mSubMesh;
14        delete   mVertexBuffer;
15}
16
17void Mesh::Load(Serializer &s)
18{
19        bool sharedVertexBuffer = false;
20
21        //Clear Data
22        delete[] mSubMesh;  mSubMesh = 0;
23        delete   mVertexBuffer; mVertexBuffer = 0;
24        mSubMeshCount = 0;
25       
26        s.ReadArray(&sharedVertexBuffer,1);
27        if (sharedVertexBuffer)
28        {
29                mVertexBuffer = new VertexBuffer;
30                mVertexBuffer->Load(s);
31        }
32        s.ReadArray(&mSubMeshCount,1);
33        mSubMesh = new SubMesh[mSubMeshCount];
34        for(size_t i = 0; i < mSubMeshCount; ++i)
35        {
36                mSubMesh[i].Load(s);
37                if (mSubMesh[i].mSharedVertexBuffer && sharedVertexBuffer)
38                {
39                        mSubMesh[i].mVertexBuffer = mVertexBuffer;
40                }
41        }
42}
43
44void Mesh::Save(Serializer &s)
45{
46        bool sharedVertexBuffer = (mVertexBuffer != 0);
47        s.WriteArray(&sharedVertexBuffer, 1);
48        if (sharedVertexBuffer)
49        {
50                mVertexBuffer->Save(s);
51        }
52        s.WriteArray(&mSubMeshCount,1);
53        for(size_t i = 0; i < mSubMeshCount; ++i)
54        {
55                mSubMesh[i].Save(s);
56        }
57}
58
Note: See TracBrowser for help on using the repository browser.