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
|
#include "render.h"
#include "rlgl.h"
void
drawLine(Vector3 start, Vector3 end, float width, int up, Color color)
{
start.x *= 100;
start.y *= 100;
start.z *= 100;
end.x *= 100;
end.y *= 100;
end.z *= 100;
width *= 2;
// 2 is z up for some reason /shrug
int ox = 0;
int oy = 0;
int oz = 0;
if(up == 1)
{
ox = (width / 2);
}
else if(up == 2)
{
oy = (width / 2);
}
else if(up == 3)
{
oz = (width / 2);
}
else if(up == -1)
{
ox = -(width / 2);
}
else if(up == -2)
{
oy = -(width / 2);
}
else if(up == -3)
{
oz = -(width / 2);
}
Vector3 points[4] = {
(Vector3){ (start.x + ox) * 1, (start.y + oy) * 1, (start.z + oz) * 1 },
(Vector3){ (start.x - ox) * 1, (start.y - oy) * 1, (start.z - oz) * 1 },
(Vector3){ (end.x + ox) * 1, (end.y + oy) * 1, (end.z + oz) * 1 },
(Vector3){ (end.x - ox) * 1, (end.y - oy) * 1, (end.z - oz) * 1 },
};
//Vector3 points[4] = {
// (Vector3){ 0, 0, 0 },
// (Vector3){ 10, 0, 0 },
// (Vector3){ 0, 10, 0 },
// (Vector3){ 10, 10, 0 },
//};
rlPushMatrix();
rlScalef(0.01, 0.01, 0.01);
DrawTriangleStrip3D(points, 4, color);
rlPopMatrix();
}
void
drawGrid(Vector3 position, int lines, int size, Color color)
{
position.x -= lines * size / 2;
position.y -= lines * size / 2;
for(int i = 0; i < lines + 1; ++i)
{
float mx = position.x;
float my = position.y + (i * size);
float mz = position.z;
drawLine(
(Vector3){
mx,
my,
mz
},
(Vector3){
mx + (size * lines),
my,
mz
},
4.0f,
2,
BLACK);
}
for(int i = 0; i < lines + 1; ++i)
{
float mx = position.x + (i * size);
float my = position.y;
float mz = position.z;
drawLine(
(Vector3){
mx,
my,
mz
},
(Vector3){
mx,
my + (size * lines),
mz
},
4.0f,
-1,
BLACK);
}
}
void
renderWorld(World* world, Camera camera)
{
//Vector3 lookat = camera.target;
//camera.target = (Vector3){0};
//camera.position.x -= lookat.x;
//camera.position.y -= lookat.y;
//camera.position.z -= lookat.z;
customBeginMode3D(camera);
//rlPushMatrix();
//rlTranslatef(
// -lookat.x,
// -lookat.y,
// -lookat.z
// );
drawPlayer(&world->players[0]);
drawPlayer(&world->players[1]);
//drawGrid((Vector3){0}, 10, 1);
for(int i = -3; i <= 3; ++i){
DrawCube((Vector3){i,3,3}, 0.5f, 0.5f, 0.5f, YELLOW);
DrawCube((Vector3){i,4,3}, 0.5f, 0.5f, 0.5f, DARKPURPLE);
//DrawCube((Vector3){i,5,3}, 0.5f, 0.5f, 0.5f, YELLOW);
//DrawCube((Vector3){i,3,4}, 0.5f, 0.5f, 0.5f, MAGENTA);
//DrawCube((Vector3){i,4,4}, 0.5f, 0.5f, 0.5f, GREEN);
//DrawCube((Vector3){i,5,4}, 0.5f, 0.5f, 0.5f, MAGENTA);
//DrawLineEx((Vector2){i, 3},(Vector2){i, -3}, 5, BLACK);
//DrawLineEx((Vector2){3, i},(Vector2){-3, i}, 5, BLACK);
}
//drawLine((Vector3){0}, (Vector3){10,0,0}, 2.0f, 2, BLACK);
drawGrid((Vector3){0}, 10, 1, BLACK);
//rlPopMatrix();
EndMode3D();
}
|