initial commit

Signed-off-by: Melik Houij <houijmelik08@protonmail.com>
pull/1/head
Milk.H 2023-03-02 09:42:39 +01:00
commit c2b85150ed
18 changed files with 4084 additions and 0 deletions

15
Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "Dairy-Drift"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
field-offset = "0.3.4"
image = "0.24.5"
gl = "0.14.0"
cgmath = "0.18.0"
tobj = "2.0.0"
[dependencies.glfw]
version = "*"

View File

@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Car_Mat.004
Ns 225.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.450000
d 1.000000
illum 2
map_Kd Car_D.png

View File

@ -0,0 +1,553 @@
# Blender v3.0.1 OBJ File: ''
# www.blender.org
mtllib CarW0.mtl
o Car
v 0.647144 -0.354370 1.880012
v 0.647144 0.320913 0.827202
v 0.647144 -0.266453 -2.186555
v 0.647144 0.290142 -2.204138
v 0.743545 0.056935 -2.305243
v 0.743545 0.133863 1.996502
v 0.695345 -0.195986 -2.221722
v 0.695345 -0.206976 1.991007
v 0.647144 -0.350128 -1.572891
v 0.647144 0.373351 -1.572891
v 0.743545 0.071387 -1.572891
v 0.695345 -0.220946 -1.572891
v 0.451528 0.756333 0.193091
v 0.451528 0.745470 -1.018213
v 0.731285 -0.018525 -1.547248
v 0.747598 -0.185274 -1.616728
v 0.695345 -0.220946 -1.608301
v 0.802170 -0.051799 -1.576720
v 0.758471 -0.159613 -2.374044
v 0.789358 -0.045402 -2.406531
v 0.718760 -0.059581 1.996502
v 0.739302 -0.200789 1.753985
v 0.740595 -0.200373 2.060169
v 0.791646 -0.072548 2.084863
v 0.791741 -0.072481 1.729119
v 0.711910 0.219446 1.697480
v 0.647144 -0.353124 0.832941
v 0.743545 0.113262 0.832941
v 0.695345 -0.210734 0.832941
v 0.695345 -0.206976 1.735475
v 0.718760 -0.059581 1.707612
v 0.695345 -0.206976 1.991007
v 0.731285 -0.009029 -2.283264
v 0.695345 -0.195986 -2.221722
v -0.794053 -0.354370 1.880012
v -0.794053 0.320913 0.827202
v -0.794053 -0.266453 -2.186555
v -0.794053 0.290142 -2.204138
v -0.890454 0.056935 -2.305243
v -0.890454 0.133863 1.996502
v -0.842254 -0.195986 -2.221722
v -0.842254 -0.206976 1.991007
v -0.794053 -0.350128 -1.572891
v -0.794053 0.373351 -1.572891
v -0.890454 0.071387 -1.572891
v -0.842254 -0.220946 -1.572891
v -0.598437 0.756333 0.193091
v -0.598437 0.745470 -1.018213
v -0.858819 0.219446 1.697480
v -0.794053 -0.353124 0.832941
v -0.890454 0.113262 0.832941
v -0.842254 -0.210734 0.832941
v -0.842254 -0.220946 -1.608301
v -0.878193 -0.018525 -1.547248
v -0.842254 -0.195986 -2.221722
v -0.878193 -0.009029 -2.283264
v -0.865669 -0.059581 1.996502
v -0.842254 -0.206976 1.991007
v -0.865669 -0.059581 1.707612
v -0.842254 -0.206976 1.735475
v -0.938650 -0.072481 1.729119
v -0.938555 -0.072548 2.084863
v -0.887504 -0.200373 2.060169
v -0.886211 -0.200789 1.753985
v -0.936267 -0.045402 -2.406531
v -0.905380 -0.159613 -2.374044
v -0.949079 -0.051799 -1.576720
v -0.894507 -0.185274 -1.616728
v 0.269499 -0.287938 -2.008919
v 0.269499 -0.238259 -2.058598
v 0.262771 -0.344209 -2.278127
v 0.262771 -0.254567 -2.278127
v 0.318265 -0.287938 -2.008919
v 0.318265 -0.238259 -2.058598
v 0.324993 -0.344209 -2.278127
v 0.324993 -0.254567 -2.278127
v 0.248018 -0.263099 -2.033758
v 0.235364 -0.299388 -2.278127
v 0.352400 -0.299388 -2.278127
v 0.339746 -0.263099 -2.033758
v -0.208114 -0.311173 -2.349040
v 0.065750 -0.311173 -2.349040
v -0.208114 -0.169367 -2.332325
v 0.065750 -0.169367 -2.332325
v 0.390279 -0.287938 -2.008919
v 0.390279 -0.238259 -2.058598
v 0.383551 -0.344209 -2.278127
v 0.383551 -0.254567 -2.278127
v 0.439045 -0.287938 -2.008919
v 0.439045 -0.238259 -2.058598
v 0.445773 -0.344209 -2.278127
v 0.445773 -0.254567 -2.278127
v 0.368798 -0.263099 -2.033758
v 0.356144 -0.299388 -2.278127
v 0.473180 -0.299388 -2.278127
v 0.460526 -0.263099 -2.033758
v 0.065750 -0.345336 2.046885
v -0.208114 -0.345336 2.046885
v 0.065750 -0.203530 2.030170
v -0.208114 -0.203530 2.030170
v 0.677522 0.219063 1.647425
v 0.695201 0.209712 1.647425
v 0.677522 0.219063 1.606797
v 0.695201 0.209712 1.606797
v 0.709928 0.280334 1.606797
v 0.709928 0.280334 1.647425
v 0.727608 0.270984 1.647425
v 0.727608 0.270984 1.606797
v 0.664945 0.254364 1.557735
v 0.797529 0.255406 1.512802
v 0.670481 0.336816 1.539998
v 0.794037 0.339942 1.496408
v 0.712489 0.292948 1.645794
v 0.706712 0.271201 1.657938
v 0.754534 0.271201 1.657938
v 0.748757 0.292948 1.645794
v 0.680616 0.333629 1.605617
v 0.777047 0.333629 1.605617
v 0.780214 0.252778 1.626115
v 0.677449 0.252778 1.626115
v -0.824431 0.219063 1.647425
v -0.842110 0.209712 1.647425
v -0.824431 0.219063 1.606797
v -0.842110 0.209712 1.606797
v -0.856837 0.280334 1.606797
v -0.856837 0.280334 1.647425
v -0.874517 0.270984 1.647425
v -0.874517 0.270984 1.606797
v -0.811854 0.254364 1.557735
v -0.944438 0.255406 1.512802
v -0.817389 0.336816 1.539998
v -0.940946 0.339942 1.496408
v -0.859398 0.292948 1.645794
v -0.853621 0.271201 1.657938
v -0.901443 0.271201 1.657938
v -0.895666 0.292948 1.645794
v -0.827524 0.333629 1.605617
v -0.923956 0.333629 1.605617
v -0.927123 0.252778 1.626115
v -0.824358 0.252778 1.626115
vt 0.436693 0.306027
vt 0.179266 0.306027
vt 0.167697 0.149524
vt 0.448261 0.149524
vt 0.179266 0.892833
vt 0.179266 0.779104
vt 0.436693 0.779103
vt 0.436693 0.892832
vt 0.162046 0.093968
vt 0.453912 0.093968
vt 0.487887 0.330820
vt 0.476057 0.759465
vt 0.401752 0.659796
vt 0.401752 0.443424
vt 0.585618 0.760329
vt 0.580273 0.876189
vt 0.534190 0.890735
vt 0.532682 0.759902
vt 0.972153 0.049703
vt 0.972153 0.024178
vt 0.960495 0.031508
vt 0.960495 0.049434
vt 0.528774 0.330061
vt 0.587266 0.330539
vt 0.489260 0.872387
vt 0.179266 0.000122
vt 0.436693 0.000122
vt 0.445302 0.033080
vt 0.170656 0.033079
vt 0.162047 0.938235
vt 0.453912 0.938234
vt 0.445303 0.985811
vt 0.170656 0.985811
vt 0.595606 0.870132
vt 0.610248 0.760496
vt 0.214207 0.659796
vt 0.214207 0.443424
vt 0.526857 0.125972
vt 0.588308 0.125972
vt 0.659294 0.344943
vt 0.967005 0.344943
vt 0.967005 0.121383
vt 0.659294 0.121383
vt 0.967005 0.858614
vt 0.659294 0.858614
vt 0.659294 0.990850
vt 0.967005 0.990850
vt 0.614109 0.330754
vt 0.436693 0.999878
vt 0.179266 0.999878
vt 0.510169 0.175530
vt 0.615836 0.143795
vt 0.588997 0.067144
vt 0.600150 0.049434
vt 0.496919 0.049434
vt 0.508342 0.067144
vt 0.915677 0.081571
vt 0.857127 0.081571
vt 0.857127 0.098288
vt 0.915677 0.098288
vt 0.508342 0.015710
vt 0.496919 0.031508
vt 0.600150 0.031508
vt 0.588997 0.015710
vt 0.128071 0.330820
vt 0.139902 0.759465
vt 0.030341 0.760330
vt 0.083277 0.759903
vt 0.081769 0.890735
vt 0.035686 0.876189
vt 0.869130 0.067144
vt 0.948828 0.067144
vt 0.857265 0.049434
vt 0.028692 0.330539
vt 0.087184 0.330061
vt 0.126699 0.872387
vt 0.857265 0.031508
vt 0.551818 0.113576
vt 0.588997 0.113576
vt 0.601300 0.098288
vt 0.542751 0.098288
vt 0.020353 0.870132
vt 0.005711 0.760497
vt 0.926240 0.081571
vt 0.926240 0.098288
vt 0.027650 0.125972
vt 0.089101 0.125972
vt 0.869130 0.067337
vt 0.906609 0.067337
vt 0.613913 0.067144
vt 0.845239 0.067144
vt 0.948828 0.015710
vt 0.869130 0.015710
vt 0.845239 0.113576
vt 0.613913 0.113576
vt 0.588997 0.067337
vt 0.551818 0.067337
vt 0.542751 0.081571
vt 0.601300 0.081571
vt 0.532187 0.081571
vt 0.532187 0.098288
vt 0.613913 0.015710
vt 0.845239 0.015710
vt 0.485261 0.049703
vt 0.485261 0.024178
vt 0.001849 0.330754
vt 0.105790 0.175530
vt 0.845239 0.067337
vt 0.613913 0.067337
vt 0.000122 0.143795
vt 0.906609 0.113576
vt 0.869130 0.113576
vt 0.071024 0.945341
vt 0.071024 0.957018
vt 0.018519 0.958112
vt 0.018447 0.946026
vt 0.123572 0.953127
vt 0.114027 0.970234
vt 0.092357 0.970234
vt 0.082812 0.953127
vt 0.018376 0.958077
vt 0.018447 0.972578
vt 0.071024 0.972175
vt 0.071024 0.957018
vt 0.018447 0.933839
vt 0.018447 0.946026
vt 0.071024 0.945341
vt 0.071024 0.933882
vt 0.114027 0.936020
vt 0.092357 0.936020
vt 0.604256 0.934001
vt 0.604256 0.987921
vt 0.501948 0.987921
vt 0.501948 0.934002
vt 0.071024 0.945341
vt 0.071024 0.957018
vt 0.018519 0.958112
vt 0.018447 0.946026
vt 0.123572 0.953127
vt 0.114027 0.970234
vt 0.092357 0.970234
vt 0.082812 0.953127
vt 0.018376 0.958077
vt 0.018447 0.972578
vt 0.071024 0.972175
vt 0.071024 0.957018
vt 0.018447 0.933839
vt 0.018447 0.946026
vt 0.071024 0.945341
vt 0.071024 0.933882
vt 0.114027 0.936020
vt 0.092357 0.936020
vt 0.604256 0.934001
vt 0.604256 0.987921
vt 0.501948 0.987921
vt 0.501948 0.934002
vt 0.041864 0.111980
vt 0.030565 0.111980
vt 0.030565 0.072822
vt 0.041864 0.072822
vt 0.074791 0.111980
vt 0.064816 0.111980
vt 0.064816 0.072822
vt 0.074791 0.072822
vt 0.007613 0.111980
vt 0.007613 0.072822
vt 0.116674 0.041668
vt 0.116674 0.067181
vt 0.081917 0.067181
vt 0.081917 0.041668
vt 0.104737 0.009901
vt 0.092631 0.009901
vt 0.093678 0.002772
vt 0.104057 0.002772
vt 0.081917 0.097338
vt 0.116674 0.097338
vt 0.104737 0.114104
vt 0.092631 0.114104
vt 0.116674 0.020619
vt 0.081917 0.020619
vt 0.040348 0.041668
vt 0.040121 0.067181
vt 0.027195 0.058006
vt 0.027195 0.050334
vt 0.135528 0.067181
vt 0.135528 0.041668
vt 0.150281 0.050334
vt 0.150281 0.058006
vt 0.041864 0.111980
vt 0.041864 0.072822
vt 0.030565 0.072822
vt 0.030565 0.111980
vt 0.074791 0.111980
vt 0.074791 0.072822
vt 0.064816 0.072822
vt 0.064816 0.111980
vt 0.007613 0.072822
vt 0.007613 0.111980
vt 0.116674 0.041668
vt 0.081917 0.041668
vt 0.081917 0.067181
vt 0.116674 0.067181
vt 0.104737 0.009901
vt 0.104057 0.002772
vt 0.093678 0.002772
vt 0.092631 0.009901
vt 0.081917 0.097338
vt 0.092631 0.114104
vt 0.104737 0.114104
vt 0.116674 0.097338
vt 0.116674 0.020619
vt 0.081917 0.020619
vt 0.040348 0.041668
vt 0.027195 0.050334
vt 0.027195 0.058006
vt 0.040121 0.067181
vt 0.135528 0.067181
vt 0.150281 0.058006
vt 0.150281 0.050334
vt 0.135528 0.041668
vn 0.0000 0.9933 0.1158
vn 0.0000 0.9914 -0.1307
vn 0.0000 0.9614 0.2752
vn 0.8997 0.4364 0.0050
vn 0.9847 -0.1743 -0.0013
vn 0.2822 -0.3453 0.8950
vn 0.9880 -0.1545 0.0017
vn 0.9353 0.3539 0.0008
vn 0.9390 0.3429 -0.0246
vn 0.0000 -0.6016 0.7988
vn 0.0000 -0.3136 -0.9496
vn 0.8972 -0.4399 -0.0379
vn 0.0000 1.0000 -0.0090
vn 0.9896 -0.1435 0.0015
vn 0.0000 0.8244 0.5661
vn 0.0000 -1.0000 -0.0012
vn 0.0000 0.3978 -0.9175
vn 0.0000 -0.9908 -0.1351
vn 0.0000 -0.0161 0.9999
vn 0.9424 -0.3345 0.0005
vn 0.0000 -0.4465 -0.8948
vn 0.9216 0.3879 -0.0139
vn 0.9488 -0.3158 0.0004
vn -0.4797 0.8774 0.0050
vn -0.9272 -0.3746 -0.0015
vn -0.5011 -0.8649 -0.0280
vn -0.8997 0.4364 0.0050
vn -0.9847 -0.1743 -0.0013
vn 0.4797 0.8774 0.0050
vn -0.9880 -0.1545 0.0017
vn -0.9353 0.3539 0.0008
vn -0.9390 0.3429 -0.0246
vn 0.0000 -0.2736 -0.9618
vn 0.1745 0.9847 0.0001
vn -0.8972 -0.4399 -0.0379
vn -0.2995 -0.2581 -0.9185
vn -0.9896 -0.1435 0.0015
vn -0.1415 -0.9899 0.0004
vn 0.0000 0.9591 -0.2830
vn 0.5011 -0.8649 -0.0280
vn -0.9454 -0.3259 -0.0077
vn 0.0000 0.9894 0.1452
vn 0.1415 -0.9899 0.0004
vn 0.2995 -0.2581 -0.9185
vn 0.0000 -0.9727 -0.2323
vn -0.2822 -0.3453 0.8950
vn -0.9424 -0.3345 0.0005
vn 0.9454 -0.3259 -0.0077
vn -0.9216 0.3879 -0.0139
vn 0.0000 -0.1897 0.9818
vn 0.9272 -0.3746 -0.0015
vn 0.0000 -0.9955 0.0950
vn -0.9488 -0.3158 0.0004
vn 0.0000 0.8304 -0.5571
vn -0.1745 0.9847 0.0001
vn -0.8232 0.5670 -0.0299
vn 0.0000 0.0000 -1.0000
vn 0.8232 0.5670 -0.0299
vn 0.0000 -0.9788 0.2046
vn 0.0000 0.9973 -0.0741
vn 0.8327 -0.5386 0.1285
vn -0.8327 -0.5386 0.1285
vn 0.0000 0.1171 -0.9931
vn 0.0000 0.1171 0.9931
vn -0.0000 0.0000 1.0000
vn 0.8840 -0.4675 0.0000
vn -0.8840 0.4675 0.0000
vn -0.3182 -0.1861 -0.9296
vn 0.0000 0.4876 0.8731
vn 0.0000 0.7027 0.7115
vn 0.0000 -0.8654 0.5010
vn 0.7308 0.2640 0.6294
vn -0.6899 0.2734 0.6703
vn -0.9813 0.0919 0.1691
vn 0.9851 0.0742 0.1549
vn -0.0000 -0.9997 -0.0232
vn -0.0035 0.9985 0.0541
vn -0.8840 -0.4675 0.0000
vn 0.8840 0.4675 0.0000
vn 0.3182 -0.1861 -0.9296
vn -0.7308 0.2640 0.6294
vn 0.6899 0.2734 0.6703
vn 0.9813 0.0919 0.1691
vn -0.9851 0.0742 0.1549
vn 0.0035 0.9985 0.0541
usemtl Car_Mat.004
s off
f 2/1/1 36/2/1 49/3/1 26/4/1
f 38/5/2 44/6/2 10/7/2 4/8/2
f 40/9/3 6/10/3 26/4/3 49/3/3
f 2/11/4 10/12/4 14/13/4 13/14/4
f 12/15/5 7/16/5 5/17/5 11/18/5
f 15/19/6 17/20/6 16/21/6 18/22/6
f 12/15/7 11/18/7 28/23/7 29/24/7
f 11/18/8 10/12/8 2/11/8 28/23/8
f 5/17/9 4/25/9 10/12/9 11/18/9
f 35/26/10 1/27/10 8/28/10 42/29/10
f 39/30/11 5/31/11 7/32/11 41/33/11
f 3/34/12 7/16/12 12/15/12 9/35/12
f 14/13/13 48/36/13 47/37/13 13/14/13
f 29/24/14 28/23/14 6/38/14 8/39/14
f 13/14/15 47/37/15 36/2/15 2/1/15
f 50/40/16 27/41/16 1/42/16 35/43/16
f 5/31/17 39/30/17 38/5/17 4/8/17
f 9/44/18 43/45/18 37/46/18 3/47/18
f 27/41/16 50/40/16 43/45/16 9/44/16
f 6/10/19 40/9/19 42/29/19 8/28/19
f 9/35/20 12/15/20 29/24/20 27/48/20
f 3/49/21 37/50/21 41/33/21 7/32/21
f 28/23/22 2/11/22 26/51/22 6/38/22
f 8/39/23 1/52/23 27/48/23 29/24/23
f 56/53/24 65/54/24 67/55/24 54/56/24
f 64/57/25 63/58/25 62/59/25 61/60/25
f 53/61/26 68/62/26 66/63/26 55/64/26
f 36/65/27 47/37/27 48/36/27 44/66/27
f 46/67/28 45/68/28 39/69/28 41/70/28
f 33/71/29 15/72/29 18/22/29 20/73/29
f 46/67/30 52/74/30 51/75/30 45/68/30
f 45/68/31 51/75/31 36/65/31 44/66/31
f 39/69/32 45/68/32 44/66/32 38/76/32
f 19/77/33 66/63/33 65/54/33 20/73/33
f 31/78/34 21/79/34 24/80/34 25/81/34
f 37/82/35 43/83/35 46/67/35 41/70/35
f 60/84/36 64/57/36 61/60/36 59/85/36
f 52/74/37 42/86/37 40/87/37 51/75/37
f 58/88/38 63/58/38 64/57/38 60/89/38
f 20/73/39 65/54/39 56/90/39 33/91/39
f 17/92/40 34/93/40 19/77/40 16/21/40
f 66/63/41 68/62/41 67/55/41 65/54/41
f 57/94/42 62/59/42 24/80/42 21/95/42
f 32/96/43 30/97/43 22/98/43 23/99/43
f 30/100/44 31/101/44 25/81/44 22/98/44
f 55/102/45 66/63/45 19/77/45 34/103/45
f 54/104/46 67/55/46 68/62/46 53/105/46
f 43/83/47 50/106/47 52/74/47 46/67/47
f 19/77/48 20/73/48 18/22/48 16/21/48
f 51/75/49 40/87/49 49/107/49 36/65/49
f 63/58/50 23/99/50 24/80/50 62/59/50
f 22/98/51 25/81/51 24/80/51 23/99/51
f 23/99/52 63/58/52 58/108/52 32/109/52
f 42/86/53 52/74/53 50/106/53 35/110/53
f 44/6/54 48/36/54 14/13/54 10/7/54
f 59/111/55 61/60/55 62/59/55 57/112/55
f 77/113/56 70/114/56 72/115/56 78/116/56
f 78/117/57 72/118/57 76/119/57 79/120/57
f 79/121/58 76/122/58 74/123/58 80/124/58
f 71/125/59 75/126/59 73/127/59 69/128/59
f 76/122/60 72/115/60 70/114/60 74/123/60
f 75/126/61 79/121/61 80/124/61 73/127/61
f 71/129/57 78/117/57 79/120/57 75/130/57
f 69/128/62 77/113/62 78/116/62 71/125/62
f 81/131/63 83/132/63 84/133/63 82/134/63
f 93/135/56 86/136/56 88/137/56 94/138/56
f 94/139/57 88/140/57 92/141/57 95/142/57
f 95/143/58 92/144/58 90/145/58 96/146/58
f 87/147/59 91/148/59 89/149/59 85/150/59
f 92/144/60 88/137/60 86/136/60 90/145/60
f 91/148/61 95/143/61 96/146/61 89/149/61
f 87/151/57 94/139/57 95/142/57 91/152/57
f 85/150/62 93/135/62 94/138/62 87/147/62
f 97/153/64 99/154/64 100/155/64 98/156/64
f 104/157/57 103/158/57 105/159/57 108/160/57
f 101/161/65 102/162/65 107/163/65 106/164/65
f 102/162/66 104/157/66 108/160/66 107/163/66
f 103/158/67 101/165/67 106/166/67 105/159/67
f 109/167/68 111/168/68 112/169/68 110/170/68
f 114/171/69 115/172/69 116/173/69 113/174/69
f 118/175/70 117/176/70 113/177/70 116/178/70
f 120/179/71 119/180/71 115/172/71 114/171/71
f 119/181/72 118/182/72 116/183/72 115/184/72
f 117/185/73 120/186/73 114/187/73 113/188/73
f 111/168/74 109/167/74 120/186/74 117/185/74
f 110/170/75 112/169/75 118/182/75 119/181/75
f 109/167/76 110/170/76 119/180/76 120/179/76
f 112/169/77 111/168/77 117/176/77 118/175/77
f 124/189/57 128/190/57 125/191/57 123/192/57
f 121/193/65 126/194/65 127/195/65 122/196/65
f 122/196/78 127/195/78 128/190/78 124/189/78
f 123/192/79 125/191/79 126/197/79 121/198/79
f 129/199/80 130/200/80 132/201/80 131/202/80
f 134/203/69 133/204/69 136/205/69 135/206/69
f 138/207/70 136/208/70 133/209/70 137/210/70
f 140/211/71 134/203/71 135/206/71 139/212/71
f 139/213/81 135/214/81 136/215/81 138/216/81
f 137/217/82 133/218/82 134/219/82 140/220/82
f 131/202/83 137/217/83 140/220/83 129/199/83
f 130/200/84 139/213/84 138/216/84 132/201/84
f 129/199/76 140/211/76 139/212/76 130/200/76
f 132/201/85 138/207/85 137/210/85 131/202/85

