mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-23 20:59:58 +01:00
Rework scene draw
This commit is contained in:
parent
2f6e21e3d8
commit
9448f5ca36
3 changed files with 729 additions and 174 deletions
774
house.h
774
house.h
|
@ -2,123 +2,677 @@
|
|||
#define HOUSE_H
|
||||
|
||||
const S3L_Unit houseVertices[] = {
|
||||
0x388,0x35e,0x157,0x388,0x35e,0x22c,0x331,0x183,0x1c9,0x331,0x17a,0x13c,0x2e0,
|
||||
0x35e,0x22c,0x2a5,0x19a,0x1c9,0x40b,0x360,0x2ba,0x2e8,0x18d,0x13c,0x33d,0x35e,
|
||||
0x157,0x30d,0x25a,-0x123,0x33d,0x35e,-0x207,0x30d,0x25c,0x6c,0x5e,0x383,0x2e0,
|
||||
0x2e0,0x35e,0x1c7,0x2a5,0x1ae,0x16c,0x26c,0x664,-0x58,0x22,0x633,-0x58,0x336,
|
||||
-0x1c,0x13e,0x2fd,-0x1c,0x13e,0x290,-0x1c,0x17e,0x290,-0x1c,0x1f6,0x336,-0x1c,
|
||||
0x1f6,0x12d,0x197,0x16c,0x10d,-0x1c,0x180,0x13e,0x2d0,0x1b9,0x10d,-0x1a,0x1d4,
|
||||
0x13e,0x2cf,0x232,0xe8,0x274,0x22a,0xba,-0x1a,0x1da,0xe8,0x275,0x1a6,0xba,-0x1c,
|
||||
0x176,0x290,0x25c,0x6c,0x2e8,0x198,0x66,0x290,0x10a,0x55,0x290,0x10a,-0x104,
|
||||
0x290,0x25a,-0x123,0x2f2,0x10a,0x55,0x2f2,0x10a,-0x104,0x2fd,-0x1c,-0x1ee,-0x344,
|
||||
0x35e,0x157,-0x2ed,0x177,0x13c,-0x2ed,0x177,0x1c9,-0x344,0x35e,0x22c,-0x262,
|
||||
0x17c,0x1c9,-0x29c,0x35e,0x22c,-0x3ba,0x369,0x2ca,-0x2f9,0x35e,0x157,-0x2a4,
|
||||
0x197,0x13c,-0x2c9,0x25e,-0xf7,-0x295,0x167,-0x1f3,-0x2a4,0x199,-0xfb,-0x262,
|
||||
0x187,0x16c,-0x29c,0x35e,0x1c7,-0x4c7,0x6a0,-0x8b,-0x3a8,0x369,-0x358,-0x2b8,
|
||||
-0x1c,0x13e,-0x2fb,-0x1c,0x13e,-0x24c,-0x1c,0x1e0,-0x24c,-0x1c,0x17e,-0x2fb,
|
||||
-0x1c,0x1e0,-0xc9,-0x1c,0x180,-0xdd,0x197,0x16c,-0xee,0x2c1,0x1b9,-0xc9,-0x1a,
|
||||
0x1d4,-0xee,0x2bf,0x232,-0x75,-0x1a,0x1da,-0x98,0x265,0x22a,-0x75,-0x1c,0x176,
|
||||
-0x98,0x266,0x1a6,-0x344,0x35e,-0x207,-0x24b,0x25e,0x47,-0x24b,0xd2,0x48,-0x2a4,
|
||||
0x199,0x4b,-0x2c9,0x25e,0x47,-0x2ad,0xd2,0x48,-0x2f9,0x35e,-0x207,0x388,0x35e,
|
||||
-0x207,0x331,0x1a7,-0x1ec,0x331,0x197,-0x279,0x388,0x34f,-0x2dd,0x4c9,0x719,
|
||||
-0x71,-0x29c,0x35e,-0x277,0x7b,0x37a,-0x2fb,0x2e0,0x35e,-0x277,0x2ae,0x1aa,
|
||||
-0x279,0x2e0,0x35e,-0x2dd,0x3fd,0x33d,-0x33a,0x2e8,0x1a7,-0x1ec,0x2ae,0x1aa,
|
||||
-0x21c,-0x227,0x664,-0x58,-0x283,0x5c7,0x47,0x336,-0x1c,-0x1ee,0x290,-0x1c,
|
||||
-0x290,0x290,-0x1c,-0x22e,0x336,-0x1c,-0x290,0x2e8,0x199,-0x115,-0x344,0x35e,
|
||||
-0x2dd,-0x2de,0x167,-0x279,-0x2de,0x167,-0x1f3,-0x29c,0x35e,-0x2dd,-0x263,0x167,
|
||||
-0x279,-0x24b,0x25e,-0xf7,-0x24b,0xd2,-0xf8,-0x263,0x167,-0x21c,-0x2f1,-0x1c,
|
||||
-0x1ee,-0x2b8,-0x1c,-0x1ee,-0x24c,-0x1c,-0x22e,-0x24c,-0x1c,-0x290,-0x2f1,-0x1c,
|
||||
-0x290,-0x2ad,0xd2,-0xf8,-0x2be,0x56d,0xa1,-0x274,0x6bc,0x64,-0x2d1,0x6b0,0x10d,
|
||||
-0x358,0x6cd,0x70,-0x31a,0x5c0,0x55,0x388,0x35e,0x22c,0x376,0x35e,-0x281,0x376,
|
||||
0x35e,-0x281,-0x344,0x35e,0x22c,-0x332,0x35e,-0x281,-0x332,0x35e,-0x281,0x388,
|
||||
0x35e,-0x2dd,0x376,0x35e,0x1d1,0x376,0x35e,0x1d1,-0x344,0x35e,-0x2dd,-0x332,
|
||||
0x35e,0x1d1,-0x332,0x35e,0x1d1};
|
||||
904, 862, 343, // 0
|
||||
904, 862, 556, // 3
|
||||
817, 387, 457, // 6
|
||||
817, 378, 316, // 9
|
||||
736, 862, 556, // 12
|
||||
677, 410, 457, // 15
|
||||
1035, 864, 698, // 18
|
||||
744, 397, 316, // 21
|
||||
829, 862, 343, // 24
|
||||
781, 602, -291, // 27
|
||||
829, 862, -519, // 30
|
||||
781, 604, 108, // 33
|
||||
94, 899, 736, // 36
|
||||
736, 862, 455, // 39
|
||||
677, 430, 364, // 42
|
||||
620, 1636, -88, // 45
|
||||
34, 1587, -88, // 48
|
||||
822, -28, 318, // 51
|
||||
765, -28, 318, // 54
|
||||
656, -28, 382, // 57
|
||||
656, -28, 502, // 60
|
||||
822, -28, 502, // 63
|
||||
301, 407, 364, // 66
|
||||
269, -28, 384, // 69
|
||||
318, 720, 441, // 72
|
||||
269, -26, 468, // 75
|
||||
318, 719, 562, // 78
|
||||
232, 628, 554, // 81
|
||||
186, -26, 474, // 84
|
||||
232, 629, 422, // 87
|
||||
186, -28, 374, // 90
|
||||
656, 604, 108, // 93
|
||||
744, 408, 102, // 96
|
||||
656, 266, 85, // 99
|
||||
656, 266, -260, // 102
|
||||
656, 602, -291, // 105
|
||||
754, 266, 85, // 108
|
||||
754, 266, -260, // 111
|
||||
765, -28, -494, // 114
|
||||
-836, 862, 343, // 117
|
||||
-749, 375, 316, // 120
|
||||
-749, 375, 457, // 123
|
||||
-836, 862, 556, // 126
|
||||
-610, 380, 457, // 129
|
||||
-668, 862, 556, // 132
|
||||
-954, 873, 714, // 135
|
||||
-761, 862, 343, // 138
|
||||
-676, 407, 316, // 141
|
||||
-713, 606, -247, // 144
|
||||
-661, 359, -499, // 147
|
||||
-676, 409, -251, // 150
|
||||
-610, 391, 364, // 153
|
||||
-668, 862, 455, // 156
|
||||
-1223, 1696, -139, // 159
|
||||
-936, 873, -856, // 162
|
||||
-696, -28, 318, // 165
|
||||
-763, -28, 318, // 168
|
||||
-588, -28, 480, // 171
|
||||
-588, -28, 382, // 174
|
||||
-763, -28, 480, // 177
|
||||
-201, -28, 384, // 180
|
||||
-221, 407, 364, // 183
|
||||
-238, 705, 441, // 186
|
||||
-201, -26, 468, // 189
|
||||
-238, 703, 562, // 192
|
||||
-117, -26, 474, // 195
|
||||
-152, 613, 554, // 198
|
||||
-117, -28, 374, // 201
|
||||
-152, 614, 422, // 204
|
||||
-836, 862, -519, // 207
|
||||
-587, 606, 71, // 210
|
||||
-587, 210, 72, // 213
|
||||
-676, 409, 75, // 216
|
||||
-713, 606, 71, // 219
|
||||
-685, 210, 72, // 222
|
||||
-761, 862, -519, // 225
|
||||
904, 862, -519, // 228
|
||||
817, 423, -492, // 231
|
||||
817, 407, -633, // 234
|
||||
904, 847, -733, // 237
|
||||
1225, 1817, -113, // 240
|
||||
-668, 862, -631, // 243
|
||||
123, 890, -763, // 246
|
||||
736, 862, -631, // 249
|
||||
686, 426, -633, // 252
|
||||
736, 862, -733, // 255
|
||||
1021, 829, -826, // 258
|
||||
744, 423, -492, // 261
|
||||
686, 426, -540, // 264
|
||||
-551, 1636, -88, // 267
|
||||
-643, 1479, 71, // 270
|
||||
822, -28, -494, // 273
|
||||
656, -28, -656, // 276
|
||||
656, -28, -558, // 279
|
||||
822, -28, -656, // 282
|
||||
744, 409, -277, // 285
|
||||
-836, 862, -733, // 288
|
||||
-734, 359, -633, // 291
|
||||
-734, 359, -499, // 294
|
||||
-668, 862, -733, // 297
|
||||
-611, 359, -633, // 300
|
||||
-587, 606, -247, // 303
|
||||
-587, 210, -248, // 306
|
||||
-611, 359, -540, // 309
|
||||
-753, -28, -494, // 312
|
||||
-696, -28, -494, // 315
|
||||
-588, -28, -558, // 318
|
||||
-588, -28, -656, // 321
|
||||
-753, -28, -656, // 324
|
||||
-685, 210, -248, // 327
|
||||
-702, 1389, 161, // 330
|
||||
-628, 1724, 100, // 333
|
||||
-721, 1712, 269, // 336
|
||||
-856, 1741, 112, // 339
|
||||
-794, 1472, 85, // 342
|
||||
904, 862, 556, // 345
|
||||
886, 862, -641, // 348
|
||||
886, 862, -641, // 351
|
||||
-836, 862, 556, // 354
|
||||
-818, 862, -641, // 357
|
||||
-818, 862, -641, // 360
|
||||
904, 862, -733, // 363
|
||||
886, 862, 465, // 366
|
||||
886, 862, 465, // 369
|
||||
-836, 862, -733, // 372
|
||||
-818, 862, 465, // 375
|
||||
-818, 862, 465 // 378
|
||||
}; // houseVertices
|
||||
|
||||
const S3L_Index houseTriangleIndices[] = {
|
||||
0,2,3,4,2,1,4,1,6,0,6,1,3,8,0,10,11,9,8,7,11,12,4,6,5,13,14,15,16,12,3,18,7,5,19,
|
||||
20,2,20,21,2,17,3,22,19,14,24,14,13,25,24,26,23,22,24,25,27,28,28,29,30,31,32,33,
|
||||
32,31,11,31,34,35,36,33,32,37,18,38,18,36,7,39,41,42,41,44,42,44,45,42,39,42,45,
|
||||
39,47,40,48,49,50,12,45,44,43,52,44,53,54,45,55,40,47,43,58,51,41,57,43,56,41,40,
|
||||
58,61,51,51,62,52,63,62,60,60,62,61,63,66,64,65,68,66,45,69,39,70,71,72,72,73,70,
|
||||
74,72,71,75,49,48,76,78,79,15,6,80,81,82,83,78,85,79,85,86,79,76,79,86,10,77,76,
|
||||
0,10,76,7,32,11,82,86,85,84,83,85,16,89,90,15,82,16,38,77,87,84,93,88,78,92,84,
|
||||
91,78,77,35,34,95,95,9,35,11,35,9,37,95,34,33,37,34,7,36,32,69,97,98,89,54,53,99,
|
||||
82,81,99,97,96,99,96,54,69,54,96,98,75,69,101,71,70,46,73,47,82,99,54,100,81,103,
|
||||
15,86,82,89,16,82,73,75,48,98,105,49,100,106,107,100,108,97,97,104,98,103,93,106,
|
||||
81,88,103,109,55,74,101,50,102,50,101,48,102,74,71,109,102,50,48,70,73,73,72,47,
|
||||
69,46,39,86,0,76,80,6,86,30,68,67,27,68,29,27,64,66,62,26,24,24,52,62,12,52,13,4,
|
||||
12,13,12,44,52,10,9,87,87,9,95,87,95,37,38,87,37,109,50,49,49,105,109,74,47,72,
|
||||
47,74,55,90,112,110,112,114,110,114,111,90,113,112,111,45,114,53,110,114,45,12,
|
||||
16,90,110,12,90,110,45,12,90,89,114,89,53,114,82,85,83,0,1,2,4,5,2,3,7,8,10,8,11,
|
||||
5,4,13,3,17,18,5,14,19,2,5,20,2,21,17,22,23,19,24,22,14,25,23,24,25,26,27,28,27,
|
||||
29,31,33,34,37,36,18,39,40,41,41,43,44,39,46,47,43,51,52,55,56,40,43,57,58,41,59,
|
||||
57,56,59,41,58,60,61,51,61,62,63,64,62,63,65,66,65,67,68,45,54,69,76,77,78,15,12,
|
||||
6,78,84,85,10,87,77,0,8,10,84,88,83,38,91,77,84,92,93,78,94,92,91,94,78,11,31,35,
|
||||
33,36,37,69,96,97,89,82,54,99,100,97,98,49,75,101,102,71,100,99,81,15,80,86,73,
|
||||
46,75,98,104,105,100,103,106,100,107,108,97,108,104,103,88,93,81,83,88,109,105,
|
||||
55,102,109,74,48,101,70,69,75,46,86,6,0,30,29,68,27,66,68,27,26,64,62,64,26,24,
|
||||
13,52,90,111,112,112,113,114,114,113,111};
|
||||
0, 2, 3, // 0
|
||||
4, 2, 1, // 3
|
||||
4, 1, 6, // 6
|
||||
0, 6, 1, // 9
|
||||
3, 8, 0, // 12
|
||||
10, 11, 9, // 15
|
||||
8, 7, 11, // 18
|
||||
12, 4, 6, // 21
|
||||
5, 13, 14, // 24
|
||||
15, 16, 12, // 27
|
||||
3, 18, 7, // 30
|
||||
5, 19, 20, // 33
|
||||
2, 20, 21, // 36
|
||||
2, 17, 3, // 39
|
||||
22, 19, 14, // 42
|
||||
24, 14, 13, // 45
|
||||
25, 24, 26, // 48
|
||||
23, 22, 24, // 51
|
||||
25, 27, 28, // 54
|
||||
28, 29, 30, // 57
|
||||
31, 32, 33, // 60
|
||||
32, 31, 11, // 63
|
||||
31, 34, 35, // 66
|
||||
36, 33, 32, // 69
|
||||
37, 18, 38, // 72
|
||||
18, 36, 7, // 75
|
||||
39, 41, 42, // 78
|
||||
41, 44, 42, // 81
|
||||
44, 45, 42, // 84
|
||||
39, 42, 45, // 87
|
||||
39, 47, 40, // 90
|
||||
48, 49, 50, // 93
|
||||
12, 45, 44, // 96
|
||||
43, 52, 44, // 99
|
||||
53, 54, 45, // 102
|
||||
55, 40, 47, // 105
|
||||
43, 58, 51, // 108
|
||||
41, 57, 43, // 111
|
||||
56, 41, 40, // 114
|
||||
58, 61, 51, // 117
|
||||
51, 62, 52, // 120
|
||||
63, 62, 60, // 123
|
||||
60, 62, 61, // 126
|
||||
63, 66, 64, // 129
|
||||
65, 68, 66, // 132
|
||||
45, 69, 39, // 135
|
||||
70, 71, 72, // 138
|
||||
72, 73, 70, // 141
|
||||
74, 72, 71, // 144
|
||||
75, 49, 48, // 147
|
||||
76, 78, 79, // 150
|
||||
15, 6, 80, // 153
|
||||
81, 82, 83, // 156
|
||||
78, 85, 79, // 159
|
||||
85, 86, 79, // 162
|
||||
76, 79, 86, // 165
|
||||
10, 77, 76, // 168
|
||||
0, 10, 76, // 171
|
||||
7, 32, 11, // 174
|
||||
82, 86, 85, // 177
|
||||
84, 83, 85, // 180
|
||||
16, 89, 90, // 183
|
||||
15, 82, 16, // 186
|
||||
38, 77, 87, // 189
|
||||
84, 93, 88, // 192
|
||||
78, 92, 84, // 195
|
||||
91, 78, 77, // 198
|
||||
35, 34, 95, // 201
|
||||
95, 9, 35, // 204
|
||||
11, 35, 9, // 207
|
||||
37, 95, 34, // 210
|
||||
33, 37, 34, // 213
|
||||
7, 36, 32, // 216
|
||||
69, 97, 98, // 219
|
||||
89, 54, 53, // 222
|
||||
99, 82, 81, // 225
|
||||
99, 97, 96, // 228
|
||||
99, 96, 54, // 231
|
||||
69, 54, 96, // 234
|
||||
98, 75, 69, // 237
|
||||
101, 71, 70, // 240
|
||||
46, 73, 47, // 243
|
||||
82, 99, 54, // 246
|
||||
100, 81, 103, // 249
|
||||
15, 86, 82, // 252
|
||||
89, 16, 82, // 255
|
||||
73, 75, 48, // 258
|
||||
98, 105, 49, // 261
|
||||
100, 106, 107, // 264
|
||||
100, 108, 97, // 267
|
||||
97, 104, 98, // 270
|
||||
103, 93, 106, // 273
|
||||
81, 88, 103, // 276
|
||||
109, 55, 74, // 279
|
||||
101, 50, 102, // 282
|
||||
50, 101, 48, // 285
|
||||
102, 74, 71, // 288
|
||||
109, 102, 50, // 291
|
||||
48, 70, 73, // 294
|
||||
73, 72, 47, // 297
|
||||
69, 46, 39, // 300
|
||||
86, 0, 76, // 303
|
||||
80, 6, 86, // 306
|
||||
30, 68, 67, // 309
|
||||
27, 68, 29, // 312
|
||||
27, 64, 66, // 315
|
||||
62, 26, 24, // 318
|
||||
24, 52, 62, // 321
|
||||
12, 52, 13, // 324
|
||||
4, 12, 13, // 327
|
||||
12, 44, 52, // 330
|
||||
10, 9, 87, // 333
|
||||
87, 9, 95, // 336
|
||||
87, 95, 37, // 339
|
||||
38, 87, 37, // 342
|
||||
109, 50, 49, // 345
|
||||
49, 105, 109, // 348
|
||||
74, 47, 72, // 351
|
||||
47, 74, 55, // 354
|
||||
90, 112, 110, // 357
|
||||
112, 114, 110, // 360
|
||||
114, 111, 90, // 363
|
||||
113, 112, 111, // 366
|
||||
45, 114, 53, // 369
|
||||
110, 114, 45, // 372
|
||||
12, 16, 90, // 375
|
||||
110, 12, 90, // 378
|
||||
110, 45, 12, // 381
|
||||
90, 89, 114, // 384
|
||||
89, 53, 114, // 387
|
||||
82, 85, 83, // 390
|
||||
0, 1, 2, // 393
|
||||
4, 5, 2, // 396
|
||||
3, 7, 8, // 399
|
||||
10, 8, 11, // 402
|
||||
5, 4, 13, // 405
|
||||
3, 17, 18, // 408
|
||||
5, 14, 19, // 411
|
||||
2, 5, 20, // 414
|
||||
2, 21, 17, // 417
|
||||
22, 23, 19, // 420
|
||||
24, 22, 14, // 423
|
||||
25, 23, 24, // 426
|
||||
25, 26, 27, // 429
|
||||
28, 27, 29, // 432
|
||||
31, 33, 34, // 435
|
||||
37, 36, 18, // 438
|
||||
39, 40, 41, // 441
|
||||
41, 43, 44, // 444
|
||||
39, 46, 47, // 447
|
||||
43, 51, 52, // 450
|
||||
55, 56, 40, // 453
|
||||
43, 57, 58, // 456
|
||||
41, 59, 57, // 459
|
||||
56, 59, 41, // 462
|
||||
58, 60, 61, // 465
|
||||
51, 61, 62, // 468
|
||||
63, 64, 62, // 471
|
||||
63, 65, 66, // 474
|
||||
65, 67, 68, // 477
|
||||
45, 54, 69, // 480
|
||||
76, 77, 78, // 483
|
||||
15, 12, 6, // 486
|
||||
78, 84, 85, // 489
|
||||
10, 87, 77, // 492
|
||||
0, 8, 10, // 495
|
||||
84, 88, 83, // 498
|
||||
38, 91, 77, // 501
|
||||
84, 92, 93, // 504
|
||||
78, 94, 92, // 507
|
||||
91, 94, 78, // 510
|
||||
11, 31, 35, // 513
|
||||
33, 36, 37, // 516
|
||||
69, 96, 97, // 519
|
||||
89, 82, 54, // 522
|
||||
99, 100, 97, // 525
|
||||
98, 49, 75, // 528
|
||||
101, 102, 71, // 531
|
||||
100, 99, 81, // 534
|
||||
15, 80, 86, // 537
|
||||
73, 46, 75, // 540
|
||||
98, 104, 105, // 543
|
||||
100, 103, 106, // 546
|
||||
100, 107, 108, // 549
|
||||
97, 108, 104, // 552
|
||||
103, 88, 93, // 555
|
||||
81, 83, 88, // 558
|
||||
109, 105, 55, // 561
|
||||
102, 109, 74, // 564
|
||||
48, 101, 70, // 567
|
||||
69, 75, 46, // 570
|
||||
86, 6, 0, // 573
|
||||
30, 29, 68, // 576
|
||||
27, 66, 68, // 579
|
||||
27, 26, 64, // 582
|
||||
62, 64, 26, // 585
|
||||
24, 13, 52, // 588
|
||||
90, 111, 112, // 591
|
||||
112, 113, 114, // 594
|
||||
114, 113, 111 // 597
|
||||
}; // houseTriangleIndices
|
||||
|
||||
const S3L_Unit houseUVs[] = {
|
||||
0x711,0x6bc,0x2af,0x711,0x6bc,0x459,0x663,0x307,0x392,0x663,0x2f4,0x278,0x5c1,
|
||||
0x6bc,0x459,0x54a,0x335,0x392,0x816,0x6c0,0x574,0x5d1,0x31b,0x278,0x67b,0x6bc,
|
||||
0x2af,0x61b,0x4b5,-0x246,0x67b,0x6bc,-0x40f,0x61b,0x4b8,0xd9,0xbc,0x707,0x5c1,
|
||||
0x5c1,0x6bc,0x38e,0x54a,0x35c,0x2d9,0x4d8,0xcc8,-0xb0,0x44,0xc66,-0xb0,0x66c,
|
||||
-0x39,0x27c,0x5fa,-0x39,0x27c,0x521,-0x39,0x2fd,0x521,-0x39,0x3ed,0x66c,-0x39,
|
||||
0x3ed,0x25a,0x32e,0x2d8,0x21b,-0x39,0x300,0x27d,0x5a1,0x372,0x21b,-0x34,0x3a8,
|
||||
0x27d,0x59e,0x464,0x1d0,0x4e9,0x455,0x174,-0x34,0x3b4,0x1d0,0x4eb,0x34d,0x174,
|
||||
-0x39,0x2ec,0x520,0x4b8,0xd9,0x5d1,0x331,0xcc,0x520,0x214,0xab,0x520,0x215,
|
||||
-0x209,0x520,0x4b5,-0x246,0x5e4,0x214,0xab,0x5e4,0x215,-0x209,0x5fa,-0x39,-0x3dc,
|
||||
-0x688,0x6bc,0x2af,-0x5da,0x2ef,0x278,-0x5da,0x2ef,0x392,-0x688,0x6bc,0x459,
|
||||
-0x4c5,0x2f8,0x392,-0x538,0x6bc,0x459,-0x775,0x6d3,0x595,-0x5f3,0x6bc,0x2af,
|
||||
-0x548,0x32e,0x278,-0x592,0x4bd,-0x1ee,-0x52b,0x2ce,-0x3e7,-0x548,0x332,-0x1f7,
|
||||
-0x4c5,0x30e,0x2d9,-0x538,0x6bc,0x38e,-0x98e,0xd41,-0x116,-0x750,0x6d3,-0x6b1,
|
||||
-0x571,-0x39,0x27c,-0x5f7,-0x39,0x27c,-0x498,-0x39,0x3c1,-0x498,-0x39,0x2fd,
|
||||
-0x5f7,-0x39,0x3c1,-0x192,-0x39,0x300,-0x1bb,0x32e,0x2d8,-0x1dd,0x582,0x372,
|
||||
-0x192,-0x34,0x3a8,-0x1dd,0x57f,0x464,-0xeb,-0x34,0x3b4,-0x130,0x4ca,0x455,-0xeb,
|
||||
-0x39,0x2ec,-0x130,0x4cc,0x34d,-0x688,0x6bc,-0x40f,-0x497,0x4bd,0x8e,-0x497,
|
||||
0x1a4,0x91,-0x548,0x332,0x97,-0x592,0x4bd,0x8e,-0x55b,0x1a4,0x91,-0x5f3,0x6bc,
|
||||
-0x40f,0x711,0x6bc,-0x40f,0x663,0x34e,-0x3d8,0x663,0x32e,-0x4f2,0x711,0x69f,
|
||||
-0x5ba,0x992,0xe32,-0xe3,-0x538,0x6bc,-0x4ee,0xf7,0x6f5,-0x5f7,0x5c1,0x6bc,
|
||||
-0x4ee,0x55d,0x354,-0x4f2,0x5c1,0x6bc,-0x5ba,0x7fa,0x67a,-0x675,0x5d1,0x34e,
|
||||
-0x3d8,0x55d,0x354,-0x439,-0x44f,0xcc8,-0xb0,-0x506,0xb8f,0x8f,0x66c,-0x39,
|
||||
-0x3dc,0x521,-0x39,-0x521,0x521,-0x39,-0x45d,0x66c,-0x39,-0x521,0x5d1,0x332,
|
||||
-0x22b,-0x688,0x6bc,-0x5ba,-0x5bc,0x2ce,-0x4f2,-0x5bc,0x2ce,-0x3e7,-0x538,0x6bc,
|
||||
-0x5ba,-0x4c6,0x2ce,-0x4f2,-0x497,0x4bd,-0x1ee,-0x497,0x1a4,-0x1f1,-0x4c6,0x2ce,
|
||||
-0x439,-0x5e3,-0x39,-0x3dc,-0x571,-0x39,-0x3dc,-0x498,-0x39,-0x45d,-0x498,-0x39,
|
||||
-0x521,-0x5e3,-0x39,-0x521,-0x55b,0x1a4,-0x1f1,-0x57d,0xadb,0x143,-0x4e9,0xd79,
|
||||
0xc8,-0x5a2,0xd60,0x21a,-0x6b0,0xd9a,0xe0,-0x635,0xb81,0xaa,0x711,0x6bc,0x459,
|
||||
0x6ed,0x6bc,-0x502,0x6ed,0x6bc,-0x502,-0x688,0x6bc,0x459,-0x664,0x6bc,-0x502,
|
||||
-0x664,0x6bc,-0x502,0x711,0x6bc,-0x5ba,0x6ed,0x6bc,0x3a2,0x6ed,0x6bc,0x3a2,
|
||||
-0x688,0x6bc,-0x5ba,-0x664,0x6bc,0x3a2,-0x664,0x6bc,0x3a2};
|
||||
1809, 1724, // 0
|
||||
1809, 1724, // 2
|
||||
1635, 775, // 4
|
||||
1635, 756, // 6
|
||||
1473, 1724, // 8
|
||||
1354, 821, // 10
|
||||
2070, 1728, // 12
|
||||
1489, 795, // 14
|
||||
1659, 1724, // 16
|
||||
1563, 1205, // 18
|
||||
1659, 1724, // 20
|
||||
1563, 1208, // 22
|
||||
188, 1799, // 24
|
||||
1473, 1724, // 26
|
||||
1354, 860, // 28
|
||||
1240, 3272, // 30
|
||||
68, 3174, // 32
|
||||
1644, -57, // 34
|
||||
1530, -57, // 36
|
||||
1313, -57, // 38
|
||||
1313, -57, // 40
|
||||
1644, -57, // 42
|
||||
602, 814, // 44
|
||||
539, -57, // 46
|
||||
637, 1441, // 48
|
||||
539, -52, // 50
|
||||
637, 1438, // 52
|
||||
464, 1257, // 54
|
||||
372, -52, // 56
|
||||
464, 1259, // 58
|
||||
372, -57, // 60
|
||||
1312, 1208, // 62
|
||||
1489, 817, // 64
|
||||
1312, 532, // 66
|
||||
1312, 533, // 68
|
||||
1312, 1205, // 70
|
||||
1508, 532, // 72
|
||||
1508, 533, // 74
|
||||
1530, -57, // 76
|
||||
-1672, 1724, // 78
|
||||
-1498, 751, // 80
|
||||
-1498, 751, // 82
|
||||
-1672, 1724, // 84
|
||||
-1221, 760, // 86
|
||||
-1336, 1724, // 88
|
||||
-1909, 1747, // 90
|
||||
-1523, 1724, // 92
|
||||
-1352, 814, // 94
|
||||
-1426, 1213, // 96
|
||||
-1323, 718, // 98
|
||||
-1352, 818, // 100
|
||||
-1221, 782, // 102
|
||||
-1336, 1724, // 104
|
||||
-2446, 3393, // 106
|
||||
-1872, 1747, // 108
|
||||
-1393, -57, // 110
|
||||
-1527, -57, // 112
|
||||
-1176, -57, // 114
|
||||
-1176, -57, // 116
|
||||
-1527, -57, // 118
|
||||
-402, -57, // 120
|
||||
-443, 814, // 122
|
||||
-477, 1410, // 124
|
||||
-402, -52, // 126
|
||||
-477, 1407, // 128
|
||||
-235, -52, // 130
|
||||
-304, 1226, // 132
|
||||
-235, -57, // 134
|
||||
-304, 1228, // 136
|
||||
-1672, 1724, // 138
|
||||
-1175, 1213, // 140
|
||||
-1175, 420, // 142
|
||||
-1352, 818, // 144
|
||||
-1426, 1213, // 146
|
||||
-1371, 420, // 148
|
||||
-1523, 1724, // 150
|
||||
1809, 1724, // 152
|
||||
1635, 846, // 154
|
||||
1635, 814, // 156
|
||||
1809, 1695, // 158
|
||||
2450, 3634, // 160
|
||||
-1336, 1724, // 162
|
||||
247, 1781, // 164
|
||||
1473, 1724, // 166
|
||||
1373, 852, // 168
|
||||
1473, 1724, // 170
|
||||
2042, 1658, // 172
|
||||
1489, 846, // 174
|
||||
1373, 852, // 176
|
||||
-1103, 3272, // 178
|
||||
-1286, 2959, // 180
|
||||
1644, -57, // 182
|
||||
1313, -57, // 184
|
||||
1313, -57, // 186
|
||||
1644, -57, // 188
|
||||
1489, 818, // 190
|
||||
-1672, 1724, // 192
|
||||
-1468, 718, // 194
|
||||
-1468, 718, // 196
|
||||
-1336, 1724, // 198
|
||||
-1222, 718, // 200
|
||||
-1175, 1213, // 202
|
||||
-1175, 420, // 204
|
||||
-1222, 718, // 206
|
||||
-1507, -57, // 208
|
||||
-1393, -57, // 210
|
||||
-1176, -57, // 212
|
||||
-1176, -57, // 214
|
||||
-1507, -57, // 216
|
||||
-1371, 420, // 218
|
||||
-1405, 2779, // 220
|
||||
-1257, 3449, // 222
|
||||
-1442, 3424, // 224
|
||||
-1712, 3482, // 226
|
||||
-1589, 2945, // 228
|
||||
1809, 1724, // 230
|
||||
1773, 1724, // 232
|
||||
1773, 1724, // 234
|
||||
-1672, 1724, // 236
|
||||
-1636, 1724, // 238
|
||||
-1636, 1724, // 240
|
||||
1809, 1724, // 242
|
||||
1773, 1724, // 244
|
||||
1773, 1724, // 246
|
||||
-1672, 1724, // 248
|
||||
-1636, 1724, // 250
|
||||
-1636, 1724 // 252
|
||||
}; // houseUVs
|
||||
|
||||
const S3L_Index houseUVIndices[] = {
|
||||
0,2,3,4,2,1,4,1,6,0,6,1,3,8,0,10,11,9,8,7,11,12,4,6,5,13,14,15,16,12,3,18,7,5,19,
|
||||
20,2,20,21,2,17,3,22,19,14,24,14,13,25,24,26,23,22,24,25,27,28,28,29,30,31,32,33,
|
||||
32,31,11,31,34,35,36,33,32,37,18,38,18,36,7,39,41,42,41,44,42,44,45,42,39,42,45,
|
||||
39,47,40,48,49,50,12,45,44,43,52,44,53,54,45,55,40,47,43,58,51,41,57,43,56,41,40,
|
||||
58,61,51,51,62,52,63,62,60,60,62,61,63,66,64,65,68,66,45,69,39,70,71,72,72,73,70,
|
||||
74,72,71,75,49,48,76,78,79,15,6,80,81,82,83,78,85,79,85,86,79,76,79,86,10,77,76,
|
||||
0,10,76,7,32,11,82,86,85,84,83,85,16,89,90,15,82,16,38,77,87,84,93,88,78,92,84,
|
||||
91,78,77,35,34,95,95,9,35,11,35,9,37,95,34,33,37,34,7,36,32,69,97,98,89,54,53,99,
|
||||
82,81,99,97,96,99,96,54,69,54,96,98,75,69,101,71,70,46,73,47,82,99,54,100,81,103,
|
||||
15,86,82,89,16,82,73,75,48,98,105,49,100,106,107,100,108,97,97,104,98,103,93,106,
|
||||
81,88,103,109,55,74,101,50,102,50,101,48,102,74,71,109,102,50,48,70,73,73,72,47,
|
||||
69,46,39,86,0,76,80,6,86,30,68,67,27,68,29,27,64,66,62,26,24,24,52,62,12,52,13,4,
|
||||
12,13,12,44,52,10,9,87,87,9,95,87,95,37,38,87,37,109,50,49,49,105,109,74,47,72,
|
||||
47,74,55,90,112,110,112,114,110,114,111,90,113,112,111,45,114,53,110,114,45,12,
|
||||
16,90,110,12,90,110,45,12,90,89,114,89,53,114,82,85,83,0,1,2,4,5,2,3,7,8,10,8,11,
|
||||
5,4,13,3,17,18,5,14,19,2,5,20,2,21,17,22,23,19,24,22,14,25,23,24,25,26,27,28,27,
|
||||
29,31,33,34,37,36,18,39,40,41,41,43,44,39,46,47,43,51,52,55,56,40,43,57,58,41,59,
|
||||
57,56,59,41,58,60,61,51,61,62,63,64,62,63,65,66,65,67,68,45,54,69,76,77,78,15,12,
|
||||
6,78,84,85,10,87,77,0,8,10,84,88,83,38,91,77,84,92,93,78,94,92,91,94,78,11,31,35,
|
||||
33,36,37,69,96,97,89,82,54,99,100,97,98,49,75,101,102,71,100,99,81,15,80,86,73,
|
||||
46,75,98,104,105,100,103,106,100,107,108,97,108,104,103,88,93,81,83,88,109,105,
|
||||
55,102,109,74,48,101,70,69,75,46,86,6,0,30,29,68,27,66,68,27,26,64,62,64,26,24,
|
||||
13,52,90,111,112,112,113,114,114,113,111};
|
||||
0, 2, 3, // 0
|
||||
4, 2, 1, // 3
|
||||
4, 1, 6, // 6
|
||||
0, 6, 1, // 9
|
||||
3, 8, 0, // 12
|
||||
10, 11, 9, // 15
|
||||
8, 7, 11, // 18
|
||||
12, 4, 6, // 21
|
||||
5, 13, 14, // 24
|
||||
15, 16, 12, // 27
|
||||
3, 18, 7, // 30
|
||||
5, 19, 20, // 33
|
||||
2, 20, 21, // 36
|
||||
2, 17, 3, // 39
|
||||
22, 19, 14, // 42
|
||||
24, 14, 13, // 45
|
||||
25, 24, 26, // 48
|
||||
23, 22, 24, // 51
|
||||
25, 27, 28, // 54
|
||||
28, 29, 30, // 57
|
||||
31, 32, 33, // 60
|
||||
32, 31, 11, // 63
|
||||
31, 34, 35, // 66
|
||||
36, 33, 32, // 69
|
||||
37, 18, 38, // 72
|
||||
18, 36, 7, // 75
|
||||
39, 41, 42, // 78
|
||||
41, 44, 42, // 81
|
||||
44, 45, 42, // 84
|
||||
39, 42, 45, // 87
|
||||
39, 47, 40, // 90
|
||||
48, 49, 50, // 93
|
||||
12, 45, 44, // 96
|
||||
43, 52, 44, // 99
|
||||
53, 54, 45, // 102
|
||||
55, 40, 47, // 105
|
||||
43, 58, 51, // 108
|
||||
41, 57, 43, // 111
|
||||
56, 41, 40, // 114
|
||||
58, 61, 51, // 117
|
||||
51, 62, 52, // 120
|
||||
63, 62, 60, // 123
|
||||
60, 62, 61, // 126
|
||||
63, 66, 64, // 129
|
||||
65, 68, 66, // 132
|
||||
45, 69, 39, // 135
|
||||
70, 71, 72, // 138
|
||||
72, 73, 70, // 141
|
||||
74, 72, 71, // 144
|
||||
75, 49, 48, // 147
|
||||
76, 78, 79, // 150
|
||||
15, 6, 80, // 153
|
||||
81, 82, 83, // 156
|
||||
78, 85, 79, // 159
|
||||
85, 86, 79, // 162
|
||||
76, 79, 86, // 165
|
||||
10, 77, 76, // 168
|
||||
0, 10, 76, // 171
|
||||
7, 32, 11, // 174
|
||||
82, 86, 85, // 177
|
||||
84, 83, 85, // 180
|
||||
16, 89, 90, // 183
|
||||
15, 82, 16, // 186
|
||||
38, 77, 87, // 189
|
||||
84, 93, 88, // 192
|
||||
78, 92, 84, // 195
|
||||
91, 78, 77, // 198
|
||||
35, 34, 95, // 201
|
||||
95, 9, 35, // 204
|
||||
11, 35, 9, // 207
|
||||
37, 95, 34, // 210
|
||||
33, 37, 34, // 213
|
||||
7, 36, 32, // 216
|
||||
69, 97, 98, // 219
|
||||
89, 54, 53, // 222
|
||||
99, 82, 81, // 225
|
||||
99, 97, 96, // 228
|
||||
99, 96, 54, // 231
|
||||
69, 54, 96, // 234
|
||||
98, 75, 69, // 237
|
||||
101, 71, 70, // 240
|
||||
46, 73, 47, // 243
|
||||
82, 99, 54, // 246
|
||||
100, 81, 103, // 249
|
||||
15, 86, 82, // 252
|
||||
89, 16, 82, // 255
|
||||
73, 75, 48, // 258
|
||||
98, 105, 49, // 261
|
||||
100, 106, 107, // 264
|
||||
100, 108, 97, // 267
|
||||
97, 104, 98, // 270
|
||||
103, 93, 106, // 273
|
||||
81, 88, 103, // 276
|
||||
109, 55, 74, // 279
|
||||
101, 50, 102, // 282
|
||||
50, 101, 48, // 285
|
||||
102, 74, 71, // 288
|
||||
109, 102, 50, // 291
|
||||
48, 70, 73, // 294
|
||||
73, 72, 47, // 297
|
||||
69, 46, 39, // 300
|
||||
86, 0, 76, // 303
|
||||
80, 6, 86, // 306
|
||||
30, 68, 67, // 309
|
||||
27, 68, 29, // 312
|
||||
27, 64, 66, // 315
|
||||
62, 26, 24, // 318
|
||||
24, 52, 62, // 321
|
||||
12, 52, 13, // 324
|
||||
4, 12, 13, // 327
|
||||
12, 44, 52, // 330
|
||||
10, 9, 87, // 333
|
||||
87, 9, 95, // 336
|
||||
87, 95, 37, // 339
|
||||
38, 87, 37, // 342
|
||||
109, 50, 49, // 345
|
||||
49, 105, 109, // 348
|
||||
74, 47, 72, // 351
|
||||
47, 74, 55, // 354
|
||||
90, 112, 110, // 357
|
||||
112, 114, 110, // 360
|
||||
114, 111, 90, // 363
|
||||
113, 112, 111, // 366
|
||||
45, 114, 53, // 369
|
||||
110, 114, 45, // 372
|
||||
12, 16, 90, // 375
|
||||
110, 12, 90, // 378
|
||||
110, 45, 12, // 381
|
||||
90, 89, 114, // 384
|
||||
89, 53, 114, // 387
|
||||
82, 85, 83, // 390
|
||||
0, 1, 2, // 393
|
||||
4, 5, 2, // 396
|
||||
3, 7, 8, // 399
|
||||
10, 8, 11, // 402
|
||||
5, 4, 13, // 405
|
||||
3, 17, 18, // 408
|
||||
5, 14, 19, // 411
|
||||
2, 5, 20, // 414
|
||||
2, 21, 17, // 417
|
||||
22, 23, 19, // 420
|
||||
24, 22, 14, // 423
|
||||
25, 23, 24, // 426
|
||||
25, 26, 27, // 429
|
||||
28, 27, 29, // 432
|
||||
31, 33, 34, // 435
|
||||
37, 36, 18, // 438
|
||||
39, 40, 41, // 441
|
||||
41, 43, 44, // 444
|
||||
39, 46, 47, // 447
|
||||
43, 51, 52, // 450
|
||||
55, 56, 40, // 453
|
||||
43, 57, 58, // 456
|
||||
41, 59, 57, // 459
|
||||
56, 59, 41, // 462
|
||||
58, 60, 61, // 465
|
||||
51, 61, 62, // 468
|
||||
63, 64, 62, // 471
|
||||
63, 65, 66, // 474
|
||||
65, 67, 68, // 477
|
||||
45, 54, 69, // 480
|
||||
76, 77, 78, // 483
|
||||
15, 12, 6, // 486
|
||||
78, 84, 85, // 489
|
||||
10, 87, 77, // 492
|
||||
0, 8, 10, // 495
|
||||
84, 88, 83, // 498
|
||||
38, 91, 77, // 501
|
||||
84, 92, 93, // 504
|
||||
78, 94, 92, // 507
|
||||
91, 94, 78, // 510
|
||||
11, 31, 35, // 513
|
||||
33, 36, 37, // 516
|
||||
69, 96, 97, // 519
|
||||
89, 82, 54, // 522
|
||||
99, 100, 97, // 525
|
||||
98, 49, 75, // 528
|
||||
101, 102, 71, // 531
|
||||
100, 99, 81, // 534
|
||||
15, 80, 86, // 537
|
||||
73, 46, 75, // 540
|
||||
98, 104, 105, // 543
|
||||
100, 103, 106, // 546
|
||||
100, 107, 108, // 549
|
||||
97, 108, 104, // 552
|
||||
103, 88, 93, // 555
|
||||
81, 83, 88, // 558
|
||||
109, 105, 55, // 561
|
||||
102, 109, 74, // 564
|
||||
48, 101, 70, // 567
|
||||
69, 75, 46, // 570
|
||||
86, 6, 0, // 573
|
||||
30, 29, 68, // 576
|
||||
27, 66, 68, // 579
|
||||
27, 26, 64, // 582
|
||||
62, 64, 26, // 585
|
||||
24, 13, 52, // 588
|
||||
90, 111, 112, // 591
|
||||
112, 113, 114, // 594
|
||||
114, 113, 111 // 597
|
||||
}; // houseUVIndices
|
||||
|
||||
S3L_Model3D house =
|
||||
{.vertices=houseVertices,.vertexCount=127,.triangles=houseTriangleIndices,
|
||||
.triangleCount=200};
|
||||
{
|
||||
.vertices = houseVertices,
|
||||
.vertexCount = 127,
|
||||
.triangles = houseTriangleIndices,
|
||||
.triangleCount = 200
|
||||
};
|
||||
|
||||
#endif // guard
|
||||
|
|
127
small3dlib.h
127
small3dlib.h
|
@ -127,13 +127,6 @@
|
|||
on. */
|
||||
#endif
|
||||
|
||||
#ifndef S3L_MAX_TRIANGES_DRAWN
|
||||
#define S3L_MAX_TRIANGES_DRAWN 128 /**< Maximum number of triangles that can
|
||||
be drawn in sorted modes. This
|
||||
affects the size of a cache used for
|
||||
triangle sorting. */
|
||||
#endif
|
||||
|
||||
#ifndef S3L_PERSPECTIVE_CORRECTION
|
||||
#define S3L_PERSPECTIVE_CORRECTION 0 /**< Specifies what type of perspective
|
||||
correction (PC) to use. Remember
|
||||
|
@ -190,12 +183,7 @@ typedef uint16_t S3L_Index;
|
|||
can in most cases solve visibility
|
||||
without requiring almost any extra
|
||||
memory compared to z-buffer. */
|
||||
#define S3L_SORT_FRONT_TO_BACK 2 /**< Sort triangles front to back AND use
|
||||
a 1bit stencil buffer to not draw over
|
||||
already drawn triangles. This prevents
|
||||
overwriting already computed pixels, but
|
||||
requires a little but extra memory (the
|
||||
stencil buffer). */
|
||||
#define S3L_SORT_FRONT_TO_BACK 2 /**< TODO */
|
||||
#ifndef S3L_SORT
|
||||
#define S3L_SORT S3L_SORT_NONE /**< Defines how to sort triangles before
|
||||
drawing a frame. This can be used to solve
|
||||
|
@ -210,6 +198,13 @@ typedef uint16_t S3L_Index;
|
|||
triangles). */
|
||||
#endif
|
||||
|
||||
#ifndef S3L_MAX_TRIANGES_DRAWN
|
||||
#define S3L_MAX_TRIANGES_DRAWN 128 /**< Maximum number of triangles that can
|
||||
be drawn in sorted modes. This
|
||||
affects the size of a cache used for
|
||||
triangle sorting. */
|
||||
#endif
|
||||
|
||||
#ifndef S3L_NEAR
|
||||
#define S3L_NEAR (S3L_FRACTIONS_PER_UNIT / 4) /**< Distance of the near
|
||||
clipping plane. */
|
||||
|
@ -1202,8 +1197,9 @@ static inline int8_t S3L_zTest(
|
|||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S3L_zBufferClear()
|
||||
|
@ -1794,64 +1790,69 @@ static inline int8_t S3L_triangleIsVisible(
|
|||
return 1;
|
||||
}
|
||||
|
||||
static inline void _S3L_drawModelTriangle(
|
||||
S3L_Scene scene,
|
||||
S3L_Index modelIndex,
|
||||
S3L_Index triangleIndex,
|
||||
S3L_Mat4 *transformMatrix,
|
||||
S3L_Camera *camera)
|
||||
{
|
||||
S3L_Vec4 modelVertex, transformed0, transformed1, transformed2;
|
||||
S3L_Index vertexIndex;
|
||||
S3L_Model3D model;
|
||||
|
||||
model = scene.models[modelIndex];
|
||||
|
||||
modelVertex.w = S3L_FRACTIONS_PER_UNIT; // has to be "1.0" for translation
|
||||
|
||||
#define project(n)\
|
||||
vertexIndex = model.triangles[triangleIndex * 3 + n] * 3;\
|
||||
modelVertex.x = model.vertices[vertexIndex];\
|
||||
modelVertex.y = model.vertices[vertexIndex + 1];\
|
||||
modelVertex.z = model.vertices[vertexIndex + 2];\
|
||||
S3L_vec3Xmat4(&modelVertex,transformMatrix);\
|
||||
transformed##n.x = modelVertex.x;\
|
||||
transformed##n.y = modelVertex.y;\
|
||||
transformed##n.z = modelVertex.z;\
|
||||
transformed##n.w = S3L_FRACTIONS_PER_UNIT;\
|
||||
S3L_perspectiveDivide(&transformed##n,camera->focalLength);
|
||||
|
||||
/* TODO: maybe create an option that would use a cache here to not
|
||||
transform the same point twice? */
|
||||
|
||||
project(0)
|
||||
project(1)
|
||||
project(2)
|
||||
|
||||
#undef project
|
||||
|
||||
if (S3L_triangleIsVisible(transformed0,transformed1,transformed2,
|
||||
model.config.backfaceCulling))
|
||||
{
|
||||
S3L_drawTriangle(transformed0,transformed1,transformed2,&(model.config),
|
||||
camera,modelIndex,triangleIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void S3L_drawScene(S3L_Scene scene)
|
||||
{
|
||||
S3L_Mat4 matFinal, matCamera;
|
||||
|
||||
S3L_makeCameraMatrix(scene.camera.transform,&matCamera);
|
||||
|
||||
for (S3L_Index modelIndex; modelIndex < scene.modelCount; ++modelIndex)
|
||||
{
|
||||
const S3L_Unit *vertices = scene.models[modelIndex].vertices;
|
||||
const S3L_Index *triangles = scene.models[modelIndex].triangles;
|
||||
|
||||
S3L_Index triangleIndex = 0;
|
||||
S3L_Index coordIndex = 0;
|
||||
|
||||
S3L_Vec4 pointModel, transformed0, transformed1, transformed2;
|
||||
S3L_Unit indexIndex = 0;
|
||||
|
||||
pointModel.w = S3L_FRACTIONS_PER_UNIT; // has to be "1.0" for translation
|
||||
|
||||
S3L_Mat4 mat1, mat2;
|
||||
|
||||
S3L_makeWorldMatrix(scene.models[modelIndex].transform,&mat1);
|
||||
S3L_makeCameraMatrix(scene.camera.transform,&mat2);
|
||||
|
||||
S3L_mat4Xmat4(&mat1,&mat2);
|
||||
S3L_makeWorldMatrix(scene.models[modelIndex].transform,&matFinal);
|
||||
S3L_mat4Xmat4(&matFinal,&matCamera);
|
||||
|
||||
S3L_Index triangleCount = scene.models[modelIndex].triangleCount;
|
||||
|
||||
S3L_Index triangleIndex = 0;
|
||||
|
||||
while (triangleIndex < triangleCount)
|
||||
{
|
||||
#define project(n)\
|
||||
indexIndex = triangles[coordIndex] * 3;\
|
||||
pointModel.x = vertices[indexIndex];\
|
||||
++indexIndex; /* TODO: put into square brackets? */\
|
||||
pointModel.y = vertices[indexIndex];\
|
||||
++indexIndex;\
|
||||
pointModel.z = vertices[indexIndex];\
|
||||
++coordIndex;\
|
||||
S3L_vec3Xmat4(&pointModel,&mat1);\
|
||||
transformed##n.x = pointModel.x;\
|
||||
transformed##n.y = pointModel.y;\
|
||||
transformed##n.z = pointModel.z;\
|
||||
transformed##n.w = S3L_FRACTIONS_PER_UNIT;\
|
||||
S3L_perspectiveDivide(&transformed##n,scene.camera.focalLength);
|
||||
|
||||
/* TODO: maybe create an option that would use a cache here to not
|
||||
transform the same point twice? */
|
||||
|
||||
project(0)
|
||||
project(1)
|
||||
project(2)
|
||||
|
||||
#undef project
|
||||
|
||||
S3L_DrawConfig *config = &(scene.models[modelIndex].config);
|
||||
|
||||
if (S3L_triangleIsVisible(transformed0,transformed1,transformed2,
|
||||
config->backfaceCulling))
|
||||
{
|
||||
S3L_drawTriangle(transformed0,transformed1,transformed2,config,
|
||||
&(scene.camera),modelIndex,triangleIndex);
|
||||
}
|
||||
_S3L_drawModelTriangle(
|
||||
scene,modelIndex,triangleIndex,&matFinal,&(scene.camera));
|
||||
|
||||
++triangleIndex;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define S3L_Z_BUFFER 0
|
||||
#define S3L_Z_BUFFER 1
|
||||
|
||||
#define S3L_PIXEL_FUNCTION drawPixel
|
||||
|
||||
|
|
Loading…
Reference in a new issue