Compare commits

8 Commits
old ... master

28 changed files with 2369 additions and 1061 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
build build
.cache

12
3dModels/fairyDust.mtl Normal file
View File

@@ -0,0 +1,12 @@
# Blender 5.1.0 MTL File: 'test.blend'
# www.blender.org
newmtl Material.001
Ns 885.309875
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2

727
3dModels/fairyDust.obj Normal file
View File

@@ -0,0 +1,727 @@
# Blender 5.1.0
# www.blender.org
mtllib fairyDust.mtl
o Cylinder.002
v 0.698513 -0.242437 0.000000 0.0000 0.4470 0.0334
v 0.044645 1.825787 0.000000 0.0000 0.4470 0.0334
v 0.656388 -0.242437 0.238906 0.0000 0.4470 0.0334
v 0.041953 1.825787 0.015270 0.0000 0.4470 0.0334
v 0.535092 -0.242437 0.448996 0.0000 0.4470 0.0334
v 0.034200 1.825787 0.028697 0.0000 0.4470 0.0334
v 0.349257 -0.242437 0.604930 0.0000 0.4470 0.0334
v 0.022323 1.825787 0.038664 0.0000 0.4470 0.0334
v 0.121296 -0.242437 0.687901 0.0000 0.4470 0.0334
v 0.007753 1.825787 0.043967 0.0000 0.4470 0.0334
v -0.121296 -0.242437 0.687901 0.0000 0.4470 0.0334
v -0.007753 1.825787 0.043967 0.0000 0.4470 0.0334
v -0.349257 -0.242437 0.604930 0.0000 0.4470 0.0334
v -0.022323 1.825787 0.038664 0.0000 0.4470 0.0334
v -0.535092 -0.242437 0.448996 0.0000 0.4470 0.0334
v -0.034200 1.825787 0.028697 0.0000 0.4470 0.0334
v -0.656388 -0.242437 0.238906 0.0000 0.4470 0.0334
v -0.041953 1.825787 0.015270 0.0000 0.4470 0.0334
v -0.698513 -0.242437 -0.000000 0.0000 0.4470 0.0334
v -0.044645 1.825787 0.000000 0.0000 0.4470 0.0334
v -0.656388 -0.242437 -0.238906 0.0000 0.4470 0.0334
v -0.041953 1.825787 -0.015270 0.0000 0.4470 0.0334
v -0.535092 -0.242437 -0.448996 0.0000 0.4470 0.0334
v -0.034200 1.825787 -0.028697 0.0000 0.4470 0.0334
v -0.349257 -0.242437 -0.604930 0.0000 0.4470 0.0334
v -0.022323 1.825787 -0.038664 0.0000 0.4470 0.0334
v -0.121296 -0.242437 -0.687901 0.0000 0.4470 0.0334
v -0.007753 1.825787 -0.043967 0.0000 0.4470 0.0334
v 0.121296 -0.242437 -0.687901 0.0000 0.4470 0.0334
v 0.007753 1.825787 -0.043967 0.0000 0.4470 0.0334
v 0.349257 -0.242437 -0.604930 0.0000 0.4470 0.0334
v 0.022323 1.825787 -0.038664 0.0000 0.4470 0.0334
v 0.535092 -0.242437 -0.448996 0.0000 0.4470 0.0334
v 0.034200 1.825787 -0.028697 0.0000 0.4470 0.0334
v 0.656388 -0.242437 -0.238906 0.0000 0.4470 0.0334
v 0.041953 1.825787 -0.015269 0.0000 0.4470 0.0334
v 0.544639 1.240545 0.000000 0.0000 0.4470 0.0334
v 0.511793 1.240545 0.186277 0.0000 0.4470 0.0334
v 0.409479 1.128906 0.371044 0.8556 0.8746 1.0000
v 0.290178 1.227410 0.470774 0.8556 0.8746 1.0000
v 0.100778 1.227410 0.539710 0.8556 0.8746 1.0000
v -0.100778 1.227410 0.539710 0.8556 0.8746 1.0000
v -0.290178 1.227410 0.470774 0.8556 0.8746 1.0000
v -0.409479 1.128906 0.371044 0.8556 0.8746 1.0000
v -0.511793 1.240545 0.186277 0.0000 0.4470 0.0334
v -0.544639 1.240545 -0.000000 0.0000 0.4470 0.0334
v -0.511793 1.240545 -0.186277 0.0000 0.4470 0.0334
v -0.417217 1.240545 -0.350087 0.0000 0.4470 0.0334
v -0.272319 1.240545 -0.471671 0.0000 0.4470 0.0334
v -0.094576 1.240545 -0.536364 0.0000 0.4470 0.0334
v 0.094576 1.240545 -0.536364 0.0000 0.4470 0.0334
v 0.272319 1.240545 -0.471671 0.0000 0.4470 0.0334
v 0.417218 1.240545 -0.350087 0.0000 0.4470 0.0334
v 0.511793 1.240545 -0.186277 0.0000 0.4470 0.0334
v 0.694426 0.474881 0.252751 0.0000 0.4470 0.0334
v 0.527394 0.631239 0.497527 0.8556 0.8746 1.0000
v 0.367433 0.488016 0.632126 0.8556 0.8746 1.0000
v 0.127608 0.488016 0.719415 0.8556 0.8746 1.0000
v -0.127608 0.488016 0.719415 0.8556 0.8746 1.0000
v -0.367433 0.488016 0.632126 0.8556 0.8746 1.0000
v -0.527394 0.631239 0.497527 0.8556 0.8746 1.0000
v -0.694426 0.474881 0.252751 0.0000 0.4470 0.0334
v -0.738993 0.474881 -0.000000 0.0000 0.4470 0.0334
v -0.694426 0.474881 -0.252751 0.0000 0.4470 0.0334
v -0.566102 0.474881 -0.475016 0.0000 0.4470 0.0334
v -0.369497 0.474881 -0.639987 0.0000 0.4470 0.0334
v -0.128325 0.474881 -0.727766 0.0000 0.4470 0.0334
v 0.128325 0.474881 -0.727766 0.0000 0.4470 0.0334
v 0.369497 0.474881 -0.639987 0.0000 0.4470 0.0334
v 0.566102 0.474881 -0.475016 0.0000 0.4470 0.0334
v 0.694426 0.474881 -0.252751 0.0000 0.4470 0.0334
v 0.738993 0.474881 0.000000 0.0000 0.4470 0.0334
v 0.410385 -1.154204 0.000000 0.0000 0.4470 0.0334
v 0.385635 -1.154204 0.140360 0.0000 0.4470 0.0334
v 0.314373 -1.154204 0.263790 0.0000 0.4470 0.0334
v 0.205192 -1.154204 0.355403 0.0000 0.4470 0.0334
v 0.071263 -1.154204 0.404150 0.0000 0.4470 0.0334
v -0.071263 -1.154204 0.404150 0.0000 0.4470 0.0334
v -0.205192 -1.154204 0.355403 0.0000 0.4470 0.0334
v -0.314373 -1.154204 0.263790 0.0000 0.4470 0.0334
v -0.385635 -1.154204 0.140360 0.0000 0.4470 0.0334
v -0.410385 -1.154204 -0.000000 0.0000 0.4470 0.0334
v -0.385635 -1.154204 -0.140360 0.0000 0.4470 0.0334
v -0.314373 -1.154204 -0.263790 0.0000 0.4470 0.0334
v -0.205192 -1.154204 -0.355403 0.0000 0.4470 0.0334
v -0.071263 -1.154204 -0.404150 0.0000 0.4470 0.0334
v 0.071263 -1.154204 -0.404150 0.0000 0.4470 0.0334
v 0.205192 -1.154204 -0.355403 0.0000 0.4470 0.0334
v 0.314373 -1.154204 -0.263790 0.0000 0.4470 0.0334
v 0.385635 -1.154204 -0.140360 0.0000 0.4470 0.0334
v 0.237705 1.675272 0.000000 0.0000 0.4470 0.0334
v 0.223370 1.675272 0.081300 0.0000 0.4470 0.0334
v 0.182093 1.675272 0.152794 0.0000 0.4470 0.0334
v 0.118853 1.675272 0.205859 0.0000 0.4470 0.0334
v 0.041277 1.675272 0.234094 0.0000 0.4470 0.0334
v -0.041277 1.675272 0.234094 0.0000 0.4470 0.0334
v -0.118853 1.675272 0.205859 0.0000 0.4470 0.0334
v -0.182093 1.675272 0.152794 0.0000 0.4470 0.0334
v -0.223370 1.675272 0.081300 0.0000 0.4470 0.0334
v -0.237705 1.675272 -0.000000 0.0000 0.4470 0.0334
v -0.223370 1.675272 -0.081300 0.0000 0.4470 0.0334
v -0.182093 1.675272 -0.152794 0.0000 0.4470 0.0334
v -0.118853 1.675272 -0.205859 0.0000 0.4470 0.0334
v -0.041277 1.675272 -0.234094 0.0000 0.4470 0.0334
v 0.041277 1.675272 -0.234094 0.0000 0.4470 0.0334
v 0.118853 1.675272 -0.205859 0.0000 0.4470 0.0334
v 0.182093 1.675272 -0.152794 0.0000 0.4470 0.0334
v 0.223370 1.675272 -0.081300 0.0000 0.4470 0.0334
v 0.046326 1.839588 0.000000 0.9696 1.0000 0.0000
v -0.023163 1.839588 -0.040120 0.9695 0.9999 0.0005
v -0.023163 1.839588 0.040120 0.9696 1.0000 0.0000
v 0.000000 2.137896 0.000000 0.9696 1.0000 0.0000
v -0.272319 1.240545 0.471671 0.0000 0.4470 0.0334
v -0.417218 1.141971 0.350087 0.0000 0.4470 0.0334
v -0.094576 1.240545 0.536364 0.0000 0.4470 0.0334
v 0.094576 1.240545 0.536364 0.0000 0.4470 0.0334
v 0.272319 1.240545 0.471671 0.0000 0.4470 0.0334
v 0.417217 1.141971 0.350087 0.0000 0.4470 0.0334
v 0.566102 0.618174 0.475016 0.0000 0.4470 0.0334
v -0.566102 0.618174 0.475016 0.0000 0.4470 0.0334
v 0.369497 0.474881 0.639987 0.0000 0.4470 0.0334
v 0.128325 0.474881 0.727766 0.0000 0.4470 0.0334
v -0.128325 0.474881 0.727766 0.0000 0.4470 0.0334
v -0.369497 0.474881 0.639987 0.0000 0.4470 0.0334
v 0.237002 1.117707 0.625731 0.1450 0.1371 0.1900
v 0.257333 0.652925 0.728921 0.1450 0.1371 0.1900
v 0.082310 1.117707 0.682034 0.1450 0.1371 0.1900
v 0.089371 0.652925 0.766453 0.1450 0.1371 0.1900
v -0.082310 1.117707 0.682034 0.1450 0.1371 0.1900
v -0.089371 0.652925 0.766453 0.1450 0.1371 0.1900
v -0.237002 1.117707 0.625731 0.1450 0.1371 0.1900
v -0.257333 0.652925 0.728921 0.1450 0.1371 0.1900
v -0.334441 1.019176 0.544276 0.1450 0.1371 0.1900
v 0.334441 1.019176 0.544276 0.1450 0.1371 0.1900
v 0.369362 0.735177 0.671046 0.1450 0.1371 0.1900
v -0.369362 0.735177 0.671046 0.1450 0.1371 0.1900
v 0.096339 1.201041 0.616476 0.1450 0.1371 0.1900
v -0.096339 1.201041 0.616476 0.1450 0.1371 0.1900
v 0.489408 0.656222 0.539235 0.1450 0.1371 0.1900
v 0.391442 1.102530 0.455240 0.1450 0.1371 0.1900
v 0.118417 0.527654 0.730721 0.1450 0.1371 0.1900
v -0.118417 0.527654 0.730721 0.1450 0.1371 0.1900
v -0.489408 0.656222 0.539235 0.1450 0.1371 0.1900
v -0.391442 1.102530 0.455240 0.1450 0.1371 0.1900
v 0.277396 1.201041 0.550577 0.1450 0.1371 0.1900
v -0.340969 0.527654 0.655392 0.1450 0.1371 0.1900
v -0.277396 1.201041 0.550577 0.1450 0.1371 0.1900
v 0.340969 0.527654 0.655392 0.1450 0.1371 0.1900
vn 0.9841 -0.1778 -0.0000
vn 0.9146 0.4043 -0.0000
vn 0.9247 -0.1778 0.3366
vn 0.7754 0.5378 0.3310
vn 0.7540 -0.1768 0.6327
vn 0.4942 0.7357 0.4632
vn 0.4920 -0.1778 0.8522
vn 0.3013 0.7980 0.5219
vn 0.1709 -0.1778 0.9691
vn 0.1541 0.7357 0.6596
vn -0.1709 -0.1778 0.9691
vn -0.1010 0.5378 0.8370
vn -0.4920 -0.1778 0.8522
vn -0.4573 0.4043 0.7921
vn -0.7540 -0.1768 0.6327
vn -0.6743 0.5378 0.5060
vn -0.9247 -0.1778 0.3366
vn -0.6483 0.7357 0.1964
vn -0.9841 -0.1778 -0.0000
vn -0.6026 0.7980 -0.0000
vn -0.9247 -0.1778 -0.3366
vn -0.6483 0.7357 -0.1964
vn -0.7538 -0.1778 -0.6325
vn -0.6743 0.5378 -0.5060
vn -0.4920 -0.1778 -0.8522
vn -0.4573 0.4043 -0.7921
vn -0.1709 -0.1778 -0.9691
vn -0.1010 0.5378 -0.8370
vn 0.1709 -0.1778 -0.9691
vn 0.1541 0.7357 -0.6596
vn 0.4920 -0.1778 -0.8522
vn 0.3013 0.7980 -0.5219
vn 0.7538 -0.1778 -0.6325
vn 0.4942 0.7357 -0.4632
vn 0.9247 -0.1778 -0.3366
vn 0.7754 0.5378 -0.3310
vn 0.9117 0.4109 -0.0000
vn 0.8130 0.4345 0.3877
vn 0.8011 0.3907 0.4535
vn 0.5809 0.7552 0.3037
vn 0.1433 0.7300 0.6682
vn -0.1433 0.7300 0.6682
vn -0.5809 0.7552 0.3037
vn -0.8011 0.3907 0.4535
vn -0.8130 0.4345 0.3877
vn -0.9117 0.4109 -0.0000
vn -0.8567 0.4109 -0.3118
vn -0.6984 0.4109 -0.5860
vn -0.4558 0.4109 -0.7895
vn -0.1583 0.4109 -0.8978
vn 0.1583 0.4109 -0.8978
vn 0.4558 0.4109 -0.7895
vn 0.6984 0.4109 -0.5860
vn 0.8567 0.4109 -0.3118
vn 0.9423 0.0728 0.3267
vn 0.6347 0.1973 0.7472
vn 0.4225 0.2699 0.8652
vn 0.1829 0.1701 0.9683
vn -0.1829 0.1701 0.9683
vn -0.4225 0.2699 0.8652
vn -0.6347 0.1973 0.7472
vn -0.9423 0.0728 0.3267
vn -0.9955 0.0944 -0.0000
vn -0.9355 0.0944 -0.3405
vn -0.7626 0.0944 -0.6399
vn -0.4978 0.0944 -0.8622
vn -0.1729 0.0944 -0.9804
vn 0.1729 0.0944 -0.9804
vn 0.4978 0.0944 -0.8622
vn 0.7626 0.0944 -0.6399
vn 0.9355 0.0944 -0.3405
vn 0.9955 0.0944 -0.0000
vn 0.6306 -0.7761 -0.0000
vn 0.5926 -0.7761 0.2157
vn 0.4830 -0.7761 0.4053
vn 0.3153 -0.7761 0.5461
vn 0.1095 -0.7761 0.6210
vn -0.1095 -0.7761 0.6210
vn -0.3153 -0.7761 0.5461
vn -0.4831 -0.7761 0.4053
vn -0.5925 -0.7761 0.2157
vn -0.6306 -0.7761 -0.0000
vn -0.5925 -0.7761 -0.2157
vn -0.4831 -0.7761 -0.4053
vn -0.3153 -0.7761 -0.5461
vn -0.1095 -0.7761 -0.6210
vn 0.1095 -0.7761 -0.6210
vn 0.3153 -0.7761 -0.5461
vn 0.4830 -0.7761 -0.4053
vn 0.5925 -0.7761 -0.2157
vn 0.7312 0.6821 -0.0000
vn 0.6871 0.6821 0.2501
vn 0.5656 0.6745 0.4746
vn 0.3656 0.6821 0.6333
vn 0.1270 0.6821 0.7201
vn -0.1270 0.6821 0.7201
vn -0.3656 0.6821 0.6333
vn -0.5656 0.6745 0.4746
vn -0.6871 0.6821 0.2501
vn -0.7312 0.6821 -0.0000
vn -0.6871 0.6821 -0.2501
vn -0.5601 0.6821 -0.4700
vn -0.3656 0.6821 -0.6333
vn -0.1270 0.6821 -0.7201
vn 0.1270 0.6821 -0.7201
vn 0.3656 0.6821 -0.6333
vn 0.5601 0.6821 -0.4700
vn 0.6871 0.6821 -0.2501
vn 0.9437 0.3307 -0.0000
vn -0.4719 0.3307 -0.8173
vn -0.4719 0.3307 0.8173
vn -0.0000 1.0000 -0.0000
vn -0.4787 0.5258 0.7031
vn -0.7169 0.4126 0.5620
vn -0.1342 0.4369 0.8895
vn 0.1342 0.4369 0.8895
vn 0.4787 0.5258 0.7031
vn 0.7169 0.4126 0.5620
vn 0.7577 0.1650 0.6315
vn -0.7577 0.1650 0.6315
vn 0.4534 0.1969 0.8693
vn 0.1663 0.2444 0.9553
vn -0.1663 0.2444 0.9553
vn -0.4534 0.1969 0.8693
vn 0.4906 0.3661 0.7907
vn 0.3424 -0.0553 0.9379
vn 0.1431 0.4003 0.9051
vn 0.1012 -0.0377 0.9942
vn -0.1431 0.4003 0.9051
vn -0.1012 -0.0377 0.9942
vn -0.4906 0.3661 0.7907
vn -0.3424 -0.0553 0.9379
vn -0.7362 0.2805 0.6159
vn 0.7362 0.2805 0.6159
vn 0.6174 0.1400 0.7741
vn -0.6174 0.1400 0.7741
vn 0.1165 0.7887 0.6037
vn -0.1165 0.7887 0.6037
vn 0.7537 0.0880 0.6512
vn 0.8090 0.3734 0.4541
vn 0.1400 -0.2577 0.9560
vn -0.1400 -0.2577 0.9560
vn -0.7537 0.0880 0.6512
vn -0.8090 0.3734 0.4541
vn 0.5043 0.6625 0.5539
vn -0.4814 -0.2028 0.8527
vn -0.5043 0.6625 0.5539
vn 0.4814 -0.2028 0.8527
vt 1.000000 1.000000
vt 0.944444 0.875000
vt 1.000000 0.875000
vt 0.888889 1.000000
vt 0.888889 0.875000
vt 0.833333 0.875000
vt 0.833333 1.000000
vt 0.777778 0.875000
vt 0.777778 1.000000
vt 0.722222 0.875000
vt 0.722222 1.000000
vt 0.666667 0.875000
vt 0.611111 1.000000
vt 0.611111 0.875000
vt 0.555555 0.875000
vt 0.500000 1.000000
vt 0.500000 0.875000
vt 0.444444 0.875000
vt 0.388889 1.000000
vt 0.388889 0.875000
vt 0.333333 0.875000
vt 0.333333 1.000000
vt 0.277778 0.875000
vt 0.277778 1.000000
vt 0.222222 0.875000
vt 0.166666 1.000000
vt 0.166666 0.875000
vt 0.111111 0.875000
vt 0.111111 1.000000
vt 0.055555 0.875000
vt 0.055555 1.000000
vt -0.000000 0.875000
vt 0.888889 0.500000
vt 0.944444 0.500000
vt 0.055555 0.750000
vt -0.000000 0.620925
vt 0.055555 0.620925
vt 0.111111 0.750000
vt 0.111111 0.620925
vt 0.166666 0.750000
vt 0.166666 0.620925
vt 0.222222 0.750000
vt 0.222222 0.620925
vt 0.277778 0.750000
vt 0.277778 0.620925
vt 0.333333 0.620925
vt 0.388889 0.620925
vt 0.333333 0.750000
vt 0.444444 0.750000
vt 0.444444 0.620925
vt 0.500000 0.620925
vt 0.555555 0.750000
vt 0.555555 0.620925
vt 0.611111 0.620925
vt 0.777791 0.742476
vt 0.833347 0.742476
vt 0.833347 0.742476
vt 0.621250 0.628449
vt 0.623706 0.742476
vt 0.722233 0.628449
vt 0.777789 0.628449
vt 0.722236 0.742476
vt 0.878750 0.628449
vt 0.876294 0.742476
vt 0.878750 0.628449
vt 0.944444 0.750000
vt 0.888889 0.620925
vt 0.944444 0.620925
vt 1.000000 0.620925
vt 1.000000 0.500000
vt 0.833333 0.620925
vt 0.833333 0.500000
vt 0.777778 0.500000
vt 0.777778 0.620925
vt 0.722222 0.500000
vt 0.722222 0.620925
vt 0.666667 0.500000
vt 0.666666 0.620925
vt 0.611111 0.500000
vt 0.555555 0.500000
vt 0.500000 0.500000
vt 0.444444 0.500000
vt 0.388889 0.500000
vt 0.333333 0.500000
vt 0.277778 0.500000
vt 0.222222 0.500000
vt 0.166666 0.500000
vt 0.111111 0.500000
vt 0.055555 0.500000
vt -0.000000 0.500000
vt 0.957846 0.370000
vt 0.595731 0.066149
vt 0.542154 0.370000
vt -0.000000 0.750000
vt 0.388889 0.750000
vt 0.500000 0.750000
vt 0.611111 0.750000
vt 0.666667 0.750000
vt 0.722222 0.750000
vt 0.777778 0.750000
vt 0.833333 0.750000
vt 0.888889 0.750000
vt 1.000000 0.750000
vt 0.000000 0.000000
vt 0.944444 1.000000
vt 0.666667 1.000000
vt 0.555555 1.000000
vt 0.444444 1.000000
vt 0.222222 1.000000
vt -0.000000 1.000000
vt 0.666680 0.742476
vt 0.722236 0.742476
vt 0.833345 0.628449
vt 0.666678 0.628449
vt 0.666680 0.742476
vt 0.833345 0.628449
vt 0.876294 0.742476
vt 0.777789 0.628449
vt 0.667915 0.475526
vt 0.750000 0.490000
vt 0.832085 0.475526
vt 0.904269 0.433851
vt 0.986354 0.291676
vt 0.986354 0.208324
vt 0.957846 0.130000
vt 0.904269 0.066149
vt 0.832085 0.024474
vt 0.750000 0.010000
vt 0.667915 0.024474
vt 0.542154 0.130000
vt 0.513646 0.208324
vt 0.513646 0.291676
vt 0.595731 0.433851
s 1
usemtl Material.001
f 2/1/2 92/2/92 91/3/91
f 92/2/92 6/4/6 93/5/93
f 6/4/6 94/6/94 93/5/93
f 8/7/8 95/8/95 94/6/94
f 10/9/10 96/10/96 95/8/95
f 12/11/12 97/12/97 96/10/96
f 97/12/97 16/13/16 98/14/98
f 16/13/16 99/15/99 98/14/98
f 99/15/99 20/16/20 100/17/100
f 20/16/20 101/18/101 100/17/100
f 101/18/101 24/19/24 102/20/102
f 24/19/24 103/21/103 102/20/102
f 26/22/26 104/23/104 103/21/103
f 28/24/28 105/25/105 104/23/104
f 105/25/105 32/26/32 106/27/106
f 32/26/32 107/28/107 106/27/106
f 34/29/34 108/30/108 107/28/107
f 36/31/36 91/32/91 108/30/108
f 5/33/5 74/34/74 3/34/3
f 54/35/54 72/36/72 71/37/71
f 53/38/53 71/37/71 70/39/70
f 52/40/52 70/39/70 69/41/69
f 51/42/51 69/41/69 68/43/68
f 50/44/50 68/43/68 67/45/67
f 66/46/66 50/44/50 67/45/67
f 65/47/65 49/48/49 66/46/66
f 47/49/47 65/47/65 64/50/64
f 63/51/63 47/49/47 64/50/64
f 45/52/45 63/51/63 62/53/62
f 120/54/120 45/52/45 62/53/62
f 137/55/137 125/56/125 145/57/145
f 143/58/143 133/59/133 144/59/144
f 142/60/142 128/61/128 130/60/130
f 138/62/138 127/55/127 137/55/137
f 139/63/139 134/64/134 135/65/135
f 38/66/38 119/67/119 55/68/55
f 72/69/72 38/66/38 55/68/55
f 1/70/1 55/68/55 3/34/3
f 55/68/55 5/33/5 3/34/3
f 5/33/5 121/71/121 7/72/7
f 121/71/121 9/73/9 7/72/7
f 122/74/122 11/75/11 9/73/9
f 123/76/123 13/77/13 11/75/11
f 124/78/124 15/79/15 13/77/13
f 15/79/15 62/53/62 17/80/17
f 17/80/17 63/51/63 19/81/19
f 19/81/19 64/50/64 21/82/21
f 64/50/64 23/83/23 21/82/21
f 65/47/65 25/84/25 23/83/23
f 66/46/66 27/85/27 25/84/25
f 67/45/67 29/86/29 27/85/27
f 68/43/68 31/87/31 29/86/29
f 69/41/69 33/88/33 31/87/31
f 70/39/70 35/89/35 33/88/33
f 35/89/35 72/36/72 1/90/1
f 76/91/76 84/92/84 88/93/88
f 15/79/15 79/77/79 13/77/13
f 25/84/25 84/83/84 23/83/23
f 35/89/35 89/88/89 33/88/33
f 11/75/11 77/73/77 9/73/9
f 21/82/21 82/81/82 19/81/19
f 31/87/31 87/86/87 29/86/29
f 7/72/7 75/33/75 5/33/5
f 17/80/17 80/79/80 15/79/15
f 3/34/3 73/70/73 1/70/1
f 27/85/27 85/84/85 25/84/25
f 1/90/1 90/89/90 35/89/35
f 13/77/13 78/75/78 11/75/11
f 23/83/23 83/82/83 21/82/21
f 33/88/33 88/87/88 31/87/31
f 9/73/9 76/72/76 7/72/7
f 19/81/19 81/80/81 17/80/17
f 29/86/29 86/85/86 27/85/27
f 108/30/108 37/94/37 54/35/54
f 107/28/107 54/35/54 53/38/53
f 106/27/106 53/38/53 52/40/52
f 105/25/105 52/40/52 51/42/51
f 104/23/104 51/42/51 50/44/50
f 103/21/103 50/44/50 49/48/49
f 102/20/102 49/48/49 48/95/48
f 101/18/101 48/95/48 47/49/47
f 100/17/100 47/49/47 46/96/46
f 99/15/99 46/96/46 45/52/45
f 98/14/98 45/52/45 114/97/114
f 113/98/113 98/14/98 114/97/114
f 96/10/96 113/98/113 115/99/115
f 95/8/95 115/99/115 116/100/116
f 117/101/117 95/8/95 116/100/116
f 93/5/93 117/101/117 118/102/118
f 38/66/38 93/5/93 118/102/118
f 91/3/91 38/66/38 37/103/37
f 109/104/109 6/4/6 4/105/4
f 109/104/109 8/7/8 6/4/6
f 111/104/111 8/7/8 109/104/109
f 111/104/111 12/11/12 10/9/10
f 111/104/111 14/106/14 12/11/12
f 111/104/111 16/13/16 14/106/14
f 111/104/111 18/107/18 16/13/16
f 111/104/111 20/16/20 18/107/18
f 110/104/110 20/16/20 111/104/111
f 110/104/110 24/19/24 22/108/22
f 110/104/110 26/22/26 24/19/24
f 110/104/110 28/24/28 26/22/26
f 110/104/110 30/109/30 28/24/28
f 110/104/110 32/26/32 30/109/30
f 109/104/109 32/26/32 110/104/110
f 109/104/109 36/31/36 34/29/34
f 109/104/109 2/110/2 36/31/36
f 109/104/109 4/105/4 2/1/2
f 111/104/111 10/9/10 8/7/8
f 110/104/110 22/108/22 20/16/20
f 109/104/109 34/29/34 32/26/32
f 111/104/111 109/104/109 112/104/112
f 110/104/110 111/104/111 112/104/112
f 109/104/109 110/104/110 112/104/112
f 43/111/43 114/97/114 44/59/44
f 42/112/42 113/98/113 43/111/43
f 41/55/41 115/99/115 42/112/42
f 41/55/41 117/101/117 116/100/116
f 40/56/40 118/102/118 117/101/117
f 39/64/39 119/67/119 118/102/118
f 44/59/44 120/54/120 61/58/61
f 57/113/57 119/67/119 56/65/56
f 58/61/58 121/71/121 57/113/57
f 59/60/59 122/74/122 58/61/58
f 59/60/59 124/78/124 123/76/123
f 60/114/60 120/54/120 124/78/124
f 131/111/131 136/58/136 132/114/132
f 129/112/129 132/114/132 130/60/130
f 127/55/127 130/60/130 128/61/128
f 126/113/126 127/55/127 128/61/128
f 135/65/135 125/56/125 126/113/126
f 142/60/142 132/114/132 146/114/146
f 147/115/147 133/59/133 131/111/131
f 148/116/148 135/65/135 126/113/126
f 145/57/145 134/64/134 140/117/140
f 146/114/146 136/58/136 143/58/143
f 138/62/138 131/111/131 129/112/129
f 141/118/141 126/113/126 128/61/128
f 58/61/58 148/116/148 141/118/141
f 42/112/42 147/115/147 138/62/138
f 60/114/60 143/58/143 61/58/61
f 40/56/40 140/117/140 39/64/39
f 57/113/57 139/63/139 148/116/148
f 43/111/43 144/59/144 147/115/147
f 59/60/59 146/114/146 60/114/60
f 56/65/56 140/117/140 139/63/139
f 42/112/42 137/55/137 41/55/41
f 58/61/58 142/60/142 59/60/59
f 61/58/61 144/59/144 44/59/44
f 41/55/41 145/57/145 40/56/40
f 2/1/2 4/105/4 92/2/92
f 92/2/92 4/105/4 6/4/6
f 6/4/6 8/7/8 94/6/94
f 8/7/8 10/9/10 95/8/95
f 10/9/10 12/11/12 96/10/96
f 12/11/12 14/106/14 97/12/97
f 97/12/97 14/106/14 16/13/16
f 16/13/16 18/107/18 99/15/99
f 99/15/99 18/107/18 20/16/20
f 20/16/20 22/108/22 101/18/101
f 101/18/101 22/108/22 24/19/24
f 24/19/24 26/22/26 103/21/103
f 26/22/26 28/24/28 104/23/104
f 28/24/28 30/109/30 105/25/105
f 105/25/105 30/109/30 32/26/32
f 32/26/32 34/29/34 107/28/107
f 34/29/34 36/31/36 108/30/108
f 36/31/36 2/110/2 91/32/91
f 5/33/5 75/33/75 74/34/74
f 54/35/54 37/94/37 72/36/72
f 53/38/53 54/35/54 71/37/71
f 52/40/52 53/38/53 70/39/70
f 51/42/51 52/40/52 69/41/69
f 50/44/50 51/42/51 68/43/68
f 66/46/66 49/48/49 50/44/50
f 65/47/65 48/95/48 49/48/49
f 47/49/47 48/95/48 65/47/65
f 63/51/63 46/96/46 47/49/47
f 45/52/45 46/96/46 63/51/63
f 120/54/120 114/97/114 45/52/45
f 137/55/137 127/55/127 125/56/125
f 143/58/143 136/58/136 133/59/133
f 142/60/142 141/118/141 128/61/128
f 138/62/138 129/112/129 127/55/127
f 139/63/139 140/117/140 134/64/134
f 38/66/38 118/102/118 119/67/119
f 72/69/72 37/103/37 38/66/38
f 1/70/1 72/69/72 55/68/55
f 55/68/55 119/67/119 5/33/5
f 5/33/5 119/67/119 121/71/121
f 121/71/121 122/74/122 9/73/9
f 122/74/122 123/76/123 11/75/11
f 123/76/123 124/78/124 13/77/13
f 124/78/124 120/54/120 15/79/15
f 15/79/15 120/54/120 62/53/62
f 17/80/17 62/53/62 63/51/63
f 19/81/19 63/51/63 64/50/64
f 64/50/64 65/47/65 23/83/23
f 65/47/65 66/46/66 25/84/25
f 66/46/66 67/45/67 27/85/27
f 67/45/67 68/43/68 29/86/29
f 68/43/68 69/41/69 31/87/31
f 69/41/69 70/39/70 33/88/33
f 70/39/70 71/37/71 35/89/35
f 35/89/35 71/37/71 72/36/72
f 90/119/90 73/120/73 74/121/74
f 74/121/74 75/122/75 76/91/76
f 76/91/76 77/123/77 78/124/78
f 78/124/78 79/125/79 80/126/80
f 80/126/80 81/127/81 82/128/82
f 82/128/82 83/129/83 84/92/84
f 84/92/84 85/130/85 86/131/86
f 86/131/86 87/132/87 88/93/88
f 88/93/88 89/133/89 90/119/90
f 90/119/90 74/121/74 76/91/76
f 76/91/76 78/124/78 80/126/80
f 80/126/80 82/128/82 84/92/84
f 84/92/84 86/131/86 88/93/88
f 88/93/88 90/119/90 76/91/76
f 76/91/76 80/126/80 84/92/84
f 15/79/15 80/79/80 79/77/79
f 25/84/25 85/84/85 84/83/84
f 35/89/35 90/89/90 89/88/89
f 11/75/11 78/75/78 77/73/77
f 21/82/21 83/82/83 82/81/82
f 31/87/31 88/87/88 87/86/87
f 7/72/7 76/72/76 75/33/75
f 17/80/17 81/80/81 80/79/80
f 3/34/3 74/34/74 73/70/73
f 27/85/27 86/85/86 85/84/85
f 1/90/1 73/90/73 90/89/90
f 13/77/13 79/77/79 78/75/78
f 23/83/23 84/83/84 83/82/83
f 33/88/33 89/88/89 88/87/88
f 9/73/9 77/73/77 76/72/76
f 19/81/19 82/81/82 81/80/81
f 29/86/29 87/86/87 86/85/86
f 108/30/108 91/32/91 37/94/37
f 107/28/107 108/30/108 54/35/54
f 106/27/106 107/28/107 53/38/53
f 105/25/105 106/27/106 52/40/52
f 104/23/104 105/25/105 51/42/51
f 103/21/103 104/23/104 50/44/50
f 102/20/102 103/21/103 49/48/49
f 101/18/101 102/20/102 48/95/48
f 100/17/100 101/18/101 47/49/47
f 99/15/99 100/17/100 46/96/46
f 98/14/98 99/15/99 45/52/45
f 113/98/113 97/12/97 98/14/98
f 96/10/96 97/12/97 113/98/113
f 95/8/95 96/10/96 115/99/115
f 117/101/117 94/6/94 95/8/95
f 93/5/93 94/6/94 117/101/117
f 38/66/38 92/2/92 93/5/93
f 91/3/91 92/2/92 38/66/38
f 43/111/43 113/98/113 114/97/114
f 42/112/42 115/99/115 113/98/113
f 41/55/41 116/100/116 115/99/115
f 41/55/41 40/56/40 117/101/117
f 40/56/40 39/64/39 118/102/118
f 39/64/39 56/65/56 119/67/119
f 44/59/44 114/97/114 120/54/120
f 57/113/57 121/71/121 119/67/119
f 58/61/58 122/74/122 121/71/121
f 59/60/59 123/76/123 122/74/122
f 59/60/59 60/114/60 124/78/124
f 60/114/60 61/58/61 120/54/120
f 131/111/131 133/59/133 136/58/136
f 129/112/129 131/111/131 132/114/132
f 127/55/127 129/112/129 130/60/130
f 126/113/126 125/56/125 127/55/127
f 135/65/135 134/64/134 125/56/125
f 142/60/142 130/60/130 132/114/132
f 147/115/147 144/59/144 133/59/133
f 148/116/148 139/63/139 135/65/135
f 145/57/145 125/56/125 134/64/134
f 146/114/146 132/114/132 136/58/136
f 138/62/138 147/115/147 131/111/131
f 141/118/141 148/116/148 126/113/126
f 58/61/58 57/113/57 148/116/148
f 42/112/42 43/111/43 147/115/147
f 60/114/60 146/114/146 143/58/143
f 40/56/40 145/57/145 140/117/140
f 57/113/57 56/65/56 139/63/139
f 43/111/43 44/59/44 144/59/144
f 59/60/59 142/60/142 146/114/146
f 56/65/56 39/64/39 140/117/140
f 42/112/42 138/62/138 137/55/137
f 58/61/58 141/118/141 142/60/142
f 61/58/61 143/58/143 144/59/144
f 41/55/41 137/55/137 145/57/145