View File

@ -0,0 +1,24 @@
# Blender MTL File: 'None'
# Material Count: 2
newmtl Car_Mat.004
Ns 225.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.450000
d 1.000000
illum 2
map_Kd Car_D.png
newmtl Wheel_Mat.003
Ns 225.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.450000
d 1.000000
illum 2
map_Kd Wheel_D.png

View File

@ -0,0 +1,854 @@
# Blender v3.0.1 OBJ File: ''
# www.blender.org
mtllib CarW1.mtl
o Car
v 0.647144 -0.354370 1.880012
v 0.647144 0.320913 0.827202
v 0.647144 -0.266453 -2.186555
v 0.647144 0.290142 -2.204138
v 0.743545 0.056935 -2.305243
v 0.743545 0.133863 1.996502
v 0.695345 -0.195986 -2.221722
v 0.695345 -0.206976 1.991007
v 0.647144 -0.350128 -1.572891
v 0.647144 0.373351 -1.572891
v 0.743545 0.071387 -1.572891
v 0.695345 -0.220946 -1.572891
v 0.451528 0.756333 0.193091
v 0.451528 0.745470 -1.018213
v 0.731285 -0.018525 -1.547248
v 0.747598 -0.185274 -1.616728
v 0.695345 -0.220946 -1.608301
v 0.802170 -0.051799 -1.576720
v 0.758471 -0.159613 -2.374044
v 0.789358 -0.045402 -2.406531
v 0.718760 -0.059581 1.996502
v 0.739302 -0.200789 1.753985
v 0.740595 -0.200373 2.060169
v 0.791646 -0.072548 2.084863
v 0.791741 -0.072481 1.729119
v 0.711910 0.219446 1.697480
v 0.647144 -0.353124 0.832941
v 0.743545 0.113262 0.832941
v 0.695345 -0.210734 0.832941
v 0.695345 -0.206976 1.735475
v 0.718760 -0.059581 1.707612
v 0.695345 -0.206976 1.991007
v 0.731285 -0.009029 -2.283264
v 0.695345 -0.195986 -2.221722
v -0.794053 -0.354370 1.880012
v -0.794053 0.320913 0.827202
v -0.794053 -0.266453 -2.186555
v -0.794053 0.290142 -2.204138
v -0.890454 0.056935 -2.305243
v -0.890454 0.133863 1.996502
v -0.842254 -0.195986 -2.221722
v -0.842254 -0.206976 1.991007
v -0.794053 -0.350128 -1.572891
v -0.794053 0.373351 -1.572891
v -0.890454 0.071387 -1.572891
v -0.842254 -0.220946 -1.572891
v -0.598437 0.756333 0.193091
v -0.598437 0.745470 -1.018213
v -0.858819 0.219446 1.697480
v -0.794053 -0.353124 0.832941
v -0.890454 0.113262 0.832941
v -0.842254 -0.210734 0.832941
v -0.842254 -0.220946 -1.608301
v -0.878193 -0.018525 -1.547248
v -0.842254 -0.195986 -2.221722
v -0.878193 -0.009029 -2.283264
v -0.865669 -0.059581 1.996502
v -0.842254 -0.206976 1.991007
v -0.865669 -0.059581 1.707612
v -0.842254 -0.206976 1.735475
v -0.938650 -0.072481 1.729119
v -0.938555 -0.072548 2.084863
v -0.887504 -0.200373 2.060169
v -0.886211 -0.200789 1.753985
v -0.936267 -0.045402 -2.406531
v -0.905380 -0.159613 -2.374044
v -0.949079 -0.051799 -1.576720
v -0.894507 -0.185274 -1.616728
v 0.269499 -0.287938 -2.008919
v 0.269499 -0.238259 -2.058598
v 0.262771 -0.344209 -2.278127
v 0.262771 -0.254567 -2.278127
v 0.318265 -0.287938 -2.008919
v 0.318265 -0.238259 -2.058598
v 0.324993 -0.344209 -2.278127
v 0.324993 -0.254567 -2.278127
v 0.248018 -0.263099 -2.033758
v 0.235364 -0.299388 -2.278127
v 0.352400 -0.299388 -2.278127
v 0.339746 -0.263099 -2.033758
v -0.208114 -0.311173 -2.349040
v 0.065750 -0.311173 -2.349040
v -0.208114 -0.169367 -2.332325
v 0.065750 -0.169367 -2.332325
v 0.390279 -0.287938 -2.008919
v 0.390279 -0.238259 -2.058598
v 0.383551 -0.344209 -2.278127
v 0.383551 -0.254567 -2.278127
v 0.439045 -0.287938 -2.008919
v 0.439045 -0.238259 -2.058598
v 0.445773 -0.344209 -2.278127
v 0.445773 -0.254567 -2.278127
v 0.368798 -0.263099 -2.033758
v 0.356144 -0.299388 -2.278127
v 0.473180 -0.299388 -2.278127
v 0.460526 -0.263099 -2.033758
v 0.065750 -0.345336 2.046885
v -0.208114 -0.345336 2.046885
v 0.065750 -0.203530 2.030170
v -0.208114 -0.203530 2.030170
v 0.677522 0.219063 1.647425
v 0.695201 0.209712 1.647425
v 0.677522 0.219063 1.606797
v 0.695201 0.209712 1.606797
v 0.709928 0.280334 1.606797
v 0.709928 0.280334 1.647425
v 0.727608 0.270984 1.647425
v 0.727608 0.270984 1.606797
v 0.664945 0.254364 1.557735
v 0.797529 0.255406 1.512802
v 0.670481 0.336816 1.539998
v 0.794037 0.339942 1.496408
v 0.712489 0.292948 1.645794
v 0.706712 0.271201 1.657938
v 0.754534 0.271201 1.657938
v 0.748757 0.292948 1.645794
v 0.680616 0.333629 1.605617
v 0.777047 0.333629 1.605617
v 0.780214 0.252778 1.626115
v 0.677449 0.252778 1.626115
v -0.824431 0.219063 1.647425
v -0.842110 0.209712 1.647425
v -0.824431 0.219063 1.606797
v -0.842110 0.209712 1.606797
v -0.856837 0.280334 1.606797
v -0.856837 0.280334 1.647425
v -0.874517 0.270984 1.647425
v -0.874517 0.270984 1.606797
v -0.811854 0.254364 1.557735
v -0.944438 0.255406 1.512802
v -0.817389 0.336816 1.539998
v -0.940946 0.339942 1.496408
v -0.859398 0.292948 1.645794
v -0.853621 0.271201 1.657938
v -0.901443 0.271201 1.657938
v -0.895666 0.292948 1.645794
v -0.827524 0.333629 1.605617
v -0.923956 0.333629 1.605617
v -0.927123 0.252778 1.626115
v -0.824358 0.252778 1.626115
vt 0.436693 0.306027
vt 0.179266 0.306027
vt 0.167697 0.149524
vt 0.448261 0.149524
vt 0.179266 0.892833
vt 0.179266 0.779104
vt 0.436693 0.779103
vt 0.436693 0.892832
vt 0.162046 0.093968
vt 0.453912 0.093968
vt 0.487887 0.330820
vt 0.476057 0.759465
vt 0.401752 0.659796
vt 0.401752 0.443424
vt 0.585618 0.760329
vt 0.580273 0.876189
vt 0.534190 0.890735
vt 0.532682 0.759902
vt 0.972153 0.049703
vt 0.972153 0.024178
vt 0.960495 0.031508
vt 0.960495 0.049434
vt 0.528774 0.330061
vt 0.587266 0.330539
vt 0.489260 0.872387
vt 0.179266 0.000122
vt 0.436693 0.000122
vt 0.445302 0.033080
vt 0.170656 0.033079
vt 0.162047 0.938235
vt 0.453912 0.938234
vt 0.445303 0.985811
vt 0.170656 0.985811
vt 0.595606 0.870132
vt 0.610248 0.760496
vt 0.214207 0.659796
vt 0.214207 0.443424
vt 0.526857 0.125972
vt 0.588308 0.125972
vt 0.659294 0.344943
vt 0.967005 0.344943
vt 0.967005 0.121383
vt 0.659294 0.121383
vt 0.967005 0.858614
vt 0.659294 0.858614
vt 0.659294 0.990850
vt 0.967005 0.990850
vt 0.614109 0.330754
vt 0.436693 0.999878
vt 0.179266 0.999878
vt 0.510169 0.175530
vt 0.615836 0.143795
vt 0.588997 0.067144
vt 0.600150 0.049434
vt 0.496919 0.049434
vt 0.508342 0.067144
vt 0.915677 0.081571
vt 0.857127 0.081571
vt 0.857127 0.098288
vt 0.915677 0.098288
vt 0.508342 0.015710
vt 0.496919 0.031508
vt 0.600150 0.031508
vt 0.588997 0.015710
vt 0.128071 0.330820
vt 0.139902 0.759465
vt 0.030341 0.760330
vt 0.083277 0.759903
vt 0.081769 0.890735
vt 0.035686 0.876189
vt 0.869130 0.067144
vt 0.948828 0.067144
vt 0.857265 0.049434
vt 0.028692 0.330539
vt 0.087184 0.330061
vt 0.126699 0.872387
vt 0.857265 0.031508
vt 0.551818 0.113576
vt 0.588997 0.113576
vt 0.601300 0.098288
vt 0.542751 0.098288
vt 0.020353 0.870132
vt 0.005711 0.760497
vt 0.926240 0.081571
vt 0.926240 0.098288
vt 0.027650 0.125972
vt 0.089101 0.125972
vt 0.869130 0.067337
vt 0.906609 0.067337
vt 0.613913 0.067144
vt 0.845239 0.067144
vt 0.948828 0.015710
vt 0.869130 0.015710
vt 0.845239 0.113576
vt 0.613913 0.113576
vt 0.588997 0.067337
vt 0.551818 0.067337
vt 0.542751 0.081571
vt 0.601300 0.081571
vt 0.532187 0.081571
vt 0.532187 0.098288
vt 0.613913 0.015710
vt 0.845239 0.015710
vt 0.485261 0.049703
vt 0.485261 0.024178
vt 0.001849 0.330754
vt 0.105790 0.175530
vt 0.845239 0.067337
vt 0.613913 0.067337
vt 0.000122 0.143795
vt 0.906609 0.113576
vt 0.869130 0.113576
vt 0.071024 0.945341
vt 0.071024 0.957018
vt 0.018519 0.958112
vt 0.018447 0.946026
vt 0.123572 0.953127
vt 0.114027 0.970234
vt 0.092357 0.970234
vt 0.082812 0.953127
vt 0.018376 0.958077
vt 0.018447 0.972578
vt 0.071024 0.972175
vt 0.071024 0.957018
vt 0.018447 0.933839
vt 0.018447 0.946026
vt 0.071024 0.945341
vt 0.071024 0.933882
vt 0.114027 0.936020
vt 0.092357 0.936020
vt 0.604256 0.934001
vt 0.604256 0.987921
vt 0.501948 0.987921
vt 0.501948 0.934002
vt 0.071024 0.945341
vt 0.071024 0.957018
vt 0.018519 0.958112
vt 0.018447 0.946026
vt 0.123572 0.953127
vt 0.114027 0.970234
vt 0.092357 0.970234
vt 0.082812 0.953127
vt 0.018376 0.958077
vt 0.018447 0.972578
vt 0.071024 0.972175
vt 0.071024 0.957018
vt 0.018447 0.933839
vt 0.018447 0.946026
vt 0.071024 0.945341
vt 0.071024 0.933882
vt 0.114027 0.936020
vt 0.092357 0.936020
vt 0.604256 0.934001
vt 0.604256 0.987921
vt 0.501948 0.987921
vt 0.501948 0.934002
vt 0.041864 0.111980
vt 0.030565 0.111980
vt 0.030565 0.072822
vt 0.041864 0.072822
vt 0.074791 0.111980
vt 0.064816 0.111980
vt 0.064816 0.072822
vt 0.074791 0.072822
vt 0.007613 0.111980
vt 0.007613 0.072822
vt 0.116674 0.041668
vt 0.116674 0.067181
vt 0.081917 0.067181
vt 0.081917 0.041668
vt 0.104737 0.009901
vt 0.092631 0.009901
vt 0.093678 0.002772
vt 0.104057 0.002772
vt 0.081917 0.097338
vt 0.116674 0.097338
vt 0.104737 0.114104
vt 0.092631 0.114104
vt 0.116674 0.020619
vt 0.081917 0.020619
vt 0.040348 0.041668
vt 0.040121 0.067181
vt 0.027195 0.058006
vt 0.027195 0.050334
vt 0.135528 0.067181
vt 0.135528 0.041668
vt 0.150281 0.050334
vt 0.150281 0.058006
vt 0.041864 0.111980
vt 0.041864 0.072822
vt 0.030565 0.072822
vt 0.030565 0.111980
vt 0.074791 0.111980
vt 0.074791 0.072822
vt 0.064816 0.072822
vt 0.064816 0.111980
vt 0.007613 0.072822
vt 0.007613 0.111980
vt 0.116674 0.041668
vt 0.081917 0.041668
vt 0.081917 0.067181
vt 0.116674 0.067181
vt 0.104737 0.009901
vt 0.104057 0.002772
vt 0.093678 0.002772
vt 0.092631 0.009901
vt 0.081917 0.097338
vt 0.092631 0.114104
vt 0.104737 0.114104
vt 0.116674 0.097338
vt 0.116674 0.020619
vt 0.081917 0.020619
vt 0.040348 0.041668
vt 0.027195 0.050334
vt 0.027195 0.058006
vt 0.040121 0.067181
vt 0.135528 0.067181
vt 0.150281 0.058006
vt 0.150281 0.050334
vt 0.135528 0.041668
vn 0.0000 0.9933 0.1158
vn 0.0000 0.9914 -0.1307
vn 0.0000 0.9614 0.2752
vn 0.8997 0.4364 0.0050
vn 0.9847 -0.1743 -0.0013
vn 0.2822 -0.3453 0.8950
vn 0.9880 -0.1545 0.0017
vn 0.9353 0.3539 0.0008
vn 0.9390 0.3429 -0.0246
vn 0.0000 -0.6016 0.7988
vn 0.0000 -0.3136 -0.9496
vn 0.8972 -0.4399 -0.0379
vn 0.0000 1.0000 -0.0090
vn 0.9896 -0.1435 0.0015
vn 0.0000 0.8244 0.5661
vn 0.0000 -1.0000 -0.0012
vn 0.0000 0.3978 -0.9175
vn 0.0000 -0.9908 -0.1351
vn 0.0000 -0.0161 0.9999
vn 0.9424 -0.3345 0.0005
vn 0.0000 -0.4465 -0.8948
vn 0.9216 0.3879 -0.0139
vn 0.9488 -0.3158 0.0004
vn -0.4797 0.8774 0.0050
vn -0.9272 -0.3746 -0.0015
vn -0.5011 -0.8649 -0.0280
vn -0.8997 0.4364 0.0050
vn -0.9847 -0.1743 -0.0013
vn 0.4797 0.8774 0.0050
vn -0.9880 -0.1545 0.0017
vn -0.9353 0.3539 0.0008
vn -0.9390 0.3429 -0.0246
vn 0.0000 -0.2736 -0.9618
vn 0.1745 0.9847 0.0001
vn -0.8972 -0.4399 -0.0379
vn -0.2995 -0.2581 -0.9185
vn -0.9896 -0.1435 0.0015
vn -0.1415 -0.9899 0.0004
vn 0.0000 0.9591 -0.2830
vn 0.5011 -0.8649 -0.0280
vn -0.9454 -0.3259 -0.0077
vn 0.0000 0.9894 0.1452
vn 0.1415 -0.9899 0.0004
vn 0.2995 -0.2581 -0.9185
vn 0.0000 -0.9727 -0.2323
vn -0.2822 -0.3453 0.8950
vn -0.9424 -0.3345 0.0005
vn 0.9454 -0.3259 -0.0077
vn -0.9216 0.3879 -0.0139
vn 0.0000 -0.1897 0.9818
vn 0.9272 -0.3746 -0.0015
vn 0.0000 -0.9955 0.0950
vn -0.9488 -0.3158 0.0004
vn 0.0000 0.8304 -0.5571
vn -0.1745 0.9847 0.0001
vn -0.8232 0.5670 -0.0299
vn 0.0000 0.0000 -1.0000
vn 0.8232 0.5670 -0.0299
vn 0.0000 -0.9788 0.2046
vn 0.0000 0.9973 -0.0741
vn 0.8327 -0.5386 0.1285
vn -0.8327 -0.5386 0.1285
vn 0.0000 0.1171 -0.9931
vn 0.0000 0.1171 0.9931
vn -0.0000 0.0000 1.0000
vn 0.8840 -0.4675 0.0000
vn -0.8840 0.4675 0.0000
vn -0.3182 -0.1861 -0.9296
vn 0.0000 0.4876 0.8731
vn 0.0000 0.7027 0.7115
vn 0.0000 -0.8654 0.5010
vn 0.7308 0.2640 0.6294
vn -0.6899 0.2734 0.6703
vn -0.9813 0.0919 0.1691
vn 0.9851 0.0742 0.1549
vn -0.0000 -0.9997 -0.0232
vn -0.0035 0.9985 0.0541
vn -0.8840 -0.4675 0.0000
vn 0.8840 0.4675 0.0000
vn 0.3182 -0.1861 -0.9296
vn -0.7308 0.2640 0.6294
vn 0.6899 0.2734 0.6703
vn 0.9813 0.0919 0.1691
vn -0.9851 0.0742 0.1549
vn 0.0035 0.9985 0.0541
usemtl Car_Mat.004
s off
f 2/1/1 36/2/1 49/3/1 26/4/1
f 38/5/2 44/6/2 10/7/2 4/8/2
f 40/9/3 6/10/3 26/4/3 49/3/3
f 2/11/4 10/12/4 14/13/4 13/14/4
f 12/15/5 7/16/5 5/17/5 11/18/5
f 15/19/6 17/20/6 16/21/6 18/22/6
f 12/15/7 11/18/7 28/23/7 29/24/7
f 11/18/8 10/12/8 2/11/8 28/23/8
f 5/17/9 4/25/9 10/12/9 11/18/9
f 35/26/10 1/27/10 8/28/10 42/29/10
f 39/30/11 5/31/11 7/32/11 41/33/11
f 3/34/12 7/16/12 12/15/12 9/35/12
f 14/13/13 48/36/13 47/37/13 13/14/13
f 29/24/14 28/23/14 6/38/14 8/39/14
f 13/14/15 47/37/15 36/2/15 2/1/15
f 50/40/16 27/41/16 1/42/16 35/43/16
f 5/31/17 39/30/17 38/5/17 4/8/17
f 9/44/18 43/45/18 37/46/18 3/47/18
f 27/41/16 50/40/16 43/45/16 9/44/16
f 6/10/19 40/9/19 42/29/19 8/28/19
f 9/35/20 12/15/20 29/24/20 27/48/20
f 3/49/21 37/50/21 41/33/21 7/32/21
f 28/23/22 2/11/22 26/51/22 6/38/22
f 8/39/23 1/52/23 27/48/23 29/24/23
f 56/53/24 65/54/24 67/55/24 54/56/24
f 64/57/25 63/58/25 62/59/25 61/60/25
f 53/61/26 68/62/26 66/63/26 55/64/26
f 36/65/27 47/37/27 48/36/27 44/66/27
f 46/67/28 45/68/28 39/69/28 41/70/28
f 33/71/29 15/72/29 18/22/29 20/73/29
f 46/67/30 52/74/30 51/75/30 45/68/30
f 45/68/31 51/75/31 36/65/31 44/66/31
f 39/69/32 45/68/32 44/66/32 38/76/32
f 19/77/33 66/63/33 65/54/33 20/73/33
f 31/78/34 21/79/34 24/80/34 25/81/34
f 37/82/35 43/83/35 46/67/35 41/70/35
f 60/84/36 64/57/36 61/60/36 59/85/36
f 52/74/37 42/86/37 40/87/37 51/75/37
f 58/88/38 63/58/38 64/57/38 60/89/38
f 20/73/39 65/54/39 56/90/39 33/91/39
f 17/92/40 34/93/40 19/77/40 16/21/40
f 66/63/41 68/62/41 67/55/41 65/54/41
f 57/94/42 62/59/42 24/80/42 21/95/42
f 32/96/43 30/97/43 22/98/43 23/99/43
f 30/100/44 31/101/44 25/81/44 22/98/44
f 55/102/45 66/63/45 19/77/45 34/103/45
f 54/104/46 67/55/46 68/62/46 53/105/46
f 43/83/47 50/106/47 52/74/47 46/67/47
f 19/77/48 20/73/48 18/22/48 16/21/48
f 51/75/49 40/87/49 49/107/49 36/65/49
f 63/58/50 23/99/50 24/80/50 62/59/50
f 22/98/51 25/81/51 24/80/51 23/99/51
f 23/99/52 63/58/52 58/108/52 32/109/52
f 42/86/53 52/74/53 50/106/53 35/110/53
f 44/6/54 48/36/54 14/13/54 10/7/54
f 59/111/55 61/60/55 62/59/55 57/112/55
f 77/113/56 70/114/56 72/115/56 78/116/56
f 78/117/57 72/118/57 76/119/57 79/120/57
f 79/121/58 76/122/58 74/123/58 80/124/58
f 71/125/59 75/126/59 73/127/59 69/128/59
f 76/122/60 72/115/60 70/114/60 74/123/60
f 75/126/61 79/121/61 80/124/61 73/127/61
f 71/129/57 78/117/57 79/120/57 75/130/57
f 69/128/62 77/113/62 78/116/62 71/125/62
f 81/131/63 83/132/63 84/133/63 82/134/63
f 93/135/56 86/136/56 88/137/56 94/138/56
f 94/139/57 88/140/57 92/141/57 95/142/57
f 95/143/58 92/144/58 90/145/58 96/146/58
f 87/147/59 91/148/59 89/149/59 85/150/59
f 92/144/60 88/137/60 86/136/60 90/145/60
f 91/148/61 95/143/61 96/146/61 89/149/61
f 87/151/57 94/139/57 95/142/57 91/152/57
f 85/150/62 93/135/62 94/138/62 87/147/62
f 97/153/64 99/154/64 100/155/64 98/156/64
f 104/157/57 103/158/57 105/159/57 108/160/57
f 101/161/65 102/162/65 107/163/65 106/164/65
f 102/162/66 104/157/66 108/160/66 107/163/66
f 103/158/67 101/165/67 106/166/67 105/159/67
f 109/167/68 111/168/68 112/169/68 110/170/68
f 114/171/69 115/172/69 116/173/69 113/174/69
f 118/175/70 117/176/70 113/177/70 116/178/70
f 120/179/71 119/180/71 115/172/71 114/171/71
f 119/181/72 118/182/72 116/183/72 115/184/72
f 117/185/73 120/186/73 114/187/73 113/188/73
f 111/168/74 109/167/74 120/186/74 117/185/74
f 110/170/75 112/169/75 118/182/75 119/181/75
f 109/167/76 110/170/76 119/180/76 120/179/76
f 112/169/77 111/168/77 117/176/77 118/175/77
f 124/189/57 128/190/57 125/191/57 123/192/57
f 121/193/65 126/194/65 127/195/65 122/196/65
f 122/196/78 127/195/78 128/190/78 124/189/78
f 123/192/79 125/191/79 126/197/79 121/198/79
f 129/199/80 130/200/80 132/201/80 131/202/80
f 134/203/69 133/204/69 136/205/69 135/206/69
f 138/207/70 136/208/70 133/209/70 137/210/70
f 140/211/71 134/203/71 135/206/71 139/212/71
f 139/213/81 135/214/81 136/215/81 138/216/81
f 137/217/82 133/218/82 134/219/82 140/220/82
f 131/202/83 137/217/83 140/220/83 129/199/83
f 130/200/84 139/213/84 138/216/84 132/201/84
f 129/199/76 140/211/76 139/212/76 130/200/76
f 132/201/85 138/207/85 137/210/85 131/202/85
o Wheel
v 0.087493 -0.000001 -0.267421
v 0.087493 0.102337 -0.247065
v 0.087493 0.189095 -0.189095
v 0.087493 0.247064 -0.102337
v 0.087493 0.267421 0.000001
v 0.087493 0.247064 0.102338
v 0.120491 0.000032 -0.000016
v 0.087493 0.189095 0.189096
v 0.087493 0.102337 0.247066
v 0.087493 -0.000001 0.267422
v 0.087493 -0.102339 0.247066
v 0.087493 -0.189097 0.189096
v 0.087493 -0.247066 0.102338
v 0.087493 -0.267423 0.000000
v 0.087493 -0.247066 -0.102337
v 0.087493 -0.189097 -0.189095
v 0.087493 -0.102339 -0.247065
v 0.120490 0.089462 -0.215982
v 0.120490 -0.000001 -0.233777
v 0.120490 0.165305 -0.165305
v 0.120490 0.215981 -0.089462
v 0.120490 0.233777 0.000001
v 0.120490 0.215981 0.089463
v 0.120490 0.165305 0.165306
v 0.120490 0.089462 0.215983
v 0.120490 -0.000001 0.233778
v 0.120490 -0.089464 0.215983
v 0.120490 -0.165307 0.165306
v 0.120490 -0.215983 0.089463
v 0.120490 -0.233779 0.000000
v 0.120490 -0.215983 -0.089462
v 0.120490 -0.165307 -0.165305
v 0.120490 -0.089464 -0.215982
v -0.087493 -0.000001 -0.267421
v -0.087493 0.102337 -0.247065
v -0.087493 0.189095 -0.189095
v -0.087493 0.247064 -0.102337
v -0.087493 0.267421 0.000001
v -0.087493 0.247064 0.102338
v -0.120491 0.000032 -0.000016
v -0.087493 0.189095 0.189096
v -0.087493 0.102337 0.247066
v -0.087493 -0.000001 0.267422
v -0.087493 -0.102339 0.247066
v -0.087493 -0.189097 0.189096
v -0.087493 -0.247066 0.102338
v -0.087493 -0.267423 0.000000
v -0.087493 -0.247066 -0.102337
v -0.087493 -0.189097 -0.189095
v -0.087493 -0.102339 -0.247065
v -0.120490 0.089462 -0.215982
v -0.120490 -0.000001 -0.233777
v -0.120490 0.165305 -0.165305
v -0.120490 0.215981 -0.089462
v -0.120490 0.233777 0.000001
v -0.120490 0.215981 0.089463
v -0.120490 0.165305 0.165306
v -0.120490 0.089462 0.215983
v -0.120490 -0.000001 0.233778
v -0.120490 -0.089464 0.215983
v -0.120490 -0.165307 0.165306
v -0.120490 -0.215983 0.089463
v -0.120490 -0.233779 0.000000
v -0.120490 -0.215983 -0.089462
v -0.120490 -0.165307 -0.165305
v -0.120490 -0.089464 -0.215982
vt 0.947129 0.746039
vt 0.741723 0.746039
vt 0.741723 0.623557
vt 0.947129 0.623557
vt 0.947129 0.624268
vt 0.741723 0.624268
vt 0.741723 0.501786
vt 0.947129 0.501786
vt 0.947129 0.746750
vt 0.741723 0.746750
vt 0.741723 0.501075
vt 0.947129 0.501075
vt 0.741723 0.379304
vt 0.947129 0.379304
vt 0.741723 0.378593
vt 0.947129 0.378593
vt 0.741723 0.256823
vt 0.947129 0.256822
vt 0.741723 0.256111
vt 0.947129 0.256111
vt 0.741723 0.134341
vt 0.947129 0.134341
vt 0.741724 0.133629
vt 0.947129 0.133630
vt 0.741723 0.011859
vt 0.947129 0.011859
vt 0.741724 0.011147
vt 0.947129 0.011148
vt 0.947129 0.991002
vt 0.741723 0.991002
vt 0.741723 0.868520
vt 0.947129 0.868520
vt 0.947129 0.991714
vt 0.741724 0.991714
vt 0.741724 0.869232
vt 0.947129 0.869232
vt 0.633313 0.736984
vt 0.655743 0.624222
vt 0.698148 0.624222
vt 0.672491 0.753212
vt 0.569439 0.832578
vt 0.599424 0.862564
vt 0.473844 0.896453
vt 0.490072 0.935631
vt 0.361082 0.918882
vt 0.361082 0.961288
vt 0.248320 0.896452
vt 0.232092 0.935631
vt 0.152726 0.832578
vt 0.122740 0.862564
vt 0.088851 0.736983
vt 0.049673 0.753212
vt 0.066422 0.624222
vt 0.024016 0.624222
vt 0.088851 0.511460
vt 0.049673 0.495232
vt 0.152726 0.415866
vt 0.122740 0.385880
vt 0.248321 0.351991
vt 0.232092 0.312813
vt 0.361082 0.329561
vt 0.361082 0.287155
vt 0.473844 0.351991
vt 0.490072 0.312813
vt 0.569439 0.415866
vt 0.599424 0.385880
vt 0.633313 0.511460
vt 0.672491 0.495232
vt 0.361103 0.624263
vt 0.633313 0.736984
vt 0.672491 0.753212
vt 0.698148 0.624222
vt 0.655743 0.624222
vt 0.569438 0.832578
vt 0.599424 0.862564
vt 0.473844 0.896453
vt 0.490072 0.935631
vt 0.361082 0.918882
vt 0.361082 0.961288
vt 0.248320 0.896452
vt 0.232092 0.935631
vt 0.152726 0.832578
vt 0.122740 0.862564
vt 0.088851 0.736983
vt 0.049673 0.753212
vt 0.066422 0.624222
vt 0.024016 0.624222
vt 0.088851 0.511460
vt 0.049673 0.495232
vt 0.152726 0.415865
vt 0.122740 0.385880
vt 0.248321 0.351991
vt 0.232092 0.312813
vt 0.361082 0.329561
vt 0.361082 0.287155
vt 0.473844 0.351991
vt 0.490072 0.312813
vt 0.569439 0.415865
vt 0.599424 0.385880
vt 0.633313 0.511460
vt 0.672491 0.495232
vt 0.361103 0.624263
vn 0.0000 -0.5556 0.8315
vn -0.0000 0.8315 -0.5556
vn -0.0000 0.5556 -0.8315
vn 0.0000 -0.8315 0.5556
vn -0.0000 0.9808 -0.1951
vn 0.0000 -0.9808 0.1951
vn -0.0000 0.9808 0.1951
vn 0.0000 -0.9808 -0.1951
vn 0.0000 0.8315 0.5556
vn -0.0000 -0.8315 -0.5556
vn 0.0000 0.5556 0.8315
vn -0.0000 -0.5556 -0.8315
vn 0.0000 0.1951 0.9808
vn -0.0000 -0.1951 -0.9808
vn -0.0000 -0.1951 0.9808
vn 0.7071 0.1379 -0.6935
vn 0.7071 0.3928 -0.5879
vn 0.7071 0.5879 -0.3928
vn 0.7071 0.6935 -0.1379
vn 0.7071 0.6935 0.1379
vn 0.7071 0.5879 0.3928
vn 0.7071 0.3928 0.5879
vn 0.7071 0.1379 0.6935
vn 0.7071 -0.1380 0.6935
vn 0.7071 -0.3928 0.5879
vn 0.7071 -0.5879 0.3928
vn 0.7071 -0.6935 0.1379
vn 0.7071 -0.6935 -0.1380
vn 0.7071 -0.5879 -0.3928
vn 0.7071 -0.3928 -0.5879
vn 0.7071 -0.1379 -0.6935
vn 1.0000 -0.0000 -0.0000
vn -0.7071 0.1379 -0.6935
vn -0.7071 0.3928 -0.5879
vn -0.7071 0.5879 -0.3928
vn -0.7071 0.6935 -0.1379
vn -0.7071 0.6935 0.1379
vn -0.7071 0.5879 0.3928
vn -0.7071 0.3928 0.5879
vn -0.7071 0.1379 0.6935
vn -0.7071 -0.1379 0.6935
vn -0.7071 -0.3928 0.5879
vn -0.7071 -0.5879 0.3928
vn -0.7071 -0.6935 0.1379
vn -0.7071 -0.6935 -0.1379
vn -0.7071 -0.5879 -0.3928
vn -0.7071 -0.3928 -0.5879
vn -0.7071 -0.1379 -0.6935
vn -1.0000 0.0000 -0.0000
vn -0.0000 0.1951 -0.9808
usemtl Wheel_Mat.003
s off
f 151/221/86 184/222/86 185/223/86 152/224/86
f 143/225/87 176/226/87 177/227/87 144/228/87
f 142/229/88 175/230/88 176/226/88 143/225/88
f 152/224/89 185/223/89 186/231/89 153/232/89
f 144/228/90 177/227/90 178/233/90 145/234/90
f 153/232/91 186/231/91 187/235/91 154/236/91
f 145/234/92 178/233/92 179/237/92 146/238/92
f 154/236/93 187/235/93 188/239/93 155/240/93
f 146/238/94 179/237/94 181/241/94 148/242/94
f 155/240/95 188/239/95 189/243/95 156/244/95
f 148/242/96 181/241/96 182/245/96 149/246/96
f 156/244/97 189/243/97 190/247/97 157/248/97
f 149/249/98 182/250/98 183/251/98 150/252/98
f 157/253/99 190/254/99 174/255/99 141/256/99
f 150/252/100 183/251/100 184/222/100 151/221/100
f 158/257/101 159/258/101 141/259/101 142/260/101
f 160/261/102 158/257/102 142/260/102 143/262/102
f 161/263/103 160/261/103 143/262/103 144/264/103
f 162/265/104 161/263/104 144/264/104 145/266/104
f 163/267/105 162/265/105 145/266/105 146/268/105
f 164/269/106 163/267/106 146/268/106 148/270/106
f 165/271/107 164/269/107 148/270/107 149/272/107
f 166/273/108 165/271/108 149/272/108 150/274/108
f 167/275/109 166/273/109 150/274/109 151/276/109
f 168/277/110 167/275/110 151/276/110 152/278/110
f 169/279/111 168/277/111 152/278/111 153/280/111
f 170/281/112 169/279/112 153/280/112 154/282/112
f 171/283/113 170/281/113 154/282/113 155/284/113
f 172/285/114 171/283/114 155/284/114 156/286/114
f 173/287/115 172/285/115 156/286/115 157/288/115
f 159/258/116 173/287/116 157/288/116 141/259/116
f 147/289/117 159/258/117 158/257/117
f 147/289/117 158/257/117 160/261/117
f 147/289/117 160/261/117 161/263/117
f 147/289/117 161/263/117 162/265/117
f 147/289/117 162/265/117 163/267/117
f 147/289/117 163/267/117 164/269/117
f 147/289/117 164/269/117 165/271/117
f 147/289/117 165/271/117 166/273/117
f 147/289/117 166/273/117 167/275/117
f 147/289/117 167/275/117 168/277/117
f 147/289/117 168/277/117 169/279/117
f 147/289/117 169/279/117 170/281/117
f 147/289/117 170/281/117 171/283/117
f 147/289/117 171/283/117 172/285/117
f 147/289/117 172/285/117 173/287/117
f 147/289/117 173/287/117 159/258/117
f 191/290/118 175/291/118 174/292/118 192/293/118
f 193/294/119 176/295/119 175/291/119 191/290/119
f 194/296/120 177/297/120 176/295/120 193/294/120
f 195/298/121 178/299/121 177/297/121 194/296/121
f 196/300/122 179/301/122 178/299/122 195/298/122
f 197/302/123 181/303/123 179/301/123 196/300/123
f 198/304/124 182/305/124 181/303/124 197/302/124
f 199/306/125 183/307/125 182/305/125 198/304/125
f 200/308/126 184/309/126 183/307/126 199/306/126
f 201/310/127 185/311/127 184/309/127 200/308/127
f 202/312/128 186/313/128 185/311/128 201/310/128
f 203/314/129 187/315/129 186/313/129 202/312/129
f 204/316/130 188/317/130 187/315/130 203/314/130
f 205/318/131 189/319/131 188/317/131 204/316/131
f 206/320/132 190/321/132 189/319/132 205/318/132
f 192/293/133 174/292/133 190/321/133 206/320/133
f 180/322/134 191/290/134 192/293/134
f 180/322/134 193/294/134 191/290/134
f 180/322/134 194/296/134 193/294/134
f 180/322/134 195/298/134 194/296/134
f 180/322/134 196/300/134 195/298/134
f 180/322/134 197/302/134 196/300/134
f 180/322/134 198/304/134 197/302/134
f 180/322/134 199/306/134 198/304/134
f 180/322/134 200/308/134 199/306/134
f 180/322/134 201/310/134 200/308/134
f 180/322/134 202/312/134 201/310/134
f 180/322/134 203/314/134 202/312/134
f 180/322/134 204/316/134 203/314/134
f 180/322/134 205/318/134 204/316/134
f 180/322/134 206/320/134 205/318/134
f 180/322/134 192/293/134 206/320/134
f 141/256/135 174/255/135 175/230/135 142/229/135

