Compare commits

...

10 commits

25 changed files with 3715 additions and 1786 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~ *~
dist dist
*.blend1

View file

@ -6,14 +6,14 @@ category: Game
license: GPL-3 license: GPL-3
license-file: LICENSE license-file: LICENSE
author: Matthias Schiffer author: Matthias Schiffer
maintainer: matthias@gamezock.de maintainer: mschiffer@universe-factory.net
build-depends: base >= 4, syb, containers, mtl, time, X11, OpenGL, hwiid, obj-model, obj-model-gl build-depends: base >= 4, syb, containers, mtl, time, X11, OpenGL, hwiid, obj-model, obj-model-opengl, fixed-point, vector-space, fixed-point-vector-space
build-type: Simple build-type: Simple
data-files: tex/*.png model/*.obj data-files: tex/*.png model/*.obj
executable: HTanks executable: HTanks
hs-source-dirs: src hs-source-dirs: src
main-is: HTanks.hs main-is: HTanks.hs
other-modules: Collision, CPUPlayer, DefaultPlayer, HWiidPlayer, Game, GLDriver, GLX, Level, MainLoop, Paths_htanks, Player, Render, Simulation, Texture, Debris, other-modules: Collision, CPUPlayer, DefaultPlayer, HWiidPlayer, Game, GLDriver, GLX, Level, MainLoop, Paths_htanks, Player, Render, Simulation, Texture, Transformable, Debris,
Tank, Model, Bindings.GLX, Bindings.GLPng Tank, Model, Vector, Bindings.GLX, Bindings.GLPng
extra-libraries: glpng extra-libraries: glpng

BIN
model/bullet.blend Normal file

Binary file not shown.

657
model/bullet.obj Normal file
View file

@ -0,0 +1,657 @@
# Blender3D v249 OBJ File: bullet.blend
# www.blender3d.org
o Circle
v 0.035355 -0.130372 -0.035355
v 0.046194 -0.130372 -0.019134
v 0.050000 -0.130372 0.000000
v 0.046194 -0.130372 0.019134
v 0.035355 -0.130372 0.035355
v 0.019134 -0.130372 0.046194
v 0.000000 -0.130372 0.050000
v -0.019134 -0.130372 0.046194
v -0.035355 -0.130372 0.035355
v -0.046194 -0.130372 0.019134
v -0.050000 -0.130372 0.000000
v -0.046194 -0.130372 -0.019134
v -0.035355 -0.130372 -0.035355
v -0.019134 -0.130372 -0.046194
v 0.000000 -0.130372 -0.050000
v 0.019134 -0.130372 -0.046194
v 0.035355 -0.110752 -0.035355
v 0.046194 -0.110752 -0.019134
v 0.050000 -0.110752 0.000000
v 0.046194 -0.110752 0.019134
v 0.035355 -0.110752 0.035355
v 0.019134 -0.110752 0.046194
v 0.000000 -0.110752 0.050000
v -0.019134 -0.110752 0.046194
v -0.035355 -0.110752 0.035355
v -0.046194 -0.110752 0.019134
v -0.050000 -0.110752 0.000000
v -0.046194 -0.110752 -0.019134
v -0.035355 -0.110752 -0.035355
v -0.019134 -0.110752 -0.046194
v 0.000000 -0.110752 -0.050000
v 0.019134 -0.110752 -0.046194
v 0.028321 -0.110752 -0.028321
v 0.037004 -0.110752 -0.015327
v 0.040053 -0.110752 0.000000
v 0.037004 -0.110752 0.015327
v 0.028321 -0.110752 0.028321
v 0.015327 -0.110752 0.037004
v 0.000000 -0.110752 0.040053
v -0.015327 -0.110752 0.037004
v -0.028321 -0.110752 0.028321
v -0.037004 -0.110752 0.015327
v -0.040053 -0.110752 0.000000
v -0.037004 -0.110752 -0.015327
v -0.028321 -0.110752 -0.028321
v -0.015327 -0.110752 -0.037004
v 0.000000 -0.110752 -0.040053
v 0.015327 -0.110752 -0.037004
v 0.037004 -0.093395 -0.015327
v 0.028321 -0.093395 -0.028321
v 0.040053 -0.093395 0.000000
v 0.037004 -0.093395 0.015327
v 0.028321 -0.093395 0.028321
v 0.015327 -0.093395 0.037004
v 0.000000 -0.093395 0.040053
v -0.015327 -0.093395 0.037004
v -0.028321 -0.093395 0.028321
v -0.037004 -0.093395 0.015327
v -0.040053 -0.093395 0.000000
v -0.037004 -0.093395 -0.015327
v -0.028321 -0.093395 -0.028321
v -0.015327 -0.093395 -0.037004
v 0.000000 -0.093395 -0.040053
v 0.015327 -0.093395 -0.037004
v 0.036574 -0.093395 -0.036574
v 0.047786 -0.093395 -0.019794
v 0.051723 -0.093395 0.000000
v 0.047786 -0.093395 0.019794
v 0.036574 -0.093395 0.036574
v 0.019794 -0.093395 0.047786
v 0.000000 -0.093395 0.051723
v -0.019794 -0.093395 0.047786
v -0.036574 -0.093395 0.036574
v -0.047786 -0.093395 0.019794
v -0.051723 -0.093395 0.000000
v -0.047786 -0.093395 -0.019794
v -0.036574 -0.093395 -0.036574
v -0.019794 -0.093395 -0.047786
v 0.000000 -0.093395 -0.051723
v 0.019794 -0.093395 -0.047786
v 0.047786 0.000933 -0.019794
v 0.036574 0.000933 -0.036574
v 0.051723 0.000933 0.000000
v 0.047786 0.000933 0.019794
v 0.036574 0.000933 0.036574
v 0.019794 0.000933 0.047786
v 0.000000 0.000933 0.051723
v -0.019794 0.000933 0.047786
v -0.036574 0.000933 0.036574
v -0.047786 0.000933 0.019794
v -0.051723 0.000933 -0.000000
v -0.047786 0.000933 -0.019794
v -0.036574 0.000933 -0.036574
v -0.019794 0.000933 -0.047786
v 0.000000 0.000933 -0.051723
v 0.019794 0.000933 -0.047786
v 0.029520 0.025836 -0.029520
v 0.038570 0.025836 -0.015976
v 0.041747 0.025836 0.000000
v 0.038570 0.025836 0.015976
v 0.029520 0.025836 0.029520
v 0.015976 0.025836 0.038570
v 0.000000 0.025836 0.041747
v -0.015976 0.025836 0.038570
v -0.029520 0.025836 0.029520
v -0.038570 0.025836 0.015976
v -0.041747 0.025836 -0.000000
v -0.038570 0.025836 -0.015976
v -0.029520 0.025836 -0.029520
v -0.015976 0.025836 -0.038570
v 0.000000 0.025836 -0.041747
v 0.015976 0.025836 -0.038570
v 0.016971 0.043947 -0.016971
v 0.022174 0.043947 -0.009185
v 0.024001 0.043947 -0.000000
v 0.022174 0.043947 0.009185
v 0.016971 0.043947 0.016971
v 0.009185 0.043947 0.022174
v 0.000000 0.043947 0.024001
v -0.009185 0.043947 0.022174
v -0.016971 0.043947 0.016971
v -0.022174 0.043947 0.009185
v -0.024001 0.043947 -0.000000
v -0.022174 0.043947 -0.009185
v -0.016971 0.043947 -0.016971
v -0.009185 0.043947 -0.022174
v 0.000000 0.043947 -0.024001
v 0.009185 0.043947 -0.022174
v 0.000000 0.052248 -0.000000
v 0.000000 -0.130372 0.000000
vt 0.442348 0.723517
vt 0.486308 0.831276
vt 0.418328 0.734761
vt 0.395167 0.750823
vt 0.373643 0.774765
vt 0.355531 0.806014
vt 0.344085 0.847527
vt 0.345069 0.900493
vt 0.631555 0.864578
vt 0.625044 0.921431
vt 0.622930 0.819506
vt 0.606315 0.784119
vt 0.585782 0.758952
vt 0.563073 0.740060
vt 0.539419 0.727158
vt 0.515323 0.719335
vt 0.490992 0.716078
vt 0.466625 0.717152
vt 0.435373 0.277216
vt 0.403973 0.264260
vt 0.500079 0.097230
vt 0.370265 0.246237
vt 0.335730 0.219943
vt 0.300081 0.182134
vt 0.262476 0.125117
vt 0.216974 0.025934
vt 0.778332 0.030350
vt 0.738758 0.123675
vt 0.701168 0.180870
vt 0.664816 0.219670
vt 0.629820 0.246695
vt 0.596015 0.265220
vt 0.563142 0.277262
vt 0.530889 0.284061
vt 0.498888 0.286402
vt 0.466847 0.284667
vt 0.459076 0.657593
vt 0.425050 0.662927
vt 0.492525 0.656254
vt 0.526268 0.659145
vt 0.560395 0.666499
vt 0.595895 0.678983
vt 0.633372 0.697880
vt 0.672738 0.726412
vt 0.715266 0.766419
vt 0.758543 0.827819
vt 0.799890 0.921453
vt 0.187806 0.885604
vt 0.230129 0.805500
vt 0.272531 0.751734
vt 0.313481 0.714767
vt 0.352656 0.690394
vt 0.389517 0.673219
vt 0.454967 0.604740
vt 0.415050 0.607973
vt 0.493828 0.603607
vt 0.532820 0.605524
vt 0.573377 0.611385
vt 0.616082 0.620340
vt 0.662800 0.633827
vt 0.716953 0.655882
vt 0.778810 0.684490
vt 0.857426 0.732283
vt 0.960309 0.806764
vt 0.057122 0.775946
vt 0.144127 0.716184
vt 0.215313 0.674136
vt 0.275173 0.645576
vt 0.325884 0.628063
vt 0.372403 0.614745
vt 0.454414 0.411584
vt 0.410358 0.408623
vt 0.497682 0.413327
vt 0.541389 0.413677
vt 0.586156 0.410672
vt 0.633149 0.407708
vt 0.685877 0.402631
vt 0.746282 0.392320
vt 0.815042 0.377662
vt 0.895950 0.356644
vt 0.995142 0.323746
vt 0.011842 0.328297
vt 0.111950 0.356544
vt 0.190537 0.373008
vt 0.257165 0.387893
vt 0.313761 0.396372
vt 0.364103 0.403965
vt 0.456937 0.383080
vt 0.413987 0.379535
vt 0.498747 0.385110
vt 0.540505 0.383766
vt 0.583838 0.382503
vt 0.629454 0.375367
vt 0.679524 0.364508
vt 0.736206 0.351371
vt 0.800809 0.330810
vt 0.875776 0.303252
vt 0.958165 0.266489
vt 0.046418 0.264682
vt 0.129767 0.300477
vt 0.203269 0.329077
vt 0.266294 0.346593
vt 0.320660 0.364084
vt 0.369024 0.373744
vt 0.460561 0.338929
vt 0.422574 0.332644
vt 0.498173 0.341211
vt 0.536405 0.339836
vt 0.575642 0.334995
vt 0.616907 0.325682
vt 0.661410 0.311265
vt 0.711247 0.291253
vt 0.764908 0.259158
vt 0.827888 0.217071
vt 0.907128 0.167677
vt 0.091213 0.167936
vt 0.169329 0.215271
vt 0.235118 0.254654
vt 0.288750 0.286234
vt 0.336602 0.308830
vt 0.380534 0.325355
vt 0.462452 0.318040
vt 0.426722 0.312070
vt 0.497797 0.320014
vt 0.533811 0.318275
vt 0.570605 0.312568
vt 0.608932 0.302035
vt 0.649660 0.285578
vt 0.693702 0.261242
vt 0.743464 0.226984
vt 0.800880 0.178871
vt 0.884225 0.108849
vt 0.118541 0.109644
vt 0.198644 0.175916
vt 0.254967 0.224836
vt 0.303820 0.258704
vt 0.347531 0.283186
vt 0.388815 0.300133
vn 0.384594 0.819025 -0.425703
vn 0.000000 1.000000 0.000000
vn 0.553056 0.801019 -0.229072
vn 0.534013 0.845454 0.000000
vn 0.553056 0.801019 0.229072
vn 0.384594 0.819025 0.425703
vn 0.192419 0.819025 0.540483
vn -0.029054 0.819025 0.572985
vn -0.246101 0.819025 0.518235
vn -0.425703 0.819025 0.384594
vn -0.540483 0.819025 0.192419
vn -0.572985 0.819025 -0.029054
vn -0.518235 0.819025 -0.246101
vn -0.384594 0.819025 -0.425703
vn -0.192419 0.819025 -0.540483
vn 0.029054 0.819025 -0.572985
vn 0.204352 0.845454 -0.493362
vn 0.622639 -0.561296 -0.545183
vn 0.646901 -0.713920 -0.267953
vn 0.000000 -1.000000 0.000000
vn 0.825770 -0.561296 -0.054750
vn 0.783868 -0.561296 0.265419
vn 0.622639 -0.561296 0.545183
vn 0.366588 -0.561296 0.741966
vn 0.054750 -0.561296 0.825770
vn -0.265419 -0.561296 0.783868
vn -0.545183 -0.561296 0.622639
vn -0.741966 -0.561296 0.366588
vn -0.825770 -0.561296 0.054750
vn -0.783868 -0.561296 -0.265419
vn -0.622608 -0.561296 -0.545183
vn -0.366588 -0.561296 -0.741966
vn -0.054750 -0.561296 -0.825770
vn 0.340922 -0.454176 -0.823084
vn 0.305734 0.601337 -0.738151
vn 0.586932 0.546983 -0.596881
vn 0.007019 0.546983 -0.837092
vn -0.313822 0.546983 -0.776055
vn -0.586932 0.546983 -0.596881
vn -0.770653 0.546983 -0.326853
vn -0.837092 0.546983 -0.007019
vn -0.776055 0.546983 0.313822
vn -0.596881 0.546983 0.586932
vn -0.326853 0.546983 0.770653
vn -0.007019 0.546983 0.837092
vn 0.313822 0.546983 0.776055
vn 0.586932 0.546983 0.596881
vn 0.805261 0.490127 0.333537
vn 0.798975 0.601337 0.000000
vn 0.805261 0.490127 -0.333537
vn 0.370312 0.252174 -0.894009
vn 0.692618 0.189581 -0.695914
vn 0.002319 0.189581 -0.981842
vn -0.373577 0.189581 -0.907987
vn -0.692618 0.189581 -0.695914
vn -0.906217 0.189581 -0.377880
vn -0.981842 0.189581 -0.002319
vn -0.907987 0.189581 0.373577
vn -0.695914 0.189581 0.692618
vn -0.377880 0.189581 0.906217
vn -0.002319 0.189581 0.981842
vn 0.373577 0.189581 0.907987
vn 0.692618 0.189581 0.695914
vn 0.896969 0.151463 0.415265
vn 0.975829 0.216468 0.028871
vn 0.916471 0.126194 -0.379620
vn 0.527360 -0.713157 -0.461776
vn -0.039247 -0.804895 -0.592059
vn -0.527360 -0.713157 -0.461776
vn -0.663961 -0.713157 -0.224799
vn -0.699454 -0.713157 0.046358
vn -0.628468 -0.713157 0.310495
vn -0.461776 -0.713157 0.527360
vn -0.224799 -0.713157 0.663961
vn 0.046358 -0.713157 0.699454
vn 0.310495 -0.713157 0.628468
vn 0.527360 -0.713157 0.461776
vn 0.663961 -0.713157 0.224799
vn 0.592059 -0.804895 -0.039247
vn 0.505570 -0.836940 -0.209418
vn 0.168493 -0.897824 -0.406781
vn 0.461776 -0.713157 -0.527360
vn 0.054750 -0.561296 -0.825770
vn -0.190283 -0.804895 -0.562029
vn -0.461776 -0.713157 -0.527360
vn -0.628468 -0.713157 -0.310495
vn -0.699454 -0.713157 -0.046358
vn -0.663961 -0.713157 0.224799
vn -0.527360 -0.713157 0.461776
vn -0.310495 -0.713157 0.628468
vn -0.046358 -0.713157 0.699454
vn 0.224799 -0.713157 0.663961
vn 0.461776 -0.713157 0.527360
vn 0.628468 -0.713157 0.310495
vn 0.825770 -0.561296 0.054750
vn 0.733879 -0.607440 -0.303964
vn 0.340922 0.454176 -0.823084
vn 0.527360 0.713157 -0.461776
vn -0.046358 0.713157 -0.699454
vn -0.310495 0.713157 -0.628468
vn -0.527360 0.713157 -0.461776
vn -0.663961 0.713157 -0.224799
vn -0.699454 0.713157 0.046358
vn -0.628468 0.713157 0.310495
vn -0.461776 0.713157 0.527360
vn -0.224799 0.713157 0.663961
vn 0.046358 0.713157 0.699454
vn 0.310495 0.713157 0.628468
vn 0.527360 0.713157 0.461776
vn 0.663961 0.713157 0.224799
vn 0.699454 0.713157 -0.046358
vn 0.406781 0.897824 -0.168493
vn 0.168493 0.897824 -0.406781
vn 0.461776 0.713157 -0.527360
vn 0.046358 0.713157 -0.699454
vn -0.224799 0.713157 -0.663961
vn -0.461776 0.713157 -0.527360
vn -0.628468 0.713157 -0.310495
vn -0.699454 0.713157 -0.046358
vn -0.663961 0.713157 0.224799
vn -0.527360 0.713157 0.461776
vn -0.310495 0.713157 0.628468
vn -0.046358 0.713157 0.699454
vn 0.224799 0.713157 0.663961
vn 0.461776 0.713157 0.527360
vn 0.628468 0.713157 0.310495
vn 0.699454 0.713157 0.046358
vn 0.823084 0.454176 -0.340922
usemtl None_Untitled
s 1
f 113/1/1 129/2/2 114/3/3
f 115/4/4 114/3/3 129/2/2
f 116/5/5 115/4/4 129/2/2
f 117/6/6 116/5/5 129/2/2
f 118/7/7 117/6/6 129/2/2
f 119/8/8 118/7/7 129/2/2
f 120/9/9 119/10/8 129/2/2
f 121/11/10 120/9/9 129/2/2
f 122/12/11 121/11/10 129/2/2
f 123/13/12 122/12/11 129/2/2
f 124/14/13 123/13/12 129/2/2
f 125/15/14 124/14/13 129/2/2
f 126/16/15 125/15/14 129/2/2
f 127/17/16 126/16/15 129/2/2
f 128/18/17 127/17/16 129/2/2
f 128/18/17 129/2/2 113/1/1
f 1/19/18 2/20/19 130/21/20
f 2/20/19 3/22/21 130/21/20
f 3/22/21 4/23/22 130/21/20
f 4/23/22 5/24/23 130/21/20
f 5/24/23 6/25/24 130/21/20
f 6/25/24 7/26/25 130/21/20
f 7/27/25 8/28/26 130/21/20
f 8/28/26 9/29/27 130/21/20
f 9/29/27 10/30/28 130/21/20
f 10/30/28 11/31/29 130/21/20
f 11/31/29 12/32/30 130/21/20
f 12/32/30 13/33/31 130/21/20
f 13/33/31 14/34/32 130/21/20
f 14/34/32 15/35/33 130/21/20
f 15/35/33 16/36/34 130/21/20
f 16/36/34 1/19/18 130/21/20
f 112/37/35 128/18/17 113/1/1
f 112/37/35 113/1/1 97/38/36
f 112/37/35 111/39/37 127/17/16
f 112/37/35 127/17/16 128/18/17
f 111/39/37 110/40/38 126/16/15
f 111/39/37 126/16/15 127/17/16
f 110/40/38 109/41/39 125/15/14
f 110/40/38 125/15/14 126/16/15
f 109/41/39 108/42/40 124/14/13
f 109/41/39 124/14/13 125/15/14
f 108/42/40 107/43/41 123/13/12
f 108/42/40 123/13/12 124/14/13
f 107/43/41 106/44/42 122/12/11
f 107/43/41 122/12/11 123/13/12
f 106/44/42 105/45/43 121/11/10
f 106/44/42 121/11/10 122/12/11
f 105/45/43 104/46/44 120/9/9
f 105/45/43 120/9/9 121/11/10
f 104/46/44 103/47/45 119/10/8
f 104/46/44 119/10/8 120/9/9
f 103/48/45 102/49/46 118/7/7
f 103/48/45 118/7/7 119/8/8
f 102/49/46 101/50/47 117/6/6
f 102/49/46 117/6/6 118/7/7
f 101/50/47 100/51/48 116/5/5
f 101/50/47 116/5/5 117/6/6
f 100/51/48 99/52/49 116/5/5
f 99/52/49 115/4/4 116/5/5
f 99/52/49 98/53/50 114/3/3
f 99/52/49 114/3/3 115/4/4
f 97/38/36 113/1/1 114/3/3
f 97/38/36 114/3/3 98/53/50
f 96/54/51 112/37/35 97/38/36
f 96/54/51 97/38/36 82/55/52
f 96/54/51 95/56/53 111/39/37
f 96/54/51 111/39/37 112/37/35
f 95/56/53 94/57/54 110/40/38
f 95/56/53 110/40/38 111/39/37
f 94/57/54 93/58/55 109/41/39
f 94/57/54 109/41/39 110/40/38
f 93/58/55 92/59/56 108/42/40
f 93/58/55 108/42/40 109/41/39
f 92/59/56 91/60/57 107/43/41
f 92/59/56 107/43/41 108/42/40
f 91/60/57 90/61/58 106/44/42
f 91/60/57 106/44/42 107/43/41
f 90/61/58 89/62/59 105/45/43
f 90/61/58 105/45/43 106/44/42
f 89/62/59 88/63/60 104/46/44
f 89/62/59 104/46/44 105/45/43
f 88/63/60 87/64/61 103/47/45
f 88/63/60 103/47/45 104/46/44
f 87/65/61 86/66/62 102/49/46
f 87/65/61 102/49/46 103/48/45
f 86/66/62 85/67/63 101/50/47
f 86/66/62 101/50/47 102/49/46
f 85/67/63 84/68/64 100/51/48
f 85/67/63 100/51/48 101/50/47
f 84/68/64 83/69/65 100/51/48
f 83/69/65 99/52/49 100/51/48
f 83/69/65 81/70/66 98/53/50
f 83/69/65 98/53/50 99/52/49
f 82/55/52 97/38/36 98/53/50
f 82/55/52 98/53/50 81/70/66
f 80/71/34 96/54/51 82/55/52
f 80/71/34 82/55/52 65/72/67
f 80/71/34 79/73/68 95/56/53
f 80/71/34 95/56/53 96/54/51
f 79/73/68 78/74/32 94/57/54
f 79/73/68 94/57/54 95/56/53
f 78/74/32 77/75/69 93/58/55
f 78/74/32 93/58/55 94/57/54
f 77/75/69 76/76/70 92/59/56
f 77/75/69 92/59/56 93/58/55
f 76/76/70 75/77/71 91/60/57
f 76/76/70 91/60/57 92/59/56
f 75/77/71 74/78/72 90/61/58
f 75/77/71 90/61/58 91/60/57
f 74/78/72 73/79/73 89/62/59
f 74/78/72 89/62/59 90/61/58
f 73/79/73 72/80/74 88/63/60
f 73/79/73 88/63/60 89/62/59
f 72/80/74 71/81/75 87/64/61
f 72/80/74 87/64/61 88/63/60
f 71/82/75 70/83/76 86/66/62
f 71/82/75 86/66/62 87/65/61
f 70/83/76 69/84/77 85/67/63
f 70/83/76 85/67/63 86/66/62
f 69/84/77 68/85/78 84/68/64
f 69/84/77 84/68/64 85/67/63
f 68/85/78 67/86/79 83/69/65
f 68/85/78 83/69/65 84/68/64
f 67/86/79 66/87/80 81/70/66
f 67/86/79 81/70/66 83/69/65
f 65/72/67 82/55/52 81/70/66
f 65/72/67 81/70/66 66/87/80
f 64/88/81 80/71/34 65/72/67
f 64/88/81 65/72/67 50/89/82
f 64/88/81 63/90/83 79/73/68
f 64/88/81 79/73/68 80/71/34
f 63/90/83 62/91/84 79/73/68
f 62/91/84 78/74/32 79/73/68
f 62/91/84 61/92/85 77/75/69
f 62/91/84 77/75/69 78/74/32
f 61/92/85 60/93/86 76/76/70
f 61/92/85 76/76/70 77/75/69
f 60/93/86 59/94/87 75/77/71
f 60/93/86 75/77/71 76/76/70
f 59/94/87 58/95/88 74/78/72
f 59/94/87 74/78/72 75/77/71
f 58/95/88 57/96/89 73/79/73
f 58/95/88 73/79/73 74/78/72
f 57/96/89 56/97/90 72/80/74
f 57/96/89 72/80/74 73/79/73
f 56/97/90 55/98/91 71/81/75
f 56/97/90 71/81/75 72/80/74
f 55/99/91 54/100/92 70/83/76
f 55/99/91 70/83/76 71/82/75
f 54/100/92 53/101/93 69/84/77
f 54/100/92 69/84/77 70/83/76
f 53/101/93 52/102/94 68/85/78
f 53/101/93 68/85/78 69/84/77
f 52/102/94 51/103/95 67/86/79
f 52/102/94 67/86/79 68/85/78
f 51/103/95 49/104/96 67/86/79
f 49/104/96 66/87/80 67/86/79
f 50/89/82 65/72/67 66/87/80
f 50/89/82 66/87/80 49/104/96
f 48/105/97 64/88/81 50/89/82
f 48/105/97 50/89/82 33/106/98
f 48/105/97 47/107/99 63/90/83
f 48/105/97 63/90/83 64/88/81
f 47/107/99 46/108/100 62/91/84
f 47/107/99 62/91/84 63/90/83
f 46/108/100 45/109/101 61/92/85
f 46/108/100 61/92/85 62/91/84
f 45/109/101 44/110/102 60/93/86
f 45/109/101 60/93/86 61/92/85
f 44/110/102 43/111/103 59/94/87
f 44/110/102 59/94/87 60/93/86
f 43/111/103 42/112/104 58/95/88
f 43/111/103 58/95/88 59/94/87
f 42/112/104 41/113/105 57/96/89
f 42/112/104 57/96/89 58/95/88
f 41/113/105 40/114/106 56/97/90
f 41/113/105 56/97/90 57/96/89
f 40/114/106 39/115/107 55/98/91
f 40/114/106 55/98/91 56/97/90
f 39/116/107 38/117/108 54/100/92
f 39/116/107 54/100/92 55/99/91
f 38/117/108 37/118/109 53/101/93
f 38/117/108 53/101/93 54/100/92
f 37/118/109 36/119/110 52/102/94
f 37/118/109 52/102/94 53/101/93
f 36/119/110 35/120/111 51/103/95
f 36/119/110 51/103/95 52/102/94
f 35/120/111 34/121/112 49/104/96
f 35/120/111 49/104/96 51/103/95
f 33/106/98 50/89/82 49/104/96
f 33/106/98 49/104/96 34/121/112
f 32/122/113 48/105/97 33/106/98
f 32/122/113 33/106/98 17/123/114
f 32/122/113 31/124/115 47/107/99
f 32/122/113 47/107/99 48/105/97
f 31/124/115 30/125/116 46/108/100
f 31/124/115 46/108/100 47/107/99
f 30/125/116 29/126/117 45/109/101
f 30/125/116 45/109/101 46/108/100
f 29/126/117 28/127/118 44/110/102
f 29/126/117 44/110/102 45/109/101
f 28/127/118 27/128/119 43/111/103
f 28/127/118 43/111/103 44/110/102
f 27/128/119 26/129/120 42/112/104
f 27/128/119 42/112/104 43/111/103
f 26/129/120 25/130/121 41/113/105
f 26/129/120 41/113/105 42/112/104
f 25/130/121 24/131/122 40/114/106
f 25/130/121 40/114/106 41/113/105
f 24/131/122 23/132/123 39/115/107
f 24/131/122 39/115/107 40/114/106
f 23/133/123 22/134/124 38/117/108
f 23/133/123 38/117/108 39/116/107
f 22/134/124 21/135/125 37/118/109
f 22/134/124 37/118/109 38/117/108
f 21/135/125 20/136/126 36/119/110
f 21/135/125 36/119/110 37/118/109
f 20/136/126 19/137/127 35/120/111
f 20/136/126 35/120/111 36/119/110
f 19/137/127 18/138/128 34/121/112
f 19/137/127 34/121/112 35/120/111
f 17/123/114 33/106/98 34/121/112
f 17/123/114 34/121/112 18/138/128
f 17/123/114 1/19/18 16/36/34
f 17/123/114 16/36/34 32/122/113
f 16/36/34 15/35/33 31/124/115
f 16/36/34 31/124/115 32/122/113
f 15/35/33 14/34/32 30/125/116
f 15/35/33 30/125/116 31/124/115
f 14/34/32 13/33/31 29/126/117
f 14/34/32 29/126/117 30/125/116
f 13/33/31 12/32/30 28/127/118
f 13/33/31 28/127/118 29/126/117
f 12/32/30 11/31/29 27/128/119
f 12/32/30 27/128/119 28/127/118
f 11/31/29 10/30/28 26/129/120
f 11/31/29 26/129/120 27/128/119
f 10/30/28 9/29/27 25/130/121
f 10/30/28 25/130/121 26/129/120
f 9/29/27 8/28/26 24/131/122
f 9/29/27 24/131/122 25/130/121
f 8/28/26 7/27/25 23/132/123
f 8/28/26 23/132/123 24/131/122
f 7/26/25 6/25/24 22/134/124
f 7/26/25 22/134/124 23/133/123
f 6/25/24 5/24/23 21/135/125
f 6/25/24 21/135/125 22/134/124
f 5/24/23 4/23/22 20/136/126
f 5/24/23 20/136/126 21/135/125
f 4/23/22 3/22/21 19/137/127
f 4/23/22 19/137/127 20/136/126
f 3/22/21 2/20/19 18/138/128
f 3/22/21 18/138/128 19/137/127
f 1/19/18 17/123/114 18/138/128
f 1/19/18 18/138/128 2/20/19

BIN
model/cube.blend Normal file

Binary file not shown.

11
model/cube.mtl Normal file
View file

@ -0,0 +1,11 @@
# Material Count: 1
newmtl Material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.483062 0.483062 0.483062
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

427
model/cube.obj Normal file
View file

@ -0,0 +1,427 @@
# Blender3D v249 OBJ File: cube.blend
# www.blender3d.org
o Cube
v -0.445003 -0.500000 0.445003
v -0.445003 -0.500000 -0.445003
v 0.445003 -0.500000 -0.445003
v 0.445003 -0.500000 0.445003
v -0.445003 0.500000 0.445003
v 0.445003 0.500000 0.445003
v 0.445003 0.500000 -0.445003
v -0.445003 0.500000 -0.445003
v 0.500000 0.445003 0.445003
v 0.500000 -0.445003 0.445003
v 0.500000 -0.445003 -0.445003
v 0.500000 0.445003 -0.445003
v -0.445003 0.445003 0.500000
v -0.445003 -0.445003 0.500000
v 0.445003 -0.445003 0.500000
v 0.445003 0.445003 0.500000
v -0.500000 0.445003 -0.445003
v -0.500000 -0.445003 -0.445003
v -0.500000 -0.445003 0.445003
v -0.500000 0.445003 0.445003
v -0.445003 -0.445003 -0.500000
v -0.445003 0.445003 -0.500000
v 0.445003 0.445003 -0.500000
v 0.445003 -0.445003 -0.500000
v 0.490850 -0.467094 0.445003
v 0.467094 -0.490850 0.445003
v 0.467094 -0.490850 -0.445003
v 0.490850 -0.467094 -0.445003
v -0.445003 -0.467094 0.490850
v -0.445003 -0.490850 0.467094
v 0.445003 -0.490850 0.467094
v 0.445003 -0.467094 0.490850
v -0.445003 -0.490850 -0.467094
v -0.445003 -0.467094 -0.490850
v 0.445003 -0.467094 -0.490850
v 0.445003 -0.490850 -0.467094
v -0.490850 -0.467094 -0.445003
v -0.467094 -0.490850 -0.445003
v -0.467094 -0.490850 0.445003
v -0.490850 -0.467094 0.445003
v -0.445003 0.467094 -0.490850
v -0.445003 0.490850 -0.467094
v 0.445003 0.490850 -0.467093
v 0.445003 0.467094 -0.490849
v -0.467094 0.490850 -0.445003
v -0.490850 0.467094 -0.445003
v -0.490850 0.467094 0.445003
v -0.467094 0.490850 0.445003
v 0.467093 0.490850 0.445003
v 0.490849 0.467094 0.445003
v 0.490850 0.467094 -0.445003
v 0.467094 0.490850 -0.445003
v -0.445003 0.490850 0.467094
v -0.445003 0.467094 0.490850
v 0.445003 0.467094 0.490850
v 0.445003 0.490850 0.467094
v 0.467094 0.445003 -0.490849
v 0.490850 0.445003 -0.467094
v 0.490850 -0.445003 -0.467094
v 0.467094 -0.445003 -0.490850
v 0.490849 0.445003 0.467094
v 0.467093 0.445003 0.490850
v 0.467094 -0.445003 0.490850
v 0.490850 -0.445003 0.467094
v -0.467094 0.445003 0.490850
v -0.490850 0.445003 0.467094
v -0.490850 -0.445003 0.467094
v -0.467094 -0.445003 0.490850
v -0.490850 0.445003 -0.467094
v -0.467094 0.445003 -0.490850
v -0.467094 -0.445003 -0.490850
v -0.490850 -0.445003 -0.467094
v 0.468509 -0.478868 -0.468509
v 0.468509 -0.468509 -0.478868
v 0.478868 -0.468509 -0.468509
v 0.468509 -0.478868 0.468509
v 0.478868 -0.468509 0.468509
v 0.468509 -0.468509 0.478868
v -0.468509 -0.478868 0.468509
v -0.468509 -0.468509 0.478868
v -0.478868 -0.468509 0.468509
v -0.468509 -0.478868 -0.468509
v -0.478868 -0.468509 -0.468509
v -0.468509 -0.468509 -0.478868
v 0.468509 0.478868 -0.468509
v 0.478868 0.468509 -0.468509
v 0.468509 0.468509 -0.478868
v 0.468509 0.478868 0.468510
v 0.468509 0.468509 0.478869
v 0.478868 0.468509 0.468510
v -0.468509 0.478868 0.468509
v -0.478868 0.468509 0.468509
v -0.468509 0.468509 0.478868
v -0.468509 0.478868 -0.468509
v -0.468509 0.468509 -0.478868
v -0.478868 0.468509 -0.468509
vt 0.968509 0.978868
vt 0.978868 0.968509
vt 0.968509 0.968509
vt 0.031491 0.031491
vt 0.021132 0.031491
vt 0.031491 0.021132
vt 0.021132 0.968509
vt 0.031491 0.978868
vt 0.031491 0.968509
vt 0.968509 0.021131
vt 0.978868 0.031490
vt 0.968509 0.031490
vt 0.054997 0.945003
vt 0.032906 0.945003
vt 0.054997 0.967094
vt 0.054997 0.032906
vt 0.032906 0.054997
vt 0.054997 0.054997
vt 0.945003 0.054997
vt 0.967094 0.054997
vt 0.945003 0.032906
vt 0.968509 0.031491
vt 0.945003 0.967094
vt 0.967094 0.945003
vt 0.945003 0.945003
vt 0.967093 0.945003
vt 0.031490 0.968509
vt 0.967093 0.054997
vt 0.945003 0.967093
vt 0.009150 0.054997
vt 0.009150 0.945003
vt 0.990849 0.945003
vt 0.978868 0.031491
vt 0.990850 0.054997
vt 0.990850 0.945003
vt 0.945003 0.009150
vt 0.054997 0.009150
vt 0.990849 0.054997
vt 0.945003 0.990849
vt 0.054997 0.990850
vt 0.945003 0.990850
vt 0.968509 0.021132
vn 0.539140 -0.462966 -0.703513
vn 0.703513 -0.539140 -0.462966
vn 0.462966 -0.703513 -0.539140
vn 0.703513 -0.462966 0.539140
vn 0.462966 -0.539140 0.703513
vn 0.539140 -0.703513 0.462966
vn -0.539140 -0.462966 0.703513
vn -0.703513 -0.539140 0.462966
vn -0.462966 -0.703513 0.539140
vn -0.703513 -0.462966 -0.539140
vn -0.462966 -0.539140 -0.703513
vn -0.539140 -0.703513 -0.462966
vn 0.703513 0.462966 -0.539140
vn 0.462966 0.539140 -0.703513
vn 0.539140 0.703513 -0.462966
vn 0.539140 0.462966 0.703513
vn 0.703513 0.539140 0.462966
vn 0.462966 0.703513 0.539140
vn -0.703513 0.462966 0.539140
vn -0.462966 0.539140 0.703513
vn -0.539140 0.703513 0.462966
vn -0.539140 0.462966 -0.703513
vn -0.703513 0.539140 -0.462966
vn -0.462966 0.703513 -0.539140
vn -0.153356 0.232643 -0.960387
vn -0.499557 0.182134 -0.846889
vn -0.200720 0.575213 -0.792962
vn -0.182134 -0.499557 -0.846889
vn -0.575213 -0.200720 -0.792962
vn -0.193823 -0.127750 -0.972655
vn 0.153356 -0.232643 -0.960387
vn 0.499557 -0.182134 -0.846889
vn 0.200720 -0.575213 -0.792962
vn 0.182134 0.499557 -0.846889
vn 0.575213 0.200720 -0.792962
vn 0.193823 0.127750 -0.972655
vn -0.960387 -0.232643 -0.153356
vn -0.846889 -0.182134 -0.499557
vn -0.792962 -0.575213 -0.200720
vn -0.846889 0.499557 -0.182134
vn -0.792962 0.200720 -0.575213
vn -0.972655 0.127750 -0.193823
vn -0.960387 0.232643 0.153356
vn -0.846889 0.182134 0.499557
vn -0.792962 0.575213 0.200720
vn -0.846889 -0.499557 0.182134
vn -0.792962 -0.200720 0.575213
vn -0.972655 -0.127750 0.193823
vn -0.127750 -0.193823 0.972655
vn -0.499557 -0.182134 0.846889
vn -0.200720 -0.575213 0.792962
vn -0.182134 0.499557 0.846889
vn -0.575213 0.200720 0.792962
vn -0.232643 0.153356 0.960387
vn 0.127750 0.193823 0.972655
vn 0.499557 0.182134 0.846889
vn 0.200720 0.575213 0.792962
vn 0.182134 -0.499557 0.846889
vn 0.575213 -0.200720 0.792962
vn 0.232643 -0.153356 0.960387
vn 0.976165 -0.153356 0.153356
vn 0.846889 -0.182134 0.499557
vn 0.814112 -0.553423 0.175848
vn 0.846889 0.499557 0.182134
vn 0.792962 0.200720 0.575213
vn 0.960387 0.153356 0.232643
vn 0.972655 0.193823 -0.127750
vn 0.846889 0.182134 -0.499557
vn 0.792962 0.575213 -0.200720
vn 0.825434 -0.520432 -0.218574
vn 0.792962 -0.200720 -0.575213
vn 0.961516 -0.194220 -0.194220
vn 0.232643 0.960387 0.153356
vn 0.182134 0.846889 0.499557
vn 0.575213 0.792962 0.200720
vn -0.499557 0.846889 0.182134
vn -0.200720 0.792962 0.575213
vn -0.127750 0.972655 0.193823
vn -0.182134 0.846889 -0.499557
vn -0.575213 0.792962 -0.200720
vn -0.232643 0.960387 -0.153356
vn 0.127750 0.972655 -0.193823
vn 0.499557 0.846889 -0.182134
vn 0.200720 0.792962 -0.575213
vn -0.194220 -0.961516 -0.194220
vn -0.520432 -0.825434 -0.218574
vn -0.200720 -0.792962 -0.575213
vn -0.553423 -0.814112 0.175848
vn -0.153356 -0.976165 0.153356
vn -0.182134 -0.846889 0.499557
vn 0.499557 -0.846889 0.182134
vn 0.200720 -0.792962 0.575213
vn 0.153356 -0.960387 0.232643
vn 0.193823 -0.972655 -0.127750
vn 0.182134 -0.846889 -0.499557
vn 0.575213 -0.792962 -0.200720
usemtl Material
s 1
f 74/1/1 75/2/2 73/3/3
f 77/4/4 78/5/5 76/6/6
f 80/6/7 81/5/8 79/4/9
f 83/7/10 84/8/11 82/9/12
f 86/2/13 87/1/14 85/3/15
f 89/10/16 90/11/17 88/12/18
f 92/5/19 93/6/20 91/4/21
f 95/8/22 96/7/23 94/9/24
f 22/13/25 70/14/26 41/15/27
f 70/14/26 95/9/22 41/15/27
f 34/16/28 84/4/11 71/17/29
f 34/16/28 71/17/29 21/18/30
f 24/19/31 60/20/32 35/21/33
f 60/20/32 74/22/1 35/21/33
f 44/23/34 87/3/14 57/24/35
f 44/23/34 57/24/35 23/25/36
f 18/19/37 72/20/38 37/21/39
f 72/20/38 83/22/10 37/21/39
f 46/23/40 96/3/23 69/24/41
f 46/23/40 69/24/41 17/25/42
f 20/13/43 66/14/44 47/15/45
f 66/14/44 92/9/19 47/15/45
f 40/16/46 81/4/8 67/17/47
f 40/16/46 67/17/47 19/18/48
f 14/18/49 68/17/50 29/16/51
f 68/17/50 80/4/7 29/16/51
f 54/15/52 93/9/20 65/14/53
f 54/15/52 65/14/53 13/13/54
f 16/25/55 62/26/56 55/23/57
f 62/26/56 89/3/16 55/23/57
f 32/21/58 78/22/5 63/20/59
f 32/21/58 63/20/59 15/19/60
f 10/18/61 64/17/62 25/16/63
f 64/17/62 77/4/4 25/16/63
f 50/15/64 90/27/17 61/14/65
f 50/15/64 61/14/65 9/13/66
f 12/25/67 58/26/68 51/23/69
f 58/26/68 86/3/13 51/23/69
f 28/21/70 75/22/2 59/20/71
f 28/21/70 59/20/71 11/19/72
f 6/19/73 56/21/74 49/28/75
f 56/21/74 88/12/18 49/28/75
f 48/17/76 91/4/21 53/16/77
f 48/17/76 53/16/77 5/18/78
f 42/15/79 94/9/24 45/14/80
f 42/15/79 45/14/80 8/13/81
f 7/25/82 52/24/83 43/29/84
f 52/24/83 85/3/15 43/29/84
f 2/13/85 38/14/86 33/15/87
f 38/14/86 82/9/12 33/15/87
f 39/17/88 1/18/89 30/16/90
f 39/17/88 30/16/90 79/4/9
f 26/20/91 76/22/6 31/21/92
f 26/20/91 31/21/92 4/19/93
f 3/25/94 36/23/95 27/24/96
f 36/23/95 73/3/3 27/24/96
f 71/17/29 84/4/11 83/5/10
f 71/17/29 83/5/10 72/30/38
f 95/9/22 70/14/26 69/31/41
f 95/9/22 69/31/41 96/7/23
f 67/30/47 81/5/8 80/4/7
f 67/30/47 80/4/7 68/17/50
f 92/9/19 66/14/44 65/31/53
f 92/9/19 65/31/53 93/7/20
f 63/30/59 78/5/5 77/4/4
f 63/30/59 77/4/4 64/17/62
f 89/3/16 62/26/56 61/32/65
f 89/3/16 61/32/65 90/2/17
f 74/33/1 60/34/32 59/20/71
f 74/33/1 59/20/71 75/22/2
f 57/24/35 87/3/14 86/2/13
f 57/24/35 86/2/13 58/35/68
f 55/36/57 89/10/16 88/12/18
f 55/36/57 88/12/18 56/21/74
f 93/6/20 54/37/52 53/16/77
f 93/6/20 53/16/77 91/4/21
f 51/35/69 86/2/13 85/3/15
f 51/35/69 85/3/15 52/24/83
f 90/11/17 50/38/64 49/28/75
f 90/11/17 49/28/75 88/12/18
f 47/30/45 92/5/19 91/4/21
f 47/30/45 91/4/21 48/17/76
f 96/7/23 46/31/40 45/14/80
f 96/7/23 45/14/80 94/9/24
f 87/1/14 44/39/34 43/29/84
f 87/1/14 43/29/84 85/3/15
f 41/40/27 95/8/22 94/9/24
f 41/40/27 94/9/24 42/15/79
f 81/5/8 40/30/46 39/17/88
f 81/5/8 39/17/88 79/4/9
f 37/31/39 83/7/10 82/9/12
f 37/31/39 82/9/12 38/14/86
f 35/41/33 74/1/1 73/3/3
f 35/41/33 73/3/3 36/23/95
f 84/8/11 34/40/28 33/15/87
f 84/8/11 33/15/87 82/9/12
f 78/42/5 32/36/58 31/21/92
f 78/42/5 31/21/92 76/22/6
f 29/37/51 80/6/7 79/4/9
f 29/37/51 79/4/9 30/16/90
f 75/2/2 28/35/70 27/24/96
f 75/2/2 27/24/96 73/3/3
f 25/16/63 77/4/4 76/6/6
f 25/16/63 76/6/6 26/37/91
f 60/20/32 24/19/31 23/25/36
f 60/20/32 23/25/36 57/24/35
f 34/16/28 21/18/30 24/19/31
f 34/16/28 24/19/31 35/21/33
f 22/13/25 41/15/27 44/23/34
f 22/13/25 44/23/34 23/25/36
f 70/14/26 22/13/25 21/18/30
f 70/14/26 21/18/30 71/17/29
f 66/14/44 20/13/43 19/18/48
f 66/14/44 19/18/48 67/17/47
f 46/23/40 17/25/42 20/13/43
f 46/23/40 20/13/43 47/15/45
f 18/19/37 37/21/39 40/16/46
f 18/19/37 40/16/46 19/18/48
f 72/20/38 18/19/37 17/25/42
f 72/20/38 17/25/42 69/24/41
f 62/26/56 16/25/55 15/19/60
f 62/26/56 15/19/60 63/20/59
f 54/15/52 13/13/54 16/25/55
f 54/15/52 16/25/55 55/23/57
f 14/18/49 29/16/51 32/21/58
f 14/18/49 32/21/58 15/19/60
f 68/17/50 14/18/49 13/13/54
f 68/17/50 13/13/54 65/14/53
f 58/26/68 12/25/67 11/19/72
f 58/26/68 11/19/72 59/20/71
f 50/15/64 9/13/66 12/25/67
f 50/15/64 12/25/67 51/23/69
f 10/18/61 25/16/63 11/19/72
f 25/16/63 28/21/70 11/19/72
f 64/17/62 10/18/61 9/13/66
f 64/17/62 9/13/66 61/14/65
f 42/15/79 8/13/81 7/25/82
f 42/15/79 7/25/82 43/29/84
f 48/17/76 5/18/78 8/13/81
f 48/17/76 8/13/81 45/14/80
f 6/19/73 49/28/75 52/24/83
f 6/19/73 52/24/83 7/25/82
f 56/21/74 6/19/73 5/18/78
f 56/21/74 5/18/78 53/16/77
f 26/20/91 4/19/93 3/25/94
f 26/20/91 3/25/94 27/24/96
f 30/16/90 1/18/89 4/19/93
f 30/16/90 4/19/93 31/21/92
f 2/13/85 33/15/87 36/23/95
f 2/13/85 36/23/95 3/25/94
f 1/18/89 39/17/88 2/13/85
f 39/17/88 38/14/86 2/13/85
f 71/17/29 72/30/38 69/31/41
f 71/17/29 69/31/41 70/14/26
f 67/30/47 68/17/50 65/14/53
f 67/30/47 65/14/53 66/31/44
f 63/20/59 64/34/62 61/32/65
f 63/20/59 61/32/65 62/26/56
f 59/20/71 60/34/32 57/32/35
f 59/20/71 57/32/35 58/26/68
f 55/23/57 56/41/74 53/40/77
f 55/23/57 53/40/77 54/15/52
f 51/23/69 52/41/83 49/40/75
f 51/23/69 49/40/75 50/15/64
f 47/30/45 48/17/76 45/14/80
f 47/30/45 45/14/80 46/31/40
f 43/29/84 44/39/34 41/40/27
f 43/29/84 41/40/27 42/15/79
f 39/17/88 40/30/46 37/31/39
f 39/17/88 37/31/39 38/14/86
f 35/41/33 36/23/95 33/15/87
f 35/41/33 33/15/87 34/40/28
f 31/21/92 32/36/58 29/37/51
f 31/21/92 29/37/51 30/16/90
f 27/24/96 28/35/70 25/34/63
f 27/24/96 25/34/63 26/20/91
f 23/25/36 24/19/31 21/18/30
f 23/25/36 21/18/30 22/13/25
f 19/18/48 20/13/43 17/25/42
f 19/18/48 17/25/42 18/19/37
f 15/19/60 16/25/55 14/18/49
f 16/25/55 13/13/54 14/18/49
f 11/19/72 12/25/67 10/18/61
f 12/25/67 9/13/66 10/18/61
f 7/25/82 8/13/81 5/18/78
f 7/25/82 5/18/78 6/19/73
f 1/18/89 2/13/85 3/25/94
f 1/18/89 3/25/94 4/19/93

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -4,17 +4,19 @@ module CPUPlayer ( CPUPlayer(..)
) where ) where
import Data.Fixed
import Data.Ratio ((%))
import Data.Typeable import Data.Typeable
import Transformable
import Vector
import GLDriver import GLDriver
import Player import Player
data CPUPlayer = CPUPlayer Micro data CPUPlayer = CPUPlayer Rotation
deriving (Typeable, Show) deriving (Typeable, Show)
instance Player CPUPlayer where instance Player CPUPlayer where
-- playerUpdate (CPUPlayer angle) _ = return (CPUPlayer (if (angle+0.2) > 180 then angle-359.8 else angle+0.2), Just angle, True, Just (-angle), ((fromIntegral . round $ angle) == angle) && ((round $ angle) `mod` 2 == 0)) -- playerUpdate (CPUPlayer angle) _ = return (CPUPlayer (if (angle+0.2) > 180 then angle-359.8 else angle+0.2), Just angle, True, Just (-angle), ((fromIntegral . round $ angle) == angle) && ((round $ angle) `mod` 2 == 0))
playerUpdate (CPUPlayer angle) _ = return (CPUPlayer (if (angle+0.2) > 180 then angle-359.8 else angle+0.2), Just angle, True, Just (-angle), False) playerUpdate (CPUPlayer dir) _ = return (CPUPlayer dir', Just dir', True, Just $ negateV dir', False)
where
dir' = (fromAngle (0.2*pi/180)) >< dir

View file

@ -5,68 +5,64 @@ module Collision ( collisionTankBorder
import Tank import Tank
import Game import Game
import Transformable
import Data.Fixed import qualified Vector as V
import Data.Ratio import Data.VectorSpace
tankWidth :: Micro tankWidth :: Coord
tankWidth = 0.4 tankWidth = 0.4
tankLength :: Micro tankLength :: Coord
tankLength = 0.95 tankLength = 0.95
bulletDiameter :: Micro bulletDiameter :: Coord
bulletDiameter = 0.05 bulletDiameter = 0.05
collisionTankBorder :: Micro -> Micro -> Tank -> Tank collisionTankBorder :: Coord -> Coord -> Tank -> Tank
collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy} collisionTankBorder lw lh tank = V.Vector dx dy >< tank
where where
dir = (fromRational . toRational . tankDir $ tank)*pi/180 corners = [ V.Vector (tankLength/2) (tankWidth/2)
cosd = fromRational (round ((cos dir)*1000000)%1000000) , V.Vector (-tankLength/2) (tankWidth/2)
sind = fromRational (round ((sin dir)*1000000)%1000000) , V.Vector (-tankLength/2) (-tankWidth/2)
, V.Vector (tankLength/2) (-tankWidth/2)
]
points = [ (tankLength/2, tankWidth/2) rotp v = tankDir tank >< v
, (-tankLength/2, tankWidth/2) transp v = v >< tankPos tank
, (-tankLength/2, -tankWidth/2)
, (tankLength/2, -tankWidth/2)
]
rotp (x, y) = (cosd*x - sind*y, sind*x + cosd*y) points = map (transp . rotp) corners
transp (x, y) = (x + tankX tank, y + tankY tank) minx = minimum $ map V.vertexX points
maxx = maximum $ map V.vertexX points
miny = minimum $ map V.vertexY points
maxy = maximum $ map V.vertexY points
pointst = map (transp . rotp) points dx = if minx < 0 then (-minx) else if maxx > lw then (-maxx+lw) else 0
minx = minimum $ map fst pointst dy = if miny < 0 then (-miny) else if maxy > lh then (-maxy+lh) else 0
maxx = maximum $ map fst pointst
miny = minimum $ map snd pointst
maxy = maximum $ map snd pointst
dx = if minx < 0 then (-minx) else if maxx > lw then (-maxx+lw) else 0
dy = if miny < 0 then (-miny) else if maxy > lh then (-maxy+lh) else 0
newx = (tankX tank) + dx
newy = (tankY tank) + dy
collisionBulletBullet :: (Bullet, Bullet) -> (Bullet, Bullet) -> Bool collisionBulletBullet :: (Bullet, Bullet) -> (Bullet, Bullet) -> Bool
collisionBulletBullet (b1, b1') (b2, b2') = distancesq < (bulletDiameter^2) collisionBulletBullet (b1, b1') (b2, b2') = distancesq < (bulletDiameter^2)
where where
distancesq = (bulletX b1' - bulletX b2')^2 + (bulletY b1' - bulletY b2')^2 distancesq = (bulletX b1' - bulletX b2')^2 + (bulletY b1' - bulletY b2')^2
collisionBulletTank :: (Bullet, Bullet) -> (Tank, Tank) -> Bool collisionBulletTank :: (Bullet, Bullet) -> (Tank, Tank) -> Bool
collisionBulletTank (b, b') (tank, tank') = (not ((between bx minx maxx) && (between by miny maxy))) && ((between bx' minx maxx) && (between by' miny maxy)) collisionBulletTank (b, b') (tank, tank') = (not ((between bx minx maxx) && (between by miny maxy))) && ((between bx' minx maxx) && (between by' miny maxy))
where where
between x a b = x >= a && x <= b between x a b = x >= a && x <= b
dir t = (fromRational . toRational . tankDir $ t)*pi/180 rotp t v = tankDir t >:< v
cosd t = fromRational (round ((cos $ dir t)*1000000)%1000000) transp t v = V.diffV (tankPos t) v
sind t = fromRational (round ((sin $ dir t)*1000000)%1000000)
rotp t (x, y) = ((cosd t)*x + (sind t)*y, -(sind t)*x + (cosd t)*y) V.Vector bx by = (rotp tank) . (transp tank) $ bulletPos b
transp t (x, y) = (x - tankX t, y - tankY t) V.Vector bx' by' = (rotp tank') . (transp tank') $ bulletPos b'
(bx, by) = (rotp tank) . (transp tank) $ (bulletX b, bulletY b) minx = -(tankLength+bulletDiameter)/2
(bx', by') = (rotp tank') . (transp tank') $ (bulletX b', bulletY b') maxx = (tankLength+bulletDiameter)/2
miny = -(tankWidth+bulletDiameter)/2
maxy = (tankWidth+bulletDiameter)/2
minx = -tankLength/2 collisionTankTank :: ((Tank, Tank), (Tank, Tank)) -> (Tank, Tank)
maxx = tankLength/2 collisionTankTank ((t1, t1'), (t2, t2')) = (t1'', t2'')
miny = -tankWidth/2 where
maxy = tankWidth/2 t1'' = t1'
t2'' = t2'

View file

@ -8,7 +8,7 @@ import qualified Data.Set as S
import Data.Fixed import Data.Fixed
import Data.Ratio ((%)) import Data.Ratio ((%))
import Data.Typeable import Data.Typeable
import Graphics.Rendering.OpenGL.GL (GLfloat, Vector3(..)) import Graphics.Rendering.OpenGL.GL (GLfloat, Vector3(..), Vertex2(..))
import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..)) import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
import Graphics.Rendering.OpenGL.GL.CoordTrans (unsafePreservingMatrix, translate, rotate) import Graphics.Rendering.OpenGL.GL.CoordTrans (unsafePreservingMatrix, translate, rotate)
import Graphics.Rendering.OpenGL.GL.VertexSpec import Graphics.Rendering.OpenGL.GL.VertexSpec
@ -16,8 +16,9 @@ import Graphics.Rendering.OpenGL.GL.VertexSpec
import Tank import Tank
import GLDriver import GLDriver
import Player import Player
import Vector
import Transformable (Coord)
import Data.VectorSpace
data DefaultPlayer = DefaultPlayer (S.Set Key) Float Float Bool data DefaultPlayer = DefaultPlayer (S.Set Key) Float Float Bool
deriving (Typeable, Show) deriving (Typeable, Show)
@ -26,12 +27,12 @@ instance Player DefaultPlayer where
playerUpdate (DefaultPlayer keys aimx aimy shoot) tank = playerUpdate (DefaultPlayer keys aimx aimy shoot) tank =
let x = (if (S.member KeyLeft keys) then (-1) else 0) + (if (S.member KeyRight keys) then 1 else 0) let x = (if (S.member KeyLeft keys) then (-1) else 0) + (if (S.member KeyRight keys) then 1 else 0)
y = (if (S.member KeyDown keys) then (-1) else 0) + (if (S.member KeyUp keys) then 1 else 0) y = (if (S.member KeyDown keys) then (-1) else 0) + (if (S.member KeyUp keys) then 1 else 0)
ax = aimx - (fromRational . toRational . tankX $ tank) ax = realToFrac $ aimx - (fromRational . toRational . tankX $ tank)
ay = aimy - (fromRational . toRational . tankY $ tank) ay = realToFrac $ aimy - (fromRational . toRational . tankY $ tank)
move = (x /= 0 || y /= 0) move = (x /= 0 || y /= 0)
angle = if move then Just $ fromRational $ round ((atan2 y x)*1000000*180/pi)%1000000 else Nothing dir = if move then Just (fst . fromVector $ Vector x y) else Nothing
aangle = if (ax /= 0 || ay /= 0) then Just $ fromRational $ round ((atan2 ay ax)*1000000*180/pi)%1000000 else Nothing adir = if (ax /= 0 || ay /= 0) then Just (fst . fromVector $ Vector ax ay) else Nothing
in return (DefaultPlayer keys aimx aimy False, angle, move, aangle, shoot) in return (DefaultPlayer keys aimx aimy False, dir, move, adir, shoot)
handleEvent (DefaultPlayer keys aimx aimy shoot) ev handleEvent (DefaultPlayer keys aimx aimy shoot) ev
| Just (KeyPressEvent key) <- fromEvent ev = DefaultPlayer (S.insert key keys) aimx aimy shoot | Just (KeyPressEvent key) <- fromEvent ev = DefaultPlayer (S.insert key keys) aimx aimy shoot
@ -41,7 +42,7 @@ instance Player DefaultPlayer where
| otherwise = DefaultPlayer keys aimx aimy shoot | otherwise = DefaultPlayer keys aimx aimy shoot
renderPlayer (DefaultPlayer _ aimx aimy _) = unsafePreservingMatrix $ do renderPlayer (DefaultPlayer _ aimx aimy _) = unsafePreservingMatrix $ do
translate $ Vector3 aimx aimy (0.2 :: GLfloat) translate $ Vector3 (realToFrac aimx) (realToFrac aimy) (0.2 :: GLfloat)
rotate 30 $ Vector3 1 0 (0 :: GLfloat) rotate 30 $ Vector3 1 0 (0 :: GLfloat)
unsafeRenderPrimitive Quads $ do unsafeRenderPrimitive Quads $ do

View file

@ -11,7 +11,7 @@ import Data.Maybe (isJust)
import Data.Ratio import Data.Ratio
import Graphics.Rendering.OpenGL.GL (($=), GLdouble, GLfloat, Vector3(..), Capability(..)) import Graphics.Rendering.OpenGL.GL (($=), GLdouble, GLfloat, Vector3(..), Capability(..))
import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, ortho, translate, scale, rotate) import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, ortho, translate, scale, rotate, frustum)
import Graphics.X11.Types import Graphics.X11.Types
import Graphics.X11.Xlib.Atom (internAtom) import Graphics.X11.Xlib.Atom (internAtom)
@ -205,10 +205,11 @@ resize lw lh w h = do
matrixMode $= Projection matrixMode $= Projection
loadIdentity loadIdentity
ortho (-sf*aspectf) (sf*aspectf) (-sf) sf (-1) 1 --ortho (-sf*aspectf) (sf*aspectf) (-sf) sf (-1) 1
scale 1 1 (0.1 :: GLfloat) --scale 1 1 (0.1 :: GLfloat)
frustum (-sf*aspectf) (sf*aspectf) (-sf) sf 10 100
rotate (-30) $ Vector3 1 0 (0 :: GLfloat) rotate (-30) $ Vector3 1 0 (0 :: GLfloat)
translate $ Vector3 (-(fromIntegral lw)/2) (-(fromIntegral lh)/2) (0 :: GLfloat) translate $ Vector3 (-(fromIntegral lw)/2) ((fromIntegral lh)/2) (-11 :: GLfloat)
matrixMode $= Modelview 0 matrixMode $= Modelview 0

View file

@ -1,26 +1,35 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Game ( Bullet(..) module Game ( Bullet(..)
, bulletX
, bulletY
, GameState(..) , GameState(..)
) where ) where
import Level import Level
import Tank import Tank
import Vector
import Control.Monad
import Control.Monad.State
import Data.Fixed
data Bullet = Bullet data Bullet = Bullet
{ bulletX :: !Micro { bulletPos :: !Vertex
, bulletY :: !Micro , bulletDir :: !Rotation
, bulletDir :: !Micro , bulletSpeed :: !Coord
, bulletSpeed :: !Micro
, bulletBouncesLeft :: !Int , bulletBouncesLeft :: !Int
, bulletTank :: !Int , bulletTank :: !Int
} deriving (Eq, Show) } deriving (Eq, Show)
bulletX :: Bullet -> Coord
bulletX = vertexX . bulletPos
bulletY :: Bullet -> Coord
bulletY = vertexY . bulletPos
instance Transformable Bullet where
transform t b = b { bulletPos = pos, bulletDir = dir } where
pos = t >< bulletPos b
dir = t >< bulletDir b
data GameState = GameState data GameState = GameState
{ level :: !Level { level :: !Level
, tanks :: ![Tank] , tanks :: ![Tank]

View file

@ -10,6 +10,8 @@ import DefaultPlayer
import HWiidPlayer import HWiidPlayer
import Simulation import Simulation
import Tank import Tank
import Vector
import GLDriver import GLDriver
import GLX import GLX
@ -20,25 +22,24 @@ import qualified Data.Map as M
import qualified Data.Set as S import qualified Data.Set as S
import Data.Time import Data.Time
import Data.Obj3D
import Data.Obj3D.GL
main :: IO () main :: IO ()
main = do main = do
let theLevel = testLevel let theLevel = testLevel
--hwiidPlayer <- newHWiidPlayer --humanPlayer <- newHWiidPlayer
let humanPlayer = DefaultPlayer S.empty 0 0 False
gl <- initGL $ glxDriver (levelWidth theLevel) (levelHeight theLevel) gl <- initGL $ glxDriver (levelWidth theLevel) (levelHeight theLevel)
when (initialized gl) $ do when (initialized gl) $ do
currentTime <- getCurrentTime currentTime <- getCurrentTime
let gamestate = GameState {level = theLevel, tanks = [ Tank 5.0 5.0 0 0 1.5 270 False 3 1 5 1 let gamestate = GameState {level = theLevel, tanks = [ Tank (Vertex 7.0 4.0) zeroV zeroV 1.5 (270*pi/180) False 3 1 5 1
, Tank 5.0 3.5 0 0 1.5 270 False 3 1 5 1 , Tank (Vertex 4.0 4.0) zeroV zeroV 1.5 (270*pi/180) False 3 1 5 1
, Tank (Vertex 10.0 4.0) zeroV zeroV 1.5 (270*pi/180) False 3 1 5 1
], bullets = []} ], bullets = []}
mainstate = MainState {run = True, driver = SomeDriver gl, time = currentTime, players = mainstate = MainState {run = True, driver = SomeDriver gl, time = currentTime, players =
[ SomePlayer $ DefaultPlayer S.empty 0 0 False [ SomePlayer humanPlayer
--SomePlayer $ hwiidPlayer , SomePlayer $ CPUPlayer $ fromAngle $ -pi/2
, SomePlayer $ CPUPlayer 0 , SomePlayer $ CPUPlayer $ fromAngle $ pi/2
], textures = M.empty, models = M.empty, gameState = gamestate} ], textures = M.empty, models = M.empty, gameState = gamestate}
runMain mainstate $ do runMain mainstate $ do

View file

@ -12,7 +12,7 @@ import Data.Maybe
import Data.Ratio ((%)) import Data.Ratio ((%))
import Data.Typeable import Data.Typeable
import HWiid import HWiid
import Graphics.Rendering.OpenGL.GL (GLfloat, Vector3(..)) import Graphics.Rendering.OpenGL.GL (GLfloat, Vector3(..), Vertex2(..))
import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..)) import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
import Graphics.Rendering.OpenGL.GL.CoordTrans (unsafePreservingMatrix, translate, rotate) import Graphics.Rendering.OpenGL.GL.CoordTrans (unsafePreservingMatrix, translate, rotate)
import Graphics.Rendering.OpenGL.GL.VertexSpec import Graphics.Rendering.OpenGL.GL.VertexSpec
@ -20,6 +20,8 @@ import Graphics.Rendering.OpenGL.GL.VertexSpec
import Player import Player
import Tank import Tank
import qualified Transformable as T
import qualified Vector as V
data HWiidPlayer = HWiidPlayer Wiimote WiimoteAccCal [(Float, Float)] data HWiidPlayer = HWiidPlayer Wiimote WiimoteAccCal [(Float, Float)]
@ -51,21 +53,21 @@ instance Player HWiidPlayer where
then take irSkipSmooth newaims then take irSkipSmooth newaims
else newaims else newaims
(aimx, aimy) = if null aims then (0, 0) else mulV (1/(fromIntegral $ length aims)) (foldr addV (0, 0) aims) (aimx, aimy) = if null aims then (0, 0) else mulV (1/(fromIntegral $ length aims)) (foldr addV (0, 0) aims)
ax = aimx - (fromRational . toRational . tankX $ tank) ax = realToFrac $ aimx - (fromRational . toRational . tankX $ tank)
ay = aimy - (fromRational . toRational . tankY $ tank) ay = realToFrac $ aimy - (fromRational . toRational . tankY $ tank)
aangle = if (ax /= 0 || ay /= 0) then Just $ fromRational $ round ((atan2 ay ax)*1000000*180/pi)%1000000 else Nothing aim = if (ax /= 0 || ay /= 0) then Just . fst . V.fromVector $ V.Vector ax ay else Nothing
move = (mx /= 0 || my /= 0) move = (mx /= 0 || my /= 0)
angle = atan2 my mx angle = atan2 my mx
moveangle = if move then Just $ fromRational $ round ((angle - (sin $ 8*x)/8)*1000000*180/pi)%1000000 else Nothing dir = if move then Just $ V.fromAngle (fromRational $ round ((angle - (sin $ 8*x)/8)*1000000)%1000000) else Nothing
when foo $ print state when foo $ print state
return (HWiidPlayer wiimote cal aims, moveangle, move, aangle, shoot) return (HWiidPlayer wiimote cal aims, dir, move, aim, shoot)
renderPlayer (HWiidPlayer _ _ []) = return () renderPlayer (HWiidPlayer _ _ []) = return ()
renderPlayer (HWiidPlayer _ _ aims) = unsafePreservingMatrix $ do renderPlayer (HWiidPlayer _ _ aims) = unsafePreservingMatrix $ do
let (x, y) = mulV (1/(fromIntegral $ length aims)) $ foldr addV (0, 0) aims let (x, y) = mulV (1/(fromIntegral $ length aims)) $ foldr addV (0, 0) aims
translate $ Vector3 x y (0.2 :: GLfloat) translate $ Vector3 (realToFrac x) (realToFrac y) (0.2 :: GLfloat)
rotate 30 $ Vector3 1 0 (0 :: GLfloat) rotate 30 $ Vector3 1 0 (0 :: GLfloat)
unsafeRenderPrimitive Quads $ do unsafeRenderPrimitive Quads $ do

View file

@ -4,12 +4,14 @@ module Model ( Model(..)
) where ) where
import Paths_htanks import Paths_htanks
import Data.Obj3D.GL (InterleavedObj) import Data.Obj3D.OpenGL (InterleavedObj)
data Model = ModelTank data Model = ModelTank | ModelBullet | ModelBlock
deriving (Eq, Ord, Show) deriving (Eq, Ord, Show)
modelPath :: Model -> IO FilePath modelPath :: Model -> IO FilePath
modelPath t = getDataFileName $ "model/" ++ (name t) ++ ".obj" modelPath t = getDataFileName $ "model/" ++ (name t) ++ ".obj"
where where
name ModelTank = "tank" name ModelTank = "tank"
name ModelBullet = "bullet"
name ModelBlock = "cube"

View file

@ -4,7 +4,7 @@ module Player ( Player(..)
, SomePlayer(..) , SomePlayer(..)
) where ) where
import Data.Fixed import Vector
import Data.Typeable import Data.Typeable
import Tank import Tank
@ -12,7 +12,7 @@ import GLDriver (SomeEvent)
class Player a where class Player a where
playerUpdate :: a -> Tank -> IO (a, Maybe Micro, Bool, Maybe Micro, Bool) playerUpdate :: a -> Tank -> IO (a, Maybe Rotation, Bool, Maybe Rotation, Bool)
handleEvent :: a -> SomeEvent -> a handleEvent :: a -> SomeEvent -> a
handleEvent player _ = player handleEvent player _ = player

View file

@ -10,19 +10,20 @@ import Player
import Tank import Tank
import Texture import Texture
import Model import Model
import qualified Vector as V
import Control.Monad.State import Control.Monad.State
import Data.Fixed import Data.Fixed
import Data.Maybe import Data.Maybe
import Data.Obj3D import Data.Obj3D
import Data.Obj3D.GL import Data.Obj3D.OpenGL
import Data.Ratio import Data.Ratio
import qualified Data.Map as M import qualified Data.Map as M
import Bindings.GLPng import Bindings.GLPng
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..), Vector3(..)) import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..), Vector3(..), Vertex2(..), Vertex4(..))
import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..)) import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
import Graphics.Rendering.OpenGL.GL.CoordTrans import Graphics.Rendering.OpenGL.GL.CoordTrans
import Graphics.Rendering.OpenGL.GL.Colors import Graphics.Rendering.OpenGL.GL.Colors
@ -80,7 +81,7 @@ setup = do
shadeModel $= Smooth shadeModel $= Smooth
lighting $= Enabled lighting $= Enabled
light (Light 0) $= Enabled light (Light 0) $= Enabled
position (Light 0) $= Vertex4 (-1) (-1) 1 (0 :: GLfloat) position (Light 0) $= Vertex4 (-1) (-1) 1.5 (0 :: GLfloat)
colorMaterial $= Just (Front, AmbientAndDiffuse) colorMaterial $= Just (Front, AmbientAndDiffuse)
clientState VertexArray $= Enabled clientState VertexArray $= Enabled
@ -96,6 +97,8 @@ setup = do
getTexture TextureCrosshair getTexture TextureCrosshair
getModel ModelTank getModel ModelTank
getModel ModelBullet
getModel ModelBlock
return () return ()
@ -113,6 +116,8 @@ render = do
textureCrosshair <- getTexture TextureCrosshair textureCrosshair <- getTexture TextureCrosshair
modelTank <- getModel ModelTank modelTank <- getModel ModelTank
modelBullet <- getModel ModelBullet
modelBlock <- getModel ModelBlock
(lw, lh) <- gets (level . gameState) >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat) (lw, lh) <- gets (level . gameState) >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat)
@ -127,70 +132,80 @@ render = do
normal $ Normal3 0 0 (1 :: GLfloat) normal $ Normal3 0 0 (1 :: GLfloat)
unsafeRenderPrimitive Quads $ do unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat) texCoord $ TexCoord2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
vertex $ Vertex2 0 lh vertex $ Vertex2 (-1) (lh+1)
texCoord $ TexCoord2 (lw/2) 0 texCoord $ TexCoord2 (lw/2+0.5) (-0.5)
vertex $ Vertex2 lw lh vertex $ Vertex2 (lw+1) (lh+1)
texCoord $ TexCoord2 (lw/2) (lh/2) texCoord $ TexCoord2 (lw/2+0.5) (lh/2+0.5)
vertex $ Vertex2 lw 0 vertex $ Vertex2 (lw+1) (-1)
texCoord $ TexCoord2 0 (lh/2) texCoord $ TexCoord2 (-0.5) (lh/2+0.5)
vertex $ Vertex2 (0 :: GLfloat) (0 :: GLfloat) vertex $ Vertex2 (-1 :: GLfloat) (-1 :: GLfloat)
texture Texture2D $= Disabled
bindInterleavedArrays modelTank bindInterleavedArrays modelTank
forM_ tanklist $ \tank -> unsafePreservingMatrix $ do forM_ tanklist $ \tank -> unsafePreservingMatrix $ do
let x = realToFrac . tankX $ tank let x = realToFrac . tankX $ tank
y = realToFrac . tankY $ tank y = realToFrac . tankY $ tank
rotDir = realToFrac . tankDir $ tank rotDir = realToFrac . V.toAngle . tankDir $ tank
rotAim = realToFrac . tankAim $ tank rotAim = realToFrac . V.toAngle . tankAim $ tank
translate $ Vector3 x y (0 :: GLfloat) translate $ Vector3 x y (0 :: GLfloat)
rotate rotDir $ Vector3 0 0 (1 :: GLfloat) rotate (rotDir*180/pi) $ Vector3 0 0 (1 :: GLfloat)
--textureBinding Texture2D $= Just textureTank textureBinding Texture2D $= Just textureTank
unsafePreservingMatrix $ do unsafePreservingMatrix $ do
rotate 90 $ Vector3 1 0 (0 :: GLfloat) rotate 90 $ Vector3 1 0 (0 :: GLfloat)
drawObject modelTank 1 drawObject modelTank 1
rotate (rotAim-rotDir) $ Vector3 0 0 (1 :: GLfloat) rotate ((rotAim-rotDir)*180/pi) $ Vector3 0 0 (1 :: GLfloat)
--textureBinding Texture2D $= Just textureCannon textureBinding Texture2D $= Just textureCannon
unsafePreservingMatrix $ do unsafePreservingMatrix $ do
rotate 90 $ Vector3 1 0 (0 :: GLfloat) rotate 90 $ Vector3 1 0 (0 :: GLfloat)
drawObject modelTank 0 drawObject modelTank 0
texture Texture2D $= Enabled texture Texture2D $= Disabled
bindInterleavedArrays modelBullet
forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do
let x = realToFrac . bulletX $ bullet let x = realToFrac . bulletX $ bullet
y = realToFrac . bulletY $ bullet y = realToFrac . bulletY $ bullet
rotDir = realToFrac . bulletDir $ bullet rotDir = realToFrac . V.toAngle . bulletDir $ bullet
translate $ Vector3 x y (0.2 :: GLfloat) translate $ Vector3 x y (0.25 :: GLfloat)
rotate 30 $ Vector3 1 0 (0 :: GLfloat) rotate ((rotDir*180/pi)-90) $ Vector3 0 0 (1 :: GLfloat)
rotate rotDir $ Vector3 0 0 (1 :: GLfloat)
textureBinding Texture2D $= Just textureBullet unsafePreservingMatrix $ do
drawObject modelBullet 0
unsafeRenderPrimitive Quads $ do bindInterleavedArrays modelBlock
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex3 (-0.1 :: GLfloat) (-0.1 :: GLfloat) 0
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat) texture Texture2D $= Enabled
vertex $ Vertex3 (-0.1 :: GLfloat) (0.1 :: GLfloat) 0 textureBinding Texture2D $= Just textureWood
forM_ [0.5..13.5] $ \x -> unsafePreservingMatrix $ do
translate $ Vector3 x 8.5 (0.5 :: GLfloat)
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
drawObject modelBlock 0
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat) forM_ [0.5..13.5] $ \x -> unsafePreservingMatrix $ do
vertex $ Vertex3 (0.1 :: GLfloat) (0.1 :: GLfloat) 0 translate $ Vector3 x (-0.5) (0.5 :: GLfloat)
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
drawObject modelBlock 0
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat) forM_ [-0.5..8.5] $ \y -> unsafePreservingMatrix $ do
vertex $ Vertex3 (0.1 :: GLfloat) (-0.1 :: GLfloat) 0 translate $ Vector3 (-0.5) y (0.5 :: GLfloat)
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
drawObject modelBlock 0
forM_ [-0.5..8.5] $ \y -> unsafePreservingMatrix $ do
translate $ Vector3 14.5 y (0.5 :: GLfloat)
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
drawObject modelBlock 0
depthFunc $= Just Always depthFunc $= Just Always

View file

@ -7,31 +7,33 @@ import Level
import MainLoop import MainLoop
import Player import Player
import Tank import Tank
import Transformable
import Vector
import Control.Monad.State import Control.Monad.State
import Data.Fixed
import Data.List import Data.List
import Data.Maybe import Data.Maybe
import Data.Ratio import Data.VectorSpace
updateAngle :: Micro -> Tank -> Tank updateAngle :: Rotation -> Tank -> Tank
updateAngle angle tank = tank {tankDir = newangle180} updateAngle dir tank = tank { tankDir = fromAngle newangle }
where where
oldangle = tankDir tank oldangle = toAngle . tankDir $ tank
angle = toAngle dir
tspeed = (tankTurnspeed tank)/100 tspeed = (tankTurnspeed tank)/100
diff = angle - oldangle diff = angle - oldangle
diff360 = if (diff > 180) diff360 = if (diff > pi)
then (diff-360) then (diff-2*pi)
else if (diff <= -180) else if (diff <= -pi)
then (diff+360) then (diff+2*pi)
else diff else diff
(diff180, angle180) = if (diff360 > 90) (diff180, angle180) = if (diff360 > pi/2)
then (diff360-180, oldangle+180) then (diff360-180, oldangle+pi)
else if (diff360 <= -90) else if (diff360 <= -pi/2)
then (diff360+180, oldangle-180) then (diff360+pi, oldangle-pi)
else (diff360, oldangle) else (diff360, oldangle)
turn = if (diff180 > tspeed) turn = if (diff180 > tspeed)
@ -42,20 +44,20 @@ updateAngle angle tank = tank {tankDir = newangle180}
newangle = angle180 + turn newangle = angle180 + turn
newangle180 = if (newangle > 180) approx :: Rotation -> Rotation -> Bool
then (newangle-360) approx r1 r2 = c1 `approx'` c2 && s1 `approx'` s2
else if (newangle <= -180) where
then (newangle+360) approx' a b = (abs (a-b)) < 0.000001
else newangle Vector c1 s1 = toVector 1 r1
Vector c2 s2 = toVector 1 r2
updateTank :: GameState -> Maybe Rotation -> Bool -> Maybe Rotation -> State Tank ()
updateTank game dir move aim = do
when (isJust dir) $
modify $ updateAngle $ fromJust dir
updateTank :: GameState -> Maybe Micro -> Bool -> Maybe Micro -> State Tank () when (isJust aim) $
updateTank game angle move aangle = do modify $ \tank -> tank { tankAim = fromJust aim }
when (isJust angle) $
modify $ updateAngle $ fromJust angle
when (isJust aangle) $
modify $ \tank -> tank {tankAim = fromJust aangle}
when move $ do when move $ do
tank <- get tank <- get
@ -63,15 +65,11 @@ updateTank game angle move aangle = do
tspeed = tankSpeed tank tspeed = tankSpeed tank
moved = tankMoving tank moved = tankMoving tank
when (isNothing angle || (isJust angle && (tdir == fromJust angle)) || moved) $ do when (isNothing dir || (isJust dir && (tdir `approx` fromJust dir) || moved)) $
let anglej = (fromRational . toRational $ tdir)*pi/180 put $ toVector (tspeed/100) tdir >< tank {tankMoving = True}
dx = tspeed * fromRational (round ((cos anglej)*1000)%100000)
dy = tspeed * fromRational (round ((sin anglej)*1000)%100000)
put tank {tankX = dx + tankX tank, tankY = dy + tankY tank, tankMoving = True}
when (not move) $ do when (not move) $ do
modify $ \tank -> tank {tankMoving = False} modify $ \tank -> tank {tankMoving = False}
let lw = fromIntegral . levelWidth . level $ game let lw = fromIntegral . levelWidth . level $ game
lh = fromIntegral . levelHeight . level $ game lh = fromIntegral . levelHeight . level $ game
@ -79,22 +77,19 @@ updateTank game angle move aangle = do
updateBullet :: GameState -> Bullet -> (Bullet, Bool) updateBullet :: GameState -> Bullet -> (Bullet, Bool)
updateBullet game bullet = (bullet {bulletX = newx, bulletY = newy, bulletDir = dir3, bulletBouncesLeft = bounces3}, bounces3 >= 0) updateBullet game bullet = (bullet {bulletPos = Vertex x' y', bulletDir = dir'', bulletBouncesLeft = bounces3}, bounces3 >= 0)
where where
angle = (fromRational . toRational . bulletDir $ bullet)*pi/180 rot180 = fromAngle pi
speed = bulletSpeed bullet speed = bulletSpeed bullet
dx = speed * fromRational (round ((cos angle)*1000)%100000) dir = bulletDir bullet
dy = speed * fromRational (round ((sin angle)*1000)%100000) Vertex x y = toVector (speed/100) dir >< bulletPos bullet
x = dx + bulletX bullet bounces = bulletBouncesLeft bullet
y = dy + bulletY bullet
lw = fromIntegral . levelWidth . level $ game lw = fromIntegral . levelWidth . level $ game
lh = fromIntegral . levelHeight . level $ game lh = fromIntegral . levelHeight . level $ game
dir = bulletDir bullet
bounces = bulletBouncesLeft bullet
sg = if dir < 0 then -1 else 1 (x', dir', bounces2) = if x < 0 then (-x, negateV dir, bounces-1) else if x > lw then (2*lw-x, negateV dir, bounces-1) else (x, dir, bounces)
(newx, dir2, bounces2) = if x < 0 then (-x, sg*180 - dir, bounces-1) else if x > lw then (2*lw-x, sg*180 - dir, bounces-1) else (x, dir, bounces) (y', dir'', bounces3) = if y < 0 then (-y, rot180 ^-^ dir', bounces2-1) else if y > lh then (2*lh-y, rot180 ^-^ dir', bounces2-1) else (y, dir', bounces2)
(newy, dir3, bounces3) = if y < 0 then (-y, -dir2, bounces2-1) else if y > lh then (2*lh-y, -dir2, bounces2-1) else (y, dir2, bounces2)
gameStep :: [(Tank, Bool)] -> GameState -> GameState gameStep :: [(Tank, Bool)] -> GameState -> GameState
gameStep tanksshoot state = state {tanks = thetanks, bullets = newbullets ++ (map snd . filter fst $ leftbullets2)} gameStep tanksshoot state = state {tanks = thetanks, bullets = newbullets ++ (map snd . filter fst $ leftbullets2)}
@ -104,8 +99,7 @@ gameStep tanksshoot state = state {tanks = thetanks, bullets = newbullets ++ (ma
thetanks = map (\(tank, n) -> tank {tankBulletsLeft = (tankBulletsLeft tank) + (countLostTankBullets n leftbullets2)}) $ zip newtanks2 [0..] thetanks = map (\(tank, n) -> tank {tankBulletsLeft = (tankBulletsLeft tank) + (countLostTankBullets n leftbullets2)}) $ zip newtanks2 [0..]
newtanks = map (\(tank, shoot, _) -> if (shoot && (tankBulletsLeft tank) > 0) then tank {tankBulletsLeft = (tankBulletsLeft tank) - 1} else tank) $ ts newtanks = map (\(tank, shoot, _) -> if (shoot && (tankBulletsLeft tank) > 0) then tank {tankBulletsLeft = (tankBulletsLeft tank) - 1} else tank) $ ts
newbullets = map (\(tank, n) -> Bullet newbullets = map (\(tank, n) -> Bullet
{ bulletX = tankX tank { bulletPos = tankPos tank
, bulletY = tankY tank
, bulletDir = tankAim tank , bulletDir = tankAim tank
, bulletSpeed = tankBulletSpeed tank , bulletSpeed = tankBulletSpeed tank
, bulletBouncesLeft = tankBulletBounces tank , bulletBouncesLeft = tankBulletBounces tank
@ -144,6 +138,6 @@ simulationStep = do
modify $ \state -> state {players = p, gameState = gameStep (zip t s) (gameState state)} modify $ \state -> state {players = p, gameState = gameStep (zip t s) (gameState state)}
where where
updateTank' game (player, tank) = do updateTank' game (player, tank) = do
(p, angle, move, aangle, shoot) <- playerUpdate player tank (p, dir, move, aim, shoot) <- playerUpdate player tank
let t = execState (updateTank game angle move aangle) tank let t = execState (updateTank game dir move aim) tank
return $ if (tankLife tank > 0) then (p, t, shoot) else (player, tank, False) return $ if (tankLife tank > 0) then (p, t, shoot) else (player, tank, False)

View file

@ -1,18 +1,31 @@
module Tank ( Tank(..) module Tank ( Tank(..)
, tankX
, tankY
) where ) where
import Data.Fixed import Vector
data Tank = Tank data Tank = Tank
{ tankX :: !Micro { tankPos :: !Vertex
, tankY :: !Micro , tankDir :: !Rotation
, tankDir :: !Micro , tankAim :: !Rotation
, tankAim :: !Micro , tankSpeed :: !Coord
, tankSpeed :: !Micro , tankTurnspeed :: !Coord
, tankTurnspeed :: !Micro
, tankMoving :: !Bool , tankMoving :: !Bool
, tankBulletSpeed :: !Micro , tankBulletSpeed :: !Coord
, tankBulletBounces :: !Int , tankBulletBounces :: !Int
, tankBulletsLeft :: !Int , tankBulletsLeft :: !Int
, tankLife :: !Int , tankLife :: !Int
} deriving (Eq, Show) } deriving (Eq, Show)
tankX :: Tank -> Coord
tankX = vertexX . tankPos
tankY :: Tank -> Coord
tankY = vertexY . tankPos
instance Transformable Tank where
transform t tank = tank { tankPos = pos , tankDir = dir, tankAim = aim } where
pos = t >< tankPos tank
dir = t >< tankDir tank
aim = t >< tankAim tank

43
src/Transformable.hs Normal file
View file

@ -0,0 +1,43 @@
{-# LANGUAGE TypeOperators, TypeSynonymInstances #-}
module Transformable ( Coord
, Vector3
, TransformMap
, Transform(..)
, ReversibleTransform(..)
, Transformable(..)
, (><)
, (>:<)
) where
import Data.LinearMap
type Coord = Double
type Vector3 = (Coord, Coord, Coord)
type TransformMap = Vector3 :-* Vector3
class Transformable a where
transform :: TransformMap -> a -> a
class Transform a where
toMap :: a -> TransformMap
class Transform a => ReversibleTransform a where
toMap' :: a -> TransformMap
instance Transformable Vector3 where
transform = lapply
instance Transform TransformMap where
toMap = id
instance Transformable TransformMap where
transform = (*.*)
(><) :: (Transform t, Transformable a) => t -> a -> a
(><) = transform . toMap
(>:<) :: (ReversibleTransform t, Transformable a) => t -> a -> a
(>:<) = transform . toMap'

93
src/Vector.hs Normal file
View file

@ -0,0 +1,93 @@
{-# LANGUAGE TypeFamilies #-}
module Vector ( Coord
, Transformable(..)
, Transform(..)
, ReversibleTransform(..)
, Vertex(..)
, Vector(..)
, Rotation
, zeroV
, (^+^)
, negateV
, (><)
, toAngle
, fromAngle
, toVector
, fromVector
, diffV
) where
import Transformable
import Data.AdditiveGroup
import Data.VectorSpace
import Data.LinearMap
data Vertex = Vertex { vertexX :: Coord, vertexY :: Coord } deriving (Show, Eq)
instance Transformable Vertex where
transform t (Vertex x y) = Vertex x' y'
where
(x', y', _) = t >< (x, y, 1) :: Vector3
data Vector = Vector { vectorX :: Coord, vectorY :: Coord } deriving (Show, Eq)
instance Transformable Vector where
transform t (Vector x y) = Vector x' y'
where
(x', y', _) = t >< (x, y, 0) :: Vector3
instance AdditiveGroup Vector where
zeroV = Vector 0 0
Vector x1 y1 ^+^ Vector x2 y2 = Vector (x1+x2) (y1+y2)
negateV (Vector x y) = Vector (-x) (-y)
instance VectorSpace Vector where
type Scalar Vector = Coord
r *^ Vector x y = Vector (r*x) (r*y)
instance InnerSpace Vector where
Vector x1 y1 <.> Vector x2 y2 = x1*x2 + y1*y2
instance Transform Vector where
toMap (Vector dx dy) = linear $ \(x, y, w) -> (x+w*dx, y+w*dy, w)
instance ReversibleTransform Vector where
toMap' = toMap . negateV
data Rotation = Rotation { rotC :: Coord, rotS :: Coord } deriving (Show, Eq)
instance Transformable Rotation where
transform t (Rotation c s) = Rotation (c'/l) (s'/l)
where
(c', s', _) = t >< (c, s, 0) :: Vector3
l = sqrt $ c'^2 + s'^2
instance AdditiveGroup Rotation where
zeroV = Rotation 1 0
Rotation c1 s1 ^+^ Rotation c2 s2 = Rotation (c1*c2 - s1*s2) (s1*c2 + c1*s2)
negateV (Rotation c s) = Rotation (-c) s
instance Transform Rotation where
toMap (Rotation c s) = linear $ \(x, y, w) -> (c*x - s*y, s*x + c*y, w)
instance ReversibleTransform Rotation where
toMap' = toMap . negateV
toAngle :: Rotation -> Coord
toAngle (Rotation c s) = atan2 s c
fromAngle :: Coord -> Rotation
fromAngle a = Rotation (cos a) (sin a)
toVector :: Coord -> Rotation -> Vector
toVector l (Rotation c s) = l *^ Vector c s
fromVector :: Vector -> (Rotation, Coord)
fromVector v = (Rotation x y, magnitude v)
where
Vector x y = normalized v
diffV :: Vertex -> Vertex -> Vector
diffV (Vertex x1 y1) (Vertex x2 y2) = Vector (x2-x1) (y2-y1)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 B

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 2.2 KiB