Endgame + little fix

This commit is contained in:
xkamikoo 2021-02-25 20:52:49 +01:00
parent 5e8f2b8330
commit e9ca499224
20 changed files with 47003 additions and 22 deletions

View File

@ -59,7 +59,7 @@
<ProjectGuid>{1B448102-E76C-4347-BDC7-40D02A567DB6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>grk-cw9</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<ProjectName>grk-project</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -74,7 +74,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

42
models/stargate.mtl Normal file
View File

@ -0,0 +1,42 @@
# Blender MTL File: 'uploads_files_911030_stargate002.blend'
# Material Count: 4
newmtl event_horizon.cycles
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl gate.cycles
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl gate_grey.cycles
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.259800 0.259800 0.259800
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl glow.cycles
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 1.000000 0.491265 0.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1

46869
models/stargate.obj Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

View File

@ -41,15 +41,13 @@ void main()
// then retrieve perpendicular vector B with the cross product of T and N
vec3 B = cross(N, T);
mat3 TBN = mat3(T, B, N);
mat3 TBN = transpose(mat3(T, B, N));
for(int i=0; i<LightsCount; i++)
LightPosTS[i] = TBN * pointLights[i].position;
fragPos = (aInstanceMatrix*vec4(vertexPosition,1)).xyz;
CameraPosTS = TBN * cameraPos;
FragPosTS = TBN * fragPos;
fragPos = (aInstanceMatrix*vec4(vertexPosition,1)).xyz;
vTexCoord = vertexTexCoord;
}

View File

@ -34,20 +34,17 @@ void main()
vec3 T = normalize(normalMatrix * aTangent);
vec3 N = normalize(normalMatrix * vertexNormal);
// re-orthogonalize T with respect to N
T = normalize(T - dot(T, N) * N);
// then retrieve perpendicular vector B with the cross product of T and N
vec3 B = cross(N, T);
mat3 TBN = mat3(T, B, N);
mat3 TBN = transpose(mat3(T, B, N));
for(int i=0; i<LightsCount; i++)
LightPosTS[i] = TBN * pointLights[i].position;
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
CameraPosTS = TBN * cameraPos;
FragPosTS = TBN * fragPos;
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
vTexCoord = vertexTexCoord;
}

View File

@ -36,7 +36,7 @@ vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
// depth of current layer
float currentLayerDepth = 0.0;
// the amount to shift the texture coordinates per layer (from vector P)
vec2 P = viewDir.xy / viewDir.z * 0.00001;
vec2 P = viewDir.xy / viewDir.z * 0.001;
vec2 deltaTexCoords = P / numLayers;
// get initial values
@ -79,7 +79,7 @@ void main()
//vec3 texture = vec3(textureColor.x, textureColor.y, textureColor.z);
vec3 ambient = vec3(0.1, 0.1, 0.1) * texture;
vec3 normal = texture2D(normalTexture, vTexCoord).rgb;
vec3 normal = texture2D(normalTexture, texCoords).rgb;
normal = normalize(normal * 2.0 - 1.0);
for(int i = 0; i < LightsCount; i++)
{
@ -92,7 +92,7 @@ void main()
float distance = (1/dist) * (1/dist);
float spec = pow(max(0,dot(R,V)),2);
float diff = max(0,dot(normal,normalize(lightDir)));
float diff = max(0,dot(normal,lightDir));
vec3 diffuse = pointLights[i].color * diff * distance * pointLights[i].intensity;
vec3 specular = spec * pointLights[i].color * (pointLights[i].intensity/dist);

View File

@ -39,15 +39,13 @@ void main()
// then retrieve perpendicular vector B with the cross product of T and N
vec3 B = cross(N, T);
mat3 TBN = mat3(T, B, N);
mat3 TBN = transpose(mat3(T, B, N));
for(int i=0; i<LightsCount; i++)
LightPosTS[i] = TBN * pointLights[i].position;
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
CameraPosTS = TBN * cameraPos;
FragPosTS = TBN * fragPos;
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
vTexCoord = vertexTexCoord;
}