View File

@ -0,0 +1,24 @@
# Blender MTL File: 'None'
# Material Count: 2
newmtl Car_Mat.004
Ns 225.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.450000
d 1.000000
illum 2
map_Kd Car_D.png
newmtl Wheel_Mat.003
Ns 225.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.450000
d 1.000000
illum 2
map_Kd Wheel_D.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -0,0 +1,11 @@
#version 330 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D texture_diffuse1;
void main()
{
FragColor = texture(texture_diffuse1, TexCoords);
}

View File

@ -0,0 +1,16 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec2 TexCoords;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
TexCoords = aTexCoords;
gl_Position = projection * view * model * vec4(aPos, 1.0);
}

View File

@ -0,0 +1,14 @@
#version 330 core
out vec4 FragColor;
in vec2 TexCoord;
// texture samplers
uniform sampler2D texture1;
uniform sampler2D texture2;
void main()
{
// linearly interpolate between both textures (80% container, 20% awesomeface)
FragColor = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), 1.0);
}

View File

@ -0,0 +1,15 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
out vec2 TexCoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}

136
src/camera.rs Normal file
View File

@ -0,0 +1,136 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
use cgmath;
use cgmath::vec3;
use cgmath::prelude::*;
type Point3 = cgmath::Point3<f32>;
type Vector3 = cgmath::Vector3<f32>;
type Matrix4 = cgmath::Matrix4<f32>;
// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
#[derive(PartialEq, Clone, Copy)]
pub enum Camera_Movement {
FORWARD,
BACKWARD,
LEFT,
RIGHT,
}
use self::Camera_Movement::*;
// Default camera values
const YAW: f32 = -90.0;
const PITCH: f32 = 0.0;
const SPEED: f32 = 2.5;
const SENSITIVTY: f32 = 0.1;
const ZOOM: f32 = 45.0;
pub struct Camera {
// Camera Attributes
pub Position: Point3,
pub Front: Vector3,
pub Up: Vector3,
pub Right: Vector3,
pub WorldUp: Vector3,
// Euler Angles
pub Yaw: f32,
pub Pitch: f32,
// Camera options
pub MovementSpeed: f32,
pub MouseSensitivity: f32,
pub Zoom: f32,
}
impl Default for Camera {
fn default() -> Camera {
let mut camera = Camera {
Position: Point3::new(0.0, 0.0, 0.0),
Front: vec3(0.0, 0.0, -1.0),
Up: Vector3::zero(), // initialized later
Right: Vector3::zero(), // initialized later
WorldUp: Vector3::unit_y(),
Yaw: YAW,
Pitch: PITCH,
MovementSpeed: SPEED,
MouseSensitivity: SENSITIVTY,
Zoom: ZOOM,
};
camera.updateCameraVectors();
camera
}
}
impl Camera {
/// Returns the view matrix calculated using Eular Angles and the LookAt Matrix
pub fn GetViewMatrix(&self) -> Matrix4 {
Matrix4::look_at(self.Position, self.Position + self.Front, self.Up)
}
/// Processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
pub fn ProcessKeyboard(&mut self, direction: Camera_Movement, deltaTime: f32) {
let velocity = self.MovementSpeed * deltaTime;
if direction == FORWARD {
self.Position += self.Front * velocity;
}
if direction == BACKWARD {
self.Position += -(self.Front * velocity);
}
if direction == LEFT {
self.Position += -(self.Right * velocity);
}
if direction == RIGHT {
self.Position += self.Right * velocity;
}
}
/// Processes input received from a mouse input system. Expects the offset value in both the x and y direction.
pub fn ProcessMouseMovement(&mut self, mut xoffset: f32, mut yoffset: f32, constrainPitch: bool) {
xoffset *= self.MouseSensitivity;
yoffset *= self.MouseSensitivity;
self.Yaw += xoffset;
self.Pitch += yoffset;
// Make sure that when pitch is out of bounds, screen doesn't get flipped
if constrainPitch {
if self.Pitch > 89.0 {
self.Pitch = 89.0;
}
if self.Pitch < -89.0 {
self.Pitch = -89.0;
}
}
// Update Front, Right and Up Vectors using the updated Eular angles
self.updateCameraVectors();
}
// Processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
pub fn ProcessMouseScroll(&mut self, yoffset: f32) {
if self.Zoom >= 1.0 && self.Zoom <= 45.0 {
self.Zoom -= yoffset;
}
if self.Zoom <= 1.0 {
self.Zoom = 1.0;
}
if self.Zoom >= 45.0 {
self.Zoom = 45.0;
}
}
/// Calculates the front vector from the Camera's (updated) Eular Angles
fn updateCameraVectors(&mut self) {
// Calculate the new Front vector
let front = Vector3 {
x: self.Yaw.to_radians().cos() * self.Pitch.to_radians().cos(),
y: self.Pitch.to_radians().sin(),
z: self.Yaw.to_radians().sin() * self.Pitch.to_radians().cos(),
};
self.Front = front.normalize();
// Also re-calculate the Right and Up vector
self.Right = self.Front.cross(self.WorldUp).normalize(); // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
self.Up = self.Right.cross(self.Front).normalize();
}
}

