diff --git a/Debug/grk-cw9.exe b/Debug/grk-cw9.exe index b7744fd..a0f1aca 100644 Binary files a/Debug/grk-cw9.exe and b/Debug/grk-cw9.exe differ diff --git a/Debug/grk-cw9.pdb b/Debug/grk-cw9.pdb index ff813b1..b84bd90 100644 Binary files a/Debug/grk-cw9.pdb and b/Debug/grk-cw9.pdb differ diff --git a/cw 9/Debug/Box.obj b/cw 9/Debug/Box.obj index d405490..a975630 100644 Binary files a/cw 9/Debug/Box.obj and b/cw 9/Debug/Box.obj differ diff --git a/cw 9/Debug/Camera.obj b/cw 9/Debug/Camera.obj index 25133ca..d1eca6d 100644 Binary files a/cw 9/Debug/Camera.obj and b/cw 9/Debug/Camera.obj differ diff --git a/cw 9/Debug/Laser.obj b/cw 9/Debug/Laser.obj index c389569..9561cfd 100644 Binary files a/cw 9/Debug/Laser.obj and b/cw 9/Debug/Laser.obj differ diff --git a/cw 9/Debug/Render_Utils.obj b/cw 9/Debug/Render_Utils.obj index 34cea9f..7aba8f2 100644 Binary files a/cw 9/Debug/Render_Utils.obj and b/cw 9/Debug/Render_Utils.obj differ diff --git a/cw 9/Debug/SOIL.obj b/cw 9/Debug/SOIL.obj index 060cd9a..4330496 100644 Binary files a/cw 9/Debug/SOIL.obj and b/cw 9/Debug/SOIL.obj differ diff --git a/cw 9/Debug/Shader_Loader.obj b/cw 9/Debug/Shader_Loader.obj index 80609be..0c7c8fc 100644 Binary files a/cw 9/Debug/Shader_Loader.obj and b/cw 9/Debug/Shader_Loader.obj differ diff --git a/cw 9/Debug/SpaceShip.obj b/cw 9/Debug/SpaceShip.obj index ee478df..02d7f20 100644 Binary files a/cw 9/Debug/SpaceShip.obj and b/cw 9/Debug/SpaceShip.obj differ diff --git a/cw 9/Debug/Texture.obj b/cw 9/Debug/Texture.obj index 9afc084..bf02be8 100644 Binary files a/cw 9/Debug/Texture.obj and b/cw 9/Debug/Texture.obj differ diff --git a/cw 9/Debug/grk-cw9.exe.recipe b/cw 9/Debug/grk-cw9.exe.recipe index 3875c78..87950e8 100644 --- a/cw 9/Debug/grk-cw9.exe.recipe +++ b/cw 9/Debug/grk-cw9.exe.recipe @@ -2,7 +2,7 @@ - C:\Users\prima\Documents\JAVA\GRK_game_scene\Debug\grk-cw9.exe + C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe diff --git a/cw 9/Debug/grk-cw9.log b/cw 9/Debug/grk-cw9.log index c8e9e2d..841f56c 100644 --- a/cw 9/Debug/grk-cw9.log +++ b/cw 9/Debug/grk-cw9.log @@ -1,53 +1,48 @@ -<<<<<<< HEAD - grk-cw9.vcxproj -> C:\Users\prima\Documents\JAVA\GRK_game_scene\Debug\grk-cw9.exe -=======  main.cpp -C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition -C:\Users\prima\Documents\JAVA\GRK_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(101,30): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(133,38): warning C4305: '=': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(156,16): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(225,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(240,98): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition +C:\Users\arciom\Desktop\GRK_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(124,30): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(166,38): warning C4305: '=': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(189,16): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(230,20): warning C4018: '<': signed/unsigned mismatch +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(266,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(280,98): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(243,68): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(283,68): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(282,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(329,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(338,108): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(317,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(372,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(381,108): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(346,87): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(389,87): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(346,223): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(349,59): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(389,223): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(392,59): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(350,37): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(385,2): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(392,20): warning C4018: '<': signed/unsigned mismatch -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(394,47): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(395,48): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(478,21): warning C4018: '<': signed/unsigned mismatch -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(480,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(637,21): warning C4305: '-=': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(639,21): warning C4305: '+=': truncation from 'double' to 'float' -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(667,21): warning C4018: '<': signed/unsigned mismatch -C:\Users\prima\Documents\JAVA\GRK_game_scene\cw 9\src\ex_9_1.hpp(669,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(393,37): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(428,2): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(434,20): warning C4018: '<': signed/unsigned mismatch +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(439,50): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(440,51): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(512,21): warning C4018: '<': signed/unsigned mismatch +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(514,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(669,21): warning C4305: '-=': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(671,21): warning C4305: '+=': truncation from 'double' to 'float' Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library - grk-cw9.vcxproj -> C:\Users\prima\Documents\JAVA\GRK_game_scene\Debug\grk-cw9.exe ->>>>>>> parent of 4a14abf (Revert "Room change") + grk-cw9.vcxproj -> C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe diff --git a/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog index 3c426b6..965627e 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog index 7629fb0..2b3cb78 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog index 6e3aca2..623a1b0 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate b/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate index 4a09ea1..253b6db 100644 --- a/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate +++ b/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate @@ -1,2 +1,2 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: -Debug|Win32|C:\Users\prima\Documents\JAVA\GRK_game_scene\| +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.22000.0: +Debug|Win32|C:\Users\arciom\Desktop\GRK_game_scene\| diff --git a/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog index f3bed20..e6d8cb5 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog index bf5e049..17d7dbb 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog differ diff --git a/cw 9/Debug/image_DXT.obj b/cw 9/Debug/image_DXT.obj index 531a565..80ef900 100644 Binary files a/cw 9/Debug/image_DXT.obj and b/cw 9/Debug/image_DXT.obj differ diff --git a/cw 9/Debug/image_helper.obj b/cw 9/Debug/image_helper.obj index 962a182..f73a11d 100644 Binary files a/cw 9/Debug/image_helper.obj and b/cw 9/Debug/image_helper.obj differ diff --git a/cw 9/Debug/main.obj b/cw 9/Debug/main.obj index ea652e2..4ad2b11 100644 Binary files a/cw 9/Debug/main.obj and b/cw 9/Debug/main.obj differ diff --git a/cw 9/Debug/stb_image_aug.obj b/cw 9/Debug/stb_image_aug.obj index 3ae82fd..217cc07 100644 Binary files a/cw 9/Debug/stb_image_aug.obj and b/cw 9/Debug/stb_image_aug.obj differ diff --git a/cw 9/Debug/vc142.idb b/cw 9/Debug/vc142.idb index 382389e..bdb08d5 100644 Binary files a/cw 9/Debug/vc142.idb and b/cw 9/Debug/vc142.idb differ diff --git a/cw 9/Debug/vc142.pdb b/cw 9/Debug/vc142.pdb index 9ec38b3..66fd8c3 100644 Binary files a/cw 9/Debug/vc142.pdb and b/cw 9/Debug/vc142.pdb differ diff --git a/cw 9/shader_laser.frag b/cw 9/shader_laser.frag new file mode 100644 index 0000000..1cbc500 --- /dev/null +++ b/cw 9/shader_laser.frag @@ -0,0 +1,61 @@ +#version 430 core + + +out vec4 out_color; +flat in vec4 color; +in vec4 pos_local; +in vec4 pos_global; + +uniform float time; +uniform vec3 laserColor; + + +float hash(float n) +{ + return fract(sin(n) * 1399763.5453123); +} + +float noise(vec3 x) +{ + vec3 p = floor(x); + vec3 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + + vec4 test1 = mix(vec4(hash(n + 170.0)), vec4(hash(n + 171.0)), sin(time)); + vec4 test2 = mix(vec4(hash(n + 113.0)), vec4(hash(n + 114.0)), sin(time)); + vec4 test3 = mix(test2, test1, sin(time)); + vec4 test4 = mix(vec4(hash(n + 57.0)), vec4(hash(n + 58.0)), sin(time)); + vec4 test5 = mix(vec4(hash(n + 0.0)), vec4(hash(n + 1.0)), sin(time)); + vec4 test6 = mix(test5, test4, sin(time)); + vec4 test7 = mix(test6, test3, sin(time)); + + + + return test7.z; + +// return mix(mix(mix(hash(n + 0.0), hash(n + 1.0)), mix(hash(n + 57.0), hash(n + 58.0))), mix(mix(hash(n + 113.0), hash(n + 114.0)), mix(hash(n + 170.0), hash(n + 171.0))), f); +} + +void main() +{ + //out_color = vec4(0.8,0.2,0.9,1.0); +// vec4 mixColor = mix(color, vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); +// out_color = mixColor / sin(time); + +// vec4 mixColor = mix(time * abs(pos_local), vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); +// out_color = mixColor / sin(time); + + + vec3 newPosLocal = vec3(pos_local.x, pos_local.y, pos_local.z); + float laserIntensity = pow(sin(time * 10.0), 2.0);//sin(time * 5.0) * 0.5 + 0.5; +// vec3 laserDistortion = vec3(noise(newPosLocal * 8.0 + vec3(0, time * 4.0, time * 2.0)) * 0.1); + + + vec3 laserDistortion = mix(vec4(laserColor, 1), vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)).xyz; + out_color = vec4(laserColor * laserIntensity/* + laserDistortion*/, 1.0); + +// vec4 mixColor = mix(pos_global, vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); +// out_color = mixColor / sin(time); + //out_color = color / time; +} \ No newline at end of file diff --git a/cw 9/shader_laser.vert b/cw 9/shader_laser.vert new file mode 100644 index 0000000..3ae6a1d --- /dev/null +++ b/cw 9/shader_laser.vert @@ -0,0 +1,18 @@ +#version 430 core + +layout(location = 0) in vec4 vertexPosition; +layout(location = 1) in vec4 vertexColor; + +uniform mat4 transformation; + +flat out vec4 color; +out vec4 pos_local; +out vec4 pos_global; + +void main() +{ + color = vertexColor; + pos_local = vertexPosition; + pos_global = transformation * vertexPosition; + gl_Position = transformation * vertexPosition; +} diff --git a/cw 9/shaders/shader_9_1.frag b/cw 9/shaders/shader_9_1.frag index 111c3fb..13f7415 100644 --- a/cw 9/shaders/shader_9_1.frag +++ b/cw 9/shaders/shader_9_1.frag @@ -15,6 +15,34 @@ uniform vec3 sunColor; uniform vec3 lightPos; uniform vec3 lightColor; +//array of laser light position +//uniform vec3 lasersLightPos[21]; +//uniform int lasersLightPosArrayIndex; + +uniform vec3 laserLightPos0; +uniform vec3 laserLightPos1; +uniform vec3 laserLightPos2; +uniform vec3 laserLightPos3; +uniform vec3 laserLightPos4; +uniform vec3 laserLightPos5; +uniform vec3 laserLightPos6; +uniform vec3 laserLightPos7; +uniform vec3 laserLightPos8; +uniform vec3 laserLightPos9; +uniform vec3 laserLightPos10; +uniform vec3 laserLightPos11; +uniform vec3 laserLightPos12; +uniform vec3 laserLightPos13; +uniform vec3 laserLightPos14; +uniform vec3 laserLightPos15; +uniform vec3 laserLightPos16; +uniform vec3 laserLightPos17; +uniform vec3 laserLightPos18; +uniform vec3 laserLightPos19; + + +uniform vec3 laserLightColor; + uniform vec3 spotlightPos; uniform vec3 spotlightColor; uniform vec3 spotlightConeDir; @@ -39,6 +67,7 @@ in vec3 sunDirTS; in vec4 sunSpacePos; in vec3 test; +uniform float time; float DistributionGGX(vec3 normal, vec3 H, float roughness){ float a = roughness*roughness; @@ -124,14 +153,141 @@ void main() //vec3 lightDir = normalize(lightDirTS); vec3 lightDir = normalize(lightPos-worldPos); + //array of lasers light + //vec3 laserLightPos = lasersLightPos[lasersLightPosArrayIndex]; + + //lasers light direction + vec3 laserLightDir0 = normalize(laserLightPos0-worldPos); + vec3 laserLightDir1 = normalize(laserLightPos1-worldPos); + vec3 laserLightDir2 = normalize(laserLightPos2-worldPos); + vec3 laserLightDir3 = normalize(laserLightPos3-worldPos); + vec3 laserLightDir4 = normalize(laserLightPos4-worldPos); + vec3 laserLightDir5 = normalize(laserLightPos5-worldPos); + vec3 laserLightDir6 = normalize(laserLightPos6-worldPos); + vec3 laserLightDir7 = normalize(laserLightPos7-worldPos); + vec3 laserLightDir8 = normalize(laserLightPos8-worldPos); + vec3 laserLightDir9 = normalize(laserLightPos9-worldPos); + vec3 laserLightDir10 = normalize(laserLightPos10-worldPos); + vec3 laserLightDir11 = normalize(laserLightPos11-worldPos); + vec3 laserLightDir12 = normalize(laserLightPos12-worldPos); + vec3 laserLightDir13 = normalize(laserLightPos13-worldPos); + vec3 laserLightDir14 = normalize(laserLightPos14-worldPos); + vec3 laserLightDir15 = normalize(laserLightPos15-worldPos); + vec3 laserLightDir16 = normalize(laserLightPos16-worldPos); + vec3 laserLightDir17 = normalize(laserLightPos17-worldPos); + vec3 laserLightDir18 = normalize(laserLightPos18-worldPos); + vec3 laserLightDir19 = normalize(laserLightPos19-worldPos); + vec3 ambient = AMBIENT*color; - vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2); //dla pocisku + vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2); vec3 ilumination; ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir); -// attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2); -// ilumination=ilumination+PBRLight(lightDir,attenuatedlightColor,normal,viewDir); dla pocisku + //LASERS LIGHTING + float laserIntensity = pow(sin(time * 10.0), 2.0); + + if((laserLightPos0.y > 0 && laserLightPos0.y < 2.2) && (laserLightPos0.z > -2.2 && laserLightPos0.z < 2.1) && (laserLightPos0.x > -1.72 && laserLightPos0.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos0-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir0,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos1.y > 0 && laserLightPos1.y < 2.2) && (laserLightPos1.z > -2.2 && laserLightPos1.z < 2.1) && (laserLightPos1.x > -1.72 && laserLightPos1.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos1-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir1,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos2.y > 0 && laserLightPos2.y < 2.2) && (laserLightPos2.z > -2.2 && laserLightPos2.z < 2.1) && (laserLightPos2.x > -1.72 && laserLightPos2.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos2-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir2,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos3.y > 0 && laserLightPos3.y < 2.2) && (laserLightPos3.z > -2.2 && laserLightPos3.z < 2.1) && (laserLightPos3.x > -1.72 && laserLightPos3.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos3-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir3,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos4.y > 0 && laserLightPos4.y < 2.2) && (laserLightPos4.z > -2.2 && laserLightPos4.z < 2.1) && (laserLightPos4.x > -1.72 && laserLightPos4.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos4-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir4,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos5.y > 0 && laserLightPos5.y < 2.2) && (laserLightPos5.z > -2.2 && laserLightPos5.z < 2.1) && (laserLightPos5.x > -1.72 && laserLightPos5.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos5-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir5,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos6.y > 0 && laserLightPos6.y < 2.2) && (laserLightPos6.z > -2.2 && laserLightPos6.z < 2.1) && (laserLightPos6.x > -1.72 && laserLightPos6.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos6-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir6,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos7.y > 0 && laserLightPos7.y < 2.2) && (laserLightPos7.z > -2.2 && laserLightPos7.z < 2.1) && (laserLightPos7.x > -1.72 && laserLightPos7.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos7-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir7,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos8.y > 0 && laserLightPos8.y < 2.2) && (laserLightPos8.z > -2.2 && laserLightPos8.z < 2.1) && (laserLightPos8.x > -1.72 && laserLightPos8.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos8-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir8,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos9.y > 0 && laserLightPos9.y < 2.2) && (laserLightPos9.z > -2.2 && laserLightPos9.z < 2.1) && (laserLightPos9.x > -1.72 && laserLightPos9.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos9-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir9,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos10.y > 0 && laserLightPos10.y < 2.2) && (laserLightPos10.z > -2.2 && laserLightPos10.z < 2.1) && (laserLightPos10.x > -1.72 && laserLightPos10.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos10-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir10,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos11.y > 0 && laserLightPos11.y < 2.2) && (laserLightPos11.z > -2.2 && laserLightPos11.z < 2.1) && (laserLightPos11.x > -1.72 && laserLightPos11.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos11-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir11,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos12.y > 0 && laserLightPos12.y < 2.2) && (laserLightPos12.z > -2.2 && laserLightPos12.z < 2.1) && (laserLightPos12.x > -1.72 && laserLightPos12.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos12-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir12,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos13.y > 0 && laserLightPos13.y < 2.2) && (laserLightPos13.z > -2.2 && laserLightPos13.z < 2.1) && (laserLightPos13.x > -1.72 && laserLightPos13.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos13-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir13,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos14.y > 0 && laserLightPos14.y < 2.2) && (laserLightPos14.z > -2.2 && laserLightPos14.z < 2.1) && (laserLightPos14.x > -1.72 && laserLightPos14.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos14-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir14,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos15.y > 0 && laserLightPos15.y < 2.2) && (laserLightPos15.z > -2.2 && laserLightPos15.z < 2.1) && (laserLightPos15.x > -1.72 && laserLightPos15.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos15-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir15,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos16.y > 0 && laserLightPos16.y < 2.2) && (laserLightPos16.z > -2.2 && laserLightPos16.z < 2.1) && (laserLightPos16.x > -1.72 && laserLightPos16.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos16-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir16,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos17.y > 0 && laserLightPos17.y < 2.2) && (laserLightPos17.z > -2.2 && laserLightPos17.z < 2.1) && (laserLightPos17.x > -1.72 && laserLightPos17.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos17-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir17,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos18.y > 0 && laserLightPos18.y < 2.2) && (laserLightPos18.z > -2.2 && laserLightPos18.z < 2.1) && (laserLightPos18.x > -1.72 && laserLightPos18.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos18-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir18,attenuatedlightColor,normal,viewDir); + } + + if((laserLightPos19.y > 0 && laserLightPos19.y < 2.2) && (laserLightPos19.z > -2.2 && laserLightPos19.z < 2.1) && (laserLightPos19.x > -1.72 && laserLightPos19.x < 1.78)){ + attenuatedlightColor = laserIntensity * laserLightColor/pow(length(laserLightPos19-worldPos),1.5); + ilumination=ilumination+PBRLight(laserLightDir19,attenuatedlightColor,normal,viewDir); + } + + //flashlight //vec3 spotlightDir= normalize(spotlightDirTS); vec3 spotlightDir= normalize(spotlightPos-worldPos); @@ -142,7 +298,7 @@ void main() ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); //sun - ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); //dla pocisku + ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); diff --git a/cw 9/shaders/shader_laser.frag b/cw 9/shaders/shader_laser.frag index b19f57f..1cbc500 100644 --- a/cw 9/shaders/shader_laser.frag +++ b/cw 9/shaders/shader_laser.frag @@ -7,6 +7,35 @@ in vec4 pos_local; in vec4 pos_global; uniform float time; +uniform vec3 laserColor; + + +float hash(float n) +{ + return fract(sin(n) * 1399763.5453123); +} + +float noise(vec3 x) +{ + vec3 p = floor(x); + vec3 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + + vec4 test1 = mix(vec4(hash(n + 170.0)), vec4(hash(n + 171.0)), sin(time)); + vec4 test2 = mix(vec4(hash(n + 113.0)), vec4(hash(n + 114.0)), sin(time)); + vec4 test3 = mix(test2, test1, sin(time)); + vec4 test4 = mix(vec4(hash(n + 57.0)), vec4(hash(n + 58.0)), sin(time)); + vec4 test5 = mix(vec4(hash(n + 0.0)), vec4(hash(n + 1.0)), sin(time)); + vec4 test6 = mix(test5, test4, sin(time)); + vec4 test7 = mix(test6, test3, sin(time)); + + + + return test7.z; + +// return mix(mix(mix(hash(n + 0.0), hash(n + 1.0)), mix(hash(n + 57.0), hash(n + 58.0))), mix(mix(hash(n + 113.0), hash(n + 114.0)), mix(hash(n + 170.0), hash(n + 171.0))), f); +} void main() { @@ -14,8 +43,17 @@ void main() // vec4 mixColor = mix(color, vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); // out_color = mixColor / sin(time); - vec4 mixColor = mix(time * abs(pos_local), vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); - out_color = mixColor / sin(time); +// vec4 mixColor = mix(time * abs(pos_local), vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); +// out_color = mixColor / sin(time); + + + vec3 newPosLocal = vec3(pos_local.x, pos_local.y, pos_local.z); + float laserIntensity = pow(sin(time * 10.0), 2.0);//sin(time * 5.0) * 0.5 + 0.5; +// vec3 laserDistortion = vec3(noise(newPosLocal * 8.0 + vec3(0, time * 4.0, time * 2.0)) * 0.1); + + + vec3 laserDistortion = mix(vec4(laserColor, 1), vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)).xyz; + out_color = vec4(laserColor * laserIntensity/* + laserDistortion*/, 1.0); // vec4 mixColor = mix(pos_global, vec4(0.0f, 0.3f, 0.3f, 1.0f), sin(time)); // out_color = mixColor / sin(time); diff --git a/cw 9/shaders/shader_laser.vert b/cw 9/shaders/shader_laser.vert index 3ae6a1d..8176f44 100644 --- a/cw 9/shaders/shader_laser.vert +++ b/cw 9/shaders/shader_laser.vert @@ -15,4 +15,4 @@ void main() pos_local = vertexPosition; pos_global = transformation * vertexPosition; gl_Position = transformation * vertexPosition; -} +} \ No newline at end of file diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index acfc411..c0a766b 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -95,11 +95,36 @@ float exposition = 1.f; glm::vec3 pointlightPos = glm::vec3(0, 2, 0); glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6); + +glm::vec3 laserLightPos0; +glm::vec3 laserLightPos1; +glm::vec3 laserLightPos2; +glm::vec3 laserLightPos3; +glm::vec3 laserLightPos4; +glm::vec3 laserLightPos5; +glm::vec3 laserLightPos6; +glm::vec3 laserLightPos7; +glm::vec3 laserLightPos8; +glm::vec3 laserLightPos9; +glm::vec3 laserLightPos10; +glm::vec3 laserLightPos11; +glm::vec3 laserLightPos12; +glm::vec3 laserLightPos13; +glm::vec3 laserLightPos14; +glm::vec3 laserLightPos15; +glm::vec3 laserLightPos16; +glm::vec3 laserLightPos17; +glm::vec3 laserLightPos18; +glm::vec3 laserLightPos19; +glm::vec3 laserLightColor = glm::vec3(1.0, 0, 0); + glm::vec3 spotlightPos = glm::vec3(0, 0, 0); glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0); glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3; float spotlightPhi = 3.14 / 4; +glm::vec3 laserColor = glm::vec3(0, 0, 0); + bool drawLaserShot = false; @@ -121,6 +146,14 @@ std::vector lasersContexts{ models::laserContext1, models:: models::laserContext16, models::laserContext17, models::laserContext18, models::laserContext19, models::laserContext20 }; +std::vector lasersLightPos{ laserLightPos0, laserLightPos1, laserLightPos2, laserLightPos3, laserLightPos4, laserLightPos5, laserLightPos6, laserLightPos7, + laserLightPos8, laserLightPos9, laserLightPos10, laserLightPos11, laserLightPos12, laserLightPos13, laserLightPos14, laserLightPos15, + laserLightPos15, laserLightPos16, laserLightPos17, laserLightPos18, laserLightPos19}; +//glm::vec3 lasersLightPos[21] = { laserLightPos0, laserLightPos1, laserLightPos2, laserLightPos3, laserLightPos4, laserLightPos5, laserLightPos6, laserLightPos7, +// laserLightPos8, laserLightPos9, laserLightPos10, laserLightPos11, laserLightPos12, laserLightPos13, laserLightPos14, laserLightPos15, +// laserLightPos16, laserLightPos17, laserLightPos18, laserLightPos19 }; + + std::vector lasers; void updateDeltaTime(float time) { @@ -191,16 +224,25 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z); + - /*glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); - glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);*/ + //lasers light + for (int i = 0; i < lasers.size(); i++) { + std::string stringLaserPos = "laserLightPos"; + stringLaserPos += std::to_string(i); + if (lasers[i].isLaserFly()) { + glUniform3f(glGetUniformLocation(program, "laserLightColor"), laserLightColor.x, laserLightColor.y, laserLightColor.z); + glUniform3f(glGetUniformLocation(program, stringLaserPos.c_str()), lasersLightPos[i].x, lasersLightPos[i].y, lasersLightPos[i].z); + /*glUniform3fv(glGetUniformLocation(program, "lasersLightPos"), 3, &lasersLightPos[i][0]); + glUniform1i(glGetUniformLocation(program, "lasersLightPosArrayIndex"), i);*/ + } + } 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); - //For shadows glm::mat4 lightVPSun = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0)); glUniformMatrix4fv(glGetUniformLocation(program, "LightVPSun"), 1, GL_FALSE, (float*)&lightVPSun); @@ -208,7 +250,6 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec glActiveTexture(GL_TEXTURE0 + 2); glBindTexture(GL_TEXTURE_2D, depthMapSun); - Core::DrawContext(context); } @@ -236,7 +277,6 @@ void renderShadowapSun(GLuint depthMapFBO, glm::mat4 lightVP) { //ustawianie programu glUseProgram(programDepth); - drawObjectDepth(sphereContext, lightVP, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f))); drawObjectDepth(sphereContext, @@ -251,14 +291,9 @@ void renderShadowapSun(GLuint depthMapFBO, glm::mat4 lightVP) { drawObjectDepth(models::planeContext, lightVP, glm::mat4()); drawObjectDepth(models::roomContext, lightVP, glm::mat4()); drawObjectDepth(models::windowContext, lightVP, glm::mat4()); - drawObjectDepth(models::sofaContext, lightVP, glm::mat4()); - - - + drawObjectDepth(models::sofaContext, lightVP, glm::mat4()); drawObjectDepth(models::booksContext, lightVP, glm::mat4()); - - glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceShip.getSpaceShipDir(), glm::vec3(0.f, 1.f, 0.f))); glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceShip.getSpaceShipDir())); glm::mat4 specshipCameraRotrationMatrix = glm::mat4({ @@ -277,7 +312,7 @@ void renderShadowapSun(GLuint depthMapFBO, glm::mat4 lightVP) { } -void drawLaser(Laser laser, Core::RenderContext laserContext, float dyst) { +void drawLaser(Laser laser, Core::RenderContext laserContext, float dyst, int index) { float time = glfwGetTime(); @@ -295,10 +330,18 @@ void drawLaser(Laser laser, Core::RenderContext laserContext, float dyst) { glm::vec3 newLaserPos = laser.getLaserPos() + laser.getLaserDir() * (laser.getLaserSpeed() * (t + sin(0.2 * t))); laser.setLaserPos(newLaserPos); + lasersLightPos[index] = glm::vec3(laser.getLaserPos().x + dyst, laser.getLaserPos().y, laser.getLaserPos().z); + + glUseProgram(programLaser); + glm::mat4 laserTransformation = createPerspectiveMatrix() * createCameraMatrix() * glm::translate(glm::vec3(laser.getLaserPos().x + dyst, laser.getLaserPos().y, laser.getLaserPos().z)) * laserCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.03f));//glm::eulerAngleXYZ(glm::radians(15.0f), time * glm::radians(45.0f), glm::radians(0.0f)); + glUniformMatrix4fv(glGetUniformLocation(programLaser, "transformation"), 1, GL_FALSE, (float*)&laserTransformation); + glUniform1f(glGetUniformLocation(programLaser, "time"), time); + glUniform3f(glGetUniformLocation(programLaser, "laserColor"), laserColor.x, laserColor.y, laserColor.z); drawObjectPBR(laserContext, - glm::translate(glm::vec3(laser.getLaserPos().x + dyst, laser.getLaserPos().y, laser.getLaserPos().z)) * laserCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.03f)), + laserTransformation, glm::vec3(1.0f, 0.f, 0.f), 0.f, 0.f); + } @@ -387,26 +430,15 @@ void renderScene(GLFWwindow* window) spotlightPos = spaceShip.getSpaceShipPos() + 0.2 * spaceShip.getSpaceShipDir(); spotlightConeDir = spaceShip.getSpaceShipDir(); - //draw lasers for (int i = 0; i < lasers.size(); i++) { if (lasers[i].isLaserFly()) { - drawLaser(lasers[i], lasersContexts[i], 0.1); - drawLaser(lasers[i], lasersContexts[i], -0.1); + laserColor = glm::vec3(1, 0, 0); + glUniform3f(glGetUniformLocation(programLaser, "laserColor"), laserColor.x, laserColor.y, laserColor.z); + glUniform1f(glGetUniformLocation(program, "time"), time); + drawLaser(lasers[i], lasersContexts[i], 0.1, i); + drawLaser(lasers[i], lasersContexts[i], -0.1, i); } - - - /*if (i % 2 == 0) { - drawLaser(lasers[i], lasersContexts[i], 0.1); - drawLaser(lasers[i], lasersContexts[i], -0.1); - - - }*/ - /*else { - drawLaser(lasers[i], lasersContexts[i], 0.1); - - }*/ - } @@ -442,7 +474,7 @@ void loadModelToContext(std::string path, Core::RenderContext& context) void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) { - std::cout << "yStart: " << startCursorYPos << "\n"; + //std::cout << "yStart: " << startCursorYPos << "\n"; float angleSpeed = 0.05f * deltaTime * 60; @@ -450,13 +482,13 @@ void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) startCursorYPos = ypos; spaceShip.setSpaceShipDir(glm::vec3(glm::eulerAngleX(angleSpeed) * glm::vec4(spaceShip.getSpaceShipDir(), 0))); //startCursorYPos = ypos; - std::cout << "yNew: " << ypos << "\n"; + //std::cout << "yNew: " << ypos << "\n"; } else if (ypos > startCursorYPos) { startCursorYPos = ypos; spaceShip.setSpaceShipDir(glm::vec3(glm::eulerAngleX(-angleSpeed) * glm::vec4(spaceShip.getSpaceShipDir(), 0))); //startCursorYPos = ypos; - std::cout << "yNew: " << ypos << "\n"; + //std::cout << "yNew: " << ypos << "\n"; } @@ -468,6 +500,8 @@ void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { + std::cout << "x = " << spaceShip.getSpaceShipPos().x << " y = " << spaceShip.getSpaceShipPos().y << " z = " << spaceShip.getSpaceShipPos().z << "\n"; + if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { drawLaserShot = true; @@ -514,7 +548,9 @@ void init(GLFWwindow* window) programDepth = shaderLoader.CreateProgram("shaders/shader_shadowap_sun.vert", "shaders/shader_shadowap_sun.frag"); - //programLaser = shaderLoader.CreateProgram("shaders/shader_laser.vert", "shaders/shader_laser.frag"); + + + programLaser = shaderLoader.CreateProgram("shader_laser.vert", "shader_laser.frag"); loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/spaceship.obj", shipContext); @@ -535,19 +571,15 @@ void init(GLFWwindow* window) loadModelToContext("./models/window.obj", models::windowContext); loadModelToContext("./models/test.obj", models::testContext); - //loadModelToContext("./models/newlaser2.obj", models::laserContext); - //lasersContexts.reserve(spaceShip.getMaxNumberOfLasers()); for (int i = 0; i < spaceShip.getMaxNumberOfLasers(); i++) { - //lasersContexts.push_back(models::laserContext); loadModelToContext("./models/newlaser2.obj", lasersContexts[i]); lasers.push_back(Laser(spaceShip.getSpaceShipDir(), spaceShip.getSpaceShipPos(), 1, false)); } - /*for (int i = 0; i < spaceShip.getMaxNumberOfLasers(); i++) { loadModelToContext("./models/newlaser2.obj", spaceShip.getGun()[i].getLaserContext()); @@ -643,48 +675,6 @@ void processInput(GLFWwindow* window) printf("spaceshipDir = glm::vec3(%ff, %ff, %ff);\n", spaceShip.getSpaceShipDir().x, spaceShip.getSpaceShipDir().y, spaceShip.getSpaceShipDir().z); } - if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) { - drawLaserShot = true; - - spaceShip.setAttackDecision(true); - /*spaceShip.laserPreparationBeforeShoot(glfwGetTime()); - - - if (spaceShip.getNumberOfLeftLasers() > 0) { - spaceShip.setNumberOfLeftLasers(spaceShip.getNumberOfLeftLasers() - 1); - } - else if (spaceShip.getNumberOfLeftLasers() == 0) { - spaceShip.setNumberOfLeftLasers(spaceShip.getMaxNumberOfLasers()); - spaceShip.setNumberOfLeftLasers(spaceShip.getNumberOfLeftLasers() - 1); - } - - lasers[spaceShip.getNumberOfLeftLasers()].setTimeSinceShootLaser(glfwGetTime()); - lasers[spaceShip.getNumberOfLeftLasers()].setLaserDir(spaceShip.getSpaceShipDir()); - lasers[spaceShip.getNumberOfLeftLasers()].setLaserPos(spaceShip.getSpaceShipPos()); - lasers[spaceShip.getNumberOfLeftLasers()].setLaserSpeed(0.01);*/ - - - for (int i = 0; i < lasers.size(); i++) { - if (!lasers[i].isLaserFly() && spaceShip.getAttackDecision()) { - lasers[i].setTimeSinceShootLaser(glfwGetTime()); - lasers[i].setLaserDir(spaceShip.getSpaceShipDir()); - lasers[i].setLaserPos(spaceShip.getSpaceShipPos()); - lasers[i].setLaserSpeed(1); - lasers[i].setLaserFly(true); - spaceShip.setAttackDecision(false); - - - std::cout << "i = " << i << " " << "laser fly = " << lasers[i].isLaserFly() << "\n"; - } - } - - - //laser.setTimeSinceShootLaser(glfwGetTime()); - //laser.setLaserDir(spaceShip.getSpaceShipDir()); - //laser.setLaserPos(spaceShip.getSpaceShipPos()); - //laser.setLaserSpeed(0.01); - } - //if(glfwGetKey(window, GLFW_MOUSE)) //cameraDir = glm::normalize(-cameraPos);