-
Notifications
You must be signed in to change notification settings - Fork 0
/
0004cube.diff
271 lines (266 loc) · 7.33 KB
/
0004cube.diff
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
diff -bNur 0003index-buffer/data_bulk.c 0004cube/data_bulk.c
--- 0003index-buffer/data_bulk.c 2019-03-03 15:08:52.160918059 -0600
+++ 0004cube/data_bulk.c 2019-03-03 15:08:52.164917190 -0600
@@ -8,25 +8,181 @@
float boneWeights[MAX_BONES_PER_VERTEX];
uint32_t boneIDs[MAX_BONES_PER_VERTEX];
} vertex_t;
+
+/* Texture
+ ####0AA1########
+ ####AAAA########
+ ####AAAA########
+ ####2AA3########
+ 4BB56CC78DD9aEEb
+ BBBBCCCCDDDDEEEE
+ BBBBCCCCDDDDEEEE
+ cBBdeCCfgDDhEEEi
+ ####jFFk########
+ ####FFFF########
+ ####FFFF########
+ ####lFFm########
+ */
+
+#define DMVPFR -0.5f
+#define DMVPBA 0.5f
+#define DMVPBO -0.5f
+#define DMVPTO 0.5f
+#define DMVPRI -0.5f
+#define DMVPLE 0.5f
+
+#define DMVUXONE 0.0f
+#define DMVUXTWO 0.25f
+#define DMVUXTHR 0.5f
+#define DMVUXFOR 0.75f
+#define DMVUXFIV 1.0f
+#define DMVUYONE 0.0f
+#define DMVUYTWO 1.0f / 3.0f
+#define DMVUYTHR 2.0f / 3.0f
+#define DMVUYFOR 1.0f
const vertex_t model_vertex[] = {
- {{-0.5f, 0.5f, -0.5f},
- {0.0f, 0.0f, -1.0f},
- {0.0f, 2.0f / 3.0f},
+ {// 0
+ {DMVPLE, DMVPTO, DMVPBA},
+ {0.0f, DMVPTO * 2, 0.0f},
+ {DMVUXTWO, DMVUYONE},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// 1
+ {DMVPRI, DMVPTO, DMVPBA},
+ {0.0f, DMVPTO * 2, 0.0f},
+ {DMVUXTHR, DMVUYONE},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// 2
+ {DMVPLE, DMVPTO, DMVPFR},
+ {0.0f, DMVPTO * 2, 0.0f},
+ {DMVUXTWO, DMVUYTWO},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// 3
+ {DMVPRI, DMVPTO, DMVPFR},
+ {0.0f, DMVPTO * 2, 0.0f},
+ {DMVUXTHR, DMVUYTWO},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// 4
+ {DMVPLE, DMVPTO, DMVPBA},
+ {DMVPLE * 2, 0.0f, 0.0f},
+ {DMVUXONE, DMVUYTWO},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// 5
+ {DMVPLE, DMVPTO, DMVPFR},
+ {DMVPLE * 2, 0.0f, 0.0f},
+ {DMVUXTWO, DMVUYTWO},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// 6
+ {DMVPL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TWO, DMVUYTHR},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// f
+ {DMVPRI, DMVPBO, DMVPFR},
+ {0.0f, 0.0f, DMVPFR * 2},
+ {DMVUXTHR, DMVUYTHR},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// g
+ {DMVPRI, DMVPBO, DMVPFR},
+ {DMVPRI * 2, 0.0f, 0.0f},
+ {DMVUXTHR, DMVUYTHR},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// h
+ {DMVPRI, DMVPBO, DMVPBA},
+ {DMVPRI * 2, 0.0f, 0.0f},
+ {DMVUXFOR, DMVUYTHR},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// i
+ {DMVPRI, DMVPBO, DMVPBA},
+ {0.0f, 0.0f, DMVPBA * 2},
+ {DMVUXFOR, DMVUYTHR},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// j
+ {DMVPLE, DMVPBO, DMVPBA},
+ {0.0f, 0.0f, DMVPBA * 2},
+ {DMVUXFIV, DMVUYTHR},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0, 0, 0, 0}},
+ {// k
+ {DMVPLE, DMVPBO, DMVPFR},
+ {0.0f, DMVPBO * 2, 0.0f},
+ {DMVUXTWO, DMVUYTHR},
{1.0f, 0.0f, 0.0f, 0.0f},
{0, 0, 0, 0}},
- {{0.5f, -0.5f, -0.5f},
- {0.0f, 0.0f, -1.0f},
- {0.0f, 1.0f / 3.0f},
+ {// k
+ {DMVPRI, DMVPBO, DMVPFR},
+ {0.0f, DMVPBO * 2, 0.0f},
+ {DMVUXTHR, DMVUYTHR},
{1.0f, 0.0f, 0.0f, 0.0f},
{0, 0, 0, 0}},
- {{-0.5f, -0.5f, -0.5f},
- {0.0f, 0.0f, -1.0f},
- {0.25f, 1.0f / 3.0f},
+ {// m
+ {DMVPLE, DMVPBO, DMVPBA},
+ {0.0f, DMVPBO * 2, 0.0f},
+ {DMVUXTWO, DMVUYFOR},
{1.0f, 0.0f, 0.0f, 0.0f},
{0, 0, 0, 0}},
- {{0.5f, 0.5f, -0.5f},
- {0.0f, 0.0f, -1.0f},
- {0.25f, 2.0f / 3.0f},
+ {// n
+ {DMVPRI, DMVPBO, DMVPBA},
+ {0.0f, DMVPBO * 2, 0.0f},
+ {DMVUXTHR, DMVUYFOR},
{1.0f, 0.0f, 0.0f, 0.0f},
{0, 0, 0, 0}},
};
@@ -67,18 +223,28 @@
struct
{
uint32_t first, second, third;
- } square[2];
+ } cube[12];
} *data_model_index = &(struct data_model_index){{
- {0, 2, 1},
- {0, 1, 3},
+ {2, 0, 1}, // A
+ {2, 1, 3},
+ {12, 4, 5}, // B
+ {12, 5, 13},
+ {14, 6, 7}, // C
+ {14, 7, 15},
+ {16, 8, 9}, // D
+ {16, 9, 17},
+ {18, 10, 11}, // E
+ {18, 11, 19},
+ {22, 20, 21}, // F
+ {22, 21, 23},
}};
const VkDeviceSize data_model_index_size = sizeof(*data_model_index);
data_model_t data_models[] = {
{
- "Square",
- offsetof(struct data_model_index, square) / sizeof(uint32_t),
- sizeof(data_model_index->square) / sizeof(uint32_t),
+ "Cube",
+ offsetof(struct data_model_index, cube) / sizeof(uint32_t),
+ sizeof(data_model_index->cube) / sizeof(uint32_t),
0,
},
};
diff -bNur 0003index-buffer/libdata.c 0004cube/libdata.c
--- 0003index-buffer/libdata.c 2019-03-03 15:08:52.160918059 -0600
+++ 0004cube/libdata.c 2019-03-03 15:08:52.164917190 -0600
@@ -192,6 +192,7 @@
inline static void handle_input(double this_frame, material_0_ubo_t *ubo_0)
{
+ float diagnal2 = 1;
bool need_lookat = false;
#define GET_KEY(key) glfwGetKey(data_window, (key))
@@ -200,8 +201,10 @@
{
double dist = 1.5 * (GET_KEY2(GLFW_KEY_W, GLFW_KEY_UP) ? this_frame - previous_frame
: previous_frame - this_frame);
- ubo_0->viewPos[0] += sinf(center_dir) * dist;
- ubo_0->viewPos[2] += cosf(center_dir) * dist;
+ if (GET_KEY(GLFW_KEY_R) ^ GET_KEY(GLFW_KEY_V))
+ diagnal2 = 0.70710678119f;
+ ubo_0->viewPos[0] += sinf(center_dir) * dist * diagnal2;
+ ubo_0->viewPos[2] += cosf(center_dir) * dist * diagnal2;
need_lookat = true;
}
@@ -212,6 +215,14 @@
need_lookat = true;
}
+ if (GET_KEY(GLFW_KEY_R) ^ GET_KEY(GLFW_KEY_V))
+ {
+ double dist = 1.5 * (GET_KEY(GLFW_KEY_R) ? this_frame - previous_frame
+ : previous_frame - this_frame);
+ ubo_0->viewPos[1] += dist * diagnal2;
+ need_lookat = true;
+ }
+
if (need_lookat)
update_vp(ubo_0);
}