175
src/main.rs Normal file
View File

@ -0,0 +1,175 @@
use std::convert::TryInto;
use glfw;
use glfw::{Action, Context, Key};
use cgmath::{Matrix4, vec3, Point3, Deg, perspective};
use cgmath::prelude::*;
const SCR_WIDTH: u32 = 1600;
const SCR_HEIGHT: u32 = 900;
const TITLE: &str = "GLFWtest";
use std::sync::mpsc::Receiver;
use std::ptr;
use std::mem;
use std::os::raw::c_void;
use std::path::Path;
use std::ffi::{CString, CStr};
mod shader;
mod model;
mod camera;
fn main() {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core));
glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
glfw.window_hint(glfw::WindowHint::Resizable(false));
glfw.window_hint(glfw::WindowHint::TransparentFramebuffer(true));
glfw.window_hint(glfw::WindowHint::Decorated(false));
let (mut window, events) = glfw.create_window(SCR_WIDTH, SCR_HEIGHT, TITLE, glfw::WindowMode::Windowed).unwrap();
let (screen_width, screen_height) = window.get_framebuffer_size();
window.make_current();
window.set_key_polling(true);
window.set_framebuffer_size_polling(true);
window.set_cursor_pos_polling(true);
window.set_cursor_mode(glfw::CursorMode::Disabled);
let mut camera = camera::Camera {
Position: Point3::new(0.0, 0.25, 1.0),
Pitch: -20.0,
..camera::Camera::default()
};
let mut firstMouse = true;
let mut lastX: f32 = SCR_WIDTH as f32 / 2.0;
let mut lastY: f32 = SCR_HEIGHT as f32 / 2.0;
// timing
let mut deltaTime: f32; // time between current frame and last frame
let mut lastFrame: f32 = 0.0;
gl::load_with(|ptr| window.get_proc_address(ptr) as *const _);
unsafe{
gl::Enable(gl::DEPTH_TEST);
gl::DepthFunc(gl::LESS);
gl::Enable(gl::STENCIL_TEST);
gl::StencilFunc(gl::NOTEQUAL, 1, 0xFF);
gl::StencilOp(gl::KEEP, gl::KEEP, gl::REPLACE);
};
let (ourshader, ourModel) = unsafe {
gl::Enable(gl::DEPTH_TEST);
let ourShader = shader::shader::new("model");
let ourModel = model::Model::new("resources/models/TestCarModel/CarW4.obj");
(ourShader, ourModel)
};
let projection: Matrix4<f32> = perspective(Deg(45.0), SCR_WIDTH as f32/ SCR_HEIGHT as f32, 0.1, 100.0);
println!("entering main loop");
while !window.should_close() {
let currentFrame = glfw.get_time() as f32;
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
process_events(&events, &mut firstMouse, &mut lastX, &mut lastY, &mut camera);
processInput(&mut window, deltaTime, &mut camera);
unsafe {
gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT);
gl::ClearColor(1.0, 1.0, 1.0, 1.0);
ourshader.Use();
let Projection: Matrix4<f32> = perspective(Deg(camera.Zoom), SCR_WIDTH as f32 / SCR_HEIGHT as f32, 0.1, 100.0);
let view = camera.GetViewMatrix();
ourshader.setMat4(&CString::new("projection").unwrap(), &projection);
ourshader.setMat4(&CString::new("view").unwrap(), &view);
let mut model = Matrix4::<f32>::from_translation(vec3(0.0, -0.3, 0.0));
model = model * Matrix4::from_scale(0.2);
ourshader.setMat4(&CString::new("model").unwrap(), &model);
gl::StencilFunc(gl::NOTEQUAL, 1, 0xFF);
gl::StencilMask(0x00);
//gl::Disable(gl::DEPTH_TEST);
ourModel.Draw(&ourshader);
gl::Enable(gl::DEPTH_TEST);
}
window.swap_buffers();
glfw.poll_events();
}
}
fn processInput(window: &mut glfw::Window, deltaTime: f32, camera: &mut camera::Camera) {
if window.get_key(Key::Escape) == Action::Press {
window.set_should_close(true)
}
if window.get_key(Key::W) == Action::Press {
camera.ProcessKeyboard(camera::Camera_Movement::FORWARD, deltaTime);
}
if window.get_key(Key::S) == Action::Press {
camera.ProcessKeyboard(camera::Camera_Movement::BACKWARD, deltaTime);
}
if window.get_key(Key::A) == Action::Press {
camera.ProcessKeyboard(camera::Camera_Movement::LEFT, deltaTime);
}
if window.get_key(Key::D) == Action::Press {
camera.ProcessKeyboard(camera::Camera_Movement::RIGHT, deltaTime);
}
}
fn process_events(events: &Receiver<(f64, glfw::WindowEvent)>,
firstMouse: &mut bool,
lastX: &mut f32,
lastY: &mut f32,
camera: &mut camera::Camera) {
for (_, event) in glfw::flush_messages(events) {
match event {
glfw::WindowEvent::FramebufferSize(width, height) => {
// make sure the viewport matches the new window dimensions; note that width and
// height will be significantly larger than specified on retina displays.
unsafe { gl::Viewport(0, 0, width, height) }
}
glfw::WindowEvent::CursorPos(xpos, ypos) => {
let (xpos, ypos) = (xpos as f32, ypos as f32);
if *firstMouse {
*lastX = xpos;
*lastY = ypos;
*firstMouse = false;
}
let xoffset = xpos - *lastX;
let yoffset = *lastY - ypos; // reversed since y-coordinates go from bottom to top
*lastX = xpos;
*lastY = ypos;
camera.ProcessMouseMovement(xoffset, yoffset, true);
}
glfw::WindowEvent::Scroll(_xoffset, yoffset) => {
camera.ProcessMouseScroll(yoffset as f32);
}
_ => {}
}
}
}

