-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeightMapLoaderClass.cpp
624 lines (415 loc) · 18.2 KB
/
HeightMapLoaderClass.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
#include "HeightMapLoaderClass.hpp"
HeightMapLoaderClass::HeightMapLoaderClass()
{
//this->HeightMapFileName = "HeightMap_files/HeightMap_SmallHands.txt";
this->HeightMapFileName = "HeightMap_files/Mini_Heightmap.txt";
//this->HeightMapFileName = "HeightMap_files/Maze_Heightmap_1.txt";
this->HeightMapImageName = "EMPTY";
this->HeightMapTextureName = new std::wstring[HEIGHTMAP_TEXTURE_COUNT];
this->SmoothNormals = true;
this->HeightMapWidth = 0;
this->HeightMapHeight = 0;
this->VertexCount = 0;
this->fc = 0;
this->VertexHeightArray = nullptr;
this->TempNormalArray = nullptr;
}
HeightMapLoaderClass::~HeightMapLoaderClass()
{
this->ReleaseAll();
}
void HeightMapLoaderClass::ReleaseAll()
{
delete this->VertexHeightArray;
delete this->TempNormalArray;
delete[] this->HeightMapTextureName;
}
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// //
// PUBLIC FUNCTIONS //
// //
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
void HeightMapLoaderClass::LoadHeightMap(
std::vector<unsigned char> *ImageData,
HeightMapVertexData* *HeightMapVertexDataArray
)
{
// PART 1
/// OPENING .txt FILE AND READING HEIGHT MAP INFORMATION
// --------------------------------------------------------
HRESULT hr;
std::ifstream input_file;
input_file.open(this->HeightMapFileName);
if (!input_file.is_open())
MessageBox(NULL, L"Failed to open 'HeightMap Text File' for READING.", L"ERROR: 'LoadHeightMap() - HeightMapLoaderClass'", MB_OK);
else // 'Reading-the-file' code
{
std::string CurrentString;
int CurrentInt;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
int TextureCount = 0;
// READING FROM FILE; looping till the end of the file is reached
while (!input_file.eof())
{
input_file >> CurrentString;
if (CurrentString == "SmoothNormals")
{
input_file >> CurrentString;
if (CurrentString == "false")
this->SmoothNormals = false;
else if (CurrentString == "true")
this->SmoothNormals = true;
}
else if (CurrentString == "TextureName")
{
input_file >> CurrentString;
CurrentString = "HeightMap_files/" + CurrentString;
if (TextureCount < HEIGHTMAP_TEXTURE_COUNT) //Safety measure to avoid over extending the array
{
this->HeightMapTextureName[TextureCount] = converter.from_bytes(CurrentString);
TextureCount++;
}
}
else if (CurrentString == "FileName")
{
input_file >> CurrentString;
this->HeightMapImageName = ("HeightMap_files/" + CurrentString);
}
else if (CurrentString == "Width")
{
input_file >> CurrentInt;
this->HeightMapWidth = CurrentInt;
}
else if (CurrentString == "Height")
{
input_file >> CurrentInt;
this->HeightMapHeight = CurrentInt;
}
else if (CurrentString == "vc")
{
input_file >> CurrentInt;
this->VertexCount = CurrentInt;
}
}
if (input_file.is_open())
input_file.close();
}
// --------------------------------------------------------
// PART 2
/// LOADING THE .png FILE
// -------------------------
unsigned UnsignedWidth, UnsignedHeight;
unsigned error; // If error != 0, then the 'decode' function failed
UnsignedWidth = abs(this->HeightMapWidth);
UnsignedHeight = abs(this->HeightMapHeight);
error = lodepng::decode((*ImageData), UnsignedWidth, UnsignedWidth, this->HeightMapImageName);
if (error != 0)
MessageBox(NULL, L"Failed to load 'HeightMap'.", L"ERROR: 'LoadHeightMap() - HeightMapClass.cpp'", MB_OK);
/// -------------------------
// PART 3
/// ALLOCATING 'VertexHeightArray' & STORING HEIGHT VALUES PER VERTEX
// ---------------------------------------------------------------------------------
this->VertexHeightArray = new float[this->VertexCount]; // Temporarily holds height data
for (int s = 0; s < this->VertexCount; s++)
this->VertexHeightArray[s] = 0.0f;
// Will only read the 'R' value (R = G = B = HeightValue);
for (int i = 0; i < this->VertexCount; i++)
{
this->VertexHeightArray[i] = (float)(*ImageData)[(i * 4)];
this->VertexHeightArray[i] /= 255; // Converting to a value between 0.0f and 1.0f
}
// ---------------------------------------------------------------------------------
// PART 4
/// (Hover over function for description)
this->ConvertToVertexData(HeightMapVertexDataArray);
}
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// //
// PRIVATE FUNCTIONS //
// //
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
void HeightMapLoaderClass::StoreToVertexData(HeightMapVertexData *HeightMapVertexDataArray)
{
}
/* ------------- COMMENTS -------------
Using all the data provided by the 'LoadHeightMap()' function, this function
creates the Vertices, TexCoordinates, Normals and Faces along with indexing
everything. The 'to-be-used' data is stored in the HeightMapVertexData parameter.
*/
void HeightMapLoaderClass::ConvertToVertexData(HeightMapVertexData* *HeightMapVertexDataArray)
{
// "LEFT SIDE! MANY VARIABLES! NOW, HANDLE IT!!!"
//
// VARIABLES LIST
// ---------------------------------------------------------------------------------
DirectX::XMVECTOR TempPointHolder1 = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
DirectX::XMVECTOR TempPointHolder2 = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
DirectX::XMVECTOR Edge1Vector = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
DirectX::XMVECTOR Edge2Vector = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
DirectX::XMVECTOR FaceNormalVector1 = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
DirectX::XMVECTOR FaceNormalVector2 = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
DirectX::XMFLOAT3 FaceNormalFloat3_1 = { 0.0f, 0.0f, 0.0f };
DirectX::XMFLOAT3 FaceNormalFloat3_2 = { 0.0f, 0.0f, 0.0f };
DirectX::XMVECTOR TempVector = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
int IndexHolder; // Provides optimization through reduced calculations
// ---------------------------------------------------------------------------------
// INITIALIZATION
// ---------------------------------------------------------------------------------
// VERTICES --- MEMORY ALLOCATION
DirectX::XMFLOAT3 *TempVertexArray;
TempVertexArray = new DirectX::XMFLOAT3[this->VertexCount];
for (int s = 0; s < this->VertexCount; s++)
TempVertexArray[s] = { 0.0f, 0.0f, 0.0f };
// VERTICES --- GRID IS CREATED (x,y,z positions in local space)
for (int i = 0; i < this->HeightMapHeight; i++) // Current Y-Coordinate of the 'Grid' (i)
{
for (int j = 0; j < this->HeightMapWidth; j++) // Current X-Coordinate of the 'Grid' (j)
{
IndexHolder = ((i * this->HeightMapWidth) + j);
TempVertexArray[IndexHolder].x = ((float)j * HEIGHTMAP_WIDTH_MULTIPLIER);
TempVertexArray[IndexHolder].y = (VertexHeightArray[IndexHolder] * HEIGHTMAP_HEIGHT_MULTIPLIER);
TempVertexArray[IndexHolder].z = ((float)i * HEIGHTMAP_WIDTH_MULTIPLIER);
}
}
// FACES & UV-TEXCOORDS --- MEMORY ALLOCATION
this->fc = ((this->HeightMapWidth - 1) * (this->HeightMapHeight - 1)) * 2; // Number of quads * 2 triangles
FaceIndexData *FaceIndexDataArray = new FaceIndexData[this->fc];
DirectX::XMFLOAT2 *TempTexCoordArray = new DirectX::XMFLOAT2[this->VertexCount];
for (int s = 0; s < this->VertexCount; s++)
TempTexCoordArray[s] = { 0.0f, 0.0f };
float TexUCoord = 0.0f;
float TexVCoord = 0.0f;
// ---------------------------------------------------------------------------------
IndexHolder = 0; // RESET
// TEXCOORDS --- CALCULATION & INDEXING
// VERTICES --- INDEXING
for (int i = 0; i < (this->HeightMapHeight - 1); i++) // Current Y-Coordinate of the 'Grid' (i)
{
for (int j = 0; j < (this->HeightMapWidth - 1); j++) // Current X-Coordinate of the 'Grid' (j)
{
// UV-TEXTCOORDS
// TOP LEFT VERTEX
TempTexCoordArray[((i * this->HeightMapWidth) + j)] = { (TexUCoord + 0.0f), (TexVCoord + 0.0f) };
// TOP RIGHT VERTEX
TempTexCoordArray[((i * this->HeightMapWidth) + (j + 1))] = { (TexUCoord + 1.0f), (TexVCoord + 0.0f) };
// BOTTOM LEFT VERTEX
TempTexCoordArray[(((i + 1) * this->HeightMapWidth) + j)] = { (TexUCoord + 0.0f), (TexVCoord + 1.0f) };
// BOTTOM RIGHT VERTEX
TempTexCoordArray[(((i + 1) * this->HeightMapWidth) + (j + 1))] = { (TexUCoord + 1.0f), (TexVCoord + 1.0f) };
TexUCoord++; // THIS = The grid will be 'TEXTURE WRAPPED' (1/2)
// FACE1 (Indexing Vertices & UV-Coordinates)
// BOTTOM LEFT VERTEX
FaceIndexDataArray[IndexHolder].Vertex1.x = (((i + 1) * this->HeightMapWidth) + j);
FaceIndexDataArray[IndexHolder].Vertex1.y = (((i + 1) * this->HeightMapWidth) + j);
// TOP LEFT VERTEX
FaceIndexDataArray[IndexHolder].Vertex2.x = ((i * this->HeightMapWidth) + j);
FaceIndexDataArray[IndexHolder].Vertex2.y = ((i * this->HeightMapWidth) + j);
// TOP RIGHT VERTEX
FaceIndexDataArray[IndexHolder].Vertex3.x = ((i * this->HeightMapWidth) + (j + 1));
FaceIndexDataArray[IndexHolder].Vertex3.y = ((i * this->HeightMapWidth) + (j + 1));
IndexHolder++; // Incrementing for next Face
// FACE2 (Indexing Vertices & UV-Coordinates)
// TOP RIGHT VERTEX
FaceIndexDataArray[IndexHolder].Vertex1.x = ((i * this->HeightMapWidth) + (j + 1));
FaceIndexDataArray[IndexHolder].Vertex1.y = ((i * this->HeightMapWidth) + (j + 1));
// BOTTOM RIGHT VERTEX
FaceIndexDataArray[IndexHolder].Vertex2.x = (((i + 1) * this->HeightMapWidth) + (j + 1));
FaceIndexDataArray[IndexHolder].Vertex2.y = (((i + 1) * this->HeightMapWidth) + (j + 1));
// BOTTOM LEFT VERTEX
FaceIndexDataArray[IndexHolder].Vertex3.x = (((i + 1) * this->HeightMapWidth) + j);
FaceIndexDataArray[IndexHolder].Vertex3.y = (((i + 1) * this->HeightMapWidth) + j);
IndexHolder++; // Incrementing for next loop
}
TexUCoord = 0; // Reseting this as we move to the next row
TexVCoord++; // THIS: The grid will be 'TEXTURE WRAPPED' (2/2)
}
IndexHolder = 0; // RESET
// NORMALS --- ALLOCATING MEMORY
// SmoothNormals = true -> Memory Allocation: VertexCount
if (this->SmoothNormals)
{
this->TempNormalArray = new DirectX::XMFLOAT3[this->VertexCount];
for (int s = 0; s < this->VertexCount; s++)
this->TempNormalArray[s] = { 0.0f, 0.0f, 0.0f };
}
// SmoothNormals = false -> Memory Allocation: FaceCount
else
{
this->TempNormalArray = new DirectX::XMFLOAT3[this->fc];
for (int s = 0; s < this->fc; s++)
this->TempNormalArray[s] = { 0.0f, 0.0f, 0.0f };
}
// NORMALS --- CALCULATING & INDEXING
// LOOP COUNT IS HALF -> calculating 2 FACES of 1 QUAD >> each loop
for (int i = 0; i < (this->fc / 2); i++)
{
// PART1: CALCULATING
// FACE1, Vertex1 (for 'FACE NORMAL')
IndexHolder = (int)FaceIndexDataArray[(i * 2)].Vertex1.x;
TempPointHolder1 = DirectX::XMVectorSet(
TempVertexArray[IndexHolder].x,
TempVertexArray[IndexHolder].y,
TempVertexArray[IndexHolder].z,
1.0f
);
// FACE1, Vertex2 (for 'FACE NORMAL')
IndexHolder = (int)FaceIndexDataArray[(i * 2)].Vertex2.x;
TempPointHolder2 = DirectX::XMVectorSet(
TempVertexArray[IndexHolder].x,
TempVertexArray[IndexHolder].y,
TempVertexArray[IndexHolder].z,
1.0f
);
Edge1Vector = DirectX::XMVectorSubtract(TempPointHolder1, TempPointHolder2);
// FACE1, Vertex3 (for 'FACE NORMAL')
IndexHolder = (int)FaceIndexDataArray[(i * 2)].Vertex3.x;
TempPointHolder2 = DirectX::XMVectorSet(
TempVertexArray[IndexHolder].x,
TempVertexArray[IndexHolder].y,
TempVertexArray[IndexHolder].z,
1.0f
);
Edge2Vector = DirectX::XMVectorSubtract(TempPointHolder1, TempPointHolder2);
FaceNormalVector1 = DirectX::XMVector3Cross(Edge2Vector, Edge1Vector); // Creating the NORMAL for FACE1
FaceNormalVector1 = DirectX::XMVector3Normalize(FaceNormalVector1); // NOT SURE IF I NEED TO NORMALIZE
// FACE2, Vertex1 (for 'FACE NORMAL')
IndexHolder = (int)FaceIndexDataArray[((i * 2) + 1)].Vertex1.x;
TempPointHolder1 = DirectX::XMVectorSet(
TempVertexArray[IndexHolder].x,
TempVertexArray[IndexHolder].y,
TempVertexArray[IndexHolder].z,
1.0f
);
// Face2, Vertex2 (for 'FACE NORMAL')
IndexHolder = (int)FaceIndexDataArray[((i * 2) + 1)].Vertex2.x;
TempPointHolder2 = DirectX::XMVectorSet(
TempVertexArray[IndexHolder].x,
TempVertexArray[IndexHolder].y,
TempVertexArray[IndexHolder].z,
1.0f
);
Edge1Vector = DirectX::XMVectorSubtract(TempPointHolder1, TempPointHolder2);
// Face2, Vertex3 (for 'FACE NORMAL')
IndexHolder = (int)FaceIndexDataArray[((i * 2) + 1)].Vertex3.x;
TempPointHolder2 = DirectX::XMVectorSet(
TempVertexArray[IndexHolder].x,
TempVertexArray[IndexHolder].y,
TempVertexArray[IndexHolder].z,
1.0f
);
Edge2Vector = DirectX::XMVectorSubtract(TempPointHolder1, TempPointHolder2);
FaceNormalVector2 = DirectX::XMVector3Cross(Edge2Vector, Edge1Vector); // Creating the NORMAL for FACE2
FaceNormalVector2 = DirectX::XMVector3Normalize(FaceNormalVector2); // NOT SURE IF I NEED TO NORMALIZE
// PART2: INDEXING
if (this->SmoothNormals)
{
DirectX::XMStoreFloat3(&FaceNormalFloat3_1, FaceNormalVector1);
DirectX::XMStoreFloat3(&FaceNormalFloat3_2, FaceNormalVector2);
// FACE 1
// BOTTOM LEFT VERTEX
IndexHolder = (int)FaceIndexDataArray[(i * 2)].Vertex1.x;
this->TempNormalArray[IndexHolder].x += FaceNormalFloat3_1.x; // (We're taking the already indexed vertex and making that the normal index as well (a unique normal per vertex))
this->TempNormalArray[IndexHolder].y += FaceNormalFloat3_1.y;
this->TempNormalArray[IndexHolder].z += FaceNormalFloat3_1.z;
FaceIndexDataArray[(i * 2)].Vertex1.z = FaceIndexDataArray[(i * 2)].Vertex1.x;
// TOP LEFT VERTEX
IndexHolder = (int)FaceIndexDataArray[(i * 2)].Vertex2.x;
this->TempNormalArray[IndexHolder].x += FaceNormalFloat3_1.x;
this->TempNormalArray[IndexHolder].y += FaceNormalFloat3_1.y;
this->TempNormalArray[IndexHolder].z += FaceNormalFloat3_1.z;
FaceIndexDataArray[(i * 2)].Vertex2.z = FaceIndexDataArray[(i * 2)].Vertex2.x;
// TOP RIGHT VERTEX
IndexHolder = (int)FaceIndexDataArray[(i * 2)].Vertex3.x;
this->TempNormalArray[IndexHolder].x += FaceNormalFloat3_1.x;
this->TempNormalArray[IndexHolder].y += FaceNormalFloat3_1.y;
this->TempNormalArray[IndexHolder].z += FaceNormalFloat3_1.z;
FaceIndexDataArray[(i * 2)].Vertex3.z = FaceIndexDataArray[(i * 2)].Vertex3.x;
// FACE 2
// TOP RIGHT VERTEX
IndexHolder = (int)FaceIndexDataArray[((i * 2) + 1)].Vertex1.x;
this->TempNormalArray[IndexHolder].x += FaceNormalFloat3_2.x;
this->TempNormalArray[IndexHolder].y += FaceNormalFloat3_2.y;
this->TempNormalArray[IndexHolder].z += FaceNormalFloat3_2.z;
FaceIndexDataArray[((i * 2) + 1)].Vertex1.z = FaceIndexDataArray[((i * 2) + 1)].Vertex1.x;
// BOTTOM RIGHT VERTEX
IndexHolder = (int)FaceIndexDataArray[((i * 2) + 1)].Vertex2.x;
this->TempNormalArray[IndexHolder].x += FaceNormalFloat3_2.x;
this->TempNormalArray[IndexHolder].y += FaceNormalFloat3_2.y;
this->TempNormalArray[IndexHolder].z += FaceNormalFloat3_2.z;
FaceIndexDataArray[((i * 2) + 1)].Vertex2.z = FaceIndexDataArray[((i * 2) + 1)].Vertex2.x;
// BOTTOM LEFT VERTEX
IndexHolder = (int)FaceIndexDataArray[((i * 2) + 1)].Vertex3.x;
this->TempNormalArray[IndexHolder].x += FaceNormalFloat3_2.x;
this->TempNormalArray[IndexHolder].y += FaceNormalFloat3_2.y;
this->TempNormalArray[IndexHolder].z += FaceNormalFloat3_2.z;
FaceIndexDataArray[((i * 2) + 1)].Vertex3.z = FaceIndexDataArray[((i * 2) + 1)].Vertex3.x;
}
// !SmoothNormals (This results in hard edges)
else
{
DirectX::XMStoreFloat3(&this->TempNormalArray[(i * 2)], FaceNormalVector1); // ((i * 2) + 1) for cool effect
FaceIndexDataArray[(i * 2)].Vertex1.z = (i * 2);
FaceIndexDataArray[(i * 2)].Vertex2.z = (i * 2);
FaceIndexDataArray[(i * 2)].Vertex3.z = (i * 2);
DirectX::XMStoreFloat3(&this->TempNormalArray[((i * 2) + 1)], FaceNormalVector2);
FaceIndexDataArray[((i * 2) + 1)].Vertex1.z = ((i * 2) + 1);
FaceIndexDataArray[((i * 2) + 1)].Vertex2.z = ((i * 2) + 1);
FaceIndexDataArray[((i * 2) + 1)].Vertex3.z = ((i * 2) + 1);
}
}
// NORMALIZING all normal vectors, if SmoothNormals = true
if (this->SmoothNormals)
{
for (int n = 0; n < this->VertexCount; n++)
{
TempVector = DirectX::XMVectorSet(
this->TempNormalArray[n].x,
this->TempNormalArray[n].y,
this->TempNormalArray[n].z,
0.0f
);
TempVector = DirectX::XMVector4Normalize(TempVector);
DirectX::XMStoreFloat3(&this->TempNormalArray[n], TempVector);
}
}
// FINAL STEP: STORING THE DATA
(*HeightMapVertexDataArray) = new HeightMapVertexData[(this->fc * 3)];
for (int i = 0; i < this->fc; i++)
{
(*HeightMapVertexDataArray)[((i * 3) + 2)].Position = TempVertexArray[(int)FaceIndexDataArray[i].Vertex1.x];
(*HeightMapVertexDataArray)[((i * 3) + 2)].texCoord = TempTexCoordArray[(int)FaceIndexDataArray[i].Vertex1.y];
(*HeightMapVertexDataArray)[((i * 3) + 2)].Normal = this->TempNormalArray[(int)FaceIndexDataArray[i].Vertex1.z];
(*HeightMapVertexDataArray)[((i * 3) + 1)].Position = TempVertexArray[(int)FaceIndexDataArray[i].Vertex2.x];
(*HeightMapVertexDataArray)[((i * 3) + 1)].texCoord = TempTexCoordArray[(int)FaceIndexDataArray[i].Vertex2.y];
(*HeightMapVertexDataArray)[((i * 3) + 1)].Normal = this->TempNormalArray[(int)FaceIndexDataArray[i].Vertex2.z];
(*HeightMapVertexDataArray)[((i * 3) + 0)].Position = TempVertexArray[(int)FaceIndexDataArray[i].Vertex3.x];
(*HeightMapVertexDataArray)[((i * 3) + 0)].texCoord = TempTexCoordArray[(int)FaceIndexDataArray[i].Vertex3.y];
(*HeightMapVertexDataArray)[((i * 3) + 0)].Normal = this->TempNormalArray[(int)FaceIndexDataArray[i].Vertex3.z];
}
// RELEASING MEMORY
delete TempVertexArray;
delete TempTexCoordArray;
delete FaceIndexDataArray;
//this->ReleaseAll();
}
// GET FUNCTIONS
int HeightMapLoaderClass::GetFaceCount()
{
return this->fc;
}
int HeightMapLoaderClass::GetHeightMapWidth()
{
return this->HeightMapWidth;
}
int HeightMapLoaderClass::GetHeightMapHeight()
{
return this->HeightMapHeight;
}
float* HeightMapLoaderClass::GetVertexHeightArray()
{
return this->VertexHeightArray;
}
std::wstring HeightMapLoaderClass::GetHeightMapTextureName(int TextureSlot)
{
return this->HeightMapTextureName[TextureSlot];
}