Initial revision
[0ad:0ad.git] / terrain / bak / 0 / Patch.cpp
1 //***********************************************************
2 //
3 // Name:                Patch.Cpp
4 // Last Update: 23/2/02
5 // Author:              Poya Manouchehri
6 //
7 // Description: CPatch is a smaller portion of the terrain.
8 //                              It handles the ROAM implementation and its
9 //                              own rendering.
10 //
11 //***********************************************************
12
13 #include "Patch.H"
14
15
16 CPatch::CPatch ()
17 {
18         m_pVertices = NULL;
19 }
20
21 CPatch::~CPatch ()
22 {
23 }
24
25 //Initialize the patch
26 void CPatch::Initialize (STerrainVertex *first_vertex)
27 {
28         m_pVertices = first_vertex;
29
30         m_Bounds.m_BoxMin.X = m_pVertices[0].m_Position.X;
31         m_Bounds.m_BoxMin.Z = m_pVertices[0].m_Position.Z;
32         
33         m_Bounds.m_BoxMax.X = m_Bounds.m_BoxMin.X + PATCH_SIZE*CELL_SIZE;
34         m_Bounds.m_BoxMax.Z = m_Bounds.m_BoxMin.Z + PATCH_SIZE*CELL_SIZE;
35
36         m_Bounds.m_BoxMin.Y = m_Bounds.m_BoxMin.Y = m_pVertices[0].m_Position.Y;
37
38         for (int j=0; j<PATCH_SIZE+1; j++)
39         {
40                 for (int i=0; i<PATCH_SIZE+1; i++)
41                 {
42                         int pos = j*MAP_SIZE + i;
43
44                         if (m_pVertices[pos].m_Position.Y < m_Bounds.m_BoxMin.Y)
45                                 m_Bounds.m_BoxMin.Y = m_pVertices[pos].m_Position.Y;
46
47                         if (m_pVertices[pos].m_Position.Y > m_Bounds.m_BoxMax.Y)
48                                 m_Bounds.m_BoxMax.Y = m_pVertices[pos].m_Position.Y;
49                 }
50         }
51
52         for (j=0; j<4; j++)
53         {
54                 for (int i=0; i<4; i++)
55                 {
56                         int pos = (j*4*MAP_SIZE) + (i*4);
57
58                         m_MiniPatches[j][i].Initialize ( &m_pVertices[pos] );
59                 }
60         }
61 }
62