1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-24 21:09:57 +01:00

Continue city

This commit is contained in:
Miloslav Číž 2019-06-20 18:33:38 +02:00
parent a675a30881
commit e4f361f26e
2 changed files with 40 additions and 25 deletions

View file

@ -56,7 +56,24 @@ uint32_t frame = 0;
void clearScreen() void clearScreen()
{ {
memset(pixels,255,S3L_RESOLUTION_X * S3L_RESOLUTION_Y * sizeof(uint32_t)); uint32_t index = 0;
for (uint16_t y = 0; y < S3L_RESOLUTION_Y; ++y)
{
S3L_Unit t = S3L_min(S3L_FRACTIONS_PER_UNIT,((y * S3L_FRACTIONS_PER_UNIT) / S3L_RESOLUTION_Y) * 4);
uint32_t r = S3L_interpolateByUnit(200,242,t);
uint32_t g = S3L_interpolateByUnit(102,255,t);
uint32_t b = S3L_interpolateByUnit(255,230,t);
uint32_t color = (r << 24) | (g << 16 ) | (b << 8);
for (uint16_t x = 0; x < S3L_RESOLUTION_X; ++x)
{
pixels[index] = color;
index++;
}
}
} }
static inline void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) static inline void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue)
@ -199,8 +216,9 @@ int main()
cityModelInit(); cityModelInit();
carModelInit(); carModelInit();
carModel.transform.translation.x += 7 * (S3L_FRACTIONS_PER_UNIT / 2); carModel.transform.translation.x = 7 * (S3L_FRACTIONS_PER_UNIT / 2);
carModel.transform.translation.z += -7 * (S3L_FRACTIONS_PER_UNIT / 2); carModel.transform.translation.z = -7 * (S3L_FRACTIONS_PER_UNIT / 2);
carModel.transform.translation.y = (S3L_FRACTIONS_PER_UNIT / 32);
models[0] = cityModel; models[0] = cityModel;
models[1] = carModel; models[1] = carModel;
@ -332,9 +350,6 @@ int main()
scene.camera.transform.rotation.y = models[1].transform.rotation.y; scene.camera.transform.rotation.y = models[1].transform.rotation.y;
if (collision(scene.camera.transform.translation))
handleCollision(&(scene.camera.transform.translation),previousCamPos);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
SDL_RenderCopy(renderer,textureSDL,NULL,NULL); SDL_RenderCopy(renderer,textureSDL,NULL,NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);

View file

@ -15,9 +15,9 @@ const S3L_Unit cityVertices[CITY_VERTEX_COUNT * 3] = {
1024, 2, -1536, // 27 1024, 2, -1536, // 27
512, 2, -2560, // 30 512, 2, -2560, // 30
0, 2, -2560, // 33 0, 2, -2560, // 33
512, 889, -2048, // 36 563, 889, -1996, // 36
512, 889, -2560, // 39 563, 889, -2611, // 39
0, 889, -2560, // 42 -51, 889, -2611, // 42
-238, 790, -3072, // 45 -238, 790, -3072, // 45
512, 792, -3072, // 48 512, 792, -3072, // 48
-1024, 388, -3072, // 51 -1024, 388, -3072, // 51
@ -36,8 +36,8 @@ const S3L_Unit cityVertices[CITY_VERTEX_COUNT * 3] = {
-512, 148, -3347, // 90 -512, 148, -3347, // 90
-1372, 297, -2017, // 93 -1372, 297, -2017, // 93
-1145, 297, -1737, // 96 -1145, 297, -1737, // 96
-1372, 1403, -2017, // 99 -1395, 1403, -2044, // 99
-1145, 1403, -1737, // 102 -1122, 1403, -1709, // 102
2560, 2, -1024, // 105 2560, 2, -1024, // 105
2048, 2, -512, // 108 2048, 2, -512, // 108
1024, 2, -3072, // 111 1024, 2, -3072, // 111
@ -67,10 +67,10 @@ const S3L_Unit cityVertices[CITY_VERTEX_COUNT * 3] = {
998, 155, -3609, // 183 998, 155, -3609, // 183
1561, 155, -3609, // 186 1561, 155, -3609, // 186
1561, 155, -3046, // 189 1561, 155, -3046, // 189
2560, 889, -1024, // 192 2508, 889, -972, // 192
3072, 889, -1024, // 195 3123, 889, -972, // 195
3072, 889, -1536, // 198 3123, 889, -1587, // 198
2560, 889, -1536, // 201 2508, 889, -1587, // 201
1024, 316, -4096, // 204 1024, 316, -4096, // 204
2048, 316, -4096, // 207 2048, 316, -4096, // 207
512, 792, -4096, // 210 512, 792, -4096, // 210
@ -104,16 +104,16 @@ const S3L_Unit cityVertices[CITY_VERTEX_COUNT * 3] = {
2048, 1484, -3584, // 294 2048, 1484, -3584, // 294
2048, 1227, -4096, // 297 2048, 1227, -4096, // 297
2560, 1484, -3584, // 300 2560, 1484, -3584, // 300
2443, 141, -5243, // 303 2443, -253, -5243, // 303
2721, 141, -4712, // 306 2721, -253, -4712, // 306
2443, 1078, -5243, // 309 2443, 1078, -5243, // 309
2721, 1078, -4712, // 312 2721, 1078, -4712, // 312
1187, 297, -993, // 315 1187, 297, -993, // 315
1414, 297, -713, // 318 1414, 297, -713, // 318
1187, 1403, -993, // 321 1177, 1403, -1022, // 321
1414, 1403, -713, // 324 1450, 1403, -687, // 324
1055, 297, -700, // 327 1055, 297, -700, // 327
1055, 1403, -700, // 330 1019, 1403, -671, // 330
3584, 2, -2048, // 333 3584, 2, -2048, // 333
3584, 2, -2560, // 336 3584, 2, -2560, // 336
3072, 2, -3072, // 339 3072, 2, -3072, // 339
@ -148,16 +148,16 @@ const S3L_Unit cityVertices[CITY_VERTEX_COUNT * 3] = {
4608, 1484, -2560, // 426 4608, 1484, -2560, // 426
4608, 1227, -3072, // 429 4608, 1227, -3072, // 429
5120, 1484, -2560, // 432 5120, 1484, -2560, // 432
5003, 141, -4219, // 435 5003, -253, -4219, // 435
5281, 141, -3688, // 438 5281, -253, -3688, // 438
5003, 1078, -4219, // 441 5003, 1078, -4219, // 441
5281, 1078, -3688, // 444 5281, 1078, -3688, // 444
3747, 297, 30, // 447 3747, 297, 30, // 447
3974, 297, 310, // 450 3974, 297, 310, // 450
3747, 1403, 30, // 453 3737, 1403, 1, // 453
3974, 1403, 310, // 456 4010, 1403, 336, // 456
3615, 297, 323, // 459 3615, 297, 323, // 459
3615, 1403, 323 // 462 3579, 1403, 352 // 462
}; // cityVertices }; // cityVertices
#define CITY_TRIANGLE_COUNT 197 #define CITY_TRIANGLE_COUNT 197