12
3dModels/obstical.mtl Normal file
View File

@@ -0,0 +1,12 @@
# Blender 5.1.0 MTL File: 'test.blend'
# www.blender.org
newmtl Material.005
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2

46
3dModels/obstical.obj Normal file
View File

@@ -0,0 +1,46 @@
# Blender 5.1.0
# www.blender.org
mtllib obstical.mtl
o Cube.002
v -4.000000 0.305749 0.305749 1.0000 1.0000 1.0000
v -0.000000 0.305749 0.305749 1.0000 1.0000 1.0000
v -4.000000 0.305749 -0.305749 1.0000 1.0000 1.0000
v -0.000000 0.305749 -0.305749 1.0000 1.0000 1.0000
v -4.000000 -0.305750 0.305749 1.0000 1.0000 1.0000
v 0.000000 -0.305749 0.305749 1.0000 1.0000 1.0000
v -4.000000 -0.305750 -0.305749 1.0000 1.0000 1.0000
v 0.000000 -0.305749 -0.305749 1.0000 1.0000 1.0000
vn -0.0000 1.0000 -0.0000
vn -0.0000 -0.0000 -1.0000
vn -0.0000 -1.0000 -0.0000
vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn 1.0000 -0.0000 -0.0000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.875000 0.500000
vt 0.625000 1.000000
vt 0.875000 0.750000
s 0
usemtl Material.005
f 2/1/1 3/2/1 1/3/1
f 4/4/2 7/5/2 3/2/2
f 8/6/3 5/7/3 7/5/3
f 6/8/4 1/9/4 5/7/4
f 7/5/5 1/10/5 3/11/5
f 4/12/6 6/8/6 8/6/6
f 2/1/1 4/4/1 3/2/1
f 4/4/2 8/6/2 7/5/2
f 8/6/3 6/8/3 5/7/3
f 6/8/4 2/13/4 1/9/4
f 7/5/5 5/7/5 1/10/5
f 4/12/6 2/14/6 6/8/6

12
3dModels/planet.mtl Normal file
View File

@@ -0,0 +1,12 @@
# Blender 5.1.0 MTL File: 'None'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2

233
3dModels/planet.obj Normal file
View File

