-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinclude.h
151 lines (126 loc) · 2.62 KB
/
include.h
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
#ifndef __H__include
#define __H__include
#include <wrl/client.h>
#include <vector>
#include <map>
#include <string>
#include <Windowsx.h>
#include <d3d11_1.h>
#include <directxmath.h>
#include <D3Dcompiler.h>
#include <directxcolors.h>
#include <fstream>
#include <tchar.h>
using namespace DirectX;
using namespace Microsoft::WRL;
using namespace std;
#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "D3DCompiler.lib")
#define Filter_NoFilter 0
#define Filter_EnergyManager 1
#define Filter_SplittingMembrane 2
#define Filter_Flagellum 3
#define Filter_CellHealth 4
#define Filter_Total_Count 5
#define Neural_InpNode_Source_ATP 0
#define Neural_InpNode_Source_ContainsOffset 1
#define Neural_InpNode_Source_Food 1
#define Neural_InpNode_Source_Poison 2
#define Neural_InpNode_Source_Oxygen 3
#define Neural_InpNode_Source_Splitting 4
#define Neural_InpNode_Total_Sources 5
void static CheckForError(HRESULT hr, string mes)
{
if (FAILED(hr))
{
MessageBox(NULL, mes.c_str(), NULL, MB_OK);
}
}
struct Vertex
{
XMFLOAT3 position;
XMFLOAT2 texturePos;
};
struct ConstantBuffer
{
XMMATRIX worldPos;
XMMATRIX worldRot;
XMMATRIX view;
XMMATRIX projection;
};
struct ModelBuffer
{
XMFLOAT4X4 scale;
XMFLOAT4X4 position;
XMFLOAT4X4 rotation;
XMFLOAT4 filterColour; //this is needed so that cells look relative to their dna
};
struct ModelData
{
bool initialized = false;
ComPtr<ID3D11Buffer> vertexBuffer;
ComPtr<ID3D11Buffer> indexBuffer;
int vertexCount;
int indexCount;
};
struct TargaHeader
{
unsigned char data1[12];
unsigned short width;
unsigned short height;
unsigned char bpp;
unsigned char data2;
};
const static int ConvertDNAtoInt(char c)
{
return (c - 32); //there are 32 characters in the front of the ASCII table that I wont use in the DNA string
}
const static float Balance(float x)
{
while (x >= XM_2PI)
{
x -= XM_2PI;
}
while (x < 0)
{
x += XM_2PI;
}
return x;
}
const static float BalanceAndLock(float x)
{
if (x > XM_PI)
x = XM_PI;
if (x < -XM_PI)
x = -XM_PI;
return x;
}
const static void TurnRadiantsIntoXandZComponent(float Rotation, float *x, float *z)
{
if (Rotation <= XM_PIDIV2)
{
*z = (Rotation / -XM_PIDIV2) + 1;
*x = 1 - *z;
}
else if (Rotation <= XM_PI)
{
*z = (Rotation / -XM_PIDIV2) + 1;
*x = (Rotation / -XM_PIDIV2) + 2;
}
else if (Rotation <= XM_PIDIV2 * 3)
{
*z = (Rotation / XM_PIDIV2) - 3;
*x = (Rotation / -XM_PIDIV2) + 2;
}
else
{
*z = (Rotation / XM_PIDIV2) - 3;
*x = (Rotation / XM_PIDIV2) - 4;
}
}
const static void TurnRadiantsIntoXandZComponentSin(float Rotation, float *x, float *z)
{
*z = cos(Rotation);
*x = sin(Rotation);
}
#endif