144
src/model.rs Normal file
View File

@ -0,0 +1,144 @@
#![allow(non_snake_case)]
#![allow(dead_code)]
use std::os::raw::c_void;
use std::path::Path;
use cgmath::{vec2, vec3};
use gl;
use image;
use image::DynamicImage::*;
use image::GenericImage;
use tobj;
mod mesh;
use mesh::{ Mesh, Texture, Vertex };
use crate::shader::shader;
#[derive(Default)]
pub struct Model {
/* Model Data */
pub meshes: Vec<Mesh>,
pub textures_loaded: Vec<Texture>, // stores all the textures loaded so far, optimization to make sure textures aren't loaded more than once.
directory: String,
}
impl Model {
/// constructor, expects a filepath to a 3D model.
pub fn new(path: &str) -> Model {
let mut model = Model::default();
model.loadModel(path);
model
}
pub fn Draw(&self, shader: &shader) {
for mesh in &self.meshes {
unsafe { mesh.Draw(shader); }
}
}
// loads a model from file and stores the resulting meshes in the meshes vector.
fn loadModel(&mut self, path: &str) {
let path = Path::new(path);
// retrieve the directory path of the filepath
self.directory = path.parent().unwrap_or_else(|| Path::new("")).to_str().unwrap().into();
let obj = tobj::load_obj(path, true/*, &tobj::LoadOptions::default()*/);
let (models, materials) = obj.unwrap();
for model in models {
let mesh = &model.mesh;
let num_vertices = mesh.positions.len() / 3;
// data to fill
let mut vertices: Vec<Vertex> = Vec::with_capacity(num_vertices);
let indices: Vec<u32> = mesh.indices.clone();
println!("num vertices = {}", num_vertices);
println!("num normals = {}", &mesh.normals.len());
println!("num TexCoords = {}", &mesh.texcoords.len());
let (p, n, t) = (&mesh.positions, &mesh.normals, &mesh.texcoords);
for i in 0..num_vertices {
vertices.push(Vertex {
Position: vec3(p[i*3], p[i*3+1], p[i*3+2]),
Normal: vec3(n[i*3], n[i*3+1], n[i*3+2]),
TexCoords: vec2(t[i*2], t[i*2+1]),
..Vertex::default()
})
}
// process material
let mut textures = Vec::new();
if let Some(material_id) = mesh.material_id {
let material = &materials[material_id];
// 1. diffuse map
if !material.diffuse_texture.is_empty() {
let texture = self.loadMaterialTexture(&material.diffuse_texture, "texture_diffuse");
textures.push(texture);
}
// 2. specular map
if !material.specular_texture.is_empty() {
let texture = self.loadMaterialTexture(&material.specular_texture, "texture_specular");
textures.push(texture);
}
// 3. normal map
if !material.normal_texture.is_empty() {
let texture = self.loadMaterialTexture(&material.normal_texture, "texture_normal");
textures.push(texture);
}
// NOTE: no height maps
}
self.meshes.push(Mesh::new(vertices, indices, textures));
}
}
fn loadMaterialTexture(&mut self, path: &str, typeName: &str) -> Texture {
{
let texture = self.textures_loaded.iter().find(|t| t.path == path);
if let Some(texture) = texture {
return texture.clone();
}
}
let texture = Texture {
id: unsafe { TextureFromFile(path, &self.directory) },
type_: typeName.into(),
path: path.into()
};
self.textures_loaded.push(texture.clone());
texture
}
}
unsafe fn TextureFromFile(path: &str, directory: &str) -> u32 {
let filename = format!("{}/{}", directory, path);
let mut textureID = 0;
gl::GenTextures(1, &mut textureID);
let img = image::open(&Path::new(&filename)).expect("Texture failed to load");
let img = img.flipv();
let format = match img {
ImageLuma8(_) => gl::RED,
ImageLumaA8(_) => gl::RG,
ImageRgb8(_) => gl::RGB,
ImageRgba8(_) => gl::RGBA,
_ => panic!("really weird image type"),
};
let data = img.as_bytes();
gl::BindTexture(gl::TEXTURE_2D, textureID);
gl::TexImage2D(gl::TEXTURE_2D, 0, format as i32, img.width() as i32, img.height() as i32,
0, format, gl::UNSIGNED_BYTE, &data[0] as *const u8 as *const c_void);
gl::GenerateMipmap(gl::TEXTURE_2D);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_S, gl::REPEAT as i32);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_T, gl::REPEAT as i32);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR_MIPMAP_LINEAR as i32);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR as i32);
textureID
}