@@ -0,0 +1,233 @@
# Blender 5.1.0
# www.blender.org
mtllib planet.mtl
o Icosphere
v 0.000000 -2.000000 0.000000 0.4368 0.6047 0.7887
v 1.447215 -0.894439 1.051451 0.4368 0.6047 0.7887
v -0.552776 -0.894440 1.701298 0.4368 0.6047 0.7887
v -1.788852 -0.894431 0.000000 0.4368 0.6047 0.7887
v -0.552776 -0.894440 -1.701298 0.4368 0.6047 0.7887
v 1.447215 -0.894439 -1.051451 0.4368 0.6047 0.7887
v 0.552776 0.894440 1.701298 0.4368 0.6047 0.7887
v -1.447215 0.894439 1.051451 0.4368 0.6047 0.7887
v -1.447215 0.894439 -1.051451 0.4368 0.6047 0.7887
v 0.552776 0.894440 -1.701298 0.4368 0.6047 0.7887
v 1.788852 0.894431 0.000000 0.4368 0.6047 0.7887
v 0.000000 2.000000 0.000000 0.4368 0.6047 0.7887
v -0.324911 -1.701309 0.999991 0.4368 0.6047 0.7887
v 0.850645 -1.701308 0.618023 0.4368 0.6047 0.7887
v 0.525738 -1.051475 1.618023 0.4368 0.6047 0.7887
v 1.701296 -1.051472 0.000000 0.4368 0.6047 0.7887
v 0.850645 -1.701308 -0.618023 0.4368 0.6047 0.7887
v -1.051460 -1.701303 0.000000 0.4368 0.6047 0.7887
v -1.376379 -1.051472 0.999994 0.4368 0.6047 0.7887
v -0.324911 -1.701309 -0.999991 0.4368 0.6047 0.7887
v -1.376379 -1.051472 -0.999994 0.4368 0.6047 0.7887
v 0.525738 -1.051475 -1.618023 0.4368 0.6047 0.7887
v 1.902116 0.000000 0.618025 0.4368 0.6047 0.7887
v 1.902116 0.000000 -0.618025 0.4368 0.6047 0.7887
v 0.000000 0.000000 2.000000 0.4368 0.6047 0.7887
v 1.175571 0.000000 1.618033 0.4368 0.6047 0.7887
v -1.902116 0.000000 0.618025 0.4368 0.6047 0.7887
v -1.175571 0.000000 1.618033 0.4368 0.6047 0.7887
v -1.175571 0.000000 -1.618033 0.4368 0.6047 0.7887
v -1.902116 0.000000 -0.618025 0.4368 0.6047 0.7887
v 1.175571 0.000000 -1.618033 0.4368 0.6047 0.7887
v 0.000000 0.000000 -2.000000 0.4368 0.6047 0.7887
v 1.376379 1.051472 0.999994 0.4368 0.6047 0.7887
v -0.525738 1.051475 1.618023 0.4368 0.6047 0.7887
v -1.701296 1.051472 0.000000 0.4368 0.6047 0.7887
v -0.525738 1.051475 -1.618023 0.4368 0.6047 0.7887
v 1.376379 1.051472 -0.999994 0.4368 0.6047 0.7887
v 0.324911 1.701309 0.999991 0.4368 0.6047 0.7887
v 1.051460 1.701303 0.000000 0.4368 0.6047 0.7887
v -0.850645 1.701308 0.618023 0.4368 0.6047 0.7887
v -0.850645 1.701308 -0.618023 0.4368 0.6047 0.7887
v 0.324911 1.701309 -0.999991 0.4368 0.6047 0.7887
vn -0.0000 -1.0000 -0.0000
vn 0.7236 -0.4472 0.5257
vn -0.2764 -0.4472 0.8506
vn -0.8944 -0.4472 -0.0000
vn -0.2764 -0.4472 -0.8506
vn 0.7236 -0.4472 -0.5257
vn 0.2764 0.4472 0.8506
vn -0.7236 0.4472 0.5257
vn -0.7236 0.4472 -0.5257
vn 0.2764 0.4472 -0.8506
vn 0.8944 0.4472 -0.0000
vn -0.0000 1.0000 -0.0000
vn -0.1625 -0.8507 0.5000
vn 0.4253 -0.8507 0.3090
vn 0.2629 -0.5257 0.8090
vn 0.8506 -0.5257 -0.0000
vn 0.4253 -0.8507 -0.3090
vn -0.5257 -0.8507 -0.0000
vn -0.6882 -0.5257 0.5000
vn -0.1625 -0.8507 -0.5000
vn -0.6882 -0.5257 -0.5000
vn 0.2629 -0.5257 -0.8090
vn 0.9511 -0.0000 0.3090
vn 0.9511 -0.0000 -0.3090
vn -0.0000 -0.0000 1.0000
vn 0.5878 -0.0000 0.8090
vn -0.9511 -0.0000 0.3090
vn -0.5878 -0.0000 0.8090
vn -0.5878 -0.0000 -0.8090
vn -0.9511 -0.0000 -0.3090
vn 0.5878 -0.0000 -0.8090
vn -0.0000 -0.0000 -1.0000
vn 0.6882 0.5257 0.5000
vn -0.2629 0.5257 0.8090
vn -0.8506 0.5257 -0.0000
vn -0.2629 0.5257 -0.8090
vn 0.6882 0.5257 -0.5000
vn 0.1625 0.8507 0.5000
vn 0.5257 0.8507 -0.0000
vn -0.4253 0.8507 0.3090
vn -0.4253 0.8507 -0.3090
vn 0.1625 0.8507 -0.5000
vt 0.181819 0.000000
vt 0.227273 0.078731
vt 0.136365 0.078731
vt 0.272728 0.157461
vt 0.318182 0.078731
vt 0.363637 0.157461
vt 0.909091 0.000000
vt 0.954545 0.078731
vt 0.863636 0.078731
vt 0.727273 0.000000
vt 0.772727 0.078731
vt 0.681818 0.078731
vt 0.545455 0.000000
vt 0.590909 0.078731
vt 0.500000 0.078731
vt 0.318182 0.236191
vt 0.090910 0.157461
vt 0.181819 0.157461
vt 0.136365 0.236191
vt 0.818182 0.157461
vt 0.909091 0.157461
vt 0.863636 0.236191
vt 0.636364 0.157461
vt 0.727273 0.157461
vt 0.681818 0.236191
vt 0.454546 0.157461
vt 0.545455 0.157461
vt 0.500000 0.236191
vt 0.227273 0.236191
vt 0.045455 0.236191
vt 0.772727 0.236191
vt 0.590909 0.236191
vt 0.409092 0.236191
vt 0.181819 0.314921
vt 0.272728 0.314921
vt 0.227273 0.393651
vt 0.000000 0.314921
vt 0.090910 0.314921
vt 0.045455 0.393651
vt 0.727273 0.314921
vt 0.818182 0.314921
vt 0.772727 0.393651
vt 0.545455 0.314921
vt 0.636364 0.314921
vt 0.590909 0.393651
vt 0.363637 0.314921
vt 0.454546 0.314921
vt 0.409092 0.393651
vt 0.500000 0.393651
vt 0.454546 0.472382
vt 0.681818 0.393651
vt 0.636364 0.472382
vt 0.863636 0.393651
vt 0.818182 0.472382
vt 0.909091 0.314921
vt 0.136365 0.393651
vt 0.090910 0.472382
vt 0.318182 0.393651
vt 0.272728 0.472382
vt 0.954545 0.236191
vt 1.000000 0.157461
vt 0.409092 0.078731
vt 0.363637 0.000000
s 1
usemtl Material.001
f 1/1/1 14/2/14 13/3/13
f 2/4/2 14/5/14 16/6/16
f 1/7/1 13/8/13 18/9/18
f 1/10/1 18/11/18 20/12/20
f 1/13/1 20/14/20 17/15/17
f 2/4/2 16/6/16 23/16/23
f 3/17/3 15/18/15 25/19/25
f 4/20/4 19/21/19 27/22/27
f 5/23/5 21/24/21 29/25/29
f 6/26/6 22/27/22 31/28/31
f 2/4/2 23/16/23 26/29/26
f 3/17/3 25/19/25 28/30/28
f 4/20/4 27/22/27 30/31/30
f 5/23/5 29/25/29 32/32/32
f 6/26/6 31/28/31 24/33/24
f 7/34/7 33/35/33 38/36/38
f 8/37/8 34/38/34 40/39/40
f 9/40/9 35/41/35 41/42/41
f 10/43/10 36/44/36 42/45/42
f 11/46/11 37/47/37 39/48/39
f 39/48/39 42/49/42 12/50/12
f 39/48/39 37/47/37 42/49/42
f 37/47/37 10/43/10 42/49/42
f 42/45/42 41/51/41 12/52/12
f 42/45/42 36/44/36 41/51/41
f 36/44/36 9/40/9 41/51/41
f 41/42/41 40/53/40 12/54/12
f 41/42/41 35/41/35 40/53/40
f 35/41/35 8/55/8 40/53/40
f 40/39/40 38/56/38 12/57/12
f 40/39/40 34/38/34 38/56/38
f 34/38/34 7/34/7 38/56/38
f 38/36/38 39/58/39 12/59/12
f 38/36/38 33/35/33 39/58/39
f 33/35/33 11/46/11 39/58/39
f 24/33/24 37/47/37 11/46/11
f 24/33/24 31/28/31 37/47/37
f 31/28/31 10/43/10 37/47/37
f 32/32/32 36/44/36 10/43/10
f 32/32/32 29/25/29 36/44/36
f 29/25/29 9/40/9 36/44/36
f 30/31/30 35/41/35 9/40/9
f 30/31/30 27/22/27 35/41/35
f 27/22/27 8/55/8 35/41/35
f 28/30/28 34/38/34 8/37/8
f 28/30/28 25/19/25 34/38/34
f 25/19/25 7/34/7 34/38/34
f 26/29/26 33/35/33 7/34/7
f 26/29/26 23/16/23 33/35/33
f 23/16/23 11/46/11 33/35/33
f 31/28/31 32/32/32 10/43/10
f 31/28/31 22/27/22 32/32/32
f 22/27/22 5/23/5 32/32/32
f 29/25/29 30/31/30 9/40/9
f 29/25/29 21/24/21 30/31/30
f 21/24/21 4/20/4 30/31/30
f 27/22/27 28/60/28 8/55/8
f 27/22/27 19/21/19 28/60/28
f 19/21/19 3/61/3 28/60/28
f 25/19/25 26/29/26 7/34/7
f 25/19/25 15/18/15 26/29/26
f 15/18/15 2/4/2 26/29/26
f 23/16/23 24/33/24 11/46/11
f 23/16/23 16/6/16 24/33/24
f 16/6/16 6/26/6 24/33/24
f 17/15/17 22/27/22 6/26/6
f 17/15/17 20/14/20 22/27/22
f 20/14/20 5/23/5 22/27/22
f 20/12/20 21/24/21 5/23/5
f 20/12/20 18/11/18 21/24/21
f 18/11/18 4/20/4 21/24/21
f 18/9/18 19/21/19 4/20/4
f 18/9/18 13/8/13 19/21/19
f 13/8/13 3/61/3 19/21/19
f 16/6/16 17/62/17 6/26/6
f 16/6/16 14/5/14 17/62/17
f 14/5/14 1/63/1 17/62/17
f 13/3/13 15/18/15 3/17/3
f 13/3/13 14/2/14 15/18/15
f 14/2/14 2/4/2 15/18/15

View File

@@ -14,3 +14,9 @@ add_executable(one src/main.c)
# target_link_libraries(one m Qt6::Widgets Qt6::Gui) # target_link_libraries(one m Qt6::Widgets Qt6::Gui)
target_link_libraries(one m) target_link_libraries(one m)
target_compile_options(one PRIVATE
-O3
-march=native
-ffast-math
)

View File

@@ -1,411 +0,0 @@
#ifndef FASTMATH_H
#define FASTMATH_H
#include <iostream>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <vector>
#define SHIFT_AMOUNT 16
#define HALF_SHIFT (SHIFT_AMOUNT / 2)
#define SHIFT_MASK ((1 << SHIFT_AMOUNT) - 1)
#define TO_FLOAT(x) \
(((float)(x >> SHIFT_AMOUNT)) + \
((double)(x & SHIFT_MASK) / (1 << SHIFT_AMOUNT)))
#define TO_INT(x) ((int32_t)(x * (1 << SHIFT_AMOUNT)))
#define MUL_F(a, b) (((a) >> HALF_SHIFT) * ((b) >> HALF_SHIFT))
#define DIV_F(a, b) ((((a) << HALF_SHIFT) / (b)) << HALF_SHIFT)
struct decimal {
int32_t i;
constexpr decimal() = default;
// constexpr decimal() : i(0) {}
constexpr decimal(float i) : i(TO_INT(i)) {}
constexpr decimal(double i) : i(TO_INT(i)) {}
constexpr decimal(int32_t i) : i(i) {}
inline friend std::ostream &operator<<(std::ostream &os, const decimal &d) {
return (os << TO_FLOAT(d.i));
}
inline friend decimal operator+(const decimal &d1, const decimal &d2) {
return {d1.i + d2.i};
}
inline decimal &operator+=(const decimal &d) { return (*this) = {i + d.i}; }
inline friend decimal operator-(const decimal &d1, const decimal &d2) {
return {d1.i - d2.i};
}
inline friend decimal operator-(const decimal &d) { return {-d.i}; }
inline friend decimal operator*(const decimal &d1, const decimal &d2) {
return {MUL_F(d1.i, d2.i)};
}
inline decimal &operator*=(const decimal &d) {
return (*this) = {MUL_F(i, d.i)};
}
inline friend decimal operator/(const decimal &d1, const decimal &d2) {
return {DIV_F(d1.i, d2.i)};
}
inline friend bool operator<(const decimal &d1, const decimal &d2) {
return d1.i < d2.i;
}
inline friend bool operator>(const decimal &d1, const decimal &d2) {
return d1.i > d2.i;
}
inline friend bool operator<=(const decimal &d1, const decimal &d2) {
return d1.i <= d2.i;
}
inline friend bool operator>=(const decimal &d1, const decimal &d2) {
return d1.i >= d2.i;
}
inline friend bool operator==(const decimal &d1, const decimal &d2) {
return d1.i == d2.i;
}
inline friend bool operator!=(const decimal &d1, const decimal &d2) {
return d1.i != d2.i;
}
inline decimal sqrt() { return {((int32_t)sqrtf(i)) << HALF_SHIFT}; }
inline float to_float() { return TO_FLOAT(i); }
inline bool isSmall() { return (abs(i) < (1 << (HALF_SHIFT - 1))); }
};
template <int n, class Dev> struct vec {
decimal v[n];
constexpr vec() noexcept = default;
template <class... Args>
constexpr vec(Args... args) noexcept : v{static_cast<decimal>(args)...} {
static_assert(sizeof...(Args) == n, "Wrong number of elements for vec");
}
friend Dev operator+(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = v1.v[i] + v2.v[i];
}
return newV;
}
friend Dev operator+=(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = v1.v[i] + v2.v[i];
}
return newV;
}
friend Dev operator-(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = v1.v[i] - v2.v[i];
}
return newV;
}
friend std::ostream &operator<<(std::ostream &os, const vec<n, Dev> &v) {
os << "(" << v.v[0];
for (int i = 1; i < n; i++) {
os << ", " << v.v[i];
}
return (os << ")" << std::endl);
}
Dev operator-() {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = -v[i];
}
return newV;
}
friend Dev operator*(const vec<n, Dev> &v, const decimal &d) {
int32_t f = d.i >> HALF_SHIFT;
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = (v.v[i].i >> HALF_SHIFT) * f;
}
return newV;
}
static Dev max(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = std::max(v1.v[i], v2.v[i]);
}
return newV;
}
static Dev min(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV.v[i] = std::min(v1.v[i], v2.v[i]);
}
return newV;
}
friend Dev operator*(const decimal &d, const vec<n, Dev> &v) {
return v * d;
}
friend decimal operator*(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
decimal res = decimal(0.0f);
for (int i = 0; i < n; i++) {
res += v1.v[i] * v2.v[i];
}
return res;
}
friend bool operator==(const vec<n, Dev> &v1, const vec<n, Dev> &v2) {
bool res = true;
for (int i = 0; i < n; i++) {
res &= v1.v[i] == v2.v[i];
}
return res;
}
bool isSmall() {
for (int i = 0; i < n; i++) {
if (!v[i].isSmall())
return false;
}
return true;
}
decimal &operator[](const int &i) { return v[i]; }
decimal len_sq() { return *this * *this; }
decimal len() { return this->len_sq().sqrt(); }
Dev normalize() {
decimal f = decimal(1.0) / this->len();
return (*this * f);
}
constexpr static Dev zero() {
Dev newV = {};
for (int i = 0; i < n; i++) {
newV[i] = decimal(0);
}
return newV;
}
};
struct vec2 : public vec<2, vec2> {
vec2(float x, float y) : vec<2, vec2>(decimal(x), decimal(y)) {}
vec2(double x, double y) : vec<2, vec2>(decimal(x), decimal(y)) {}
vec2(int32_t x, int32_t y) : vec<2, vec2>(decimal(x), decimal(y)) {}
vec2(decimal x, decimal y) : vec<2, vec2>(x, y) {}
decimal &x() { return v[0]; }
decimal &y() { return v[1]; }
};
struct vec3 : public vec<3, vec3> {
constexpr vec3() : vec<3, vec3>() {}
constexpr vec3(float x, float y, float z)
: vec<3, vec3>(decimal(x), decimal(y), decimal(z)) {}
constexpr vec3(double x, double y, double z)
: vec<3, vec3>(decimal(x), decimal(y), decimal(z)) {}
constexpr vec3(int32_t x, int32_t y, int32_t z)
: vec<3, vec3>(decimal(x), decimal(y), decimal(z)) {}
constexpr vec3(decimal x, decimal y, decimal z) : vec<3, vec3>(x, y, z) {}
inline decimal &x() { return v[0]; }
inline decimal &y() { return v[1]; }
inline decimal &z() { return v[2]; }
inline vec3 cross(vec3 &v) {
return vec3((y() * v.z()) - (z() * v.y()),
(z() * v.x()) - (x() * v.z()),
(x() * v.y()) - (y() * v.x()));
}
};
struct vec4 : public vec<4, vec4> {
constexpr vec4() : vec<4, vec4>() {}
vec4(float x, float y, float z, float w)
: vec<4, vec4>(decimal(x), decimal(y), decimal(z), decimal(w)) {}
vec4(double x, double y, double z, double w)
: vec<4, vec4>(decimal(x), decimal(y), decimal(z), decimal(w)) {}
vec4(int32_t x, int32_t y, int32_t z, int32_t w)
: vec<4, vec4>(decimal(x), decimal(y), decimal(z), decimal(w)) {}
vec4(vec3 v, decimal w) : vec<4, vec4>(v.x(), v.y(), v.z(), w) {}
decimal &x() { return v[0]; }
decimal &y() { return v[1]; }
decimal &z() { return v[2]; }
decimal &w() { return v[3]; }
};
template <int n, class Dev> struct mat {
decimal m[n * n];
static const int size = n;
friend Dev operator+(const mat<n, Dev> &m1, const mat<n, Dev> &m2) {
Dev newM = {};
for (int i = 0; i < n * n; i++) {
newM.v[i] = m1.m[i] + m2.m[i];
}
return newM;
}
friend Dev operator+=(const mat<n, Dev> &m1, const mat<n, Dev> &m2) {
Dev newM = {};
for (int i = 0; i < n * n; i++) {
newM.m[i] = m1.m[i] + m2.m[i];
}
return newM;
}
friend Dev operator-(const mat<n, Dev> &m1, const mat<n, Dev> &m2) {
Dev newM = {};
for (int i = 0; i < n * n; i++) {
newM.m[i] = m1.m[i] - m2.m[i];
}
return newM;
}
friend std::ostream &operator<<(std::ostream &os, const mat<n, Dev> &m) {
for (int i = 0; i < n; i++) {
os << "|" << m.m[i * n];
for (int j = 1; j < n; j++) {
os << ", " << m.m[i * n + j];
}
os << "|" << "\n";
}
return (os << std::endl);
}
template <class Dev1>
friend Dev1 operator*(const mat<n, Dev> &mat, const vec<n, Dev1> &v) {
Dev1 newV = vec<n, Dev1>::zero();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
newV[i] += mat.m[i * n + j] * v.v[j];
}
}
return newV;
}
decimal &operator[](const int &i) { return m[i]; }
friend Dev operator*(const mat<n, Dev> &m1, const mat<n, Dev> &m2) {
Dev newM = mat<n, Dev>::zero();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
newM[i * n + j] += m1.m[i * n + k] * m2.m[k * n + j];
}
}
}
return newM;
}
constexpr static Dev identity() {
Dev newM = {};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j)
newM.m[i * n + i] = decimal(1.0f);
else
newM.m[i * n + j] = decimal(0.0f);
}
}
return newM;
}
constexpr static Dev zero() {
Dev newM = {};
for (int i = 0; i < n * n; i++) {
newM[i] = decimal(0);
}
return newM;
}
inline void set(int x, int y, decimal v) { m[y * n + x] = v; }
inline decimal get(int x, int y) { return m[y * n + x]; }
friend bool operator==(const mat<n, Dev> &m1, const mat<n, Dev> &m2) {
bool res = true;
for (int i = 0; i < n * n; i++) {
res &= m1.m[i] == m2.m[i];
}
return res;
}
bool isSmall() {
for (int i = 0; i < n; i++) {
if (!m[i].isSmall())
return false;
}
return true;
}
template <class Dev1> Dev1 cutTo() const {
static_assert(Dev1::size < n, "Can only convert to smaller matrix");
Dev1 newM = mat<Dev1::size, Dev1>::zero();
for (int i = 0; i < Dev1::size; i++) {
for (int j = 0; j < Dev1::size; j++) {
newM.m[Dev1::size * i + j] = m[n * i + j];
}
}
return newM;
}
};
template <int n> struct matN : public mat<n, matN<n>> {};
struct mat3 : public mat<3, mat3> {};
struct mat4 : public mat<4, mat4> {
static mat4 translation(const vec3 &v) {
mat4 newM = mat4::identity();
for (int i = 0; i < 3; i++) {
newM[4 * i + 3] = v.v[i];
}
return newM;
}
static mat4 rotateOnX(float a) {
mat4 newM = mat4::identity();
newM.m[1 * 4 + 1] = cos(a), newM.m[2 * 4 + 2] = cos(a);
newM.m[1 * 4 + 2] = -sin(a), newM.m[2 * 4 + 1] = sin(a);
return newM;
}
static mat4 rotateOnY(float a) {
mat4 newM = mat4::identity();
newM.m[0 * 4 + 0] = cos(a), newM.m[2 * 4 + 2] = cos(a);
newM.m[0 * 4 + 2] = sin(a), newM.m[2 * 4 + 0] = -sin(a);
return newM;
}
static mat4 rotateOnZ(float a) {
mat4 newM = mat4::identity();
newM.m[0 * 4 + 0] = cos(a), newM.m[1 * 4 + 1] = cos(a);
newM.m[1 * 4 + 0] = sin(a), newM.m[0 * 4 + 1] = -sin(a);
return newM;
}
};
#endif

156
main.cpp
View File

@@ -1,156 +0,0 @@
#include "fastmath.hpp"
#include "polygon.hpp"
#include "renderer.hpp"
#include "rendertarget.hpp"
#include "testModel.hpp"
#include <QApplication>
#include <QImage>
#include <QLabel>
#include <QObject>
#include <QPixmap>
#include <QTimer>
#include <chrono>
#include <functional>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#define HIGHT 64
#define WIDTH 64
#define FAA_FAC 2
#define RHIGHT ((int)(HIGHT * FAA_FAC))
#define RWIDTH ((int)(WIDTH * FAA_FAC))
char *drawToString(unsigned short *img) {
char *textImg = (char *)malloc(200000 * sizeof(char));
// strcat(textImg,"\e[1;1H\e[2J"); --clear
for (int y = 0; y < HIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
// printf("%d,%d\n",x,y);
char buff[20];
unsigned short val = 0;
int my = y * FAA_FAC;
int mx = x * FAA_FAC;
val += img[my * RWIDTH + mx];
val += img[my * RWIDTH + mx + 1];
val += img[(my + 1) * RWIDTH + mx];
val += img[(my + 1) * RWIDTH + mx + 1];
sprintf(buff, "\033[38;5;%dm██\033[0m", 232 + val / 4);
strcat(textImg, buff);
}
strcat(textImg, "\n");
}
return textImg;
}
void drawImage(unsigned short *img) {
decimal heightPerPix = decimal(1.0) / decimal((float)(HIGHT * FAA_FAC));
decimal widthPerPix = decimal(1.0) / decimal((float)(WIDTH * FAA_FAC));
polygon poly = polygon(vec3(0.9, 0.9, 0.0) * decimal(128.0),
vec3(0.5, 0.1, 0.0) * decimal(128.0),
vec3(0.1, 0.9, 0.0) * decimal(128.0));
// printf("\n hpp: %f, wpp: %f
// \n",TO_FLOAT(heightPerPix),TO_FLOAT(widthPerPix)); calcViewPos(t);
for (decimal y = 0; y < decimal((float)(RHIGHT)); y += decimal(1.0)) {
for (decimal x = 0; x < decimal((float)(RWIDTH)); x += decimal(1.0)) {
vec3 p = vec3(x, y, 0.0);
if (poly.contains(p)) {
img[(y.i >> SHIFT_AMOUNT) * RWIDTH + (x.i >> SHIFT_AMOUNT)] =
(unsigned short)23; // (((-normal[1]+(1 <<
// SHIFT_AMOUNT))*14)>>SHIFT_AMOUNT);
}
}
}
printf("done writing %d \n", *(img + sizeof(unsigned short) * 32 * 32));
}
int main(int argc, char *argv[]) {
Rendertarget target(128, 128);
Renderer renderer;
renderer.target = &target;
polygon poly =
polygon(vec3(0.9, 0.9, 1.0), vec3(0.5, 0.1, 1.0), vec3(0.1, 0.9, 1.0));
std::chrono::steady_clock::time_point begin =
std::chrono::steady_clock::now();
renderer.render(&testModel, mat4::translation(vec3(0.0f, -1.0f, 5.0f)) *
mat4::rotateOnY(-1.5707963267948966f));
std::chrono::steady_clock::time_point end =
std::chrono::steady_clock::now();
std::cout << "Time difference = "
<< std::chrono::duration_cast<std::chrono::milliseconds>(end -
begin)
.count()
<< "[ms]" << std::endl;
uint8_t *pixel = new uint8_t[64 * 64 * 3];
/*for (int i = 0; i < 64 * 64 * 3; i++) {
pixel[i] = target.pixels[i].i >> SHIFT_AMOUNT;
}*/
std::function<void(int, uint32_t *)> addTo = [&target](int start,
uint32_t *arr) {
for (int c = 0; c < 3; c++) {
arr[c] += target.pixels[start + c];
}
};
QApplication a(argc, argv);
QWidget widget;
widget.setAutoFillBackground(true);
widget.setGeometry(0, 0, 500, 500);
QLabel display(&widget);
QImage img((unsigned char *)pixel, 64, 64, QImage::Format_RGB888);
// display.setPixmap(QPixmap::fromImage(img).scaled(widget.size()));
float rot = 0.f;
std::function<void()> renderLoop = [&addTo, &target, &pixel, &renderer,
&display, &widget, &img, &rot]() {
std::chrono::steady_clock::time_point begin =
std::chrono::steady_clock::now();
renderer.render(&testModel, mat4::translation(vec3(0.0f, -1.0f, 5.0f)) *
mat4::rotateOnY(rot));
std::chrono::steady_clock::time_point end =
std::chrono::steady_clock::now();
std::cout << "Time difference = "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
end - begin)
.count()
<< "[ms]" << std::endl;
for (int x = 0; x < 64; x++) {
for (int y = 0; y < 64; y++) {
uint32_t result[3] = {};
addTo((target.width * y * 2 + x * 2) * 3, result);
addTo((target.width * (y * 2 + 1) + x * 2) * 3, result);
addTo((target.width * y * 2 + (x * 2 + 1)) * 3, result);
addTo((target.width * (y * 2 + 1) + (x * 2 + 1)) * 3, result);
for (int c = 0; c < 3; c++) {
pixel[(WIDTH * (WIDTH - y - 1) + WIDTH - x - 1) * 3 + c] =
result[c] >> 2;
}
}
}
// QImage img((unsigned char *)pixel, 64, 64, QImage::Format_RGB888);
display.setPixmap(QPixmap::fromImage(img).scaled(widget.size() * 1));
rot += 0.1f;
};
renderLoop();
widget.show();
QTimer timer;
timer.setInterval(20);
timer.start();
QObject::connect(&timer, &QTimer::timeout, &widget, renderLoop);
return a.exec();
}

View File

@@ -1,16 +0,0 @@
#ifndef MODEL_H
#define MODEL_H
#include "fastmath.hpp"
#include <tuple>
#include <vector>
struct model {
std::vector<vec3> verts;
// At 0 vertecie index, at 1 normal index
std::vector<std::tuple<uint16_t, uint16_t>> faces;
std::vector<vec3> normals;
std::vector<vec3> colors;
};
#endif

142
parseObj.py Normal file → Executable file
View File

@@ -1,63 +1,95 @@
# Open the file in read mode #!/usr/bin/env python3
file = open("plane.obj", "r")
# Read the entire content of the file import os
content = file.read().split("\n")
file.close() dir_name = "3dModels/"
startVerts = 0
verts = []
for index, line in enumerate(content):
if line[0] == "o":
startVerts = index + 1
content = content[startVerts:]
break
for index, line in enumerate(content):
if "vn" in line:
endVerts = index
verts = content[:endVerts]
content = content[endVerts:]
break
normals = [] def source_model(file_name: str):
for index, line in enumerate(content): # Open the file in read mode
if "vt" in line: file = open(dir_name + file_name + ".obj", "r")
normals = content[:index]
content = content[index:]
break
startFaces = 0 # Read the entire content of the file
faces = [] content = file.read().split("\n")
for index, line in enumerate(content):
if line[0] == "f":
startFaces = index
faces = content[startFaces:-1]
break
colors = ["vec3(" + ",".join(vert.split(" ")[4:7]) + ")" for vert in verts] file.close()
verts = ["{" + ",".join(vert.split(" ")[1:4]) + "}" for vert in verts]
faces = [
",".join([str(int((d.split("/")[0])) - 1) for d in face.split(" ")[1:4]])
for face in faces
]
normals = ["vec3(" + ",".join(normal.split(" ")[1:4]) + ")" for normal in normals]
out = ( startVerts = 0
'#include "../renderer.h" \n const model testModel = {(vec3[]){' verts = []
+ ",".join(verts) for index, line in enumerate(content):
+ "},(int[]){" if line[0] == "o":
+ ",".join(faces) startVerts = index + 1
+ "}," content = content[startVerts:]
+ str(len(verts)) break
+ ","
+ str(len(faces) * 3)
+ "};"
)
with open("src/models/plane.h", "w") as f: for index, line in enumerate(content):
f.write(out) if "vn" in line:
print(faces) endVerts = index
# Close the file verts = content[:endVerts]
content = content[endVerts:]
break
normals = []
for index, line in enumerate(content):
if "vt" in line:
normals = content[:index]
content = content[index:]
break
startFaces = 0
faces = []
for index, line in enumerate(content):
if line[0] == "f":
startFaces = index
faces = content[startFaces:-1]
break
colors = ["{" + ",".join(vert.split(" ")[4:7]) + "}" for vert in verts]
verts = ["{" + ",".join(vert.split(" ")[1:4]) + "}" for vert in verts]
faces = [
",".join(
[
str(int((d.split("/")[0])) - 1) + "," + str(int((d.split("/")[2])) - 1)
for d in face.split(" ")[1:4]
]
)
for face in faces
]
normals = ["{" + ",".join(normal.split(" ")[1:4]) + "}" for normal in normals]
mtl_file = open(dir_name + file_name + ".mtl", "r")
shiny = mtl_file.read().split("\n")[4].split(" ")[1]
mtl_file.close()
print(shiny)
out = (
'#include "../renderer.h" \n const model '
+ file_name
+ "_model = {(vec3[]){"
+ ",".join(verts)
+ "},(int[]){"
+ ",".join(faces)
+ "},(vec3[]){"
+ ",".join(normals)
+ "},(vec3[]){"
+ ",".join(colors)
+ "},"
+ str(len(verts))
+ ","
+ str(len(faces) * 6)
+ ","
+ str(float(shiny) / 20)
+ "};"
)
with open("src/models/" + file_name + ".h", "w") as f:
f.write(out)
# Close the file
f.close()
model_files = os.listdir("3dModels")
li = range(0, 10)
for file in model_files:
if file.endswith(".obj"):
source_model(file[:-4])

727
plane.obj Normal file
View File

@@ -0,0 +1,727 @@
# Blender 5.1.0
# www.blender.org
mtllib plane.mtl
o Cylinder.002
v 0.698513 0.757563 0.000000 0.0000 0.4470 0.0334
v 0.044645 2.825787 0.000000 0.0000 0.4470 0.0334
v 0.656388 0.757563 0.238906 0.0000 0.4470 0.0334
v 0.041953 2.825787 0.015270 0.0000 0.4470 0.0334
v 0.535092 0.757563 0.448996 0.0000 0.4470 0.0334
v 0.034200 2.825787 0.028697 0.0000 0.4470 0.0334
v 0.349257 0.757563 0.604930 0.0000 0.4470 0.0334
v 0.022323 2.825787 0.038664 0.0000 0.4470 0.0334
v 0.121296 0.757563 0.687901 0.0000 0.4470 0.0334
v 0.007753 2.825787 0.043967 0.0000 0.4470 0.0334
v -0.121296 0.757563 0.687901 0.0000 0.4470 0.0334
v -0.007753 2.825787 0.043967 0.0000 0.4470 0.0334
v -0.349257 0.757563 0.604930 0.0000 0.4470 0.0334
v -0.022323 2.825787 0.038664 0.0000 0.4470 0.0334
v -0.535092 0.757563 0.448996 0.0000 0.4470 0.0334
v -0.034200 2.825787 0.028697 0.0000 0.4470 0.0334
v -0.656388 0.757563 0.238906 0.0000 0.4470 0.0334
v -0.041953 2.825787 0.015270 0.0000 0.4470 0.0334
v -0.698513 0.757563 -0.000000 0.0000 0.4470 0.0334
v -0.044645 2.825787 0.000000 0.0000 0.4470 0.0334
v -0.656388 0.757563 -0.238906 0.0000 0.4470 0.0334
v -0.041953 2.825787 -0.015270 0.0000 0.4470 0.0334
v -0.535092 0.757563 -0.448996 0.0000 0.4470 0.0334
v -0.034200 2.825787 -0.028697 0.0000 0.4470 0.0334
v -0.349257 0.757563 -0.604930 0.0000 0.4470 0.0334
v -0.022323 2.825787 -0.038664 0.0000 0.4470 0.0334
v -0.121296 0.757563 -0.687901 0.0000 0.4470 0.0334
v -0.007753 2.825787 -0.043967 0.0000 0.4470 0.0334
v 0.121296 0.757563 -0.687901 0.0000 0.4470 0.0334
v 0.007753 2.825787 -0.043967 0.0000 0.4470 0.0334
v 0.349257 0.757563 -0.604930 0.0000 0.4470 0.0334
v 0.022323 2.825787 -0.038664 0.0000 0.4470 0.0334
v 0.535092 0.757563 -0.448996 0.0000 0.4470 0.0334
v 0.034200 2.825787 -0.028697 0.0000 0.4470 0.0334
v 0.656388 0.757563 -0.238906 0.0000 0.4470 0.0334
v 0.041953 2.825787 -0.015269 0.0000 0.4470 0.0334
v 0.544639 2.240545 0.000000 0.0000 0.4470 0.0334
v 0.511793 2.240545 0.186277 0.0000 0.4470 0.0334
v 0.409479 2.128906 0.371044 0.8556 0.8746 1.0000
v 0.290178 2.227410 0.470774 0.8556 0.8746 1.0000
v 0.100778 2.227410 0.539710 0.8556 0.8746 1.0000
v -0.100778 2.227410 0.539710 0.8556 0.8746 1.0000
v -0.290178 2.227410 0.470774 0.8556 0.8746 1.0000
v -0.409479 2.128906 0.371044 0.8556 0.8746 1.0000
v -0.511793 2.240545 0.186277 0.0000 0.4470 0.0334
v -0.544639 2.240545 -0.000000 0.0000 0.4470 0.0334
v -0.511793 2.240545 -0.186277 0.0000 0.4470 0.0334
v -0.417217 2.240545 -0.350087 0.0000 0.4470 0.0334
v -0.272319 2.240545 -0.471671 0.0000 0.4470 0.0334
v -0.094576 2.240545 -0.536364 0.0000 0.4470 0.0334
v 0.094576 2.240545 -0.536364 0.0000 0.4470 0.0334
v 0.272319 2.240545 -0.471671 0.0000 0.4470 0.0334
v 0.417218 2.240545 -0.350087 0.0000 0.4470 0.0334
v 0.511793 2.240545 -0.186277 0.0000 0.4470 0.0334
v 0.694426 1.474881 0.252751 0.0000 0.4470 0.0334
v 0.527394 1.631239 0.497527 0.8556 0.8746 1.0000
v 0.367433 1.488016 0.632126 0.8556 0.8746 1.0000
v 0.127608 1.488016 0.719415 0.8556 0.8746 1.0000
v -0.127608 1.488016 0.719415 0.8556 0.8746 1.0000
v -0.367433 1.488016 0.632126 0.8556 0.8746 1.0000
v -0.527394 1.631239 0.497527 0.8556 0.8746 1.0000
v -0.694426 1.474881 0.252751 0.0000 0.4470 0.0334
v -0.738993 1.474881 -0.000000 0.0000 0.4470 0.0334
v -0.694426 1.474881 -0.252751 0.0000 0.4470 0.0334
v -0.566102 1.474881 -0.475016 0.0000 0.4470 0.0334
v -0.369497 1.474881 -0.639987 0.0000 0.4470 0.0334
v -0.128325 1.474881 -0.727766 0.0000 0.4470 0.0334
v 0.128325 1.474881 -0.727766 0.0000 0.4470 0.0334
v 0.369497 1.474881 -0.639987 0.0000 0.4470 0.0334
v 0.566102 1.474881 -0.475016 0.0000 0.4470 0.0334
v 0.694426 1.474881 -0.252751 0.0000 0.4470 0.0334
v 0.738993 1.474881 0.000000 0.0000 0.4470 0.0334
v 0.410385 -0.154204 0.000000 0.0000 0.4470 0.0334
v 0.385635 -0.154204 0.140360 0.0000 0.4470 0.0334
v 0.314373 -0.154204 0.263790 0.0000 0.4470 0.0334
v 0.205192 -0.154204 0.355403 0.0000 0.4470 0.0334
v 0.071263 -0.154204 0.404150 0.0000 0.4470 0.0334
v -0.071263 -0.154204 0.404150 0.0000 0.4470 0.0334
v -0.205192 -0.154204 0.355403 0.0000 0.4470 0.0334
v -0.314373 -0.154204 0.263790 0.0000 0.4470 0.0334
v -0.385635 -0.154204 0.140360 0.0000 0.4470 0.0334
v -0.410385 -0.154204 -0.000000 0.0000 0.4470 0.0334
v -0.385635 -0.154204 -0.140360 0.0000 0.4470 0.0334
v -0.314373 -0.154204 -0.263790 0.0000 0.4470 0.0334
v -0.205192 -0.154204 -0.355403 0.0000 0.4470 0.0334
v -0.071263 -0.154204 -0.404150 0.0000 0.4470 0.0334
v 0.071263 -0.154204 -0.404150 0.0000 0.4470 0.0334
v 0.205192 -0.154204 -0.355403 0.0000 0.4470 0.0334
v 0.314373 -0.154204 -0.263790 0.0000 0.4470 0.0334
v 0.385635 -0.154204 -0.140360 0.0000 0.4470 0.0334
v 0.237705 2.675272 0.000000 0.0000 0.4470 0.0334
v 0.223370 2.675272 0.081300 0.0000 0.4470 0.0334
v 0.182093 2.675272 0.152794 0.0000 0.4470 0.0334
v 0.118853 2.675272 0.205859 0.0000 0.4470 0.0334
v 0.041277 2.675272 0.234094 0.0000 0.4470 0.0334
v -0.041277 2.675272 0.234094 0.0000 0.4470 0.0334
v -0.118853 2.675272 0.205859 0.0000 0.4470 0.0334
v -0.182093 2.675272 0.152794 0.0000 0.4470 0.0334
v -0.223370 2.675272 0.081300 0.0000 0.4470 0.0334
v -0.237705 2.675272 -0.000000 0.0000 0.4470 0.0334
v -0.223370 2.675272 -0.081300 0.0000 0.4470 0.0334
v -0.182093 2.675272 -0.152794 0.0000 0.4470 0.0334
v -0.118853 2.675272 -0.205859 0.0000 0.4470 0.0334
v -0.041277 2.675272 -0.234094 0.0000 0.4470 0.0334
v 0.041277 2.675272 -0.234094 0.0000 0.4470 0.0334
v 0.118853 2.675272 -0.205859 0.0000 0.4470 0.0334
v 0.182093 2.675272 -0.152794 0.0000 0.4470 0.0334
v 0.223370 2.675272 -0.081300 0.0000 0.4470 0.0334
v 0.046326 2.839588 0.000000 0.9696 1.0000 0.0000
v -0.023163 2.839588 -0.040120 0.9695 0.9999 0.0005
v -0.023163 2.839588 0.040120 0.9696 1.0000 0.0000
v 0.000000 3.137896 0.000000 0.9696 1.0000 0.0000
v -0.272319 2.240545 0.471671 0.0000 0.4470 0.0334
v -0.417218 2.141971 0.350087 0.0000 0.4470 0.0334
v -0.094576 2.240545 0.536364 0.0000 0.4470 0.0334
v 0.094576 2.240545 0.536364 0.0000 0.4470 0.0334
v 0.272319 2.240545 0.471671 0.0000 0.4470 0.0334
v 0.417217 2.141971 0.350087 0.0000 0.4470 0.0334
v 0.566102 1.618174 0.475016 0.0000 0.4470 0.0334
v -0.566102 1.618174 0.475016 0.0000 0.4470 0.0334
v 0.369497 1.474881 0.639987 0.0000 0.4470 0.0334
v 0.128325 1.474881 0.727766 0.0000 0.4470 0.0334
v -0.128325 1.474881 0.727766 0.0000 0.4470 0.0334
v -0.369497 1.474881 0.639987 0.0000 0.4470 0.0334
v 0.237002 2.117707 0.625731 0.1450 0.1371 0.1900
v 0.257333 1.652925 0.728921 0.1450 0.1371 0.1900
v 0.082310 2.117707 0.682034 0.1450 0.1371 0.1900
v 0.089371 1.652925 0.766453 0.1450 0.1371 0.1900
v -0.082310 2.117707 0.682034 0.1450 0.1371 0.1900
v -0.089371 1.652925 0.766453 0.1450 0.1371 0.1900
v -0.237002 2.117707 0.625731 0.1450 0.1371 0.1900
v -0.257333 1.652925 0.728921 0.1450 0.1371 0.1900
v -0.334441 2.019176 0.544276 0.1450 0.1371 0.1900
v 0.334441 2.019176 0.544276 0.1450 0.1371 0.1900
v 0.369362 1.735177 0.671046 0.1450 0.1371 0.1900
v -0.369362 1.735177 0.671046 0.1450 0.1371 0.1900
v 0.096339 2.201041 0.616476 0.1450 0.1371 0.1900
v -0.096339 2.201041 0.616476 0.1450 0.1371 0.1900
v 0.489408 1.656222 0.539235 0.1450 0.1371 0.1900
v 0.391442 2.102530 0.455240 0.1450 0.1371 0.1900
v 0.118417 1.527654 0.730721 0.1450 0.1371 0.1900
v -0.118417 1.527654 0.730721 0.1450 0.1371 0.1900
v -0.489408 1.656222 0.539235 0.1450 0.1371 0.1900
v -0.391442 2.102530 0.455240 0.1450 0.1371 0.1900
v 0.277396 2.201041 0.550577 0.1450 0.1371 0.1900
v -0.340969 1.527654 0.655392 0.1450 0.1371 0.1900
v -0.277396 2.201041 0.550577 0.1450 0.1371 0.1900
v 0.340969 1.527654 0.655392 0.1450 0.1371 0.1900
vn 0.9841 -0.1778 -0.0000
vn 0.9146 0.4043 -0.0000
vn 0.9247 -0.1778 0.3366
vn 0.7754 0.5378 0.3310
vn 0.7540 -0.1768 0.6327
vn 0.4942 0.7357 0.4632
vn 0.4920 -0.1778 0.8522
vn 0.3013 0.7980 0.5219
vn 0.1709 -0.1778 0.9691
vn 0.1541 0.7357 0.6596
vn -0.1709 -0.1778 0.9691
vn -0.1010 0.5378 0.8370
vn -0.4920 -0.1778 0.8522
vn -0.4573 0.4043 0.7921
vn -0.7540 -0.1768 0.6327
vn -0.6743 0.5378 0.5060
vn -0.9247 -0.1778 0.3366
vn -0.6483 0.7357 0.1964
vn -0.9841 -0.1778 -0.0000
vn -0.6026 0.7980 -0.0000
vn -0.9247 -0.1778 -0.3366
vn -0.6483 0.7357 -0.1964
vn -0.7538 -0.1778 -0.6325
vn -0.6743 0.5378 -0.5060
vn -0.4920 -0.1778 -0.8522
vn -0.4573 0.4043 -0.7921
vn -0.1709 -0.1778 -0.9691
vn -0.1010 0.5378 -0.8370
vn 0.1709 -0.1778 -0.9691
vn 0.1541 0.7357 -0.6596
vn 0.4920 -0.1778 -0.8522
vn 0.3013 0.7980 -0.5219
vn 0.7538 -0.1778 -0.6325
vn 0.4942 0.7357 -0.4632
vn 0.9247 -0.1778 -0.3366
vn 0.7754 0.5378 -0.3310
vn 0.9117 0.4109 -0.0000
vn 0.8130 0.4345 0.3877
vn 0.8011 0.3907 0.4535
vn 0.5809 0.7552 0.3037
vn 0.1433 0.7300 0.6682
vn -0.1433 0.7300 0.6682
vn -0.5809 0.7552 0.3037
vn -0.8011 0.3907 0.4535
vn -0.8130 0.4345 0.3877
vn -0.9117 0.4109 -0.0000
vn -0.8567 0.4109 -0.3118
vn -0.6984 0.4109 -0.5860
vn -0.4558 0.4109 -0.7895
vn -0.1583 0.4109 -0.8978
vn 0.1583 0.4109 -0.8978
vn 0.4558 0.4109 -0.7895
vn 0.6984 0.4109 -0.5860
vn 0.8567 0.4109 -0.3118
vn 0.9423 0.0728 0.3267
vn 0.6347 0.1973 0.7472
vn 0.4225 0.2699 0.8652
vn 0.1829 0.1701 0.9683
vn -0.1829 0.1701 0.9683
vn -0.4225 0.2699 0.8652
vn -0.6347 0.1973 0.7472
vn -0.9423 0.0728 0.3267
vn -0.9955 0.0944 -0.0000
vn -0.9355 0.0944 -0.3405
vn -0.7626 0.0944 -0.6399
vn -0.4978 0.0944 -0.8622
vn -0.1729 0.0944 -0.9804
vn 0.1729 0.0944 -0.9804
vn 0.4978 0.0944 -0.8622
vn 0.7626 0.0944 -0.6399
vn 0.9355 0.0944 -0.3405
vn 0.9955 0.0944 -0.0000
vn 0.6306 -0.7761 -0.0000
vn 0.5926 -0.7761 0.2157
vn 0.4830 -0.7761 0.4053
vn 0.3153 -0.7761 0.5461
vn 0.1095 -0.7761 0.6210
vn -0.1095 -0.7761 0.6210
vn -0.3153 -0.7761 0.5461
vn -0.4831 -0.7761 0.4053
vn -0.5925 -0.7761 0.2157
vn -0.6306 -0.7761 -0.0000
vn -0.5925 -0.7761 -0.2157
vn -0.4831 -0.7761 -0.4053
vn -0.3153 -0.7761 -0.5461
vn -0.1095 -0.7761 -0.6210
vn 0.1095 -0.7761 -0.6210
vn 0.3153 -0.7761 -0.5461
vn 0.4830 -0.7761 -0.4053
vn 0.5925 -0.7761 -0.2157
vn 0.7312 0.6821 -0.0000
vn 0.6871 0.6821 0.2501
vn 0.5656 0.6745 0.4746
vn 0.3656 0.6821 0.6333
vn 0.1270 0.6821 0.7201
vn -0.1270 0.6821 0.7201
vn -0.3656 0.6821 0.6333
vn -0.5656 0.6745 0.4746
vn -0.6871 0.6821 0.2501
vn -0.7312 0.6821 -0.0000
vn -0.6871 0.6821 -0.2501
vn -0.5601 0.6821 -0.4700
vn -0.3656 0.6821 -0.6333
vn -0.1270 0.6821 -0.7201
vn 0.1270 0.6821 -0.7201
vn 0.3656 0.6821 -0.6333
vn 0.5601 0.6821 -0.4700
vn 0.6871 0.6821 -0.2501
vn 0.9437 0.3307 -0.0000
vn -0.4719 0.3307 -0.8173
vn -0.4719 0.3307 0.8173
vn -0.0000 1.0000 -0.0000
vn -0.4787 0.5258 0.7031
vn -0.7169 0.4126 0.5620
vn -0.1342 0.4369 0.8895
vn 0.1342 0.4369 0.8895
vn 0.4787 0.5258 0.7031
vn 0.7169 0.4126 0.5620
vn 0.7577 0.1650 0.6315
vn -0.7577 0.1650 0.6315
vn 0.4534 0.1969 0.8693
vn 0.1663 0.2444 0.9553
vn -0.1663 0.2444 0.9553
vn -0.4534 0.1969 0.8693
vn 0.4906 0.3661 0.7907
vn 0.3424 -0.0553 0.9379
vn 0.1431 0.4003 0.9051
vn 0.1012 -0.0377 0.9942
vn -0.1431 0.4003 0.9051
vn -0.1012 -0.0377 0.9942
vn -0.4906 0.3661 0.7907
vn -0.3424 -0.0553 0.9379
vn -0.7362 0.2805 0.6159
vn 0.7362 0.2805 0.6159
vn 0.6174 0.1400 0.7741
vn -0.6174 0.1400 0.7741
vn 0.1165 0.7887 0.6037
vn -0.1165 0.7887 0.6037
vn 0.7537 0.0880 0.6512
vn 0.8090 0.3734 0.4541
vn 0.1400 -0.2577 0.9560
vn -0.1400 -0.2577 0.9560
vn -0.7537 0.0880 0.6512
vn -0.8090 0.3734 0.4541
vn 0.5043 0.6625 0.5539
vn -0.4814 -0.2028 0.8527
vn -0.5043 0.6625 0.5539
vn 0.4814 -0.2028 0.8527
vt 1.000000 1.000000
vt 0.944444 0.875000
vt 1.000000 0.875000
vt 0.888889 1.000000
vt 0.888889 0.875000
vt 0.833333 0.875000
vt 0.833333 1.000000
vt 0.777778 0.875000
vt 0.777778 1.000000
vt 0.722222 0.875000
vt 0.722222 1.000000
vt 0.666667 0.875000
vt 0.611111 1.000000
vt 0.611111 0.875000
vt 0.555555 0.875000
vt 0.500000 1.000000
vt 0.500000 0.875000
vt 0.444444 0.875000
vt 0.388889 1.000000
vt 0.388889 0.875000
vt 0.333333 0.875000
vt 0.333333 1.000000
vt 0.277778 0.875000
vt 0.277778 1.000000
vt 0.222222 0.875000
vt 0.166666 1.000000
vt 0.166666 0.875000
vt 0.111111 0.875000
vt 0.111111 1.000000
vt 0.055555 0.875000
vt 0.055555 1.000000
vt -0.000000 0.875000
vt 0.888889 0.500000
vt 0.944444 0.500000
vt 0.055555 0.750000
vt -0.000000 0.620925
vt 0.055555 0.620925
vt 0.111111 0.750000
vt 0.111111 0.620925
vt 0.166666 0.750000
vt 0.166666 0.620925
vt 0.222222 0.750000
vt 0.222222 0.620925
vt 0.277778 0.750000
vt 0.277778 0.620925
vt 0.333333 0.620925
vt 0.388889 0.620925
vt 0.333333 0.750000
vt 0.444444 0.750000
vt 0.444444 0.620925
vt 0.500000 0.620925
vt 0.555555 0.750000
vt 0.555555 0.620925
vt 0.611111 0.620925
vt 0.777791 0.742476
vt 0.833347 0.742476
vt 0.833347 0.742476
vt 0.621250 0.628449
vt 0.623706 0.742476
vt 0.722233 0.628449
vt 0.777789 0.628449
vt 0.722236 0.742476
vt 0.878750 0.628449
vt 0.876294 0.742476
vt 0.878750 0.628449
vt 0.944444 0.750000
vt 0.888889 0.620925
vt 0.944444 0.620925
vt 1.000000 0.620925
vt 1.000000 0.500000
vt 0.833333 0.620925
vt 0.833333 0.500000
vt 0.777778 0.500000
vt 0.777778 0.620925
vt 0.722222 0.500000
vt 0.722222 0.620925
vt 0.666667 0.500000
vt 0.666666 0.620925
vt 0.611111 0.500000
vt 0.555555 0.500000
vt 0.500000 0.500000
vt 0.444444 0.500000
vt 0.388889 0.500000
vt 0.333333 0.500000
vt 0.277778 0.500000
vt 0.222222 0.500000
vt 0.166666 0.500000
vt 0.111111 0.500000
vt 0.055555 0.500000
vt -0.000000 0.500000
vt 0.957846 0.370000
vt 0.595731 0.066149
vt 0.542154 0.370000
vt -0.000000 0.750000
vt 0.388889 0.750000
vt 0.500000 0.750000
vt 0.611111 0.750000
vt 0.666667 0.750000
vt 0.722222 0.750000
vt 0.777778 0.750000
vt 0.833333 0.750000
vt 0.888889 0.750000
vt 1.000000 0.750000
vt 0.000000 0.000000
vt 0.944444 1.000000
vt 0.666667 1.000000
vt 0.555555 1.000000
vt 0.444444 1.000000
vt 0.222222 1.000000
vt -0.000000 1.000000
vt 0.666680 0.742476
vt 0.722236 0.742476
vt 0.833345 0.628449
vt 0.666678 0.628449
vt 0.666680 0.742476
vt 0.833345 0.628449
vt 0.876294 0.742476
vt 0.777789 0.628449
vt 0.667915 0.475526
vt 0.750000 0.490000
vt 0.832085 0.475526
vt 0.904269 0.433851
vt 0.986354 0.291676
vt 0.986354 0.208324
vt 0.957846 0.130000
vt 0.904269 0.066149
vt 0.832085 0.024474
vt 0.750000 0.010000
vt 0.667915 0.024474
vt 0.542154 0.130000
vt 0.513646 0.208324
vt 0.513646 0.291676
vt 0.595731 0.433851
s 1
usemtl Material.001
f 2/1/2 92/2/92 91/3/91
f 92/2/92 6/4/6 93/5/93
f 6/4/6 94/6/94 93/5/93
f 8/7/8 95/8/95 94/6/94
f 10/9/10 96/10/96 95/8/95
f 12/11/12 97/12/97 96/10/96
f 97/12/97 16/13/16 98/14/98
f 16/13/16 99/15/99 98/14/98
f 99/15/99 20/16/20 100/17/100
f 20/16/20 101/18/101 100/17/100
f 101/18/101 24/19/24 102/20/102
f 24/19/24 103/21/103 102/20/102
f 26/22/26 104/23/104 103/21/103
f 28/24/28 105/25/105 104/23/104
f 105/25/105 32/26/32 106/27/106
f 32/26/32 107/28/107 106/27/106
f 34/29/34 108/30/108 107/28/107
f 36/31/36 91/32/91 108/30/108
f 5/33/5 74/34/74 3/34/3
f 54/35/54 72/36/72 71/37/71
f 53/38/53 71/37/71 70/39/70
f 52/40/52 70/39/70 69/41/69
f 51/42/51 69/41/69 68/43/68
f 50/44/50 68/43/68 67/45/67
f 66/46/66 50/44/50 67/45/67
f 65/47/65 49/48/49 66/46/66
f 47/49/47 65/47/65 64/50/64
f 63/51/63 47/49/47 64/50/64
f 45/52/45 63/51/63 62/53/62
f 120/54/120 45/52/45 62/53/62
f 137/55/137 125/56/125 145/57/145
f 143/58/143 133/59/133 144/59/144
f 142/60/142 128/61/128 130/60/130
f 138/62/138 127/55/127 137/55/137
f 139/63/139 134/64/134 135/65/135
f 38/66/38 119/67/119 55/68/55
f 72/69/72 38/66/38 55/68/55
f 1/70/1 55/68/55 3/34/3
f 55/68/55 5/33/5 3/34/3
f 5/33/5 121/71/121 7/72/7
f 121/71/121 9/73/9 7/72/7
f 122/74/122 11/75/11 9/73/9
f 123/76/123 13/77/13 11/75/11
f 124/78/124 15/79/15 13/77/13
f 15/79/15 62/53/62 17/80/17
f 17/80/17 63/51/63 19/81/19
f 19/81/19 64/50/64 21/82/21
f 64/50/64 23/83/23 21/82/21
f 65/47/65 25/84/25 23/83/23
f 66/46/66 27/85/27 25/84/25
f 67/45/67 29/86/29 27/85/27
f 68/43/68 31/87/31 29/86/29
f 69/41/69 33/88/33 31/87/31
f 70/39/70 35/89/35 33/88/33
f 35/89/35 72/36/72 1/90/1
f 76/91/76 84/92/84 88/93/88
f 15/79/15 79/77/79 13/77/13
f 25/84/25 84/83/84 23/83/23
f 35/89/35 89/88/89 33/88/33
f 11/75/11 77/73/77 9/73/9
f 21/82/21 82/81/82 19/81/19
f 31/87/31 87/86/87 29/86/29
f 7/72/7 75/33/75 5/33/5
f 17/80/17 80/79/80 15/79/15
f 3/34/3 73/70/73 1/70/1
f 27/85/27 85/84/85 25/84/25
f 1/90/1 90/89/90 35/89/35
f 13/77/13 78/75/78 11/75/11
f 23/83/23 83/82/83 21/82/21
f 33/88/33 88/87/88 31/87/31
f 9/73/9 76/72/76 7/72/7
f 19/81/19 81/80/81 17/80/17
f 29/86/29 86/85/86 27/85/27
f 108/30/108 37/94/37 54/35/54
f 107/28/107 54/35/54 53/38/53
f 106/27/106 53/38/53 52/40/52
f 105/25/105 52/40/52 51/42/51
f 104/23/104 51/42/51 50/44/50
f 103/21/103 50/44/50 49/48/49
f 102/20/102 49/48/49 48/95/48
f 101/18/101 48/95/48 47/49/47
f 100/17/100 47/49/47 46/96/46
f 99/15/99 46/96/46 45/52/45
f 98/14/98 45/52/45 114/97/114
f 113/98/113 98/14/98 114/97/114
f 96/10/96 113/98/113 115/99/115
f 95/8/95 115/99/115 116/100/116
f 117/101/117 95/8/95 116/100/116
f 93/5/93 117/101/117 118/102/118
f 38/66/38 93/5/93 118/102/118
f 91/3/91 38/66/38 37/103/37
f 109/104/109 6/4/6 4/105/4
f 109/104/109 8/7/8 6/4/6
f 111/104/111 8/7/8 109/104/109
f 111/104/111 12/11/12 10/9/10
f 111/104/111 14/106/14 12/11/12
f 111/104/111 16/13/16 14/106/14
f 111/104/111 18/107/18 16/13/16
f 111/104/111 20/16/20 18/107/18
f 110/104/110 20/16/20 111/104/111
f 110/104/110 24/19/24 22/108/22
f 110/104/110 26/22/26 24/19/24
f 110/104/110 28/24/28 26/22/26
f 110/104/110 30/109/30 28/24/28
f 110/104/110 32/26/32 30/109/30
f 109/104/109 32/26/32 110/104/110
f 109/104/109 36/31/36 34/29/34
f 109/104/109 2/110/2 36/31/36
f 109/104/109 4/105/4 2/1/2
f 111/104/111 10/9/10 8/7/8
f 110/104/110 22/108/22 20/16/20
f 109/104/109 34/29/34 32/26/32
f 111/104/111 109/104/109 112/104/112
f 110/104/110 111/104/111 112/104/112
f 109/104/109 110/104/110 112/104/112
f 43/111/43 114/97/114 44/59/44
f 42/112/42 113/98/113 43/111/43
f 41/55/41 115/99/115 42/112/42
f 41/55/41 117/101/117 116/100/116
f 40/56/40 118/102/118 117/101/117
f 39/64/39 119/67/119 118/102/118
f 44/59/44 120/54/120 61/58/61
f 57/113/57 119/67/119 56/65/56
f 58/61/58 121/71/121 57/113/57
f 59/60/59 122/74/122 58/61/58
f 59/60/59 124/78/124 123/76/123
f 60/114/60 120/54/120 124/78/124
f 131/111/131 136/58/136 132/114/132
f 129/112/129 132/114/132 130/60/130
f 127/55/127 130/60/130 128/61/128
f 126/113/126 127/55/127 128/61/128
f 135/65/135 125/56/125 126/113/126
f 142/60/142 132/114/132 146/114/146
f 147/115/147 133/59/133 131/111/131
f 148/116/148 135/65/135 126/113/126
f 145/57/145 134/64/134 140/117/140
f 146/114/146 136/58/136 143/58/143
f 138/62/138 131/111/131 129/112/129
f 141/118/141 126/113/126 128/61/128
f 58/61/58 148/116/148 141/118/141
f 42/112/42 147/115/147 138/62/138
f 60/114/60 143/58/143 61/58/61
f 40/56/40 140/117/140 39/64/39
f 57/113/57 139/63/139 148/116/148
f 43/111/43 144/59/144 147/115/147
f 59/60/59 146/114/146 60/114/60
f 56/65/56 140/117/140 139/63/139
f 42/112/42 137/55/137 41/55/41
f 58/61/58 142/60/142 59/60/59
f 61/58/61 144/59/144 44/59/44
f 41/55/41 145/57/145 40/56/40
f 2/1/2 4/105/4 92/2/92
f 92/2/92 4/105/4 6/4/6
f 6/4/6 8/7/8 94/6/94
f 8/7/8 10/9/10 95/8/95
f 10/9/10 12/11/12 96/10/96
f 12/11/12 14/106/14 97/12/97
f 97/12/97 14/106/14 16/13/16
f 16/13/16 18/107/18 99/15/99
f 99/15/99 18/107/18 20/16/20
f 20/16/20 22/108/22 101/18/101
f 101/18/101 22/108/22 24/19/24
f 24/19/24 26/22/26 103/21/103
f 26/22/26 28/24/28 104/23/104
f 28/24/28 30/109/30 105/25/105
f 105/25/105 30/109/30 32/26/32
f 32/26/32 34/29/34 107/28/107
f 34/29/34 36/31/36 108/30/108
f 36/31/36 2/110/2 91/32/91
f 5/33/5 75/33/75 74/34/74
f 54/35/54 37/94/37 72/36/72
f 53/38/53 54/35/54 71/37/71
f 52/40/52 53/38/53 70/39/70
f 51/42/51 52/40/52 69/41/69
f 50/44/50 51/42/51 68/43/68
f 66/46/66 49/48/49 50/44/50
f 65/47/65 48/95/48 49/48/49
f 47/49/47 48/95/48 65/47/65
f 63/51/63 46/96/46 47/49/47
f 45/52/45 46/96/46 63/51/63
f 120/54/120 114/97/114 45/52/45
f 137/55/137 127/55/127 125/56/125
f 143/58/143 136/58/136 133/59/133
f 142/60/142 141/118/141 128/61/128
f 138/62/138 129/112/129 127/55/127
f 139/63/139 140/117/140 134/64/134
f 38/66/38 118/102/118 119/67/119
f 72/69/72 37/103/37 38/66/38
f 1/70/1 72/69/72 55/68/55
f 55/68/55 119/67/119 5/33/5
f 5/33/5 119/67/119 121/71/121
f 121/71/121 122/74/122 9/73/9
f 122/74/122 123/76/123 11/75/11
f 123/76/123 124/78/124 13/77/13
f 124/78/124 120/54/120 15/79/15
f 15/79/15 120/54/120 62/53/62
f 17/80/17 62/53/62 63/51/63
f 19/81/19 63/51/63 64/50/64
f 64/50/64 65/47/65 23/83/23
f 65/47/65 66/46/66 25/84/25
f 66/46/66 67/45/67 27/85/27
f 67/45/67 68/43/68 29/86/29
f 68/43/68 69/41/69 31/87/31
f 69/41/69 70/39/70 33/88/33
f 70/39/70 71/37/71 35/89/35
f 35/89/35 71/37/71 72/36/72
f 90/119/90 73/120/73 74/121/74
f 74/121/74 75/122/75 76/91/76
f 76/91/76 77/123/77 78/124/78
f 78/124/78 79/125/79 80/126/80
f 80/126/80 81/127/81 82/128/82
f 82/128/82 83/129/83 84/92/84
f 84/92/84 85/130/85 86/131/86
f 86/131/86 87/132/87 88/93/88
f 88/93/88 89/133/89 90/119/90
f 90/119/90 74/121/74 76/91/76
f 76/91/76 78/124/78 80/126/80
f 80/126/80 82/128/82 84/92/84
f 84/92/84 86/131/86 88/93/88
f 88/93/88 90/119/90 76/91/76
f 76/91/76 80/126/80 84/92/84
f 15/79/15 80/79/80 79/77/79
f 25/84/25 85/84/85 84/83/84
f 35/89/35 90/89/90 89/88/89
f 11/75/11 78/75/78 77/73/77
f 21/82/21 83/82/83 82/81/82
f 31/87/31 88/87/88 87/86/87
f 7/72/7 76/72/76 75/33/75
f 17/80/17 81/80/81 80/79/80
f 3/34/3 74/34/74 73/70/73
f 27/85/27 86/85/86 85/84/85
f 1/90/1 73/90/73 90/89/90
f 13/77/13 79/77/79 78/75/78
f 23/83/23 84/83/84 83/82/83
f 33/88/33 89/88/89 88/87/88
f 9/73/9 77/73/77 76/72/76
f 19/81/19 82/81/82 81/80/81
f 29/86/29 87/86/87 86/85/86
f 108/30/108 91/32/91 37/94/37
f 107/28/107 108/30/108 54/35/54
f 106/27/106 107/28/107 53/38/53
f 105/25/105 106/27/106 52/40/52
f 104/23/104 105/25/105 51/42/51
f 103/21/103 104/23/104 50/44/50
f 102/20/102 103/21/103 49/48/49
f 101/18/101 102/20/102 48/95/48
f 100/17/100 101/18/101 47/49/47
f 99/15/99 100/17/100 46/96/46
f 98/14/98 99/15/99 45/52/45
f 113/98/113 97/12/97 98/14/98
f 96/10/96 97/12/97 113/98/113
f 95/8/95 96/10/96 115/99/115
f 117/101/117 94/6/94 95/8/95
f 93/5/93 94/6/94 117/101/117
f 38/66/38 92/2/92 93/5/93
f 91/3/91 92/2/92 38/66/38
f 43/111/43 113/98/113 114/97/114
f 42/112/42 115/99/115 113/98/113
f 41/55/41 116/100/116 115/99/115
f 41/55/41 40/56/40 117/101/117
f 40/56/40 39/64/39 118/102/118
f 39/64/39 56/65/56 119/67/119
f 44/59/44 114/97/114 120/54/120
f 57/113/57 121/71/121 119/67/119
f 58/61/58 122/74/122 121/71/121
f 59/60/59 123/76/123 122/74/122
f 59/60/59 60/114/60 124/78/124
f 60/114/60 61/58/61 120/54/120
f 131/111/131 133/59/133 136/58/136
f 129/112/129 131/111/131 132/114/132
f 127/55/127 129/112/129 130/60/130
f 126/113/126 125/56/125 127/55/127
f 135/65/135 134/64/134 125/56/125
f 142/60/142 130/60/130 132/114/132
f 147/115/147 144/59/144 133/59/133
f 148/116/148 139/63/139 135/65/135
f 145/57/145 125/56/125 134/64/134
f 146/114/146 132/114/132 136/58/136
f 138/62/138 147/115/147 131/111/131
f 141/118/141 148/116/148 126/113/126
f 58/61/58 57/113/57 148/116/148
f 42/112/42 43/111/43 147/115/147
f 60/114/60 146/114/146 143/58/143
f 40/56/40 145/57/145 140/117/140
f 57/113/57 56/65/56 139/63/139
f 43/111/43 44/59/44 144/59/144
f 59/60/59 142/60/142 146/114/146
f 56/65/56 39/64/39 140/117/140
f 42/112/42 138/62/138 137/55/137
f 58/61/58 141/118/141 142/60/142
f 61/58/61 143/58/143 144/59/144
f 41/55/41 137/55/137 145/57/145