View File

@ -24,6 +24,7 @@
int msgId = 0;
int checkTimer = 360;
int frames = 0;
bool endgame = false;
const char* screenMsg[4] = { "Znajdz zaloganta w pasie asteroid", "Znalazles zaloganta!",
"Uszkodzenie oslon termicznych", "Zderzenie z duzym obiektem" };
@ -55,12 +56,27 @@ public:
auto actorName2 = ((Object*)ac2->userData)->GetName();
if ((actorName1 == "Space Humster" && actorName2 == "Corvette") || (actorName2 == "Space Humster" && actorName1 == "Corvette"))
{
endgame = true;
checkTimer = frames + 240;
msgId = 1;
auto humster = getActor("Space Humster");
((Object*)humster->userData)->exists = false;
humster->setActorFlag(PxActorFlag::eDISABLE_SIMULATION, true);
}
if ((actorName1 == "stargate" && actorName2 == "Corvette") || (actorName2 == "stargate" && actorName1 == "Corvette"))
{
if (endgame)
{
checkTimer = frames + 240;
msgId = 1;
}
else
{
checkTimer = frames + 240;
msgId = 0;
}
}
}
virtual void onConstraintBreak(PxConstraintInfo* constraints, PxU32 count) {}
virtual void onWake(PxActor** actors, PxU32 count) {}
@ -117,10 +133,16 @@ GLuint earthTexture;
GLuint marsTexture;
GLuint moonTexture;
GLuint icyTexture;
GLuint stargateTexture;
GLuint neptunTexture;
GLuint jowisTexture;
GLuint mercuryTexture;
GLuint venusTexture;
GLuint skyboxTexture;
GLuint particleTexture;
GLuint parallax_diffuse;
GLuint parallax_normal;
GLuint parallax_disp;
//assimp
std::shared_ptr<Model> cube;
@ -129,6 +151,7 @@ std::shared_ptr<Model> corvette;
std::shared_ptr<Model> asteroid;
std::shared_ptr<Model> crewmate;
std::shared_ptr<Model> hamster;
std::shared_ptr<Model> stargate;
//asteroids
GLuint bufferAsteroids;
@ -176,7 +199,6 @@ void SortParticles() {
std::sort(&ParticlesContainer[0], &ParticlesContainer[MaxParticles]);
}
int FindUnusedParticle() {
for (int i = LastUsedParticle; i < MaxParticles; i++) {
@ -577,6 +599,8 @@ void updateObjects()
auto marsPos = mars->findOrbit(lastTime / 5.0f, sunPos2, glm::vec3(0, 1, 0), glm::vec3(-6.5f, 0.0f, -6.5f));
mars->SetPosition(marsPos);
mars->SetRotation(glm::vec3(0, 0, 1), lastTime / 2.0f);
auto actorMars = getActor("Mars");
actorMars->setKinematicTarget(PxTransform(PxVec3(marsPos.x, marsPos.y, marsPos.z)));
Object *jowis = findObject("Jowis");
Object *jowisMoon1 = findObject("MoonJup1");
@ -585,6 +609,8 @@ void updateObjects()
auto jowisPos = jowis->findOrbit(lastTime / 15.0f, sunPos, glm::vec3(0, 1, 0), glm::vec3(-55.5f, 2.0f, -55.5f));
jowis->SetPosition(jowisPos);
jowis->SetRotation(glm::vec3(0, 0, 1), lastTime/2.0f);
auto actorJowis = getActor("Jowis");
actorJowis->setKinematicTarget(PxTransform(PxVec3(jowisPos.x, jowisPos.y, jowisPos.z)));
auto jowisMoon1Pos = jowisMoon1->findOrbit(lastTime, jowisPos, glm::vec3(1, 0, 0), glm::vec3(0, 3.5, 0));
jowisMoon1->SetPosition(jowisMoon1Pos);
@ -602,11 +628,30 @@ void updateObjects()
auto neptunPos = neptun->findOrbit(lastTime / 17.0f, sunPos, glm::vec3(0, 1, 0), glm::vec3(-85.5f, -2.0f, -85.5f));
neptun->SetPosition(neptunPos);
neptun->SetRotation(glm::vec3(1, 0, 0), lastTime / 2.0f);
auto actorNeptune = getActor("Neptun");
actorNeptune->setKinematicTarget(PxTransform(PxVec3(neptunPos.x, neptunPos.y, neptunPos.z)));
Object *planet1 = findObject("planet1");
auto planet1Pos = planet1->findOrbit(lastTime / 12.0f, sunPos2, glm::vec3(0, 1, 0), glm::vec3(-20.5f, 2.0f, -20.5f));
planet1->SetPosition(planet1Pos);
planet1->SetRotation(glm::vec3(-1, 0, 0), lastTime);
auto actorPlanet1 = getActor("planet1");
actorPlanet1->setKinematicTarget(PxTransform(PxVec3(planet1Pos.x, planet1Pos.y, planet1Pos.z)));
Object *planet2 = findObject("planet2");
auto planet2Pos = planet2->findOrbit(lastTime / 10.0f, sunPos, glm::vec3(0, 1, 0), glm::vec3(-15.5f, 1.0f, -15.5f));
planet2->SetPosition(planet2Pos);
planet2->SetRotation(glm::vec3(-1, 0, 0), lastTime/5.0f);
auto actorPlanet2 = getActor("planet2");
actorPlanet2->setKinematicTarget(PxTransform(PxVec3(planet2Pos.x, planet2Pos.y, planet2Pos.z)));
Object *deadstar = findObject("Dead star");
auto starPos = deadstar->findOrbit(lastTime / 35.0f, sunPos, glm::vec3(0, 1, 0), glm::vec3(-135.5f, 0.0f, -135.5f));
deadstar->SetPosition(starPos);
deadstar->SetRotation(glm::vec3(0, 0, 1), lastTime / 12.0f);
auto actorStar = getActor("Dead star");
actorStar->setKinematicTarget(PxTransform(PxVec3(starPos.x, starPos.y, starPos.z)));
}
void updatePhysics()
@ -835,7 +880,6 @@ void renderScene()
glutSwapBuffers();
}
void initPhysics()
{
material = pxScene.physics->createMaterial(0.5, 0.5, 0.5);
@ -846,8 +890,10 @@ void initPhysics()
{
if (obj.GetName() == "Space Humster")
rectangleShape = pxScene.physics->createShape(PxBoxGeometry(0.3f, 0.3f, 0.3f), *material);
if (obj.GetName() == "stargater")
rectangleShape = pxScene.physics->createShape(PxBoxGeometry(obj.GetScale().x, obj.GetScale().y, obj.GetScale().z), *material);
if (obj.GetName() == "humster")
rectangleShape = pxScene.physics->createShape(PxBoxGeometry(0.3f, 0.3f, 0.3f), *material);
rectangleShape = pxScene.physics->createShape(PxBoxGeometry(obj.GetScale().x, obj.GetScale().y, obj.GetScale().z), *material);
else if (obj.GetName() == "Corvette")
rectangleShape = pxScene.physics->createShape(PxBoxGeometry(0.5f, 0.5f, 0.5f), *material);
else rectangleShape = pxScene.physics->createShape(PxBoxGeometry(1, 1, 1), *material);
@ -1040,6 +1086,11 @@ void initObjects()
sunPos2, glm::vec3(0.1f), glm::vec3(2.5f), 0, false, false);
objects.push_back(obj);
obj = Object("stargate", stargate, stargateTexture, programSun, glm::vec3(0.9f, 0.9f, 2.0f),
glm::vec3(cameraPos + glm::vec3(80, -0.3, 55)), glm::vec3(0.1f), glm::vec3(1.0f), 0, false, false);
//obj.textureDepthID = -1;
objects.push_back(obj);
Object planet = Object("Earth", sphere, earthTexture, programTex, glm::vec3(1.0f),
glm::vec3(-10.5f, 0.0f, -10.5f), glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(0.5f, 0.5f, 0.5f), 0, false, true);
objects.push_back(planet);
@ -1056,6 +1107,14 @@ void initObjects()
glm::vec3(-40.5f, 0.0f, -6.5f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.7f), 0, false, true);
objects.push_back(planet);
planet = Object("planet1", sphere, venusTexture, programTex, glm::vec3(1.0f),
glm::vec3(-90.5f, 0.0f, -6.5f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(1.2f), 0, false, true);
objects.push_back(planet);
planet = Object("planet2", sphere, mercuryTexture, programTex, glm::vec3(1.0f),
glm::vec3(-90.5f, 0.0f, -6.5f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(1.2f), 0, false, true);
objects.push_back(planet);
planet = Object("Dead star", sphere, icyTexture, programTex, glm::vec3(1.0f),
glm::vec3(-60.5f, 0.0f, -60.5f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(5.0f), 0, false, true);
objects.push_back(planet);
@ -1076,8 +1135,11 @@ void initObjects()
glm::vec3(-5, 0, 0), glm::vec3(1, 0, 1), glm::vec3(0.1), 0, true, false);
objects.push_back(crewmateObj);
crewmateObj = Object("humster", hamster, programParallax, glm::vec3(1.0f),
crewmateObj = Object("humster", cube, programParallax, glm::vec3(1.0f),
glm::vec3(5, 0, 5), glm::vec3(1, 0, 1), glm::vec3(0.1), 0, true, false);
crewmateObj.textureDiffuseID = parallax_diffuse;
crewmateObj.textureNormalID = parallax_normal;
crewmateObj.textureDepthID = parallax_disp;
objects.push_back(crewmateObj);
//glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.7f + glm::vec3(0, -0.25f, 0)) * glm::rotate(-cameraAngle + glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.0001f));;
@ -1114,8 +1176,10 @@ void init()
asteroid = std::make_shared<Model>("models/Asteroid_X.obj");
sphere = std::make_shared<Model>("models/sphere.obj");
cube = std::make_shared<Model>("models/cube.obj");
stargate = std::make_shared<Model>("models/stargate.obj");
sunTexture = Core::LoadTexture("textures/sun.png");
stargateTexture = Core::LoadTexture("textures/stargate.png");
earthTexture = Core::LoadTexture("textures/earth2.png");
moonTexture = Core::LoadTexture("textures/moon.png");
particleTexture = Core::LoadTexture("textures/sun.png");
@ -1123,6 +1187,13 @@ void init()
marsTexture = Core::LoadTexture("models/textures/Mars/2k_mars.png");
jowisTexture = Core::LoadTexture("models/textures/Jupiter/2k_jupiter.png");
neptunTexture = Core::LoadTexture("models/textures/Neptune/2k_neptune.png");
venusTexture = Core::LoadTexture("models/textures/Mercury/2k_venus.png");
mercuryTexture = Core::LoadTexture("models/textures/Mercury/2k_mercury.png");
parallax_diffuse = Core::LoadTexture("textures/parallax_diffuse.png");
parallax_normal = Core::LoadTexture("textures/parallax_normal.png");
parallax_disp = Core::LoadTexture("textures/parallax_disp.png");
skyboxTexture = loadCubemap(faces);
initParticles();
@ -1154,6 +1225,12 @@ void init()
l4.color = glm::vec3(1.0f, 0.0f, 0.0f);
l4.intensity = 0.001;
lights.push_back(l4);
Light l5;
l5.position = glm::vec3(cameraPos + glm::vec3(80, -0.3, 55));
l5.color = glm::vec3(0.7f, 0.7f, 1.0f);
l5.intensity = 20;
lights.push_back(l5);
}
void shutdown()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
textures/parallax_disp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
textures/photothumb.db Normal file

Binary file not shown.

BIN
textures/stargate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB