Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
880c8bbdcc | |||
0341c78d4e | |||
af355854be | |||
![]() |
1154459fde | ||
![]() |
37aa8e0c99 | ||
![]() |
41e8ffc696 | ||
![]() |
875b220344 | ||
![]() |
ec113f9da1 | ||
![]() |
addd1df429 | ||
![]() |
ff48b9a2be | ||
![]() |
04042d4f42 | ||
![]() |
466c85ae1a | ||
![]() |
af8e53a3a9 | ||
![]() |
9b39a17247 | ||
![]() |
422109ae49 | ||
![]() |
9afb118663 | ||
132c845995 | |||
20de9d3498 | |||
f110bd68f0 | |||
ca1d464e33 | |||
d2daab5ceb | |||
575d4c3bf9 | |||
427ee4905e | |||
![]() |
2be5ef3136 | ||
![]() |
8882b979c2 | ||
![]() |
de7f1f637c | ||
bdaaac6577 | |||
315ea823c6 | |||
40eeb29faa | |||
8f3ea06e20 | |||
![]() |
f8986d1920 | ||
![]() |
0c8f79ae0f | ||
7b5cede4b0 | |||
ccefcaabda | |||
![]() |
178cf4402b | ||
c929abb6af | |||
59b56b9798 | |||
![]() |
fe11b8de6e | ||
![]() |
1daaba6e17 |
30
README.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Interaktywny symulator lotu kosmicznego 3D "Interstellar Odyssey"
|
||||
![Screenshot](screenshot.png)
|
||||
|
||||
## Motyw Aplikacji:
|
||||
Interstellar Odyssey to gra zręcznościowa, której celem jest zebranie określonej liczby gwiazdek jednocześnie unikając pojawiających sie asteroid, które mogą zostać zniszczone pociskami gracza.
|
||||
|
||||
### Sceny:
|
||||
- Kosmiczne asteroidy i planety.<br>
|
||||
- Pasy asteroid. <br>
|
||||
|
||||
### Interakcje:
|
||||
- Sterowanie statkiem.
|
||||
- Strzelanie pociskami.
|
||||
- Zbieranie gwiazdek.
|
||||
- Unikanie przeszkód.
|
||||
- Niszczenie asteroid.
|
||||
|
||||
### Przełożenie Metod Grafiki na Realizację Motywu Aplikacji:
|
||||
* Mapowanie Normalnych: Detale powierzchni planet i asteroid, nadana trójwymiarowość.
|
||||
* PBR (Physically Based Rendering): Odpowiedzialne za realistyczne oświetlenie, cienie, odbicia i tekstury wysokiej jakości na statkach kosmicznych i otaczających obiektach, stosujące model Fresnela-Schlick
|
||||
* Proceduralne Generowanie Terenu: Generowanie asteroid i gwiazdek w przestrzeni kosmicznej.
|
||||
* Skybox
|
||||
* Kolizje
|
||||
* Animacja ruchu statku: Płynne i realistyczne ruchy statku kosmicznego przy skręcaniu, wznoszeniu i opadaniu.
|
||||
|
||||
###
|
||||
Wiktoria Grzesik <br>
|
||||
Maksymilian Szygenda <br>
|
||||
Nikodem Hederych <br>
|
||||
|
@ -37,6 +37,8 @@
|
||||
<ClInclude Include="src\Texture.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="shaders\rocket.frag" />
|
||||
<None Include="shaders\rocket.vert" />
|
||||
<None Include="shaders\shader_5_1.frag" />
|
||||
<None Include="shaders\shader_5_1.vert" />
|
||||
<None Include="shaders\shader_5_1_tex.frag" />
|
||||
@ -47,6 +49,8 @@
|
||||
<None Include="shaders\shader_5_tex.vert" />
|
||||
<None Include="shaders\shader_skybox.frag" />
|
||||
<None Include="shaders\shader_skybox.vert" />
|
||||
<None Include="shaders\signs.frag" />
|
||||
<None Include="shaders\signs.vert" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}</ProjectGuid>
|
||||
@ -67,7 +71,7 @@
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
@ -121,5 +121,17 @@
|
||||
<None Include="shaders\shader_5_tex.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\rocket.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\rocket.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\signs.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\signs.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
0
cw 7/models/Blank.mtl
Normal file
14597
cw 7/models/CraneoOBJ.obj
Normal file
358
cw 7/models/estrellica.obj
Normal file
@ -0,0 +1,358 @@
|
||||
# This file uses centimeters as units for non-parametric coordinates.
|
||||
|
||||
mtllib estrellica.mtl
|
||||
g default
|
||||
v 7.889562 1.150329 -2.173651
|
||||
v 2.212808 1.150329 -2.230414
|
||||
v 0.068023 1.150328 -7.923502
|
||||
v -2.151306 1.150329 -2.254857
|
||||
v -7.817406 1.150328 -2.261558
|
||||
v -3.523133 1.150328 1.888122
|
||||
v -4.869315 1.150328 6.987552
|
||||
v -0.006854 1.150329 4.473047
|
||||
v 4.838127 1.150328 7.041885
|
||||
v 3.538153 1.150329 1.927652
|
||||
v 0.033757 0.000000 -0.314657
|
||||
v 0.035668 2.269531 -0.312831
|
||||
vt 0.626409 0.064409
|
||||
vt 0.548284 0.007647
|
||||
vt 0.451716 0.007647
|
||||
vt 0.373591 0.064409
|
||||
vt 0.343750 0.156250
|
||||
vt 0.373591 0.248091
|
||||
vt 0.451716 0.304853
|
||||
vt 0.548284 0.304853
|
||||
vt 0.626409 0.248091
|
||||
vt 0.656250 0.156250
|
||||
vt 0.375000 0.312500
|
||||
vt 0.400000 0.312500
|
||||
vt 0.425000 0.312500
|
||||
vt 0.450000 0.312500
|
||||
vt 0.475000 0.312500
|
||||
vt 0.500000 0.312500
|
||||
vt 0.525000 0.312500
|
||||
vt 0.550000 0.312500
|
||||
vt 0.575000 0.312500
|
||||
vt 0.600000 0.312500
|
||||
vt 0.625000 0.312500
|
||||
vt 0.500000 0.688440
|
||||
vt 0.500000 0.156250
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
s off
|
||||
g pCylinder1
|
||||
usemtl initialShadingGroup
|
||||
f 1/11/1 11/22/2 2/12/3
|
||||
f 2/12/4 11/22/5 3/13/6
|
||||
f 3/13/7 11/22/8 4/14/9
|
||||
f 4/14/10 11/22/11 5/15/12
|
||||
f 5/15/13 11/22/14 6/16/15
|
||||
f 6/16/16 11/22/17 7/17/18
|
||||
f 7/17/19 11/22/20 8/18/21
|
||||
f 8/18/22 11/22/23 9/19/24
|
||||
f 9/19/25 11/22/26 10/20/27
|
||||
f 10/20/28 11/22/29 1/21/30
|
||||
f 1/1/31 12/23/32 10/10/33
|
||||
f 10/10/34 12/23/35 9/9/36
|
||||
f 9/9/37 12/23/38 8/8/39
|
||||
f 8/8/40 12/23/41 7/7/42
|
||||
f 7/7/43 12/23/44 6/6/45
|
||||
f 6/6/46 12/23/47 5/5/48
|
||||
f 5/5/49 12/23/50 4/4/51
|
||||
f 4/4/52 12/23/53 3/3/54
|
||||
f 3/3/55 12/23/56 2/2/57
|
||||
f 2/2/58 12/23/59 1/1/60
|
||||
g default
|
||||
v 7.889562 1.150329 -2.173651
|
||||
v 2.212808 1.150329 -2.230414
|
||||
v 0.068023 1.150328 -7.923502
|
||||
v -2.151306 1.150329 -2.254857
|
||||
v -7.817406 1.150328 -2.261558
|
||||
v -3.523133 1.150328 1.888122
|
||||
v -4.869315 1.150328 6.987552
|
||||
v -0.006854 1.150329 4.473047
|
||||
v 4.838127 1.150328 7.041885
|
||||
v 3.538153 1.150329 1.927652
|
||||
v 0.033757 0.000000 -0.314657
|
||||
v 0.035668 2.269531 -0.312831
|
||||
vt 0.626409 0.064409
|
||||
vt 0.548284 0.007647
|
||||
vt 0.451716 0.007647
|
||||
vt 0.373591 0.064409
|
||||
vt 0.343750 0.156250
|
||||
vt 0.373591 0.248091
|
||||
vt 0.451716 0.304853
|
||||
vt 0.548284 0.304853
|
||||
vt 0.626409 0.248091
|
||||
vt 0.656250 0.156250
|
||||
vt 0.375000 0.312500
|
||||
vt 0.400000 0.312500
|
||||
vt 0.425000 0.312500
|
||||
vt 0.450000 0.312500
|
||||
vt 0.475000 0.312500
|
||||
vt 0.500000 0.312500
|
||||
vt 0.525000 0.312500
|
||||
vt 0.550000 0.312500
|
||||
vt 0.575000 0.312500
|
||||
vt 0.600000 0.312500
|
||||
vt 0.625000 0.312500
|
||||
vt 0.500000 0.688440
|
||||
vt 0.500000 0.156250
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
s off
|
||||
g pCylinder1
|
||||
f 13/34/61 23/45/62 14/35/63
|
||||
f 14/35/64 23/45/65 15/36/66
|
||||
f 15/36/67 23/45/68 16/37/69
|
||||
f 16/37/70 23/45/71 17/38/72
|
||||
f 17/38/73 23/45/74 18/39/75
|
||||
f 18/39/76 23/45/77 19/40/78
|
||||
f 19/40/79 23/45/80 20/41/81
|
||||
f 20/41/82 23/45/83 21/42/84
|
||||
f 21/42/85 23/45/86 22/43/87
|
||||
f 22/43/88 23/45/89 13/44/90
|
||||
f 13/24/91 24/46/92 22/33/93
|
||||
f 22/33/94 24/46/95 21/32/96
|
||||
f 21/32/97 24/46/98 20/31/99
|
||||
f 20/31/100 24/46/101 19/30/102
|
||||
f 19/30/103 24/46/104 18/29/105
|
||||
f 18/29/106 24/46/107 17/28/108
|
||||
f 17/28/109 24/46/110 16/27/111
|
||||
f 16/27/112 24/46/113 15/26/114
|
||||
f 15/26/115 24/46/116 14/25/117
|
||||
f 14/25/118 24/46/119 13/24/120
|
||||
g default
|
||||
v 7.889562 1.150329 -2.173651
|
||||
v 2.212808 1.150329 -2.230414
|
||||
v 0.068023 1.150328 -7.923502
|
||||
v -2.151306 1.150329 -2.254857
|
||||
v -7.817406 1.150328 -2.261558
|
||||
v -3.523133 1.150328 1.888122
|
||||
v -4.869315 1.150328 6.987552
|
||||
v -0.006854 1.150329 4.473047
|
||||
v 4.838127 1.150328 7.041885
|
||||
v 3.538153 1.150329 1.927652
|
||||
v 0.033757 0.000000 -0.314657
|
||||
v 0.035668 2.269531 -0.312831
|
||||
vt 0.626409 0.064409
|
||||
vt 0.548284 0.007647
|
||||
vt 0.451716 0.007647
|
||||
vt 0.373591 0.064409
|
||||
vt 0.343750 0.156250
|
||||
vt 0.373591 0.248091
|
||||
vt 0.451716 0.304853
|
||||
vt 0.548284 0.304853
|
||||
vt 0.626409 0.248091
|
||||
vt 0.656250 0.156250
|
||||
vt 0.375000 0.312500
|
||||
vt 0.400000 0.312500
|
||||
vt 0.425000 0.312500
|
||||
vt 0.450000 0.312500
|
||||
vt 0.475000 0.312500
|
||||
vt 0.500000 0.312500
|
||||
vt 0.525000 0.312500
|
||||
vt 0.550000 0.312500
|
||||
vt 0.575000 0.312500
|
||||
vt 0.600000 0.312500
|
||||
vt 0.625000 0.312500
|
||||
vt 0.500000 0.688440
|
||||
vt 0.500000 0.156250
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.005105 -0.859861 -0.510503
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn 0.365127 -0.920739 -0.137556
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn -0.360232 -0.922140 -0.141034
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn 0.000604 -0.859880 -0.510496
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.189615 -0.962051 0.196222
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn -0.358980 -0.928522 -0.094766
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn 0.120430 -0.965019 0.232884
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn -0.122414 -0.965251 0.230880
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.363409 -0.927039 -0.092374
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.188029 -0.961689 0.199495
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.183421 0.963579 0.194606
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn 0.355062 0.930476 -0.090252
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn -0.119338 0.967005 0.225079
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn 0.117452 0.966757 0.227125
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.350315 0.932055 -0.092478
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn -0.184852 0.963969 0.191293
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn 0.000591 0.866128 -0.499821
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn -0.351624 0.925964 -0.137664
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.356828 0.924447 -0.134430
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
vn 0.004998 0.866108 -0.499832
|
||||
s off
|
||||
g pCylinder1
|
||||
f 25/57/121 35/68/122 26/58/123
|
||||
f 26/58/124 35/68/125 27/59/126
|
||||
f 27/59/127 35/68/128 28/60/129
|
||||
f 28/60/130 35/68/131 29/61/132
|
||||
f 29/61/133 35/68/134 30/62/135
|
||||
f 30/62/136 35/68/137 31/63/138
|
||||
f 31/63/139 35/68/140 32/64/141
|
||||
f 32/64/142 35/68/143 33/65/144
|
||||
f 33/65/145 35/68/146 34/66/147
|
||||
f 34/66/148 35/68/149 25/67/150
|
||||
f 25/47/151 36/69/152 34/56/153
|
||||
f 34/56/154 36/69/155 33/55/156
|
||||
f 33/55/157 36/69/158 32/54/159
|
||||
f 32/54/160 36/69/161 31/53/162
|
||||
f 31/53/163 36/69/164 30/52/165
|
||||
f 30/52/166 36/69/167 29/51/168
|
||||
f 29/51/169 36/69/170 28/50/171
|
||||
f 28/50/172 36/69/173 27/49/174
|
||||
f 27/49/175 36/69/176 26/48/177
|
||||
f 26/48/178 36/69/179 25/47/180
|
22893
cw 7/models/heart.obj
Normal file
32679
cw 7/models/rocket.obj
Normal file
143647
cw 7/models/spaceship_new.obj
Normal file
0
cw 7/shaders/particle.frag
Normal file
0
cw 7/shaders/particle.vert
Normal file
36
cw 7/shaders/rocket.frag
Normal file
@ -0,0 +1,36 @@
|
||||
#version 330 core
|
||||
|
||||
in vec3 fragNormal;
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
struct Material {
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
// Dodaj inne właściwości materiałów, jeśli są potrzebne
|
||||
};
|
||||
|
||||
uniform Material material;
|
||||
uniform vec3 lightPosition;
|
||||
uniform vec3 viewPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = normalize(fragNormal);
|
||||
vec3 lightDirection = normalize(lightPosition - gl_FragCoord.xyz);
|
||||
float diff = max(dot(normal, lightDirection), 0.0);
|
||||
|
||||
vec3 viewDirection = normalize(viewPosition - gl_FragCoord.xyz);
|
||||
vec3 reflectDirection = reflect(-lightDirection, normal);
|
||||
float spec = pow(max(dot(viewDirection, reflectDirection), 0.0), 32.0);
|
||||
|
||||
vec3 ambient = material.ambient;
|
||||
vec3 diffuse = material.diffuse * diff;
|
||||
vec3 specular = material.specular * spec;
|
||||
|
||||
vec3 finalColor = ambient + diffuse + specular;
|
||||
|
||||
fragColor = vec4(finalColor, 1.0);
|
||||
}
|
18
cw 7/shaders/rocket.vert
Normal file
@ -0,0 +1,18 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 inPosition;
|
||||
layout(location = 1) in vec3 inNormal;
|
||||
layout(location = 2) in vec2 inTexCoord;
|
||||
|
||||
out vec3 fragNormal;
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = transformation * modelMatrix * vec4(inPosition, 1.0);
|
||||
fragNormal = mat3(transpose(inverse(modelMatrix))) * inNormal;
|
||||
fragTexCoord = inTexCoord;
|
||||
}
|
@ -1,18 +1,121 @@
|
||||
#version 430 core
|
||||
|
||||
float AMBIENT = 0.1;
|
||||
float AMBIENT = 0.03;
|
||||
float PI = 3.14;
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
|
||||
uniform vec3 cameraPos;
|
||||
|
||||
uniform vec3 color;
|
||||
|
||||
|
||||
uniform vec3 lightPos;
|
||||
uniform vec3 lightColor;
|
||||
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 spotlightColor;
|
||||
uniform vec3 spotlightConeDir;
|
||||
uniform vec3 spotlightPhi;
|
||||
|
||||
uniform float metallic;
|
||||
uniform float roughness;
|
||||
|
||||
uniform float exposition;
|
||||
|
||||
in vec3 vecNormal;
|
||||
in vec3 worldPos;
|
||||
|
||||
out vec4 outColor;
|
||||
|
||||
|
||||
in vec3 viewDirTS;
|
||||
in vec3 lightDirTS;
|
||||
in vec3 spotlightDirTS;
|
||||
in vec3 sunDirTS;
|
||||
|
||||
in vec3 test;
|
||||
|
||||
float GGX(vec3 normal, vec3 H, float roughness){
|
||||
float a = roughness*roughness;
|
||||
float a2 = a*a;
|
||||
float NdotH = max(dot(normal, H), 0.0);
|
||||
float NdotH2 = NdotH*NdotH;
|
||||
|
||||
float num = a2;
|
||||
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
||||
denom = PI * denom * denom;
|
||||
|
||||
return num / denom;
|
||||
}
|
||||
float Gs_GGX(float NdotV, float roughness){
|
||||
float r = (roughness + 1.0);
|
||||
float k = (r*r) / 8.0;
|
||||
|
||||
float num = NdotV;
|
||||
float denom = NdotV * (1.0 - k) + k;
|
||||
|
||||
return num / denom;
|
||||
}
|
||||
float GS(vec3 normal, vec3 V, vec3 lightDir, float roughness){
|
||||
float NdotV = max(dot(normal, V), 0.0);
|
||||
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||
float ggx2 = Gs_GGX(NdotV, roughness);
|
||||
float ggx1 = Gs_GGX(NdotL, roughness);
|
||||
|
||||
return ggx1 * ggx2;
|
||||
}
|
||||
vec3 fS(float cosTheta, vec3 F0){
|
||||
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||
}
|
||||
|
||||
vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||
float diffuse=max(0,dot(normal,lightDir));
|
||||
|
||||
//vec3 V = normalize(cameraPos-worldPos);
|
||||
vec3 F0 = vec3(0.04);
|
||||
F0 = mix(F0, color, metallic);
|
||||
|
||||
vec3 H = normalize(V + lightDir);
|
||||
|
||||
float NDF = GGX(normal, H, roughness);
|
||||
float G = GS(normal, V, lightDir, roughness);
|
||||
vec3 F = fS(max(dot(H, V), 0.0), F0);
|
||||
|
||||
vec3 kS = F;
|
||||
vec3 kD = vec3(1.0) - kS;
|
||||
kD *= 1.0 - metallic;
|
||||
|
||||
vec3 numerator = NDF * G * F;
|
||||
float denominator = 4.0 * max(dot(normal, V), 0.0) * max(dot(normal, lightDir), 0.0) + 0.0001;
|
||||
vec3 specular = numerator / denominator;
|
||||
|
||||
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||
return (kD * color / PI + specular) * radiance * NdotL;
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightDir = normalize(lightPos-worldPos);
|
||||
vec3 normal = normalize(vecNormal);
|
||||
float diffuse=max(0,dot(normal,lightDir));
|
||||
outColor = vec4(color*min(1,AMBIENT+diffuse), 1.0);
|
||||
|
||||
vec3 viewDir = normalize(cameraPos-worldPos);
|
||||
|
||||
vec3 lightDir = normalize(lightPos-worldPos);
|
||||
|
||||
|
||||
vec3 ambient = AMBIENT*color;
|
||||
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2);
|
||||
vec3 ilumination;
|
||||
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
vec3 spotlightDir= normalize(spotlightPos-worldPos);
|
||||
|
||||
|
||||
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);
|
||||
attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2);
|
||||
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
|
||||
|
||||
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 2) in vec2 vertexTexCoord;
|
||||
layout(location = 3) in vec3 vertexTangent;
|
||||
layout(location = 4) in vec3 vertexBitangent;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
@ -10,9 +12,32 @@ uniform mat4 modelMatrix;
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
|
||||
uniform vec3 lightPos;
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 cameraPos;
|
||||
uniform vec3 sunDir;
|
||||
|
||||
out vec3 viewDirTS;
|
||||
out vec3 lightDirTS;
|
||||
out vec3 spotlightDirTS;
|
||||
out vec3 sunDirTS;
|
||||
|
||||
void main()
|
||||
{
|
||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
|
||||
vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent);
|
||||
vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent);
|
||||
mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal));
|
||||
|
||||
vec3 V = normalize(cameraPos-worldPos);
|
||||
viewDirTS = TBN*V;
|
||||
vec3 L = normalize(lightPos-worldPos);
|
||||
lightDirTS = TBN*L;
|
||||
vec3 SL = normalize(spotlightPos-worldPos);
|
||||
spotlightDirTS = TBN*SL;
|
||||
sunDirTS = TBN*sunDir;
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#version 430 core
|
||||
|
||||
float AMBIENT = 0.1;
|
||||
|
||||
float MAX_DISTANCE = 6.0;
|
||||
uniform vec3 color;
|
||||
uniform vec3 lightPos;
|
||||
uniform sampler2D colorTexture;
|
||||
@ -16,6 +16,10 @@ void main()
|
||||
vec3 lightDir = normalize(lightPos-worldPos);
|
||||
vec3 normal = normalize(vecNormal);
|
||||
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
||||
if (distanceToCamera > MAX_DISTANCE)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
float diffuse=max(0,dot(normal,lightDir));
|
||||
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
#version 430 core
|
||||
|
||||
uniform vec3 objectColor;
|
||||
|
||||
in vec3 interpNormal;
|
||||
uniform float exposition;
|
||||
uniform sampler2D sunTexture;
|
||||
out vec4 outColor;
|
||||
in vec2 TexCoords;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(objectColor, 1.0);
|
||||
vec3 textureColor = texture2D(sunTexture, TexCoords).xyz;
|
||||
vec3 adjustedColor = 1.0 - exp(-textureColor * exposition);
|
||||
|
||||
// Output the color with unchanged alpha
|
||||
outColor = vec4(clamp(adjustedColor, 0.0, 1.0), 1.0);
|
||||
//outColor = vec4(textureColor*min(1,exposition), 1.0);
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec2 vertexTexCoord;
|
||||
layout(location = 2) in vec3 vertexNormal;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 2) in vec2 vertexTexCoord;
|
||||
|
||||
|
||||
uniform mat4 transformation;
|
||||
|
||||
out vec3 interpNormal;
|
||||
out vec2 TexCoords;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
interpNormal = vertexNormal;
|
||||
TexCoords = vertexTexCoord;
|
||||
}
|
||||
|
@ -1,31 +1,72 @@
|
||||
#version 430 core
|
||||
|
||||
float AMBIENT = 0.1;
|
||||
float AMBIENT = 0.4;
|
||||
float roughness;
|
||||
float metalic;
|
||||
float MAX_DISTANCE = 12.0;
|
||||
|
||||
uniform vec3 color;
|
||||
uniform sampler2D colorTexture;
|
||||
uniform sampler2D normalSampler;
|
||||
|
||||
uniform sampler2D metalnessTexture;
|
||||
uniform sampler2D roughnessTexture;
|
||||
|
||||
in vec3 worldPos;
|
||||
in vec2 vecTex;
|
||||
|
||||
in vec3 viewDirTS;
|
||||
in vec3 lightDirTS;
|
||||
|
||||
in float distanceToCamera;
|
||||
out vec4 outColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = vec3(0,0,1);
|
||||
vec3 lightDir = normalize(lightDirTS);
|
||||
vec3 L = (lightDirTS);
|
||||
vec3 V = (viewDirTS);
|
||||
|
||||
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
||||
float metalnessValue = texture2D(metalnessTexture, vecTex).r;
|
||||
float roughnessValue = texture2D(roughnessTexture, vecTex).r;
|
||||
|
||||
roughness =roughnessValue;
|
||||
metalic = metalnessValue;
|
||||
|
||||
vec3 N = texture2D(normalSampler, vecTex).xyz;
|
||||
N = 2.0 * N - 1.0;
|
||||
N = normalize(N);
|
||||
|
||||
//float diffuse=max(0,dot(normal,lightDir));
|
||||
float diffuse=max(0,dot(N,lightDir));
|
||||
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
|
||||
vec3 H = normalize(L + V);
|
||||
float NdotH = max(0.0, dot(N, H));
|
||||
float NdotL = max(dot(N, L),0.0000001 );
|
||||
float NdotV = max(0.0, dot(N, V));
|
||||
float VdotH = max(0.00001, dot(V, H));
|
||||
float k = pow((roughness +1),2.0)/8.0;
|
||||
|
||||
|
||||
float D = (roughness * roughness) / (3.14159 * pow(pow(NdotH * NdotH,2.0) * (roughness * roughness - 1.0) + 1.0, 2.0));
|
||||
float ggx1 = NdotV / (NdotV * (1.0 - k) + k);
|
||||
float ggx2 = NdotL / (NdotL * (1.0 - k) + k);
|
||||
vec3 F0 = mix(vec3(0.04), vec3(1.0), metalic);
|
||||
float G = ggx1 * ggx2;
|
||||
vec3 F = F0 + (1.0-F0)*pow(1-dot(V,H),5.0);
|
||||
|
||||
vec3 specular = (D*G*F)/(4*NdotL*NdotV+0.00001);
|
||||
vec3 kD = vec3(1.0) - F;
|
||||
|
||||
vec3 BRDF = kD*(textureColor/3.1458493) + specular;
|
||||
|
||||
if (distanceToCamera > MAX_DISTANCE)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float diffuse=max(0.0001,dot(N,L));
|
||||
|
||||
|
||||
|
||||
outColor = vec4(BRDF*(AMBIENT + diffuse)*1.5, 1.0);
|
||||
}
|
||||
|
@ -17,11 +17,15 @@ uniform vec3 cameraPos;
|
||||
|
||||
out vec3 viewDirTS;
|
||||
out vec3 lightDirTS;
|
||||
|
||||
out float distanceToCamera;
|
||||
mat3 TBN;
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
|
||||
vec3 tangent = normalize(mat3(modelMatrix) * vertexTangent);
|
||||
vec3 bitangent = normalize(mat3(modelMatrix) * vertexBitangent);
|
||||
vec3 normal = normalize(mat3(modelMatrix) * vertexNormal);
|
||||
@ -38,6 +42,6 @@ void main()
|
||||
|
||||
vecTex = vertexTexCoord;
|
||||
vecTex.y = 1.0 - vecTex.y;
|
||||
|
||||
distanceToCamera = length(worldPos - cameraPos);
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
}
|
||||
|
36
cw 7/shaders/signs.frag
Normal file
@ -0,0 +1,36 @@
|
||||
float AMBIENT = 0.2;
|
||||
|
||||
uniform vec3 color;
|
||||
uniform float metalness;
|
||||
uniform float roughness;
|
||||
uniform vec3 lightPos;
|
||||
uniform vec3 lightColor;
|
||||
in vec3 viewDirTS;
|
||||
in vec3 lightDirTS;
|
||||
in vec3 worldPos;
|
||||
|
||||
out vec4 outColor;
|
||||
in mat3 TBN;
|
||||
void main()
|
||||
{
|
||||
vec3 normal = normalize(TBN * vec3(0, 0, 1)); // Normal z TBN
|
||||
vec3 L = normalize(lightPos - worldPos);
|
||||
vec3 V = normalize(viewDirTS);
|
||||
vec3 H = normalize(L + V);
|
||||
|
||||
float k = pow((roughness + 1), 2.0) / 8.0;
|
||||
|
||||
float D = (roughness * roughness) / (3.14159 * pow(pow(dot(normal, H), 2.0) * (roughness * roughness - 1.0) + 1.0, 2.0));
|
||||
float G = dot(normal, L) / (dot(normal, L) * (1.0 - k) + k);
|
||||
vec3 F0 = mix(vec3(0.04), color, metalness);
|
||||
vec3 F = F0 + (1.0 - F0) * pow(1 - dot(V, H), 5.0);
|
||||
|
||||
vec3 specular = lightColor * (D * G * F) / (4 * dot(normal, L) * dot(normal, V) + 0.00001);
|
||||
vec3 kD = vec3(1.0) - F;
|
||||
|
||||
vec3 diffuse = lightColor * kD * (color / 3.1458493);
|
||||
|
||||
vec3 finalColor = (diffuse + specular) * min(1.0, AMBIENT + max(dot(normal, L), 0.0));
|
||||
|
||||
outColor = vec4(finalColor, 1.0);
|
||||
}
|
41
cw 7/shaders/signs.vert
Normal file
@ -0,0 +1,41 @@
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 3) in vec3 vertexTangent;
|
||||
layout(location = 4) in vec3 vertexBitangent;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
out vec3 worldPos;
|
||||
out vec2 vecTex;
|
||||
|
||||
uniform vec3 lightPos;
|
||||
uniform vec3 cameraPos;
|
||||
|
||||
out vec3 viewDirTS;
|
||||
out vec3 lightDirTS;
|
||||
out mat3 TBN;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 tangent = normalize(mat3(modelMatrix) * vertexTangent);
|
||||
vec3 bitangent = normalize(mat3(modelMatrix) * vertexBitangent);
|
||||
vec3 normal = normalize(mat3(modelMatrix) * vertexNormal);
|
||||
|
||||
mat3 TBN = transpose(mat3(tangent, bitangent, normal));
|
||||
|
||||
vec3 worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
||||
|
||||
vec3 viewDir = normalize(cameraPos - worldPos);
|
||||
vec3 lightDir = normalize(lightPos - worldPos);
|
||||
|
||||
viewDirTS = vec3(TBN * viewDir);
|
||||
lightDirTS = vec3(TBN * lightDir);
|
||||
|
||||
vecTex = vec2((worldPos.x + 10.0) / 20.0, 1.0 - (worldPos.y + 10.0) / 20.0);
|
||||
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
}
|
@ -15,14 +15,21 @@
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include "SOIL/SOIL.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
namespace texture {
|
||||
GLuint earth;
|
||||
GLuint clouds;
|
||||
GLuint moon;
|
||||
GLuint ship;
|
||||
GLuint rust;
|
||||
GLuint sun;
|
||||
|
||||
GLuint mars;
|
||||
GLuint mercury;
|
||||
@ -38,6 +45,11 @@ namespace texture {
|
||||
GLuint moonNormal;
|
||||
GLuint shipNormal;
|
||||
GLuint rustNormal;
|
||||
|
||||
GLuint metalnessSphere;
|
||||
GLuint roughnessSphere;
|
||||
GLuint metalnessShip;
|
||||
GLuint roughnessShip;
|
||||
}
|
||||
|
||||
|
||||
@ -47,27 +59,44 @@ GLuint programTex;
|
||||
GLuint programEarth;
|
||||
GLuint programProcTex;
|
||||
GLuint programSkyBox;
|
||||
GLuint programSign;
|
||||
|
||||
Core::Shader_Loader shaderLoader;
|
||||
|
||||
Core::RenderContext shipContext;
|
||||
Core::RenderContext sphereContext;
|
||||
Core::RenderContext cubeContext;
|
||||
Core::RenderContext starContext;
|
||||
Core::RenderContext saberContext;
|
||||
Core::RenderContext heartContext;
|
||||
Core::RenderContext rocketContext;
|
||||
|
||||
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
|
||||
glm::vec3 cameraPos = glm::vec3(-3.f, 0, 0);
|
||||
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
||||
|
||||
glm::vec3 spaceshipPos = glm::vec3(-4.f, 0, 0);
|
||||
glm::vec3 spaceshipPos = glm::vec3(-3.f, 0, 0);
|
||||
glm::vec3 spaceshipDir = glm::vec3(1.f, 0.f, 0.f);
|
||||
|
||||
bool START_AS = false;
|
||||
float a = 3 ;
|
||||
|
||||
bool fire = false;
|
||||
float a = 3;
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_real_distribution<float> distribution(-0.5f, 0.5f);
|
||||
std::uniform_real_distribution<float> planetoidsYDistribution(-1.f, 1.f);
|
||||
std::uniform_real_distribution<float> planetoidsScaleDistribution(0.01f, 0.05f);
|
||||
float planetoidsArray[500][4];
|
||||
//std::uniform_real_distribution<float> distribution(-0.5f, 0.5f);
|
||||
std::uniform_real_distribution<float> radiusDistribution(-6.f, 6.f);
|
||||
std::uniform_real_distribution<float> planetoidsYDistribution(-5.f, 5.f);
|
||||
std::uniform_real_distribution<float> planetoidsXDistribution(-2.f, 11.f);
|
||||
std::uniform_real_distribution<float> planetoidsScaleDistribution(0.2f, 0.3f);
|
||||
std::vector<glm::vec4> shearVectors;
|
||||
std::vector<glm::vec3> scaleVectors;
|
||||
std::vector<glm::vec3> ammunitionPositions;
|
||||
std::vector<glm::mat4> ammunitionModelMatrices;
|
||||
|
||||
const int arraySize = 200;
|
||||
const int planetoidParams = 5;
|
||||
std::vector<std::vector<float>> planetoidsVector(arraySize, std::vector<float>(planetoidParams));
|
||||
|
||||
float tempPlanArray[200][2];
|
||||
|
||||
glm::vec3 asteroid_Calc = spaceshipDir * glm::vec3(a, a, a);
|
||||
glm::vec3 asteroid_Pos = spaceshipPos + glm::vec3(0, a, 0) + asteroid_Calc;
|
||||
glm::vec3 distance = asteroid_Pos - spaceshipPos;
|
||||
@ -75,11 +104,37 @@ glm::vec3 distance = asteroid_Pos - spaceshipPos;
|
||||
double step = 0.0000001;
|
||||
|
||||
GLuint VAO,VBO;
|
||||
float lastAsteroidTime = 0;
|
||||
float aspectRatio = 1.f;
|
||||
float lastFiretime = 0;
|
||||
float ammoReloadTime = 3.0f; // Czas ładowania amunicji w sekundach
|
||||
float ammoReloadProgress = 0.0f;
|
||||
|
||||
float aspectRatio = 1.f;
|
||||
glm::vec3 ammoPos;
|
||||
unsigned int textureID;
|
||||
|
||||
float tiltAngleSide;
|
||||
float tiltAngleUpDown;
|
||||
|
||||
int colission = 3;
|
||||
int star = 0;
|
||||
int star_counter = 0;
|
||||
float starMetalness = 0.8;
|
||||
float starRoughness = 0.1;
|
||||
glm::vec3 lightPos = glm::vec3(-8, 4, 2);
|
||||
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8) * 100;
|
||||
|
||||
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
||||
glm::vec3 spotlightColor = glm::vec3(0.5, 0.9, 0.8) * 10;
|
||||
float exposition = 1.f;
|
||||
float spotlightPhi = 3.14 / 3;
|
||||
|
||||
|
||||
double easeInExpo(double x) {
|
||||
return pow(2, 10 * x - 10);
|
||||
}
|
||||
|
||||
|
||||
glm::mat4 createCameraMatrix()
|
||||
{
|
||||
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f)));
|
||||
@ -101,7 +156,7 @@ glm::mat4 createPerspectiveMatrix()
|
||||
|
||||
glm::mat4 perspectiveMatrix;
|
||||
float n = 0.05;
|
||||
float f = 20.;
|
||||
float f = 60.;
|
||||
float a1 = glm::min(aspectRatio, 1.f);
|
||||
float a2 = glm::min(1 / aspectRatio, 1.f);
|
||||
perspectiveMatrix = glm::mat4({
|
||||
@ -117,28 +172,72 @@ glm::mat4 createPerspectiveMatrix()
|
||||
return perspectiveMatrix;
|
||||
}
|
||||
|
||||
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
|
||||
|
||||
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float metalness, float roughness, glm::vec3 cameraPos) {
|
||||
glUseProgram(program);
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
glUniform1f(glGetUniformLocation(program, "exposition"), exposition);
|
||||
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), 0, 0, 0);
|
||||
glUniform1f(glGetUniformLocation(program, "metalness"), metalness);
|
||||
glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
|
||||
glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
||||
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
Core::DrawContext(context);
|
||||
|
||||
}
|
||||
void drawObjectSigns(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float metalness, float roughness, glm::vec3 lightstarPos) {
|
||||
glUseProgram(programSign);
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
|
||||
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, GLuint normalMapId) {
|
||||
glUniformMatrix4fv(glGetUniformLocation(programSign, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programSign, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(programSign, "lightPos"), lightstarPos.x, lightstarPos.y, lightstarPos.z);
|
||||
|
||||
glUniform3f(glGetUniformLocation(programSign, "color"), color.x, color.y, color.z);
|
||||
glUniform3f(glGetUniformLocation(programSign, "lightColor"), lightColor.r, lightColor.g, lightColor.b);
|
||||
glUniform3f(glGetUniformLocation(programSign, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
glUniform1f(glGetUniformLocation(programSign, "metalness"), metalness);
|
||||
glUniform1f(glGetUniformLocation(programSign, "roughness"), roughness);
|
||||
|
||||
|
||||
// Przesyłanie informacji o widoku (view) do shadera
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
|
||||
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, GLuint normalMapId, GLuint metalnessTexture, GLuint roughnessTexture) {
|
||||
glUseProgram(programTex);
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(programTex, "lightPos"), 0, 0, 0);
|
||||
|
||||
Core::SetActiveTexture(normalMapId, "normalSampler", programTex, 1);
|
||||
Core::SetActiveTexture(textureID, "colorTexture", programTex, 0);
|
||||
|
||||
glUniform1i(glGetUniformLocation(programTex, "metalnessTexture"), 2);
|
||||
glUniform1i(glGetUniformLocation(programTex, "roughnessTexture"), 3);
|
||||
|
||||
// Bind metalness and roughness textures to texture units
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, metalnessTexture);
|
||||
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, roughnessTexture);
|
||||
|
||||
glUniform3f(glGetUniformLocation(programTex, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
Core::DrawContext(context);
|
||||
|
||||
}
|
||||
@ -150,36 +249,156 @@ void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
|
||||
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUniform3f(glGetUniformLocation(programSkyBox, "lightPos"), 0, 0, 0);
|
||||
//Core::SetActiveTexture(textureID, "colorTexture", programSkyBox, 0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||
Core::DrawContext(context);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
}
|
||||
|
||||
void generateAsteroids(glm::vec3 asteroid_Pos, glm::vec3 distance, double step) {
|
||||
glm::vec3 normalizedDir = glm::normalize(distance);
|
||||
asteroid_Pos = asteroid_Pos - normalizedDir *step;
|
||||
drawObjectTexture(sphereContext, glm::translate(asteroid_Pos) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::moonNormal);
|
||||
|
||||
void drawObjectSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID)
|
||||
{
|
||||
glUseProgram(programSun);
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniform1f(glGetUniformLocation(programSun, "exposition"), 1.f);
|
||||
Core::SetActiveTexture(textureID, "sunTexture", programSun, 0);
|
||||
glActiveTexture(GL_TEXTURE0); // Activate texture unit 0
|
||||
glBindTexture(GL_TEXTURE_2D, textureID);
|
||||
Core::DrawContext(sphereContext);
|
||||
}
|
||||
|
||||
|
||||
//float speed = 0.03;
|
||||
float speed = 0.02;
|
||||
float starind = 50;
|
||||
|
||||
|
||||
|
||||
bool checkCollision(glm::vec3 objectPos, float objectRadius, glm::vec3 spaceshipPos, float spaceshipRadius, bool isStar) {
|
||||
float distance = glm::length(objectPos - spaceshipPos);
|
||||
float starExtraRadius = isStar ? 0.03f : 0.0f;
|
||||
return distance < objectRadius + spaceshipRadius + starExtraRadius;
|
||||
}
|
||||
|
||||
void generatePlanetoidBelt() {
|
||||
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
|
||||
float x = planetoidsArray[i][0];
|
||||
float z = planetoidsArray[i][1];
|
||||
float y = planetoidsArray[i][2];
|
||||
float pScale = planetoidsArray[i][3];
|
||||
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
float z = tempPlanArray[i][0];
|
||||
float y = tempPlanArray[i][1];
|
||||
glm::vec3 Scale = scaleVectors[i];
|
||||
bool collision = false;
|
||||
planetoidsVector[i][3] -= speed;
|
||||
float x = planetoidsVector[i][3];
|
||||
|
||||
if (planetoidsVector[i][3] < -3.5f) {
|
||||
//planetoidsArray[i][0] += spaceshipPos.z - planetoidsArray[i][0];
|
||||
//planetoidsArray[i][1] += spaceshipPos.y - planetoidsArray[i][1];
|
||||
|
||||
tempPlanArray[i][0] = spaceshipPos.z + planetoidsVector[i][0];
|
||||
tempPlanArray[i][1] = spaceshipPos.y + planetoidsVector[i][1];
|
||||
planetoidsVector[i][3] = 11.f;
|
||||
z = tempPlanArray[i][0];
|
||||
y = tempPlanArray[i][1];
|
||||
x = planetoidsVector[i][3];
|
||||
planetoidsVector[i][4] = 0;
|
||||
}
|
||||
|
||||
|
||||
if (planetoidsVector[i][4] == 1) {
|
||||
// Planeta ju<6A> uczestniczy<7A>a w kolizji, przejd<6A> do kolejnej iteracji
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
float prevZ = tempPlanArray[j][0];
|
||||
float prevY = tempPlanArray[j][1];
|
||||
glm::vec3 prevScale = scaleVectors[j];
|
||||
float prevX = planetoidsVector[j][3];
|
||||
float dx = x - prevX;
|
||||
float dy = y - prevY;
|
||||
float dz = z - prevZ;
|
||||
float distanceSquared = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
float sumRadiiSquared = glm::length2(Scale + prevScale);
|
||||
|
||||
|
||||
if (distanceSquared < sumRadiiSquared) {
|
||||
collision = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!collision) {
|
||||
if (fmod(i, starind) == 0) {
|
||||
if (checkCollision(glm::vec3(x, y, z), 0.1f, spaceshipPos, 0.08f, true)) {
|
||||
// Kolizja z gwiazd<7A>
|
||||
//std::cout << "Collision with star " << i << std::endl;
|
||||
planetoidsVector[i][4] = 1;
|
||||
star_counter++;
|
||||
if (star_counter == 3) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (checkCollision(glm::vec3(x, y, z), 0.1f, spaceshipPos, 0.08f, true))
|
||||
{
|
||||
//kolizja z asteroida
|
||||
std::cout << "Collision with asteroid " << i << std::endl;
|
||||
colission--;
|
||||
planetoidsVector[i][4] = 1;
|
||||
if (colission == 0)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int n = 0; n < ammunitionPositions.size(); ++n)
|
||||
{
|
||||
if (checkCollision(glm::vec3(x, y, z), 0.1f, ammunitionPositions[n], 0.08f, true))
|
||||
{
|
||||
// Asteroida zestrzelona
|
||||
std::cout << "Collision with ammo " << i << std::endl;
|
||||
planetoidsVector[i][4] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!collision) {
|
||||
if (fmod(i, starind) == 0) {
|
||||
float time = glfwGetTime();
|
||||
glm::mat4 modelMatrix = glm::translate(glm::vec3(x, y, z)) * glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 1.0f));
|
||||
drawObjectColor(starContext, modelMatrix * glm::eulerAngleX(time) * glm::scale(glm::vec3(0.03f)), glm::vec3(0.1, 1.f, 1.0), starMetalness, starRoughness, glm::vec3(x-1, y, z));
|
||||
if (star == 0)
|
||||
{
|
||||
star++;
|
||||
std::cout << "Star " << star << std::endl;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
float rotationAngle = glm::radians(70*y);
|
||||
glm::mat4 transformationMatrix = glm::translate(glm::vec3(x, y, z)) *
|
||||
glm::rotate(glm::mat4(1.0f), rotationAngle, glm::vec3(1.0f, 0.0f, 1.0f)) *
|
||||
glm::scale(glm::vec3(Scale));
|
||||
drawObjectTexture(sphereContext, transformationMatrix,
|
||||
texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
||||
}
|
||||
}
|
||||
|
||||
drawObjectTexture(sphereContext,glm::eulerAngleY(time / 5) * glm::translate(glm::vec3(x, y, z)) * glm::scale(glm::vec3(pScale)), texture::moon, texture::moonNormal);
|
||||
}
|
||||
}
|
||||
|
||||
int steps = 0;
|
||||
|
||||
|
||||
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
||||
@ -189,37 +408,81 @@ glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
void drawStars(int star_number) {
|
||||
float yOffset = 0.55f + spaceshipPos.y;
|
||||
float zOffset =5.10f + spaceshipPos.z;
|
||||
float scaleFactor = 0.03f;
|
||||
|
||||
for (int i = 0; i < star_number; ++i) {
|
||||
drawObjectSigns(starContext, glm::translate(glm::vec3(2.3f, yOffset, (zOffset) - i * 0.5f ))
|
||||
* glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f))
|
||||
* glm::scale(glm::vec3(scaleFactor)), glm::vec3(0.1, 1.f, 1.0), starMetalness, starRoughness,glm::vec3(1.0f, yOffset, zOffset));
|
||||
}
|
||||
}
|
||||
|
||||
void drawHearts(int collision_number) {
|
||||
float yOffset = -0.5f + spaceshipPos.y;
|
||||
float zOffset = 6.15 + spaceshipPos.z;
|
||||
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (collision_number > i) {
|
||||
drawObjectSigns(heartContext, glm::translate(glm::vec3(3.5f, yOffset, (zOffset) - i * 0.5f))
|
||||
* glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f))
|
||||
* glm::scale(glm::vec3(0.025f)), glm::vec3(1, 0, 0), starMetalness, starRoughness, glm::vec3(1.0f, yOffset, zOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
void updateAmmunition() {
|
||||
if (fire) {
|
||||
glm::vec3 newAmmoPos = spaceshipPos + glm::vec3(0.025f, 0.f, 0.f);
|
||||
ammunitionPositions.push_back(newAmmoPos);
|
||||
fire = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void renderAmmunition() {
|
||||
|
||||
for (int i = ammunitionPositions.size() - 1; i >= 0; --i) {
|
||||
ammunitionPositions[i] = ammunitionPositions[i] + glm::vec3(0.025f, 0.f, 0.f);
|
||||
if (ammunitionPositions[i].x > 3.f) {
|
||||
ammunitionPositions.erase(ammunitionPositions.begin() + i);
|
||||
}
|
||||
else {
|
||||
glm::mat4 modelMatrix = glm::translate(ammunitionPositions[i]) * glm::rotate(glm::mat4(1.0f), glm::radians(90.f), glm::vec3(1.0f, 0.0f, 0.f));
|
||||
drawObjectColor(rocketContext, glm::translate(ammunitionPositions[i]) * glm::rotate(glm::mat4(1.0f), glm::radians(270.f), glm::vec3(0.0f, 1.0f, 0.f)) * glm::scale(glm::vec3(0.003f)), glm::vec3(0.1, 0.1, 0.7), starMetalness, starRoughness, spaceshipPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderScene(GLFWwindow* window)
|
||||
{
|
||||
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glm::mat4 transformation;
|
||||
float time = glfwGetTime();
|
||||
|
||||
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
|
||||
glDepthMask(GL_FALSE);
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(16.0f, -4.0f, -13.0f)) * glm::scale(glm::mat4(), glm::vec3(2)), texture::sun);
|
||||
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(12.0f, -4.2f, -8.0f)) * glm::scale(glm::vec3(0.3f)), texture::earth);
|
||||
//drawObjectTexture(sphereContext,
|
||||
// glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(8.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
||||
|
||||
drawObjectTexture(sphereContext, glm::scale(glm::mat4(), glm::vec3(2.0f, 2.0f, 2.0f)), texture::rust, texture::rustNormal);
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(14.f, -4.5, -9.f)) * glm::scale(glm::vec3(0.05f)), texture::mercury);
|
||||
//drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(9.f, -5.f, -7.0f)) * glm::scale(glm::vec3(0.1f)), texture::mars);
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(12.f, -2.7f, -5.5f)) * glm::scale(glm::vec3(0.2f)), texture::venus);
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(4.f, -2.f, 3.0f)) * glm::scale(glm::vec3(0.57f)), texture::jupiter);
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(15.f, -3.f, 6.0f)) * glm::scale(glm::vec3(0.8f)), texture::saturn);
|
||||
//drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(13.f, -8.0f, 8.0f)) * glm::scale(glm::vec3(0.6f)), texture::uranus);
|
||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(13.f, 0.f, 7.0f)) * glm::scale(glm::vec3(0.35f)), texture::neptune);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(8.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.3f)), texture::earth, texture::earthNormal);
|
||||
drawObjectTexture(sphereContext,
|
||||
glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(8.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::moonNormal);
|
||||
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.15f)), texture::mercury, texture::rustNormal);
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 4) * glm::translate(glm::vec3(10.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.2f)), texture::mars, texture::rustNormal);
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(6.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.3f)), texture::venus, texture::rustNormal);
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 5) * glm::translate(glm::vec3(14.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.9f)), texture::jupiter, texture::rustNormal);
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 6) * glm::translate(glm::vec3(17.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.9f)), texture::saturn, texture::rustNormal);
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 7) * glm::translate(glm::vec3(20.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.6f)), texture::uranus, texture::rustNormal);
|
||||
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 8) * glm::translate(glm::vec3(23.f, 0, 0)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.6f)), texture::neptune, texture::rustNormal);
|
||||
|
||||
|
||||
|
||||
//drawObjectColor(shipContext,
|
||||
// glm::translate(cameraPos + 1.5 * cameraDir + cameraUp * -0.5f) * inveseCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
|
||||
// glm::vec3(0.3, 0.3, 0.5)
|
||||
// );
|
||||
spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||
|
||||
specshipCameraRotrationMatrix = glm::mat4({
|
||||
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
|
||||
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
|
||||
@ -227,36 +490,33 @@ void renderScene(GLFWwindow* window)
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
|
||||
drawObjectTexture(shipContext,
|
||||
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>())*glm::scale(glm::vec3(0.1f)),
|
||||
texture::ship, texture::shipNormal
|
||||
);
|
||||
|
||||
glm::translate(spaceshipPos) *
|
||||
specshipCameraRotrationMatrix *
|
||||
glm::eulerAngleY(glm::pi<float>()) *
|
||||
glm::rotate(glm::mat4(), tiltAngleSide * glm::radians(30.0f), glm::vec3(0, 0, 1)) *
|
||||
glm::rotate(glm::mat4(), tiltAngleUpDown * glm::radians(20.0f), glm::vec3(1, 0, 0)) *
|
||||
glm::scale(glm::vec3(0.025f)),
|
||||
texture::ship, texture::shipNormal, texture::metalnessShip, texture::roughnessShip);
|
||||
//drawObjectTexture(shipContext,
|
||||
// glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>())*glm::scale(glm::vec3(0.1f)),
|
||||
// texture::ship, texture::shipNormal
|
||||
//);
|
||||
updateAmmunition();
|
||||
renderAmmunition();
|
||||
generatePlanetoidBelt();
|
||||
//if (fire == true){
|
||||
// ammoPos = ammoPos + glm::vec3(0.025f, 0.f, 0.f);
|
||||
// glm::mat4 modelMatrix = glm::translate(ammoPos) * glm::rotate(glm::mat4(1.0f), glm::radians(90.f), glm::vec3(1.0f, 0.0f, 0.f));
|
||||
// drawObjectColor(rocketContext, modelMatrix * glm::rotate(glm::mat4(1.0f), glm::radians(270.f), glm::vec3(0.0f, 1.0f, 0.f)) * glm::scale(glm::vec3(0.003f)), glm::vec3(0.1, 0.1, 0.7), starMetalness, starRoughness, spaceshipPos);
|
||||
// }
|
||||
|
||||
if (time - lastAsteroidTime < 5 && START_AS) { //funkcja generujaca pierwsza asteroide
|
||||
step = step + 0.03;
|
||||
generateAsteroids(asteroid_Pos, distance, step);
|
||||
//steps++;
|
||||
//std::cout << steps << std::endl;
|
||||
}
|
||||
else {
|
||||
float random_x = distribution(gen);
|
||||
float random_y = distribution(gen);
|
||||
float random_z = distribution(gen);
|
||||
//std::cout << random_x << std::endl;
|
||||
glm::vec3 random_dir = glm::normalize(glm::vec3(spaceshipDir.x + random_x, spaceshipDir.y + random_y, spaceshipDir.z + random_z));
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
drawStars(star_counter);
|
||||
drawHearts(colission);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
asteroid_Calc = a * random_dir;
|
||||
glm::vec3 estimated_Spaceship_Pos = spaceshipPos + glm::vec3(1.f, 1.f, 1.f) * glm::normalize(spaceshipDir);
|
||||
asteroid_Pos = spaceshipPos + glm::vec3(0, a / 5, 0) + asteroid_Calc;
|
||||
|
||||
distance = asteroid_Pos - estimated_Spaceship_Pos;
|
||||
lastAsteroidTime = time;
|
||||
step = 0.0001;
|
||||
//std::cout << cameraDir.x << cameraDir.y << cameraDir.z << std::endl;
|
||||
//steps = 0;
|
||||
}
|
||||
glUseProgram(0);
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
@ -287,22 +547,22 @@ void init(GLFWwindow* window)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
|
||||
|
||||
//programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
||||
//programEarth = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
||||
//programProcTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
||||
|
||||
programTex = shaderLoader.CreateProgram("shaders/shader_5_tex.vert", "shaders/shader_5_tex.frag");
|
||||
programEarth = shaderLoader.CreateProgram("shaders/shader_5_tex.vert", "shaders/shader_5_tex.frag");
|
||||
programProcTex = shaderLoader.CreateProgram("shaders/shader_5_tex.vert", "shaders/shader_5_tex.frag");
|
||||
|
||||
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
||||
|
||||
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
|
||||
programSign = shaderLoader.CreateProgram("shaders/signs.vert", "shaders/signs.frag");
|
||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||
loadModelToContext("./models/spaceship.obj", shipContext);
|
||||
loadModelToContext("./models/spaceship_new.obj", shipContext);
|
||||
loadModelToContext("./models/cube.obj", cubeContext);
|
||||
loadModelToContext("./models/estrellica.obj", starContext);
|
||||
loadModelToContext("./models/CraneoOBJ.obj", saberContext);
|
||||
loadModelToContext("./models/heart.obj", heartContext);
|
||||
loadModelToContext("./models/rocket.obj", rocketContext);
|
||||
|
||||
texture::earth = Core::LoadTexture("textures/earth.png");
|
||||
texture::ship = Core::LoadTexture("textures/spaceship.jpg");
|
||||
texture::ship = Core::LoadTexture("textures/ship/spaceship_color.jpg");
|
||||
texture::moon = Core::LoadTexture("textures/moon.jpg");
|
||||
texture::rust = Core::LoadTexture("textures/rust.jpg");
|
||||
|
||||
@ -313,31 +573,45 @@ void init(GLFWwindow* window)
|
||||
texture::saturn = Core::LoadTexture("textures/8k_saturn.jpg");
|
||||
texture::uranus = Core::LoadTexture("textures/2k_uranus.jpg");
|
||||
texture::neptune = Core::LoadTexture("textures/2k_neptune.jpg");
|
||||
|
||||
|
||||
|
||||
texture::sun = Core::LoadTexture("textures/2k_sun.jpg");
|
||||
|
||||
texture::earthNormal = Core::LoadTexture("textures/earth_normalmap.png");
|
||||
texture::shipNormal = Core::LoadTexture("textures/spaceship_normal.jpg");
|
||||
texture::shipNormal = Core::LoadTexture("textures/ship/spaceship_nmap.jpg");
|
||||
texture::rustNormal = Core::LoadTexture("textures/rust_normal.jpg");
|
||||
texture::moonNormal = Core::LoadTexture("textures/moon_normal.jpg");
|
||||
|
||||
texture::metalnessSphere = Core::LoadTexture("textures/rusty_metal_sheet_diff_2k.jpg");
|
||||
texture::roughnessSphere = Core::LoadTexture("textures/rough_concrete_diff_1k.jpg");
|
||||
|
||||
texture::metalnessShip = Core::LoadTexture("textures/ship/spaceship_metalness.jpg");
|
||||
texture::roughnessShip = Core::LoadTexture("textures/ship/spaceship_rough.jpg");
|
||||
|
||||
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
float z = radiusDistribution(gen);
|
||||
float x = planetoidsXDistribution(gen);
|
||||
float y = planetoidsYDistribution(gen);
|
||||
planetoidsVector[i][0] = z;
|
||||
planetoidsVector[i][1] = y;
|
||||
planetoidsVector[i][3] = x;
|
||||
glm::vec3 scaleVector = glm::vec3(planetoidsScaleDistribution(gen), planetoidsScaleDistribution(gen), planetoidsScaleDistribution(gen));
|
||||
scaleVectors.push_back(scaleVector);
|
||||
|
||||
}
|
||||
const int arraySize = 200;
|
||||
const int planetoidParams = 5;
|
||||
std::sort(planetoidsVector.begin(), planetoidsVector.end(),
|
||||
[](const auto& a, const auto& b) {
|
||||
return a[3] < b[3];
|
||||
});
|
||||
|
||||
for (int i = 0; i < arraySize; ++i) {
|
||||
tempPlanArray[i][0] = planetoidsVector[i][0];
|
||||
tempPlanArray[i][1] = planetoidsVector[i][1];
|
||||
}
|
||||
|
||||
glGenTextures(1, &textureID);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||
std::uniform_real_distribution<float> angleDistribution(0.0f, 2.0f * glm::pi<float>());
|
||||
std::uniform_real_distribution<float> radiusDistribution(10.f, 17.f);
|
||||
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
float angle = angleDistribution(gen);
|
||||
float radius = radiusDistribution(gen);
|
||||
float y = planetoidsYDistribution(gen);
|
||||
float pScale = planetoidsScaleDistribution(gen);
|
||||
planetoidsArray[i][0] = radius * std::cos(angle);
|
||||
planetoidsArray[i][1] = radius * std::sin(angle);
|
||||
planetoidsArray[i][2] = y;
|
||||
planetoidsArray[i][3] = pScale;
|
||||
}
|
||||
|
||||
std::vector<std::string> filepaths = {
|
||||
"textures/skybox/space_rt.png",
|
||||
@ -375,62 +649,82 @@ void shutdown(GLFWwindow* window)
|
||||
double lastX = 0.0;
|
||||
double lastY = 0.0;
|
||||
|
||||
void mouseCallback(GLFWwindow* window, double xpos, double ypos) {
|
||||
|
||||
double deltaX = xpos - lastX;
|
||||
double deltaY = ypos - lastY;
|
||||
lastX = xpos;
|
||||
lastY = ypos;
|
||||
//std::cout << lastY << " " << ypos << std::endl;
|
||||
const float sensitivity = 0.001f;
|
||||
deltaX *= sensitivity;
|
||||
deltaY *= sensitivity;
|
||||
glm::mat4 rotationMatrix = glm::eulerAngleY(-deltaX);
|
||||
spaceshipDir = glm::normalize(rotationMatrix * glm::vec4(spaceshipDir,0));
|
||||
spaceshipDir = spaceshipDir + glm::vec3(0, - deltaY / 4, 0);
|
||||
/*specshipCameraRotrationMatrix = glm::rotate(specshipCameraRotrationMatrix, static_cast<float>(deltaX), glm::vec3(0.f, 1.f, 0.f));
|
||||
specshipCameraRotrationMatrix = glm::rotate(specshipCameraRotrationMatrix, static_cast<float>(deltaY), spaceshipSide);
|
||||
spaceshipDir = glm::normalize(glm::vec3(-specshipCameraRotrationMatrix[2]));
|
||||
spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));*/
|
||||
|
||||
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) {
|
||||
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
|
||||
fire = true;
|
||||
ammoPos = spaceshipPos;
|
||||
lastFiretime = glfwGetTime();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//obsluga wejscia
|
||||
void processInput(GLFWwindow* window)
|
||||
{
|
||||
spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
|
||||
float angleSpeed = 0.01f;
|
||||
float angleSpeed = 0.005f;
|
||||
float moveSpeed = 0.01f;
|
||||
|
||||
double x = 0.01;
|
||||
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipDir * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipDir * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
|
||||
spaceshipPos += glm::vec3(0.f,moveSpeed,0.f);
|
||||
tiltAngleUpDown -= easeInExpo(x);
|
||||
}
|
||||
else {
|
||||
if (tiltAngleUpDown < 0) {
|
||||
tiltAngleUpDown += 0.003;
|
||||
}
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS){
|
||||
spaceshipPos -= glm::vec3(0.f, moveSpeed, 0.f);
|
||||
tiltAngleUpDown += easeInExpo(x);
|
||||
}
|
||||
else {
|
||||
if (tiltAngleUpDown > 0) {
|
||||
tiltAngleUpDown -= 0.003;
|
||||
}
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipSide * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipSide * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipUp * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipUp * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
if (glfwGetKey(window, GLFW_KEY_G) == GLFW_PRESS)
|
||||
START_AS = true;
|
||||
|
||||
glfwSetCursorPosCallback(window, mouseCallback);
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) {
|
||||
spaceshipPos -= glm::vec3(0.f, 0.f, moveSpeed);
|
||||
tiltAngleSide -= easeInExpo(x);
|
||||
} else {
|
||||
if (tiltAngleSide < 0) {
|
||||
tiltAngleSide += 0.003;
|
||||
}
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
|
||||
spaceshipPos += glm::vec3(0.f, 0.f, moveSpeed);
|
||||
tiltAngleSide += easeInExpo(-x);
|
||||
} else {
|
||||
if (tiltAngleSide > 0) {
|
||||
tiltAngleSide -= 0.003;
|
||||
}
|
||||
}
|
||||
|
||||
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 2, 0) * 0.1f;
|
||||
|
||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||
|
||||
cameraPos = spaceshipPos - 0.5 * spaceshipDir+ glm::vec3(0.f,0.3,0.f);
|
||||
cameraDir = spaceshipDir;
|
||||
|
||||
tiltAngleSide = fmaxf(-1, fminf(1, tiltAngleSide));
|
||||
tiltAngleUpDown = fmaxf(-1, fminf(1, tiltAngleUpDown));
|
||||
|
||||
|
||||
//cameraDir = glm::normalize(-cameraPos);
|
||||
|
||||
}
|
||||
|
BIN
cw 7/textures/rough_concrete_diff_1k.jpg
Normal file
After Width: | Height: | Size: 1018 KiB |
BIN
cw 7/textures/rusty_metal_sheet_diff_2k.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
cw 7/textures/ship/spaceship_color.jpg
Normal file
After Width: | Height: | Size: 3.3 MiB |
BIN
cw 7/textures/ship/spaceship_metalness.jpg
Normal file
After Width: | Height: | Size: 1.9 MiB |
BIN
cw 7/textures/ship/spaceship_nmap.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
cw 7/textures/ship/spaceship_rough.jpg
Normal file
After Width: | Height: | Size: 3.4 MiB |
BIN
screenshot.png
Normal file
After Width: | Height: | Size: 2.6 MiB |