View File

@@ -1,134 +0,0 @@
#ifndef POLYGON_H
#define POLYGON_H
#include "fastmath.hpp"
#include <iostream>
struct polygon {
vec3 points[3];
decimal delta[9];
bool small = false;
decimal baryFactor;
decimal bounding[4]; // min x, max x, min y, max y
vec3 normals[3];
vec3 colors[3];
vec3 barycentrics;
vec3 boundingBarycentrics;
polygon(const vec3 &v1, const vec3 &v2, const vec3 &v3)
: points{v1, v2, v3}, delta{} {}
polygon() : points{}, delta{} {}
void calcDelta() {
for (int i = 0; i < 3; i++) {
int n = (i + 1) % 3;
delta[i * 3] = points[i].y() - points[n].y();
delta[i * 3 + 1] = points[n].x() - points[i].x();
delta[i * 3 + 2] =
points[i].x() * points[n].y() - points[i].y() * points[n].x();
if (delta[i * 3].i == 0 && delta[i * 3 + 1].i == 0)
small = true;
}
bounding[0] = points[0].x();
bounding[1] = points[0].x();
bounding[2] = points[0].y();
bounding[3] = points[0].y();
for (int i = 1; i < 3; i++) {
if (bounding[0] > points[i].x())
bounding[0] = points[i].x();
if (bounding[1] < points[i].x())
bounding[1] = points[i].x();
if (bounding[2] > points[i].y())
bounding[2] = points[i].y();
if (bounding[3] < points[i].y())
bounding[3] = points[i].y();
}
baryFactor =
(points[1].x() - points[0].x()) * (points[2].y() - points[1].y()) -
(points[1].y() - points[0].y()) * (points[2].x() - points[1].x());
if (baryFactor.isSmall()) {
small = true;
} else
baryFactor = decimal(1.0) / baryFactor;
// std::cout << baryFactor << std::endl;
/*if ((bounding[1].i - bounding[0].i < 1 << HALF_SHIFT) &&
(bounding[3].i - bounding[2].i < 1 << HALF_SHIFT))
small = true;*/
}
vec3 avgNormal() {
vec3 result;
for (int i = 0; i < 3; i++) {
result += normals[i];
}
return result * decimal(0.3333);
}
const bool depContains(const vec3 &p) {
// if (skip)
// return false;
for (int i = 0; i < 3; i++) {
if (small)
return true;
vec3 d = p;
if ((d.x() * delta[i * 3] + d.y() * delta[i * 3 + 1] +
delta[i * 3 + 2]) > decimal(0.2))
return false;
}
return true;
}
const bool contains(const vec3 &p) {
if (small)
return true;
else
return (barycentrics[0] >= decimal(-0.01)) &&
(barycentrics[1] >= decimal(-0.01)) &&
(barycentrics[2] >= decimal(-0.01));
}
friend std::ostream &operator<<(std::ostream &os, const polygon &p) {
for (int i = 0; i < 3; i++) {
os << p.points[i];
}
return os;
}
vec3 calcNormal() {
return normals[0] * boundingBarycentrics[0] +
normals[1] * boundingBarycentrics[1] +
normals[2] * boundingBarycentrics[2];
}
vec3 calcColor() {
return colors[0] * boundingBarycentrics[0] +
colors[1] * boundingBarycentrics[1] +
colors[2] * boundingBarycentrics[2];
}
decimal calcDepth() {
return points[0].z() * boundingBarycentrics[0] +
points[1].z() * boundingBarycentrics[1] +
points[2].z() * boundingBarycentrics[2];
}
void calcBarycentric(vec3 s) {
// if (small)
// return vec3(decimal(0.333), decimal(0.333), decimal(0.333));
barycentrics[0] = (points[1].x() - s.x()) * (points[2].y() - s.y()) -
(points[2].x() - s.x()) * (points[1].y() - s.y());
barycentrics[1] = (points[2].x() - s.x()) * (points[0].y() - s.y()) -
(points[0].x() - s.x()) * (points[2].y() - s.y());
barycentrics = barycentrics * baryFactor;
barycentrics[2] = decimal(1.0) - barycentrics[1] - barycentrics[0];
// return result;
boundingBarycentrics = vec3::max(
vec3::min(barycentrics, vec3(1.0, 1.0, 1.0)), vec3(0.0, 0.0, 0.0));
}
};
#endif

View File

@@ -1,136 +0,0 @@
#ifndef RENDERER_H
#define RENDERER_H
#include "fastmath.hpp"
#include "model.hpp"
#include "polygon.hpp"
#include "rendertarget.hpp"
#include <bits/stdc++.h>
#include <cstring>
#include <memory.h>
#define SCREEN_SPACE_SIZE 8.0
class Renderer {
public:
Rendertarget *target;
bool clearTarget = true;
vec3 sunDir = vec3(1.0, -1.0, 1.0).normalize();
void toScreenSpace(vec3 *np, mat4 matrix) {
vec4 tp = (matrix * vec4(*np, decimal(1.0f)));
tp.x() = tp.x() / tp.z() * decimal(2.0) * decimal(SCREEN_SPACE_SIZE) +
decimal(SCREEN_SPACE_SIZE);
tp.y() = tp.y() / tp.z() * decimal(2.0) * decimal(SCREEN_SPACE_SIZE) +
decimal(SCREEN_SPACE_SIZE);
*np = vec3(tp.x(), tp.y(), tp.z());
}
void render(const model *model, const mat4 matrix) {
decimal widthScale =
decimal(SCREEN_SPACE_SIZE * 2) / decimal((float)target->width);
decimal heightScale =
decimal(SCREEN_SPACE_SIZE * 2) / decimal((float)target->height);
decimal invWidthScale =
decimal((float)(target->width / SCREEN_SPACE_SIZE / 2));
decimal invHeightScale =
decimal((float)(target->height / SCREEN_SPACE_SIZE / 2));
// TODO clear target with memset
if (clearTarget) {
// memset((wchar_t *)target->pixels, 0,
// target->height * target->width * sizeof(target[0]));
target->clearDepth();
target->clearTarget();
}
vec3 verts[model->verts.size()] = {};
std::copy(model->verts.begin(), model->verts.end(), verts);
for (int i = 0; i < model->verts.size(); i++) {
toScreenSpace(verts + i, matrix);
}
vec3 normals[model->normals.size()] = {};
mat3 normalMatrix = matrix.cutTo<mat3>();
for (int i = 0; i < model->normals.size(); i++) {
normals[i] = normalMatrix * model->normals[i];
}
polygon testP;
for (int f = 0; f < model->faces.size(); f += 3) {
testP.small = false;
for (int p = 0; p < 3; p++) {
testP.points[p] = verts[std::get<0>(model->faces[f + p])];
testP.colors[p] =
model->colors[std::get<0>(model->faces[f + p])];
testP.normals[p] = normals[std::get<1>(model->faces[f + p])];
}
if ((testP.avgNormal() * vec3(0.0, 0.0, 1.0)) > decimal(0.))
continue;
testP.calcDelta();
int startX = std::max<int>(
(testP.bounding[0] * invWidthScale).i >> SHIFT_AMOUNT, 0);
int endX = std::min<int>((testP.bounding[1] * invWidthScale).i >>
SHIFT_AMOUNT,
(uint32_t)target->width - 1);
int startY = std::max<int>(
(testP.bounding[2] * invHeightScale).i >> SHIFT_AMOUNT, 0);
int endY = std::min<int>((testP.bounding[3] * invHeightScale).i >>
SHIFT_AMOUNT,
target->height - 1);
vec3 pos = vec3(testP.bounding[0], testP.bounding[2], 0.0);
for (int x = startX; x < endX; x++) {
for (int y = startY; y < endY; y++) {
if (testP.depContains(pos)) {
testP.calcBarycentric(pos);
decimal depth = testP.calcDepth();
if (depth < target->getDepth(x, y)) {
// std::cout << factors << std::endl;
vec3 normal = testP.calcNormal();
vec3 color = testP.calcColor();
decimal lightFac =
std::max(normal * (-sunDir), decimal(0.0)) +
decimal(0.5);
;
target->setDepth(x, y, depth);
target->set(x, y,
(color * decimal(120.0)) * lightFac);
// target->set(x, y,
// vec3(lightFac * decimal(200.0), 0, 0));
// target->set(x, y,
// (normal + vec3(1.0, 1.0, 1.0)) *
// decimal(120.0));
// target->set(
// x, y,
// (testP.avgNormal() + vec3(1.0, 1.0, 1.0)) *
// decimal(120.0));
// target->set(x, y,
// testP.barycentrics * decimal(200.0));
// if (!factors.isSmall())
// target->set(x, y, vec3(0., 255.0, 0.));
}
// target->set(x, y, vec3(0.0, 255.0, 0.0));
}
pos.y() += heightScale;
}
pos.y() = decimal(testP.bounding[2]);
pos.x() += widthScale;
}
}
}
};
#endif

View File

@@ -1,45 +0,0 @@
#ifndef RENDERTARGET_H
#define RENDERTARGET_H
#include "fastmath.hpp"
class Rendertarget {
public:
const int width;
const int height;
Rendertarget(int width, int height) : width(width), height(height) {
pixels = new uint8_t[width * height * 3];
depth = new decimal[width * height];
for (int i = 0; i < width * height * 3; i++) {
pixels[i] = 0;
}
}
void set(int x, int y, vec3 val) {
int start = (width * y + x) * 3;
for (int i = 0; i < 3; i++) {
pixels[start + i] = (uint8_t)(val[i].i >> SHIFT_AMOUNT);
}
}
decimal getDepth(int x, int y) { return depth[width * y + x]; }
void setDepth(int x, int y, decimal val) { depth[width * y + x] = val; }
void clearDepth() {
for (int i = 0; i < width * height; i++) {
depth[i].i = std::numeric_limits<int32_t>::max();
}
}
void clearTarget() {
for (int i = 0; i < width * height * 3; i++) {
pixels[i] = 0;
}
}
uint8_t *pixels;
decimal *depth;
};
#endif

30
src/athmosphere.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef ATHMOSPHERE_H
#define ATHMOSPHERE_H
#include "linmath.h"
#include "rendertarget.h"
void renderAthmosphere(render_target *target, const mat4x4 invProj) {
float widthF = 2. / target->width;
float heightF = 2. / target->height;
for (int y = 0; y < target->height; y++) {
for (int x = 0; x < target->width; x++) {
vec4 tmp = {((float)x) * widthF - 1.f, ((float)y) * heightF - 1.0f,
((float)target_get_depth(target, x, y)) / 65536.0f, 1.0f};
// vec4_scale(tmp, tmp, 1.0f / tmp[2]);
vec4 pos;
mat4x4_mul_vec4(pos, invProj, tmp);
vec4_scale(pos, pos, 1.0f / pos[3]);
// pos[2] = -pos[2];
vec4_scale(pos, pos, -.1f);
// vec4_scale(tmp, tmp, -1.f);
// tmp[3] = -tmp[2];
vec3_set(pos, pos[2]);
target_set_color(target, x, y, pos);
}
}
}
#endif

123
src/game.h Normal file
View File