162
src/model/mesh.rs Normal file
View File

@ -0,0 +1,162 @@
#![allow(non_snake_case)]
#![allow(dead_code)]
use std::ffi::CString;
use std::mem::size_of;
use std::os::raw::c_void;
use std::ptr;
use cgmath::{ Vector3, Vector2 };
use cgmath::prelude::*;
use gl;
use field_offset::offset_of;
use crate::shader::shader;
// NOTE: without repr(C) the compiler may reorder the fields or use different padding/alignment than C.
// Depending on how you pass the data to OpenGL, this may be bad. In this case it's not strictly
// necessary though because of the `offset!` macro used below in setupMesh()
#[repr(C)]
pub struct Vertex {
// position
pub Position: Vector3<f32>,
// normal
pub Normal: Vector3<f32>,
// texCoords
pub TexCoords: Vector2<f32>,
// tangent
pub Tangent: Vector3<f32>,
// bitangent
pub Bitangent: Vector3<f32>,
}
impl Default for Vertex {
fn default() -> Self {
Vertex {
Position: Vector3::zero(),
Normal: Vector3::zero(),
TexCoords: Vector2::zero(),
Tangent: Vector3::zero(),
Bitangent: Vector3::zero(),
}
}
}
#[derive(Clone)]
pub struct Texture {
pub id: u32,
pub type_: String,
pub path: String,
}
pub struct Mesh {
/* Mesh Data */
pub vertices: Vec<Vertex>,
pub indices: Vec<u32>,
pub textures: Vec<Texture>,
pub VAO: u32,
/* Render data */
VBO: u32,
EBO: u32,
}
impl Mesh {
pub fn new(vertices: Vec<Vertex>, indices: Vec<u32>, textures: Vec<Texture>) -> Mesh {
let mut mesh = Mesh {
vertices, indices, textures,
VAO: 0, VBO: 0, EBO: 0
};
// now that we have all the required data, set the vertex buffers and its attribute pointers.
unsafe { mesh.setupMesh() }
mesh
}
/// render the mesh
pub unsafe fn Draw(&self, shader: &shader) {
// bind appropriate textures
let mut diffuseNr = 0;
let mut specularNr = 0;
let mut normalNr = 0;
let mut heightNr = 0;
for (i, texture) in self.textures.iter().enumerate() {
gl::ActiveTexture(gl::TEXTURE0 + i as u32); // active proper texture unit before binding
// retrieve texture number (the N in diffuse_textureN)
let name = &texture.type_;
let number = match name.as_str() {
"texture_diffuse" => {
diffuseNr += 1;
diffuseNr
},
"texture_specular" => {
specularNr += 1;
specularNr
}
"texture_normal" => {
normalNr += 1;
normalNr
}
"texture_height" => {
heightNr += 1;
heightNr
}
_ => panic!("unknown texture type")
};
// now set the sampler to the correct texture unit
let sampler = CString::new(format!("{}{}", name, number)).unwrap();
gl::Uniform1i(gl::GetUniformLocation(shader.ID, sampler.as_ptr()), i as i32);
// and finally bind the texture
gl::BindTexture(gl::TEXTURE_2D, texture.id);
}
// draw mesh
gl::BindVertexArray(self.VAO);
gl::DrawElements(gl::TRIANGLES, self.indices.len() as i32, gl::UNSIGNED_INT, ptr::null());
gl::BindVertexArray(0);
// always good practice to set everything back to defaults once configured.
gl::ActiveTexture(gl::TEXTURE0);
}
unsafe fn setupMesh(&mut self) {
// create buffers/arrays
gl::GenVertexArrays(1, &mut self.VAO);
gl::GenBuffers(1, &mut self.VBO);
gl::GenBuffers(1, &mut self.EBO);
gl::BindVertexArray(self.VAO);
// load data into vertex buffers
gl::BindBuffer(gl::ARRAY_BUFFER, self.VBO);
// A great thing about structs with repr(C) is that their memory layout is sequential for all its items.
// The effect is that we can simply pass a pointer to the struct and it translates perfectly to a glm::vec3/2 array which
// again translates to 3/2 floats which translates to a byte array.
let size = (self.vertices.len() * size_of::<Vertex>()) as isize;
let data = &self.vertices[0] as *const Vertex as *const c_void;
gl::BufferData(gl::ARRAY_BUFFER, size, data, gl::STATIC_DRAW);
gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.EBO);
let size = (self.indices.len() * size_of::<u32>()) as isize;
let data = &self.indices[0] as *const u32 as *const c_void;
gl::BufferData(gl::ELEMENT_ARRAY_BUFFER, size, data, gl::STATIC_DRAW);
// set the vertex attribute pointers
let size = size_of::<Vertex>() as i32;
// vertex Positions
gl::EnableVertexAttribArray(0);
gl::VertexAttribPointer(0, 3, gl::FLOAT, gl::FALSE, size, offset_of!(Vertex => Position).get_byte_offset() as *const c_void);
// vertex normals
gl::EnableVertexAttribArray(1);
gl::VertexAttribPointer(1, 3, gl::FLOAT, gl::FALSE, size, offset_of!(Vertex => Normal).get_byte_offset() as *const c_void);
// vertex texture coords
gl::EnableVertexAttribArray(2);
gl::VertexAttribPointer(2, 2, gl::FLOAT, gl::FALSE, size, offset_of!(Vertex => TexCoords).get_byte_offset() as *const c_void);
// vertex tangent
gl::EnableVertexAttribArray(3);
gl::VertexAttribPointer(3, 3, gl::FLOAT, gl::FALSE, size, offset_of!(Vertex => Tangent).get_byte_offset() as *const c_void);
// vertex bitangent
gl::EnableVertexAttribArray(4);
gl::VertexAttribPointer(4, 3, gl::FLOAT, gl::FALSE, size, offset_of!(Vertex => Bitangent).get_byte_offset() as *const c_void);
gl::BindVertexArray(0);
}
}

