collision update

This commit is contained in:
minni0n 2023-02-07 15:56:13 +01:00
parent 2e9ba4386c
commit e9d45fe6e3
27 changed files with 127 additions and 38 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<FullPath>C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe</FullPath> <FullPath>C:\Users\Serhii\source\repos\GRK_game_scene2\Debug\grk-cw9.exe</FullPath>
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

View File

@ -1,49 +1,58 @@
 main.cpp  main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.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\Serhii\source\repos\GRK_game_scene2\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(133,30): warning C4305: 'initializing': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(137,30): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(175,38): warning C4305: '=': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(180,38): warning C4305: '=': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(198,16): warning C4305: 'initializing': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(203,16): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(239,20): warning C4018: '<': signed/unsigned mismatch C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(244,20): warning C4018: '<': signed/unsigned mismatch
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(288,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(293,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(302,98): warning C4305: 'argument': truncation from 'double' to 'T' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(307,98): warning C4305: 'argument': truncation from 'double' to 'T'
with with
[ [
T=float T=float
] ]
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(305,68): warning C4305: 'argument': truncation from 'double' to 'T' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(310,68): warning C4305: 'argument': truncation from 'double' to 'T'
with with
[ [
T=float T=float
] ]
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(339,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(348,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(422,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(431,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(433,108): warning C4305: 'argument': truncation from 'double' to 'T' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(442,108): warning C4305: 'argument': truncation from 'double' to 'T'
with with
[ [
T=float T=float
] ]
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(441,87): warning C4305: 'argument': truncation from 'double' to 'T' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(450,87): warning C4305: 'argument': truncation from 'double' to 'T'
with with
[ [
T=float T=float
] ]
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(441,223): warning C4305: 'argument': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(450,223): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(444,59): warning C4305: 'argument': truncation from 'double' to 'T' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(453,59): warning C4305: 'argument': truncation from 'double' to 'T'
with with
[ [
T=float T=float
] ]
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(445,37): warning C4305: 'argument': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(454,37): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(482,2): warning C4305: 'argument': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(494,2): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(493,20): warning C4018: '<': signed/unsigned mismatch C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(505,20): warning C4018: '<': signed/unsigned mismatch
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(498,50): warning C4305: 'argument': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(510,50): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(499,51): warning C4305: 'argument': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(511,51): warning C4305: 'argument': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(576,21): warning C4018: '<': signed/unsigned mismatch C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(588,21): warning C4018: '<': signed/unsigned mismatch
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(578,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(590,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(601,17): warning C4101: 'data': unreferenced local variable C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(613,17): warning C4101: 'data': unreferenced local variable
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(803,21): warning C4305: '-=': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(714,28): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(805,21): warning C4305: '+=': truncation from 'double' to 'float' C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(715,28): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(716,28): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(739,32): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(740,32): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(741,32): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(777,28): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(778,28): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(779,28): warning C4305: 'initializing': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(899,21): warning C4305: '-=': truncation from 'double' to 'float'
C:\Users\Serhii\source\repos\GRK_game_scene2\cw 9\src\ex_9_1.hpp(901,21): warning C4305: '+=': truncation from 'double' to 'float'
Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 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 LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
grk-cw9.vcxproj -> C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe grk-cw9.vcxproj -> C:\Users\Serhii\source\repos\GRK_game_scene2\Debug\grk-cw9.exe

View File

@ -1,2 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.22000.0: PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:VcpkgTriplet=x86-windows:
Debug|Win32|C:\Users\arciom\Desktop\GRK_game_scene\| Debug|Win32|C:\Users\Serhii\source\repos\GRK_game_scene2\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@


View File

@ -167,6 +167,7 @@ std::vector<glm::vec3> lasersLightPos{ laserLightPos0, laserLightPos1, laserLigh
// laserLightPos16, laserLightPos17, laserLightPos18, laserLightPos19 }; // laserLightPos16, laserLightPos17, laserLightPos18, laserLightPos19 };
std::vector<Laser> lasers; std::vector<Laser> lasers;
void updateDeltaTime(float time) { void updateDeltaTime(float time) {
@ -708,19 +709,97 @@ void shutdown(GLFWwindow* window)
shaderLoader.DeleteProgram(program); shaderLoader.DeleteProgram(program);
} }
bool check_room_collision(int plus_or_minus) { bool check_window_collision(int plus_or_minus) {
float spaceShipX = 0.20445;
float spaceShipY = 0.04875;
float spaceShipZ = 0.16275;
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f); glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
float moveSpeed = 0.02f * deltaTime * 60; float moveSpeed = 0.02f * deltaTime * 60;
glm::vec3 spaceShipPos = spaceShip.getSpaceShipPos() + (spaceShip.getSpaceShipDir() * moveSpeed) * plus_or_minus; glm::vec3 spaceShipPos = spaceShip.getSpaceShipPos() + (spaceShip.getSpaceShipDir() * moveSpeed) * plus_or_minus;
bool collision = spaceShipPos.z < -2.04 || spaceShipPos.z > 2.06 || //bool collision = (-1 < spaceShipPos.x < 1) && (0.0 < spaceShipPos.y < 0.9) && (-1.5 < spaceShipPos.z < 0.5);
spaceShipPos.x < -1.61 || spaceShipPos.x > 1.59 ||
spaceShipPos.y > 2.15 || spaceShipPos.y < 0.11;
bool collision =
/*(-1.83187 < spaceShipPos.x) &&
(spaceShipPos.x < -1.8) &&*/
(1.01537 + spaceShipY < spaceShipPos.y) &&
(spaceShipPos.y < 1.97 - spaceShipY) &&
(-0.249217 + spaceShipZ < spaceShipPos.z) &&
(spaceShipPos.z < 0.750784 - spaceShipZ);
return collision; //if you want check textures position, return false instead collision return collision;
} }
bool check_room_collision(int plus_or_minus) {
float spaceShipX = 0.20445 / 2;
float spaceShipY = 0.04875 / 2;
float spaceShipZ = 0.16275 / 2;
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
float moveSpeed = 0.02f * deltaTime * 60;
glm::vec3 spaceShipPos = spaceShip.getSpaceShipPos() + (spaceShip.getSpaceShipDir() * moveSpeed) * plus_or_minus;
if ((spaceShipPos.x >= 2 + spaceShipX || spaceShipPos.x <= -2 - spaceShipX) ||
(spaceShipPos.y >= 2.5 + spaceShipY || spaceShipPos.y <= 0.0 - spaceShipY) ||
(spaceShipPos.z >= 2.5 + spaceShipZ || spaceShipPos.z <= -2.5 - spaceShipZ))
{
return false;
}
else
{
if (check_window_collision(plus_or_minus)) {
//printf("WINDOW 1");
return false;
}
else {
bool collision =
spaceShipPos.z < -2.2 + spaceShipZ || spaceShipPos.z > 2.1 - spaceShipZ ||
spaceShipPos.x < -1.72 + spaceShipX || spaceShipPos.x > 1.78 - spaceShipX ||
spaceShipPos.y < 0.0 + spaceShipY || spaceShipPos.y > 2.2 - spaceShipY;
return collision;
}
}
}
bool check_sofa_collision(int plus_or_minus) {
float spaceShipX = 0.20445;
float spaceShipY = 0.04875;
float spaceShipZ = 0.16275;
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
float moveSpeed = 0.02f * deltaTime * 60;
glm::vec3 spaceShipPos = spaceShip.getSpaceShipPos() + (spaceShip.getSpaceShipDir() * moveSpeed) * plus_or_minus;
//bool collision = (-1 < spaceShipPos.x < 1) && (0.0 < spaceShipPos.y < 0.9) && (-1.5 < spaceShipPos.z < 0.5);
bool collision =
(-1.07 - spaceShipX < spaceShipPos.x) &&
(spaceShipPos.x < 1.05 + spaceShipX) &&
(0.0 - spaceShipY < spaceShipPos.y) &&
(spaceShipPos.y < 0.64 + spaceShipY) &&
(-1.57 - spaceShipZ< spaceShipPos.z) &&
(spaceShipPos.z < -0.49 + spaceShipZ);
return collision;
}
//obsluga wejscia //obsluga wejscia
void processInput(GLFWwindow* window) void processInput(GLFWwindow* window)
{ {
@ -737,14 +816,14 @@ void processInput(GLFWwindow* window)
glfwSetWindowShouldClose(window, true); glfwSetWindowShouldClose(window, true);
} }
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
if (!check_room_collision(1)) { if (!check_room_collision(1) && !check_sofa_collision(1)) {
spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceShip.getSpaceShipDir() * moveSpeed); spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceShip.getSpaceShipDir() * moveSpeed);
} }
//spaceshipPos += spaceshipDir * moveSpeed; //spaceshipPos += spaceshipDir * moveSpeed;
} }
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
if (!check_room_collision(-1)) { if (!check_room_collision(-1) && !check_sofa_collision(-1)) {
spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceShip.getSpaceShipDir() * moveSpeed); spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceShip.getSpaceShipDir() * moveSpeed);
} }
//spaceshipPos -= spaceshipDir * moveSpeed; //spaceshipPos -= spaceshipDir * moveSpeed;
@ -752,14 +831,14 @@ void processInput(GLFWwindow* window)
} }
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) {
//spaceshipPos += spaceshipSide * moveSpeed; //spaceshipPos += spaceshipSide * moveSpeed;
if (!check_room_collision(1)) { if (!check_room_collision(1) && !check_sofa_collision(1)) {
spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceshipSide * moveSpeed); spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() + spaceshipSide * moveSpeed);
} }
} }
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) {
if (!check_room_collision(-1)) { if (!check_room_collision(-1) && !check_sofa_collision(-1)) {
spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceshipSide * moveSpeed); spaceShip.setSpaceShipPos(spaceShip.getSpaceShipPos() - spaceshipSide * moveSpeed);
} }