@@ -0,0 +1,123 @@
#ifndef GAME_H
#define GAME_H
#include "gameObjs.h"
#include "linmath.h"
#include "renderer.h"
typedef struct {
vec2 pos;
float holeSize;
uint8_t isUsed;
} obsticale_data;
void updateObsticales(renderData *rData) {
mat4x4 transform = {};
mat4x4 draw = {};
for (int i = 0; i < nextGameObj; i++) {
gameObj *obst = gameObjs + i;
// printf("render Obst\n");
if (!(obst->type & 2))
continue;
if (!(obst->inUse))
continue;
obst->transform[3][1] -= rData->deltaTime * 2;
mat4x4_identity(transform);
transform[0][0] = 2.0f;
printf("Obj ID: %d, Hole Size: %f", i, obst->holeSize);
mat4x4_getPos(transform)[0] = obst->transform[3][0] - obst->holeSize * 0.5;
mat4x4_getPos(transform)[1] = obst->transform[3][1];
mat4x4_getPos(transform)[2] = -10;
mat4x4_mul(draw, rData->projMat, transform);
render(rData->target, obst->model, &draw, rData->vert_buffer);
mat4x4_getPos(transform)[0] =
obst->transform[3][0] + 8 + obst->holeSize * 0.5;
// mat4x4_scale_aniso(transform, transform, 1, -1, 1);
mat4x4_mul(draw, rData->projMat, transform);
render(rData->target, obst->model, &draw, rData->vert_buffer);
if (obst->transform[3][1] < -5.0f)
obst->inUse = 0;
}
}
void spawnObst(float posX, float holeSize) {
for (int i = 0; i < nextGameObj; i++) {
gameObj *obst = gameObjs + i;
if (!(obst->type & 2))
continue;
if (obst->inUse)
continue;
obst->inUse = 1;
obst->transform[3][0] = posX;
obst->transform[3][1] = 4.0f;
obst->holeSize = holeSize;
return;
}
}
void drawRocket(renderData *rData) {
mat4x4 drawMat = {};
for (int i = 0; i < nextGameObj; i++) {
gameObj *rocket = gameObjs + i;
if (rocket->transform[3][0] < -4.5) {
// vec3_set(rocket->velocity, 0.0f);
rocket->transform[3][0] = 4.5f;
}
if (rocket->transform[3][0] > 4.5) {
// vec3_set(rocket->velocity, 0.0f);
rocket->transform[3][0] = -4.5f;
}
if (!(rocket->type & 1))
continue;
mat4x4_translate_in_place(rocket->transform,
rocket->velocity[0] * rData->deltaTime,
rocket->velocity[1] * rData->deltaTime,
rocket->velocity[2] * rData->deltaTime);
mat4x4_mul(drawMat, rData->projMat, rocket->transform);
render(rData->target, rocket->model, &drawMat, rData->vert_buffer);
}
}
void drawPlanet(renderData *rData) {
mat4x4 drawMat = {};
for (int i = 0; i < nextGameObj; i++) {
gameObj *planet = gameObjs + i;
if (!(planet->type & 4))
continue;
mat4x4_mul(drawMat, rData->projMat, planet->transform);
render(rData->target, planet->model, &drawMat, rData->vert_buffer);
}
}
uint8_t didHit(gameObj *obj) {
for (int i = 0; i < nextGameObj; i++) {
gameObj *obst = gameObjs + i;
if (!(obst->type & 2))
continue;
if ((obj->transform[3][0] - obj->hitBox[0] * 0.5 <
obst->transform[3][0] - obst->holeSize * 0.5 ||
obj->transform[3][0] + obj->hitBox[0] * 0.5 >
obst->transform[3][0] + obst->holeSize * 0.5) &&
(obj->transform[3][1] - obj->hitBox[1] * 0.5 <
obst->transform[3][1] + obst->hitBox[1] * 0.5 &&
obj->transform[3][1] + obj->hitBox[1] * 0.5 >
obst->transform[3][1] - obst->hitBox[1] * 0.5)) {
return 1;
}
}
return 0;
}
#endif

82
src/gameObjs.h Normal file
View File

@@ -0,0 +1,82 @@
#ifndef GAME_OBJ_H
#define GAME_OBJ_H
#include "linmath.h"
#include "models/fairyDust.h"
#include "models/obstical.h"
#include "models/planet.h"
#include "renderer.h"
typedef struct {
mat4x4 transform;
vec3 velocity;
vec2 hitBox;
const model *model;
float holeSize;
uint8_t type; // 1 Obst, 0 Rocket
uint8_t inUse;
} gameObj;
#define OBST_CNT 3
int nextGameObj = 3;
gameObj gameObjs[16] = {{{{0.5, 0., 0., 0.},
{0., 0.5, 0., 0.},
{0., 0., 0.5, 0.},
{0., -3.0f, -10., 1.}},
{0.0, 0.0, 0.0},
{0.3f, .5f},
&fairyDust_model,
1,
1},
{{{0.5, 0., 0., 0.},
{0., 0.5, 0., 0.},
{0., 0., 0.5, 0.},
{0., +3.0f, -10., 1.}},
{0.0, 0.0, 0.0},
{0.3f, .5f},
&fairyDust_model,
1,
1},
{{{1., 0., 0., 0.},
{0., 1., 0., 0.},
{0., 0., 1., 0.},
{0., .0f, -15., 1.}},
{0.0, 0.0, 0.0},
{0.0f, .0f},
&planet_model,
4,
1}};
const model *allModel[] = {&fairyDust_model, &obstical_model};
void init_obsts() {
mat4x4 transform = {{1.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0},
{0.0, 0.0, 1.0, 0.0},
{0.0, 0.0, -10.0, 1.0}};
vec3 vel = {0};
for (int i = 0; i < OBST_CNT; i++) {
mat4x4_dup(gameObjs[nextGameObj].transform, transform);
vec3_dup(gameObjs[nextGameObj].velocity, vel);
gameObjs[nextGameObj].hitBox[0] = 4.0f;
gameObjs[nextGameObj].hitBox[1] = 1.0f;
gameObjs[nextGameObj].model = &obstical_model;
gameObjs[nextGameObj].holeSize = 0.f;
gameObjs[nextGameObj].type = 2;
gameObjs[nextGameObj].inUse = 0;
nextGameObj++;
}
}
int vertBufferSize() {
int count = sizeof(allModel) / sizeof(void *);
int result = 0;
for (int i = 0; i < count; i++) {
if (result < allModel[i]->vert_size) {
result = allModel[i]->vert_size;
}
}
return result * sizeof(vec4);
}
#endif

View File

