summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoDX9/Src/DecodedVArray.cpp
blob: 7ee5d16634980d1d26aba12426993d3a1d996a88 (plain)
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
#include "stdafx.h"
#include "DecodedVArray.h"

#include "main.h"

DecodedVArray::DecodedVArray()
{
	Zero();
}

DecodedVArray::~DecodedVArray()
{
	Destroy();
}

void DecodedVArray::Zero()
{
	size       = 0;
	count      = 0;
	components = 0;
	positions  = 0;
	posMtxInds = 0;
	for (int i=0; i<3; i++)
		normals[i] = 0;
	for (int i=0; i<8; i++)
	{
		texMtxInds[i] = 0;
		uvs[i] = 0;
	}
	for (int i=0; i<2; i++)
		colors[i] = 0;
}

void DecodedVArray::Destroy()
{
	//,,
	delete [] positions;
	delete [] posMtxInds;
	for (int i=0; i<3; i++)
		delete [] normals[i];
	for (int i=0; i<2; i++)
		delete [] colors[i];
	for (int i=0; i<8; i++)
	{
		delete [] uvs[i];
		delete [] texMtxInds[i];
	}
	Zero();
}

void DecodedVArray::Create(int _size, int pmcount, int tmcount, int nrmcount, int colcount, int tccount)
{
	size = _size;
	// position matrix indices
	if (pmcount)
		posMtxInds = new DecMtxInd[size];
	// texture matrix indices
	if (tmcount)
		for (int i=0; i<tmcount; i++)
			texMtxInds[i] = new DecMtxInd[size];
	// positions (always)
	positions = new DecPos[size]; 
	// normals 
	if (nrmcount)
		for (int i=0; i<nrmcount; i++)
			normals[i] = new DecNormal[size];
	// colors
	if (colcount)
		for (int i=0; i<colcount; i++)
			colors[i] = new DecColor[size];

	if (tccount)
		for (int i=0; i<tccount; i++)
			uvs[i] = new DecUV[size];
}