171
src/shader.rs Normal file
View File

@ -0,0 +1,171 @@
use gl;
use std::fs;
use std::ffi::{CString, CStr};
use std::str;
use cgmath::prelude::*;
/// Shader Struct for creating and using shaders in the Context of engine
///
pub struct shader {
pub ID: gl::types::GLuint,
}
impl shader
{
/// Shader Constructor, will read, Compile and Create GLSL Program for use
///
/// # Example
/// `new(String::from("Example"))`
/// if the String given was "Example" the Program expects both shaders to be in the directory "resources/shaders/Example/"
/// with the vertex shader being called "shader.vert" and fragment "shader.frag"
pub fn new(path: &str) -> shader
{
//read file contents
let VERT_SHADER = fs::read_to_string(format!("resources/shaders/{path}/shader.vert")).unwrap();
let FRAG_SHADER = std::fs::read_to_string(format!("resources/shaders/{path}/shader.frag")).unwrap();
//create vertex shader
let vertex_shader = unsafe {gl::CreateShader(gl::VERTEX_SHADER) };
unsafe {
gl::ShaderSource(vertex_shader, 1, &VERT_SHADER.as_bytes().as_ptr().cast(), &VERT_SHADER.len().try_into().unwrap());
gl::CompileShader(vertex_shader);
}
//error Checking
let mut success = 0;
unsafe {
gl::GetShaderiv(vertex_shader, gl::COMPILE_STATUS, &mut success);
if success == 0 {
let mut log_len = 0_i32;
let mut v: Vec<u8> = Vec::with_capacity(1024);
gl::GetShaderInfoLog(vertex_shader, 1024, &mut log_len, v.as_mut_ptr().cast());
v.set_len(log_len.try_into().unwrap());
panic!("Vertex Shader Compile Error: {}", String::from_utf8_lossy(&v));
}
let fragment_shader = gl::CreateShader(gl::FRAGMENT_SHADER);
gl::ShaderSource(fragment_shader, 1, &FRAG_SHADER.as_bytes().as_ptr().cast(), &FRAG_SHADER.len().try_into().unwrap());
gl::CompileShader(fragment_shader);
let mut success = 0;
gl::GetShaderiv(fragment_shader, gl::COMPILE_STATUS, &mut success);
if success == 0 {
let mut v: Vec<u8> = Vec::with_capacity(1024);
let mut log_len = 0_i32;
gl::GetShaderInfoLog(fragment_shader, 1024, &mut log_len, v.as_mut_ptr().cast());
v.set_len(log_len.try_into().unwrap());
panic!("Fragment Shader Compile Error: {}", String::from_utf8_lossy(&v));
}
let shader_program = gl::CreateProgram();
gl::AttachShader(shader_program, vertex_shader);
gl::AttachShader(shader_program, fragment_shader);
gl::LinkProgram(shader_program);
let mut success = 0;
gl::GetProgramiv(shader_program, gl::LINK_STATUS, &mut success);
if success == 0 {
let mut v: Vec<u8> = Vec::with_capacity(1024);
let mut log_len = 0_i32;
gl::GetProgramInfoLog(shader_program, 1024, &mut log_len, v.as_mut_ptr().cast());
v.set_len(log_len.try_into().unwrap());
panic!("Program Link Error: {}", String::from_utf8_lossy(&v));
}
gl::DetachShader(shader_program, vertex_shader);
gl::DetachShader(shader_program, fragment_shader);
gl::DeleteShader(vertex_shader);
gl::DeleteShader(fragment_shader);
// return program
shader {
ID: shader_program,
}
}
}
/// uses Shader
pub fn Use(&self)
{
unsafe {gl::UseProgram(self.ID);}
}
// BOILERPLATE JUMPSCARE
pub fn setBool(&self, name: &CStr, value: bool )
{unsafe {gl::Uniform1i(gl::GetUniformLocation(self.ID, name.as_ptr()), value as i32);}}
pub fn setInt(&self, name: &CStr, value: u32 )
{unsafe {gl::Uniform1i(gl::GetUniformLocation(self.ID, name.as_ptr()), value as i32);}}
pub fn setFloat(&self, name: &CStr, value: f32 )
{unsafe {gl::Uniform1f(gl::GetUniformLocation(self.ID, name.as_ptr()), value as f32);}}
pub fn setVec2(&self, name: &CStr, value: &cgmath::Vector2<f32> )
{unsafe {gl::Uniform2fv(gl::GetUniformLocation(self.ID, name.as_ptr()), 1, value.as_ptr());}}
pub fn setVector2d(&self, name: &CStr, x: f32, y: f32)
{unsafe {gl::Uniform2f(gl::GetUniformLocation(self.ID, name.as_ptr()), x, y);}}
pub fn setVector3(&self, name: &CStr, value: cgmath::Vector3<f32> )
{unsafe {gl::Uniform3fv(gl::GetUniformLocation(self.ID, name.as_ptr()), 1, value.as_ptr());}}
pub fn setVector3d(&self, name: &CStr, x: f32, y: f32, z: f32 )
{unsafe {gl::Uniform3f(gl::GetUniformLocation(self.ID, name.as_ptr()), x, y, z);}}
pub fn setVector4(&self, name: &CStr, value: &cgmath::Vector4<f32> )
{unsafe {gl::Uniform4fv(gl::GetUniformLocation(self.ID, name.as_ptr()), 1, value.as_ptr());}}
pub fn setVector4d(&self, name: &CStr, x: f32, y: f32, z: f32, w: f32)
{unsafe {gl::Uniform4f(gl::GetUniformLocation(self.ID, name.as_ptr()), x, y, z, w);}}
pub fn setMat2(&self, name: &CStr, value: &cgmath::Matrix2<f32>)
{unsafe {gl::UniformMatrix2fv(gl::GetUniformLocation(self.ID, name.as_ptr()), 1, gl::FALSE, value.as_ptr());}}
pub fn setMat3(&self, name: &CStr, value: &cgmath::Matrix3<f32>)
{unsafe {gl::UniformMatrix3fv(gl::GetUniformLocation(self.ID, name.as_ptr()), 1, gl::FALSE, value.as_ptr());}}
pub fn setMat4(&self, name: &CStr, value: &cgmath::Matrix4<f32>)
{unsafe {gl::UniformMatrix4fv(gl::GetUniformLocation(self.ID, name.as_ptr()), 1, gl::FALSE, value.as_ptr());}}
}
#[cfg(test)]
mod tests {
use glfw;
use glfw::Context;
use gl;
use super::*;
#[test]
fn ShaderLoading() {
// initialize GLFW
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
// set window hints
glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core));
glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
glfw.window_hint(glfw::WindowHint::Resizable(false));
//create Window
let (mut window, events) = glfw.create_window(480, 320, "Shader Test", glfw::WindowMode::Windowed).unwrap();
let (screen_width, screen_height) = window.get_framebuffer_size();
// setup window
window.make_current();
window.set_key_polling(true);
// initialize gl
gl::load_with(|ptr| window.get_proc_address(ptr) as *const _);
let Shader = shader::new("basic");
Shader.Use();
}
}