@@ -17,8 +17,10 @@
#define REPEAT_2(FN) REPEAT_1(FN) FN(1) #define REPEAT_2(FN) REPEAT_1(FN) FN(1)
#define REPEAT_3(FN) REPEAT_2(FN) FN(2) #define REPEAT_3(FN) REPEAT_2(FN) FN(2)
#define REPEAT_4(FN) REPEAT_3(FN) FN(3) #define REPEAT_4(FN) REPEAT_3(FN) FN(3)
#define REPEAT_4N(FN) REPEAT_3(FN) FN(3)
#define add(i) r[i] = a[i] + b[i]; #define add(i) r[i] = a[i] + b[i];
#define set(i) r[i] = v;
#define sub(i) r[i] = a[i] - b[i]; #define sub(i) r[i] = a[i] - b[i];
#define scale(i) r[i] = v[i] * s; #define scale(i) r[i] = v[i] * s;
#define add_scale(i) r[i] = v[i] * s; #define add_scale(i) r[i] = v[i] * s;
@@ -29,6 +31,9 @@
#define LINMATH_H_DEFINE_VEC(n) \ #define LINMATH_H_DEFINE_VEC(n) \
typedef float vec##n[n]; \ typedef float vec##n[n]; \
LINMATH_H_FUNC void vec##n##_set(vec##n r, float const v) { \
REPEAT_##n(set); \
} \
LINMATH_H_FUNC void vec##n##_add(vec##n r, vec##n const a, vec##n const b) { \ LINMATH_H_FUNC void vec##n##_add(vec##n r, vec##n const a, vec##n const b) { \
REPEAT_##n(add); \ REPEAT_##n(add); \
} \ } \
@@ -87,6 +92,7 @@ LINMATH_H_DEFINE_VEC(2)
LINMATH_H_DEFINE_VEC(3) LINMATH_H_DEFINE_VEC(3)
LINMATH_H_DEFINE_VEC(4) LINMATH_H_DEFINE_VEC(4)
#undef set
#undef add #undef add
#undef sub #undef sub
#undef scale #undef scale
@@ -124,6 +130,9 @@ LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 const v, vec4 const n) {
} }
typedef vec4 mat4x4[4]; typedef vec4 mat4x4[4];
LINMATH_H_FUNC float *mat4x4_getPos(mat4x4 M) { return M[3]; }
LINMATH_H_FUNC void mat4x4_identity(mat4x4 M) { LINMATH_H_FUNC void mat4x4_identity(mat4x4 M) {
int i, j; int i, j;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
@@ -186,14 +195,36 @@ LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b) {
} }
mat4x4_dup(M, temp); mat4x4_dup(M, temp);
} }
LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 const M, vec4 const v) { LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 const M, vec4 const v) {
int i, j; r[0] = M[0][0] * v[0];
for (j = 0; j < 4; ++j) { r[0] += M[1][0] * v[1];
r[j] = 0.f; r[0] += M[2][0] * v[2];
for (i = 0; i < 4; ++i) r[0] += M[3][0] * v[3];
r[j] += M[i][j] * v[i];
} r[1] = M[0][1] * v[0];
r[1] += M[1][1] * v[1];
r[1] += M[2][1] * v[2];
r[1] += M[3][1] * v[3];
r[2] = M[0][2] * v[0];
r[2] += M[1][2] * v[1];
r[2] += M[2][2] * v[2];
r[2] += M[3][2] * v[3];
r[3] = M[0][3] * v[0];
r[3] += M[1][3] * v[1];
r[3] += M[2][3] * v[2];
r[3] += M[3][3] * v[3];
} }
// LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 const M, vec4 const v) {
// int i, j;
// for (j = 0; j < 4; ++j) {
// r[j] = 0.f;
// for (i = 0; i < 4; ++i)
// r[j] += M[i][j] * v[i];
// }
// }
LINMATH_H_FUNC void mat4x4_translate(mat4x4 T, float x, float y, float z) { LINMATH_H_FUNC void mat4x4_translate(mat4x4 T, float x, float y, float z) {
mat4x4_identity(T); mat4x4_identity(T);
T[3][0] = x; T[3][0] = x;

View File

@@ -1,5 +1,7 @@
#include "athmosphere.h"
#include "game.h"
#include "gameObjs.h"
#include "linmath.h" #include "linmath.h"
#include "models/plane.h"
#include "renderer.h" #include "renderer.h"
#include <signal.h> #include <signal.h>
#include <stdint.h> #include <stdint.h>
@@ -9,10 +11,11 @@
#include <termios.h> #include <termios.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <zlib.h>
#define PI 3.141592653589793f #define PI 3.141592653589793f
#define WIDTH 512 #define WIDTH 1024
#define HEIGHT 512 #define HEIGHT 1024
#define PIX_COUNT (WIDTH * HEIGHT) #define PIX_COUNT (WIDTH * HEIGHT)
volatile sig_atomic_t stop = 0; volatile sig_atomic_t stop = 0;
@@ -31,22 +34,25 @@ static char encoding_table[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
void base64encode(render_target *t, char *buff) { void base64encode(render_target *t, char *buff) {
for (int i = 0; i < PIX_COUNT * 4; i += 4) { for (int i = 0; i < PIX_COUNT; i++) {
uint8_t r = t->pixels[i]; int start = i * 3;
uint8_t g = t->pixels[i + 1]; uint8_t r = t->pixels[start];
uint8_t b = t->pixels[i + 2]; uint8_t g = t->pixels[start + 1];
uint8_t b = t->pixels[start + 2];
int s = 0; int s = 0;
s |= r << 16; s |= r << 16;
s |= g << 8; s |= g << 8;
s |= b; s |= b;
buff[i] = encoding_table[s >> 18]; start = i * 4;
buff[start] = encoding_table[s >> 18];
s &= 0777777; s &= 0777777;
buff[i + 1] = encoding_table[s >> 12]; buff[start + 1] = encoding_table[s >> 12];
s &= 07777; s &= 07777;
buff[i + 2] = encoding_table[s >> 6]; buff[start + 2] = encoding_table[s >> 6];
s &= 077; s &= 077;
buff[i + 3] = encoding_table[s]; buff[start + 3] = encoding_table[s];
} }
} }
@@ -99,22 +105,16 @@ int main(void) {
setupKeyboard(); setupKeyboard();
render_target target = {WIDTH, HEIGHT, malloc(PIX_COUNT * 4)}; render_target target = {WIDTH, HEIGHT, malloc(PIX_COUNT * 3),
malloc(PIX_COUNT * 2)};
clearTarget(&target); clearTarget(&target);
// model m; renderData rData = {0, {}, &target, malloc(vertBufferSize())};
// m = create_model((vec3[]){{-2.0f, -2.0f, -10.0f},
// {-2.0f, 2.0f, -10.0f},
// {2.0f, 2.0f, -10.0f},
// {2.0f, -2.0f, -10.0f}},
// (int[]){0, 2, 1, 0, 3, 2}, 4, 6);
// vec3_print(m.verts[0]);
vec4 *buffer = malloc(sizeof(vec4) * testModel.vert_size);
mat4x4 projMat = {};
mat4x4 viewMat = {}; mat4x4 viewMat = {};
mat4x4 drawMat = {}; mat4x4 drawMat = {};
mat4x4_identity(viewMat); mat4x4_identity(viewMat);
mat4x4_perspective(projMat, 45.0 / 180.0 * PI, 1, 2.f, 20.0f); mat4x4_perspective(rData.projMat, 45.0 / 180.0 * PI, 1, 0.1f, 40.0f);
const int buffSize = PIX_COUNT * 4; const int buffSize = PIX_COUNT * 4;
@@ -125,13 +125,22 @@ int main(void) {
clock_t start = clock(); clock_t start = clock();
clock_t now = clock(); clock_t now = clock();
clock_t renderC; clock_t renderC;
clock_t athmosC;
clock_t lastDeploy = clock();
init_obsts();
gameObj *rocket = gameObjs;
gameObj *deploy = gameObjs + 1;
gameObj *planet = gameObjs + 2;
while (!stop) { while (!stop) {
now = clock(); now = clock();
printf("total time: %fms\n", rData.deltaTime = ((float)(now - start)) / CLOCKS_PER_SEC;
((float)(now - start)) / (0.001 * CLOCKS_PER_SEC));
printf("render time: %fms\n", ((float)renderC) / (0.001 * CLOCKS_PER_SEC));
start = now; start = now;
printf("total time: %fms\n", rData.deltaTime * 1000);
printf("render time: %fms\n", ((float)renderC) / (0.001 * CLOCKS_PER_SEC));
printf("athmos time: %fms\n", ((float)athmosC) / (0.001 * CLOCKS_PER_SEC));
if (read(STDIN_FILENO, &lastKey, 1) == -1) { if (read(STDIN_FILENO, &lastKey, 1) == -1) {
perror("read failed"); perror("read failed");
@@ -139,30 +148,79 @@ int main(void) {
continue; continue;
} }
float v = 1.0f - powf(0.01f, rData.deltaTime);
switch (lastKey) { switch (lastKey) {
case 'w': // case 'w':
mat4x4_translate_in_place(viewMat, 0, 0, -0.2); // rocket.velocity[1] = (rocket.velocity[1] * 0.9 + 20 * 0.1);
break; //
case 's': // // mat4x4_translate_in_place(viewMat, 0, 0, -0.2);
mat4x4_translate_in_place(viewMat, 0, 0, 0.2); // break;
break; // case 's':
// mat4x4_translate_in_place(viewMat, 0, 0, 0.2);
// break;
case 'a': case 'a':
mat4x4_translate_in_place(viewMat, -0.2, 0, 0); // mat4x4_translate_in_place(viewMat, -0.2, 0, 0);
rocket->velocity[0] =
rocket->velocity[0] + v * (-15.0f - rocket->velocity[0]);
break; break;
case 'd': case 'd':
mat4x4_translate_in_place(viewMat, 0.2, 0, 0); // mat4x4_translate_in_place(viewMat, 0.2, 0, 0);
rocket->velocity[0] =
rocket->velocity[0] + v * (15.0f - rocket->velocity[0]);
break;
case 'j':
// mat4x4_translate_in_place(viewMat, -0.2, 0, 0);
deploy->velocity[0] =
deploy->velocity[0] + v * (-15.0f - deploy->velocity[0]);
break;
case 'k':
// mat4x4_translate_in_place(viewMat, 0.2, 0, 0);
deploy->velocity[0] =
deploy->velocity[0] + v * (15.0f - deploy->velocity[0]);
break;
case 'h':
// mat4x4_rotate_Y(planet->transform, planet->transform,
// 0.1 * rData.deltaTime);
break;
case '\n':
// mat4x4_translate_in_place(viewMat, 0.2, 0, 0);
if (((float)(clock() - lastDeploy)) / CLOCKS_PER_SEC > 2.0f) {
lastDeploy = clock();
spawnObst(deploy->transform[3][0], 1.5f);
}
break; break;
} }
lastKey = 0; lastKey = 0;
printf("%f", ((float)(clock() - lastDeploy)) / CLOCKS_PER_SEC);
// mat4x4_translate_in_place(viewMat, 0, 0, .1); // rocket->velocity[1] +=
mat4x4_mul(drawMat, projMat, viewMat); // (-4.0f + 0.5 * powf(MIN(rocket->velocity[1], 0.0), 2.0f)) *
// rData.deltaTime;
// float v = rData.deltaTime*10;
// v = 1.0f - powf(0.7f, rData.deltaTime);
// rocket->velocity[0] =
// rocket->velocity[0] + v * (0.0f - rocket->velocity[0]);
// mat4x4_mul(drawMat, rData.projMat, viewMat);
clearTarget(&target); clearTarget(&target);
renderC = clock(); renderC = clock();
render(&target, &testModel, &drawMat, buffer); drawRocket(&rData);
updateObsticales(&rData);
drawPlanet(&rData);
renderC = clock() - renderC; renderC = clock() - renderC;
mat4x4 invProj;
mat4x4_invert(invProj, rData.projMat);
athmosC = clock();
// renderAthmosphere(&target, invProj);
athmosC = clock() - athmosC;
if (didHit(rocket)) {
stop = 1;
}
base64encode(&target, encodeBuff); base64encode(&target, encodeBuff);
printf("\033[H"); printf("\033[H");
printImage(encodeBuff); printImage(encodeBuff);

2
src/models/fairyDust.h Normal file

File diff suppressed because one or more lines are too long

2
src/models/obstical.h Normal file
View File

@@ -0,0 +1,2 @@
#include "../renderer.h"
const model obstical_model = {(vec3[]){{-4.000000,0.305749,0.305749},{-0.000000,0.305749,0.305749},{-4.000000,0.305749,-0.305749},{-0.000000,0.305749,-0.305749},{-4.000000,-0.305750,0.305749},{0.000000,-0.305749,0.305749},{-4.000000,-0.305750,-0.305749},{0.000000,-0.305749,-0.305749}},(int[]){1,0,2,0,0,0,3,1,6,1,2,1,7,2,4,2,6,2,5,3,0,3,4,3,6,4,0,4,2,4,3,5,5,5,7,5,1,0,3,0,2,0,3,1,7,1,6,1,7,2,5,2,4,2,5,3,1,3,0,3,6,4,4,4,0,4,3,5,1,5,5,5},(vec3[]){{-0.0000,1.0000,-0.0000},{-0.0000,-0.0000,-1.0000},{-0.0000,-1.0000,-0.0000},{-0.0000,-0.0000,1.0000},{-1.0000,-0.0000,-0.0000},{1.0000,-0.0000,-0.0000}},(vec3[]){{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000},{1.0000,1.0000,1.0000}},8,72,12.5};

View File

@@ -1,2 +0,0 @@
#include "../renderer.h"
const model testModel = {(vec3[]){{1.000000,1.000000,-11.000000},{1.000000,-1.000000,-11.000000},{1.000000,1.000000,-9.000000},{1.000000,-1.000000,-9.000000},{-1.000000,1.000000,-11.000000},{-1.000000,-1.000000,-11.000000},{-1.000000,1.000000,-9.000000},{-1.000000,-1.000000,-9.000000}},(int[]){4,2,0,2,7,3,6,5,7,1,7,5,0,3,1,4,1,5,4,6,2,2,6,7,6,4,5,1,3,7,0,2,3,4,0,1},8,36};

2
src/models/planet.h Normal file
View File

@@ -0,0 +1,2 @@
#include "../renderer.h"
const model planet_model = {(vec3[]){{0.000000,-2.000000,0.000000},{1.447215,-0.894439,1.051451},{-0.552776,-0.894440,1.701298},{-1.788852,-0.894431,0.000000},{-0.552776,-0.894440,-1.701298},{1.447215,-0.894439,-1.051451},{0.552776,0.894440,1.701298},{-1.447215,0.894439,1.051451},{-1.447215,0.894439,-1.051451},{0.552776,0.894440,-1.701298},{1.788852,0.894431,0.000000},{0.000000,2.000000,0.000000},{-0.324911,-1.701309,0.999991},{0.850645,-1.701308,0.618023},{0.525738,-1.051475,1.618023},{1.701296,-1.051472,0.000000},{0.850645,-1.701308,-0.618023},{-1.051460,-1.701303,0.000000},{-1.376379,-1.051472,0.999994},{-0.324911,-1.701309,-0.999991},{-1.376379,-1.051472,-0.999994},{0.525738,-1.051475,-1.618023},{1.902116,0.000000,0.618025},{1.902116,0.000000,-0.618025},{0.000000,0.000000,2.000000},{1.175571,0.000000,1.618033},{-1.902116,0.000000,0.618025},{-1.175571,0.000000,1.618033},{-1.175571,0.000000,-1.618033},{-1.902116,0.000000,-0.618025},{1.175571,0.000000,-1.618033},{0.000000,0.000000,-2.000000},{1.376379,1.051472,0.999994},{-0.525738,1.051475,1.618023},{-1.701296,1.051472,0.000000},{-0.525738,1.051475,-1.618023},{1.376379,1.051472,-0.999994},{0.324911,1.701309,0.999991},{1.051460,1.701303,0.000000},{-0.850645,1.701308,0.618023},{-0.850645,1.701308,-0.618023},{0.324911,1.701309,-0.999991}},(int[]){0,0,13,13,12,12,1,1,13,13,15,15,0,0,12,12,17,17,0,0,17,17,19,19,0,0,19,19,16,16,1,1,15,15,22,22,2,2,14,14,24,24,3,3,18,18,26,26,4,4,20,20,28,28,5,5,21,21,30,30,1,1,22,22,25,25,2,2,24,24,27,27,3,3,26,26,29,29,4,4,28,28,31,31,5,5,30,30,23,23,6,6,32,32,37,37,7,7,33,33,39,39,8,8,34,34,40,40,9,9,35,35,41,41,10,10,36,36,38,38,38,38,41,41,11,11,38,38,36,36,41,41,36,36,9,9,41,41,41,41,40,40,11,11,41,41,35,35,40,40,35,35,8,8,40,40,40,40,39,39,11,11,40,40,34,34,39,39,34,34,7,7,39,39,39,39,37,37,11,11,39,39,33,33,37,37,33,33,6,6,37,37,37,37,38,38,11,11,37,37,32,32,38,38,32,32,10,10,38,38,23,23,36,36,10,10,23,23,30,30,36,36,30,30,9,9,36,36,31,31,35,35,9,9,31,31,28,28,35,35,28,28,8,8,35,35,29,29,34,34,8,8,29,29,26,26,34,34,26,26,7,7,34,34,27,27,33,33,7,7,27,27,24,24,33,33,24,24,6,6,33,33,25,25,32,32,6,6,25,25,22,22,32,32,22,22,10,10,32,32,30,30,31,31,9,9,30,30,21,21,31,31,21,21,4,4,31,31,28,28,29,29,8,8,28,28,20,20,29,29,20,20,3,3,29,29,26,26,27,27,7,7,26,26,18,18,27,27,18,18,2,2,27,27,24,24,25,25,6,6,24,24,14,14,25,25,14,14,1,1,25,25,22,22,23,23,10,10,22,22,15,15,23,23,15,15,5,5,23,23,16,16,21,21,5,5,16,16,19,19,21,21,19,19,4,4,21,21,19,19,20,20,4,4,19,19,17,17,20,20,17,17,3,3,20,20,17,17,18,18,3,3,17,17,12,12,18,18,12,12,2,2,18,18,15,15,16,16,5,5,15,15,13,13,16,16,13,13,0,0,16,16,12,12,14,14,2,2,12,12,13,13,14,14,13,13,1,1,14,14},(vec3[]){{-0.0000,-1.0000,-0.0000},{0.7236,-0.4472,0.5257},{-0.2764,-0.4472,0.8506},{-0.8944,-0.4472,-0.0000},{-0.2764,-0.4472,-0.8506},{0.7236,-0.4472,-0.5257},{0.2764,0.4472,0.8506},{-0.7236,0.4472,0.5257},{-0.7236,0.4472,-0.5257},{0.2764,0.4472,-0.8506},{0.8944,0.4472,-0.0000},{-0.0000,1.0000,-0.0000},{-0.1625,-0.8507,0.5000},{0.4253,-0.8507,0.3090},{0.2629,-0.5257,0.8090},{0.8506,-0.5257,-0.0000},{0.4253,-0.8507,-0.3090},{-0.5257,-0.8507,-0.0000},{-0.6882,-0.5257,0.5000},{-0.1625,-0.8507,-0.5000},{-0.6882,-0.5257,-0.5000},{0.2629,-0.5257,-0.8090},{0.9511,-0.0000,0.3090},{0.9511,-0.0000,-0.3090},{-0.0000,-0.0000,1.0000},{0.5878,-0.0000,0.8090},{-0.9511,-0.0000,0.3090},{-0.5878,-0.0000,0.8090},{-0.5878,-0.0000,-0.8090},{-0.9511,-0.0000,-0.3090},{0.5878,-0.0000,-0.8090},{-0.0000,-0.0000,-1.0000},{0.6882,0.5257,0.5000},{-0.2629,0.5257,0.8090},{-0.8506,0.5257,-0.0000},{-0.2629,0.5257,-0.8090},{0.6882,0.5257,-0.5000},{0.1625,0.8507,0.5000},{0.5257,0.8507,-0.0000},{-0.4253,0.8507,0.3090},{-0.4253,0.8507,-0.3090},{0.1625,0.8507,-0.5000}},(vec3[]){{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887},{0.4368,0.6047,0.7887}},42,480,12.5};

View File

@@ -4,13 +4,16 @@
#include "linmath.h" #include "linmath.h"
#include "rendertarget.h" #include "rendertarget.h"
#define EXPOSURE 2
typedef struct { typedef struct {
vec3 *verts; vec3 *verts;
// vec3 *normals;
// vec3 *color;
int *index; int *index;
vec3 *normals;
vec3 *color;
int vert_size; int vert_size;
int index_size; int index_size;
float shininess;
} model; } model;
typedef struct { typedef struct {
@@ -27,6 +30,13 @@ typedef struct {
vec3 barycentrics; vec3 barycentrics;
} polygon; } polygon;
typedef struct {
float deltaTime;
mat4x4 projMat;
render_target *target;
vec4 *vert_buffer;
} renderData;
// model static inline create_model(vec3 *verts, int *index, int vert_size, // model static inline create_model(vec3 *verts, int *index, int vert_size,
// int index_size) { // int index_size) {
// model m = {verts, 0, 0, index, vert_size, index_size}; // model m = {verts, 0, 0, index, vert_size, index_size};
@@ -34,6 +44,8 @@ typedef struct {
// vec3_print(verts[0]); // vec3_print(verts[0]);
// return m; // return m;
// }; // };
//
const vec3 lightDir = {0.707, 0.707, 0.0f};
void initPoly(polygon *p) { void initPoly(polygon *p) {
vec4 **points = p->points; vec4 **points = p->points;
@@ -88,11 +100,24 @@ void calcBarycentrics(polygon *p, vec2 s, vec3 r) {
r[0] = 1.f - r[1] - r[2]; r[0] = 1.f - r[1] - r[2];
} }
float applyBary(const vec3 bary, float a, float b, float c) { float fApplyBary(const vec3 bary, float a, float b, float c) {
// float result = 0;
return bary[0] * a + bary[1] * b + bary[2] * c; return bary[0] * a + bary[1] * b + bary[2] * c;
} }
void vApplyBary(const vec3 bary, const vec3 a, const vec3 b, const vec3 c,
vec3 dst) {
vec3 tmp = {};
dst[0] = 0;
dst[1] = 0;
dst[2] = 0;
vec3_scale(tmp, a, bary[0]);
vec3_add(dst, dst, tmp);
vec3_scale(tmp, b, bary[1]);
vec3_add(dst, dst, tmp);
vec3_scale(tmp, c, bary[2]);
vec3_add(dst, dst, tmp);
}
void render(render_target *target, const model *model, mat4x4 *matrix, void render(render_target *target, const model *model, mat4x4 *matrix,
vec4 *buffer) { vec4 *buffer) {
@@ -107,65 +132,107 @@ void render(render_target *target, const model *model, mat4x4 *matrix,
mat4x4_mul_vec4(buffer[i], *matrix, tmp); mat4x4_mul_vec4(buffer[i], *matrix, tmp);
vec4_scale(buffer[i], buffer[i], 1.0 / buffer[i][3]); vec4_scale(buffer[i], buffer[i], 1.0 / buffer[i][3]);
vec4_print(buffer[i]); // vec4_print(buffer[i]);
} }
polygon p = {}; polygon p = {};
for (int i = 0; i < model->index_size; i += 3) { vec3 *normals[3] = {};
vec3 *colors[3] = {};
for (int i = 0; i < model->index_size; i += 6) {
p.points[0] = buffer + model->index[i]; p.points[0] = buffer + model->index[i];
p.points[1] = buffer + model->index[i + 1]; p.points[1] = buffer + model->index[i + 2];
p.points[2] = buffer + model->index[i + 2]; p.points[2] = buffer + model->index[i + 4];
initPoly(&p); initPoly(&p);
if (p.norm[2] > 0) if (p.norm[2] > 0)
continue; continue;
printf("baryFac: %f\n", p.baryFactor); normals[0] = model->normals + model->index[i + 1];
normals[1] = model->normals + model->index[i + 3];
normals[2] = model->normals + model->index[i + 5];
// printf("min x :%f, min y: %f\nmax x: %f, max y: %f \n", p.bounding[0], colors[0] = model->color + model->index[i];
// p.bounding[2], p.bounding[1], p.bounding[3]); colors[1] = model->color + model->index[i + 2];
colors[2] = model->color + model->index[i + 4];
// int startX = floor((MAX(-1.0f, p.bounding[0])+1.0)*target->width*0.5);
// int startY = floor((MAX(-1.0f, p.bounding[2])+1.0)*target->height*0.5);
//
// int endX = floor((MIN(1.0f, p.bounding[1])+1.0f)*target->width*0.5);
// int endY = floor((MAX(1.0f, p.bounding[3])+1.0f)*target->height*0.5);
float texWidth = 2.0f / target->width; float texWidth = 2.0f / target->width;
float texHight = 2.0f / target->width; float texHight = 2.0f / target->width;
float startX = MAX(-1.0f, p.bounding[0]); // float startX = MAX(-1.0f, p.bounding[0]);
float startY = MAX(-1.0f, p.bounding[2]); // float startY = MAX(-1.0f, p.bounding[2]);
float endX = MIN(1.0f, p.bounding[1]); // float endX = MIN(1.0f, p.bounding[1]);
float endY = MIN(1.0f, p.bounding[3]); // float endY = MIN(1.0f, p.bounding[3]);
float startX = (MAX(-1.0f, p.bounding[0]) + 1.0f) * 0.5f * target->width;
float endY = (-MAX(-1.0f, p.bounding[2]) + 1.0f) * 0.5f * target->height;
float endX = (MIN(1.0f, p.bounding[1]) + 1.0f) * 0.5f * target->width;
float startY = (-MIN(1.0f, p.bounding[3]) + 1.0f) * 0.5f * target->height;
// printf("min x :%f, min y: %f\n max x: %f, max y: %f \n", startX, startY,
// endX, endY);
//
vec2 sp = {}; vec2 sp = {};
vec3 bary = {}; vec3 bary = {};
vec4 val = {0}; vec3 val = {0};
vec3 nor = {};
vec3 color = {};
for (float y = startY; y < endY; y += texHight) { vec3 viewDir = {};
for (float x = startX; x < endX; x += texWidth) { vec3 halfWay = {};
sp[0] = x;
sp[1] = y; for (int y = startY; y < endY; y += 1) {
for (int x = startX; x < endX; x += 1) {
// for (float y = startY; y < endY; y += texHight) {
// for (float x = startX; x < endX; x += texWidth) {
float fX = ((float)x) * texWidth - 1.0f;
float fY = 1.0f - ((float)y) * texHight;
sp[0] = fX;
sp[1] = fY;
vec3 pos = {};
calcBarycentrics(&p, sp, bary); calcBarycentrics(&p, sp, bary);
if (bary[0] >= 0.0f && bary[1] >= 0.0f && bary[2] >= 0.0f) { if (bary[0] >= -0.000001f && bary[1] >= -0.000001f &&
uint8_t depth = (uint8_t)(255.0 * applyBary(bary, (*p.points[0])[2], bary[2] >= -0.000001f) {
(*p.points[1])[2], float fDepth = fApplyBary(bary, (*p.points[0])[2], (*p.points[1])[2],
(*p.points[2])[2])); (*p.points[2])[2]);
int pX = (int)((x + 1.f) * target->width * 0.5f); uint16_t depth = (uint16_t)(65536.0 * fDepth);
int pY = (int)((-y + 1.f) * target->height * 0.5f); if (depth < target_get_depth(target, x, y)) {
if (depth < getDepth(target, pX, pY)) { vApplyBary(bary, (*normals[0]), (*normals[1]), (*normals[2]), nor);
vec3_dup(val, bary); vec3_norm(nor, nor);
vApplyBary(bary, (*colors[0]), (*colors[1]), (*colors[2]), color);
vApplyBary(bary, (*p.points[0]), (*p.points[1]), (*p.points[2]),
pos);
viewDir[0] = fX;
viewDir[1] = -fY;
viewDir[2] = 2.144663;
vec3_norm(viewDir, viewDir);
vec3_add(halfWay, viewDir, lightDir);
vec3_norm(halfWay, halfWay);
vec3_dup(val, color);
float diffuse = MAX(vec3_dot(nor, lightDir), 0.0f);
// float l = powf(MAX(vec3_dot(halfWay, nor), 0.0), 2.0);
float spec =
powf(MAX(vec3_dot(halfWay, nor), 0.0), model->shininess);
spec *= (model->shininess + 8.0) / 25.1327;
// val[0] = nor[0] * 0.5 + 0.5;
// val[1] = nor[1] * 0.5 + 0.5;
// val[2] = nor[2] * 0.5 + 0.5;
// val[0] = ((float)depth) / 255.0f; // val[0] = ((float)depth) / 255.0f;
// val[1] = ((float)depth) / 255.0f; // val[1] = ((float)depth) / 255.0f;
// val[2] = ((float)depth) / 255.0f; // val[2] = ((float)depth) / 255.0f;
val[3] = ((float)depth) / 255.0f; vec3_scale(val, val, diffuse * 0.5 + spec + 0.2);
// vec3_dup(val, bary);
set(target, pX, pY, val); // vec3_min(val, val, (vec3){1.0f, 1.0f, 1.0f});
// vec3_set(val, fDepth);
// val[3] = ((float)depth) / 255.0f;
// vec3_set(val, diffuse * 0.5 + spec + 0.5);
// vec3_add(val, val, pos);
val[0] = 1.0f - expf(-EXPOSURE * val[0]);
val[1] = 1.0f - expf(-EXPOSURE * val[1]);
val[2] = 1.0f - expf(-EXPOSURE * val[2]);
target_set(target, x, y, val, depth);
} }
} }
} }

View File

@@ -7,49 +7,54 @@ typedef struct {
int width; int width;
int height; int height;
uint8_t *pixels; uint8_t *pixels;
uint16_t *depth;
} render_target; } render_target;
int bufferSize(int width, int height) { int bufferSize(int width, int height) {
return width * height * 4 * sizeof(uint8_t); return width * height * 3 * sizeof(uint8_t);
} }
void clearTarget(render_target *r) { void clearTarget(render_target *r) {
memset(r->pixels, 0, 4 * r->height * r->width * sizeof(uint8_t)); memset(r->pixels, 0, 3 * r->height * r->width * sizeof(uint8_t));
for (int i = 3; i < r->height * r->height * 4; i += 4) { memset(r->depth, 255, r->height * r->width * sizeof(uint16_t));
r->pixels[i] = 255; // for (int i = 3; i < r->height * r->height * 3; i += 3) {
} // r->pixels[i] = 255;
// }
} }
void setColor(render_target *r, int x, int y, vec3 val) { LINMATH_H_FUNC void target_set_color(render_target *r, int x, int y, vec3 val) {
int start = (r->width * y + x) * 4; int start = (r->width * y + x) * 3;
r->pixels[start + 0] = (uint8_t)(val[0] * 255); r->pixels[start + 0] = (uint8_t)(val[0] * 255);
r->pixels[start + 1] = (uint8_t)(val[1] * 255); r->pixels[start + 1] = (uint8_t)(val[1] * 255);
r->pixels[start + 2] = (uint8_t)(val[2] * 255); r->pixels[start + 2] = (uint8_t)(val[2] * 255);
} }
void getColor(render_target *r, int x, int y, int dst[3]) { LINMATH_H_FUNC void target_get_color(render_target *r, int x, int y,
int start = (r->width * y + x) * 4; int dst[3]) {
int start = (r->width * y + x) * 3;
dst[0] = r->pixels[start + 0]; dst[0] = r->pixels[start + 0];
dst[1] = r->pixels[start + 1]; dst[1] = r->pixels[start + 1];
dst[2] = r->pixels[start + 2]; dst[2] = r->pixels[start + 2];
} }
void set(render_target *r, int x, int y, vec4 val) { LINMATH_H_FUNC void target_set(render_target *r, int x, int y, vec3 val,
int start = (r->width * y + x) * 4; uint16_t depth) {
int start = (r->width * y + x) * 3;
r->pixels[start + 0] = (uint8_t)(val[0] * 255); r->pixels[start + 0] = (uint8_t)(val[0] * 255);
r->pixels[start + 1] = (uint8_t)(val[1] * 255); r->pixels[start + 1] = (uint8_t)(val[1] * 255);
r->pixels[start + 2] = (uint8_t)(val[2] * 255); r->pixels[start + 2] = (uint8_t)(val[2] * 255);
r->pixels[start + 3] = (uint8_t)(val[3] * 255); r->depth[r->width * y + x] = depth;
} }
void get(render_target *r, int x, int y, int dst[4]) { // LINMATH_H_FUNC void get(render_target *r, int x, int y, int d
int start = (r->width * y + x) * 4; // int start = (r->width * y + x) * 3;
dst[0] = r->pixels[start + 0]; // dst[0] = r->pixels[start + 0];
dst[1] = r->pixels[start + 1]; // dst[1] = r->pixels[start + 1];
dst[2] = r->pixels[start + 2]; // dst[2] = r->pixels[start + 2];
dst[3] = r->pixels[start + 3]; // dst[3] = r->pixels[start + 3];
// }
LINMATH_H_FUNC void target_set_depth(render_target *r, int x, int y,
float val) {
r->depth[(r->width * y + x)] = (uint16_t)(val * 255);
} }
void setDepth(render_target *r, int x, int y, float val) { LINMATH_H_FUNC uint16_t target_get_depth(render_target *r, int x, int y) {
r->pixels[(r->width * y + x) * 4 + 3] = (uint8_t)(val * 255); return r->depth[r->width * y + x];
}
uint8_t getDepth(render_target *r, int x, int y) {
return r->pixels[(r->width * y + x) * 4 + 3];
} }
#endif #endif

File diff suppressed because one or more lines are too long