int main() { //////////////////////////////////////////BASICS/////////////////////////////////////////// srand(time(NULL)); glfwInit(); //WINDOW Window window(50, 50, 800, 600, "ParticleSystem"); glfwMakeContextCurrent(window.getWindow()); //CAM cam.setPosition(glm::vec4(-15.0, 0.0, 7.0, 1.0)); cam.setNearFar(0.1f, 100.0f); cam.setLookAt(glm::vec3(cam.getPosition().x, cam.getPosition().y, cam.getPosition().z - 1.0)); cam.setKeySpeed(8.0); iH.setAllInputMaps(cam); iH.changeActiveInputMap("Pilotview"); //Callback glfwSetKeyCallback(window.getWindow(), key_callback); //More then just 60 fps, vsync off glfwSwapInterval(0); glewInit(); //SHADER VertexShader vsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.vert"))); FragmentShader fsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.frag"))); ShaderProgram shaderSkybox(vsSkybox, fsSkybox); VertexShader vsObject(loadShaderSource(SHADERS_PATH + std::string("/TextureShader3D/TextureShader3D.vert"))); FragmentShader fsObject(loadShaderSource(SHADERS_PATH + std::string("/TextureShader3D/TextureShader3D.frag"))); ShaderProgram shaderObject(vsObject, fsObject); /////////////////////////////////////////TEXTURES////////////////////////////////////////// //COMIC CLOUD Texture* comicBalloonTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/balloon01.png"); Texture* comicBalloonTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/balloon02.png"); Texture* comicBalloonTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/balloon03.png"); Texture* comicBalloonTex4 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/balloon04.png"); Texture* comicCloudTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/cloud01.png"); Texture* comicCloudTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/cloud02.png"); Texture* comicCloudTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/cloud03.png"); Texture* comicCloudTex4 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/cloud04.png"); Texture* comicExclamationMarkTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/exclamationMark01.png"); Texture* comicExclamationMarkTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/exclamationMark02.png"); Texture* comicExclamationMarkTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/exclamationMark03.png"); Texture* comicExclamationMarkTex4 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/exclamationMark04.png"); Texture* comicLightningTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/lightning01.png"); Texture* comicLightningTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/lightning02.png"); Texture* comicLightningTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/lightning03.png"); Texture* comicLightningTex4 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/lightning04.png"); Texture* comicSpiralTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/spiral01.png"); Texture* comicSpiralTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/spiral02.png"); Texture* comicSpiralTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/spiral03.png"); Texture* comicSpiralTex4 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/spiral04.png"); Texture* comicSpiralTex5 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/spiral05.png"); Texture* comicSpiralTex6 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/spiral06.png"); Texture* comicStarTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/star01.png"); Texture* comicStarTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/comicCloud/star02.png"); //FIRE Texture* fireTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/fire/flame01_L.png"); Texture* fireTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/fire/flame02_L.png"); Texture* fireTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/fire/flame03_L.png"); //PARTICLE Texture* particleBlackTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/virus.png"); Texture* particleWhiteTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/particle.png"); Texture* snowTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/snowflake.png"); //TODO better Resolution Texture* glowwormTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/glowworm.png"); Texture* energyTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/energy.png"); Texture* fireflyTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/firefly.png"); Texture* fireSparkTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/sparkOrange.png"); Texture* fireSparkTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/particle/sparkRed.png"); //RAIN Texture* rainTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/rain/rain.png"); //TODO darker //SMOKE Texture* drawSmokeTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeDraw/smoke01_L.png"); Texture* drawSmokeTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeDraw/smoke02_L.png"); Texture* drawSmokeTex3 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeDraw/smoke03_L.png"); Texture* drawSmokeTex4 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeDraw/smoke04_L.png"); Texture* smokeWhiteTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeWhite/smokeWhite01.png"); Texture* smokeWhiteTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeWhite/smokeWhite02.png"); Texture* smokeBlackTex1 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeBlack/smokeBlack01.png"); Texture* smokeBlackTex2 = new Texture((char*)RESOURCES_PATH "/ParticleSystem/smoke/smokeBlack/smokeBlack02.png"); //STAR Texture* fireWorkYellowTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/star/starYellow.png"); //TODO Work? Texture* fireWorkOrangeTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/star/starPink.png"); //TODO Work? Texture* fireWorkRedTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/star/starRed.png"); //TODO Work? Texture* fireWorkBlueTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/star/starBlue.png"); //TODO Work? Texture* fireWorkGreenTex = new Texture((char*)RESOURCES_PATH "/ParticleSystem/star/starGreen.png"); //TODO Work? ///////////////////////////////////////FINAL EMITTER/////////////////////////////////////// //FINAL EMITTER SNOW Emitter* snow = new Emitter(0, glm::vec3(0.0, 5.0, 0.0), 0.0, 0.166, 100, 30.0, true); snow->setVelocity(0); snow->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, 1.0), 0.5f); snow->setAreaEmitting(false,true, 10.0, 10000); snow->addTexture(snowTex, 0.0); snow->defineLook(true, 0.04, 2.0); particleCount += (100 * 30 / 0.166); //FINAL EMITTER STRONG SNOW Emitter* snowStrong = new Emitter(0, glm::vec3(-3.5, 4.0, 0.0), 0.0, 0.166, 100, 15.0, true); snowStrong->setVelocity(2); snowStrong->usePhysicDirectionGravity(glm::vec4(0.6, -1.5, 0.0, 1.0), 2.6f); snowStrong->setAreaEmitting(false, true, 8.0, 10000); snowStrong->addTexture(snowTex, 0.0); snowStrong->defineLook(true, 0.03, 1.0, 3.0); particleCount += (100 * 15.0 / 0.166); //FINAL EMITTER WHITE SMOKE Emitter* smokeWhite = new Emitter(0, glm::vec3(3.0, -1.0, 1.0), 0.0, 0.4, 1, 8.0, true); smokeWhite->setVelocity(2); smokeWhite->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.8), 0.3f); smokeWhite->addTexture(smokeWhiteTex1, 1.0); smokeWhite->addTexture(smokeWhiteTex2, 0.25); std::vector<float> smokeWhiteSize{ 0.05f, 0.5f, 0.75f, 1.2f }; std::vector<float> smokeWhiteTime{ 0.0f, 0.4f, 0.75f, 1.0f }; smokeWhite->defineLook(true, smokeWhiteSize, smokeWhiteTime, 1.0, 4.0, 3.0, false, 0.3); smokeWhite->switchToGeometryShader(); particleCount += (1 * 8.0 / 0.4); //FINAL EMITTER BLACK SMOKE Emitter* smokeBlack = new Emitter(0, glm::vec3(6.0, -1.0, 1.0), 0.0, 0.6, 1, 8.0, true); smokeBlack->setVelocity(2); smokeBlack->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.8), 0.3f); smokeBlack->addTexture(smokeBlackTex1, 1.0); smokeBlack->addTexture(smokeBlackTex2, 0.2); std::vector<float> smokeBlackSize{ 0.1f, 0.4f, 0.8f, 1.2f }; std::vector<float> smokeBlackTime{ 0.0f, 0.2f, 0.75f, 1.0f }; smokeBlack->defineLook(true, smokeBlackSize, smokeBlackTime, 1.0, 5.0, 3.0, false, 0.3); smokeBlack->switchToGeometryShader(); particleCount += (1 * 8 / 0.4); //FINAL EMITTER CLOUD SMOKE Emitter* smokeCloud = new Emitter(0, glm::vec3(15.0, -1.0, 1.0), 0.0, 0.3, 1, 10.0, true); smokeCloud->setVelocity(3); smokeCloud->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.1), 0.15f); smokeCloud->addTexture(smokeWhiteTex1, 1.0); smokeCloud->addTexture(smokeWhiteTex2, 0.08); std::vector<float> smokeCloudSize{ 0.1f, 0.4f, 0.8f, 1.2f }; std::vector<float> smokeCloudTime{ 0.0f, 0.2f, 0.75f, 1.0f }; smokeCloud->defineLook(true, smokeBlackSize, smokeBlackTime, 1.0, 2.0, 4.0, false, 0.3); smokeCloud->switchToGeometryShader(); particleCount += (1 * 10.0 / 0.3); //FINAL EMITTER RAIN Emitter* rain = new Emitter(0, glm::vec3(0.0, 3.0, 0.0), 0.0, 0.02, 50, 5.0, true); rain->setVelocity(0); rain->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, 1.0), 5.0f); rain->setAreaEmitting(false, true, 8.0, 10000); rain->addTexture(rainTex, 0.0); rain->defineLook(true, 0.03, 1.0, 0.0); particleCount += (50 * 5.0 / 0.02); //FINAL EMITTER FONTAINE Emitter* fontaine = new Emitter(0, glm::vec3(-15.0,-1.0, 1.0), 0.0, 0.05, 5, 2.0, true); fontaine->setVelocity(0); fontaine->usePhysicTrajectory(glm::vec4(0.0, 0.0, 0.0, 1.0), 1.0); //fontaine->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.0), 0.7f); fontaine->defineLook(false, 0.3, 0.0, 0.5, 0.0, true, 1.0); particleCount += (3 * 2.0 / 0.05); //FINAL EMITTER CIRCLE Emitter* circle = new Emitter(0, glm::vec3(-18.0, 0.0, 1.0), 0.0, 0.2, 50, 4.0, true); circle->setVelocity(4); circle->addTexture(fireSparkTex1, 1.0); circle->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.0), 0.3f); circle->addTexture(fireSparkTex2 ,0.1); circle->defineLook(true, 0.03, 0.0, 2.0, 1.0, true, 0.0); circle->switchToGeometryShader(); particleCount += (50 * 4.0 / 0.4); //FINAL EMITTER QUAD Emitter* quad = new Emitter(0, glm::vec3(-21.0, 0.0, 1.0), 0.0, 1.0, 100, 1.0, true); quad->setVelocity(0); quad->setAreaEmitting(true, true, 0.5, 1); quad->defineLook(false, 0.1, 0.0, 0.0, 0.0, false, 0.0); particleCount += (50 * 1.0 / 1.0); //FINAL EMITTER FRUITFLIES Emitter* fruitFlies = new Emitter(0, glm::vec3(11.5, 0.0, 1.0), 0.0, 0.166, 2, 10.0, true); fruitFlies->setVelocity(0); fruitFlies->usePhysicSwarmCircleMotion(true, true, true, 3.0); fruitFlies->setAreaEmitting(true, true, 0.5, 100); fruitFlies->addTexture(particleBlackTex, 0.0); fruitFlies->defineLook(true, 0.012, 3.0, 3.0, 0.0, true, 1.0); fruitFlies->switchToGeometryShader(); particleCount += (2 * 10.0 / 0.166); //FINAL SCREEN EMITTER FRUITFLIES Emitter* screenFruitFlies = new Emitter(0, glm::vec3(-0.2, 0.2, 7.0), 0.0, 0.1, 2, 10.0, true); screenFruitFlies->setVelocity(0); screenFruitFlies->usePhysicSwarmCircleMotion(true, true, true, 3.0); screenFruitFlies->setAreaEmitting(true, false, 2.5, 1000); screenFruitFlies->addTexture(particleBlackTex, 0.0); screenFruitFlies->defineLook(true, 0.02, 1.0, 3.0, 0.0, true, 1.0); screenFruitFlies->switchToGeometryShader(); particleCount += (3 * 10.0 / 0.166); //FINAL EMITTER GLOWWORM Emitter* glowworm = new Emitter(0, glm::vec3(-3.0, 0.0, 1.0), 0.0, 0.2, 1, 10.0, true); glowworm->setVelocity(0); glowworm->usePhysicSwarmCircleMotion(true, true, true, 3.0); glowworm->setAreaEmitting(true, false, 0.4, 1000); glowworm->addTexture(glowwormTex, 0.0); glowworm->defineLook(true, 0.1, 1.0, 1.5); particleCount += (1 * 10.0 / 0.2); //FINAL EMITTER ENERGYBALL Emitter* energyBall = new Emitter(0, glm::vec3(-12.0, -1.0, 1.0), 0.0, 0.01, 5, 15.0, true); energyBall->setVelocity(5); energyBall->usePhysicPointGravity(glm::vec4(-10.0, 1.0, 1.0, 3.0), 8.0, 2, 1.8); energyBall->addTexture(energyTex, 1.0); energyBall->defineLook(true, 0.04); particleCount += (5 * 15.0 / 0.01); //FINAL EMITTER COMIC CLOUD Emitter* cloud01 = new Emitter(0, glm::vec3(-6.0, 0.5, 1.0), 0.0, 1.6, 1, 10.0, true); cloud01->setVelocity(4); cloud01->usePhysicPointGravity(glm::vec4(0.0, -1.0, 0.0, -0.0), 0.0, 0, 0.72); cloud01->addTexture(comicCloudTex1, 0.0); std::vector<float> cloudSize1{ 0.8f, 1.6f }; std::vector<float> cloudTime1{ 0.0f, 1.0f }; cloud01->defineLook(true, cloudSize1, cloudTime1, 0.4, 4.0, 0.0, false, 0.3); cloud01->switchToGeometryShader(); particleCount += (1 * 1.5 / 10.0); Emitter* cloud02 = new Emitter(0, glm::vec3(-6.0, 0.5, 1.0), 0.0, 2.3, 1, 10.0, true); cloud02->setVelocity(4); cloud02->usePhysicPointGravity(glm::vec4(0.0, -1.0, 0.0, -0.0), 0.0, 0, 0.6); cloud02->addTexture(comicCloudTex3, 0.0); std::vector<float> cloudSize2{ 0.8f, 1.6f }; std::vector<float> cloudTime2{ 0.0f, 1.0f }; cloud02->defineLook(true, cloudSize2, cloudTime2, 0.4, 4.0, 0.0, false, 0.3); cloud02->switchToGeometryShader(); particleCount += (1 * 2.1 / 10.0); Emitter* cloud03 = new Emitter(0, glm::vec3(-7.0, 1.0, 1.0), 0.0, 0.0, 1, 0.0, false); cloud03->setVelocity(0); cloud03->addTexture(comicBalloonTex4, 1.0); cloud03->defineLook(true, 0.8, 2.0); cloud03->switchToGeometryShader(); particleCount += 1; Emitter* cloud04 = new Emitter(0, glm::vec3(-4.8, 2.0, 1.0), 0.0, 0.0, 1, 0.0, false); cloud04->setVelocity(0); cloud04->addTexture(comicStarTex2, 1.0); cloud04->defineLook(true, 0.3, 2.0, 0.0, 0.0, false, 0.6); cloud04->switchToGeometryShader(); particleCount += 1; Emitter* cloud05 = new Emitter(0, glm::vec3(-7.0, -1.0, 1.0), 0.0, 0.0, 1, 0.0, false); cloud05->setVelocity(0); cloud05->addTexture(comicStarTex2, 1.0); cloud05->defineLook(true, 0.5, 2.0, 0.0, 0.0, true, 0.4); cloud05->switchToGeometryShader(); particleCount += 1; Emitter* cloud06 = new Emitter(0, glm::vec3(-4.3, 0.2, 1.0), 0.0, 0.0, 1, 0.0, false); cloud06->setVelocity(0); cloud06->addTexture(comicSpiralTex5, 1.0); cloud06->defineLook(true, 0.3, 2.0); cloud06->switchToGeometryShader(); particleCount += 1; Emitter* cloud07 = new Emitter(0, glm::vec3(-8.0, 0.7, 1.0), 0.0, 0.0, 1, 0.0, false); cloud07->setVelocity(0); cloud07->addTexture(comicSpiralTex3, 1.0); cloud07->defineLook(true, 0.3, 2.0); cloud07->switchToGeometryShader(); particleCount += 1; Emitter* cloud08 = new Emitter(0, glm::vec3(-7.9, 2.1, 1.0), 0.0, 0.0, 1, 0.0, false); cloud08->setVelocity(0); cloud08->addTexture(comicLightningTex1, 1.0); cloud08->defineLook(true, 0.6, 2.0); cloud08->switchToGeometryShader(); particleCount += 1; Emitter* cloud09 = new Emitter(0, glm::vec3(-4.0, 1.4, 1.0), 0.0, 0.0, 1, 0.0, false); cloud09->setVelocity(0); cloud09->addTexture(comicLightningTex4, 1.0); cloud09->defineLook(true, 0.5, 2.0); cloud09->switchToGeometryShader(); particleCount += 1; Emitter* cloud10 = new Emitter(0, glm::vec3(-3.7, 0.8, 1.0), 0.0, 0.0, 1, 0.0, false); cloud10->setVelocity(0); cloud10->addTexture(comicExclamationMarkTex3, 1.0); cloud10->defineLook(true, 0.3, 2.0); cloud10->switchToGeometryShader(); particleCount += 1; Emitter* cloud11 = new Emitter(0, glm::vec3(-6.5, 2.4, 1.0), 0.0, 0.0, 1, 0.0, false); cloud11->setVelocity(0); cloud11->addTexture(comicExclamationMarkTex2, 1.0); cloud11->defineLook(true, 0.5, 2.0); cloud11->switchToGeometryShader(); particleCount += 1; ////////////////////////////////NOT FINAL EMITTER//////////////////////////////// //FINAL EMITTER MAXIMUM; SET POSITION Emitter* maximumParticle = new Emitter(0, glm::vec3(-21.0, -3.0, 0.0), 0.0, 0.2, 5000, 12.0, true); maximumParticle->setVelocity(3); maximumParticle->usePhysicDirectionGravity(glm::vec4(0.0, 1.0, 0.0, 0.2), 0.5); maximumParticle->defineLook(false, 0.01); int particleCountMax = 5000 * 12 / 0.2; //particleMax with Texture //!EMITTER FIRE Emitter* fireMiddle = new Emitter(0, glm::vec3(9.0, 0.0, 1.0), 0.0, 1.0, 3.0, 4.0, true); fireMiddle->setVelocity(3); fireMiddle->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.5), 0.2); fireMiddle->addTexture(fireTex1, 1.0); //fireMiddle->addTexture(fireTex2, 0.5); fireMiddle->addTexture(fireTex3, 0.0); fireMiddle->defineLook(true, 0.5, 1.0, 2.0); fireMiddle->switchToGeometryShader(); Emitter* fireSmoke = new Emitter(0, glm::vec3(9.0, -1.0, 1.0), 0.0, 0.4, 1, 8.0, true); fireSmoke->setVelocity(2); fireSmoke->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -0.8), 0.3f); fireSmoke->addTexture(smokeBlackTex1, 1.0); fireSmoke->addTexture(smokeBlackTex2, 0.08); std::vector<float> fireSmokeSize{ 0.1f, 0.4f, 0.8f, 1.2f }; std::vector<float> fireSmokeTime{ 0.0f, 0.2f, 0.75f, 1.0f }; fireSmoke->defineLook(true, fireSmokeSize, fireSmokeTime, 1.0, 4.0, 1.0, false, 0.3); fireSmoke->switchToGeometryShader(); Emitter* firefly = new Emitter(0, glm::vec3(9.1, -0.9, 1.0), 0.0, 1.3, 1, 9.0, true); firefly->setVelocity(3); firefly->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -1.5), 0.13f); firefly->addTexture(fireflyTex, 1.0); firefly->defineLook(true, 0.04, 2.0, 2.0, 0.0, false, 0.3); Emitter* fireSparkOrange = new Emitter(0, glm::vec3(9.1, -0.9, 1.0), 0.0, 0.1, 1, 0.8, true); fireSparkOrange->setVelocity(3); fireSparkOrange->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -1.0), 1.5f); fireSparkOrange->addTexture(fireSparkTex1, 1.0); fireSparkOrange->defineLook(true, 0.02, 0.4, 0.3, 0.0, false, 0.3); Emitter* fireSparkRed = new Emitter(0, glm::vec3(9.1, -0.9, 1.0), 0.0, 0.1, 1, 1.0, true); fireSparkRed->setVelocity(3); fireSparkRed->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, -1.5), 1.5f); fireSparkRed->addTexture(fireSparkTex2, 1.0); fireSparkRed->defineLook(true, 0.02, 0.4, 0.3, 0.0, false, 0.3); //!EMITTER FIREWORK Emitter* firework = new Emitter(0, glm::vec3(0.6, 0.6, 0.0), 0.0, 0.5, 5, 1.0, true); firework->setVelocity(4); firework->usePhysicDirectionGravity(glm::vec4(0.0,-1.0,0.0,0.1), 1.0f); //firework->addTexture(*fireWorkYellowTex, 0.0); //firework->defineLook(true, 0.8, 0.1, 0.2); Emitter* firework2 = new Emitter(0, glm::vec3(-0.6, -0.6, 0.0), 0.0, 0.5, 5, 1.0, true); firework2->setVelocity(4); firework2->usePhysicDirectionGravity(glm::vec4(0.0, -1.0, 0.0, 0.1), 1.0f); //firework2->addTexture(*fireWorkOrangeTex, 0.0); //firework2->defineLook(true, 0.8, 0.1, 0.2); //////////////////////////////////////OUR SCENE/////////////////////////////////////////////// //SKYBOX Cube cube; const char *textureNames[6] = { /*(char*)RESOURCES_PATH "/PereaBeach1/posx.jpg", (char*)RESOURCES_PATH "/PereaBeach1/negx.jpg", (char*)RESOURCES_PATH "/PereaBeach1/posy.jpg", (char*)RESOURCES_PATH "/PereaBeach1/negy.jpg", (char*)RESOURCES_PATH "/PereaBeach1/posz.jpg", (char*)RESOURCES_PATH "/PereaBeach1/negz.jpg"*/ (char*)RESOURCES_PATH "/Color/testTex.png", (char*)RESOURCES_PATH "/Color/testTex.png", (char*)RESOURCES_PATH "/Color/testTex.png", (char*)RESOURCES_PATH "/Color/testTex.png", (char*)RESOURCES_PATH "/Color/testTex.png", (char*)RESOURCES_PATH "/Color/testTex.png" }; Skybox skybox(textureNames); Node skyboxNode("skybox"); skyboxNode.addGeometry(&cube); //OBJECTS Teapot teapot; teapot.loadBufferData(); Sphere sphere; sphere.loadBufferData(); Rect plane; plane.loadBufferData(); //TEXTURES Texture chrome((char*)RESOURCES_PATH "/Metal/chrome.jpg"); Texture marble((char*)RESOURCES_PATH "/Wall/seamless_marble.png"); //TODO JPG Texture cvLogo((char*)RESOURCES_PATH "/Symbol/cv_logo.bmp"); Texture bricks((char*)RESOURCES_PATH "/Wall/brick.bmp"); //CREATING NODES Level testLevel("testLevel"); Scene testScene("testScene"); testLevel.addScene(&testScene); testLevel.changeScene("testScene"); Node cube1("cube1"); cube1.addGeometry(&cube); cube1.addTexture(&chrome); cube1.setModelMatrix(glm::translate(cube1.getModelMatrix(), glm::vec3(-0.3, 0.25, 0.4))); cube1.setModelMatrix(glm::scale(cube1.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3))); Node cube2("cube2"); cube2.addGeometry(&cube); cube2.addTexture(&chrome); cube2.setModelMatrix(glm::translate(cube2.getModelMatrix(), glm::vec3(0.7, 0.25, 0.4))); cube2.setModelMatrix(glm::scale(cube2.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3))); Node wallNode1("wall1"); wallNode1.addGeometry(&plane); wallNode1.addTexture(&marble); wallNode1.setModelMatrix(glm::translate(wallNode1.getModelMatrix(), glm::vec3(0.0, -1.0, 0.0))); wallNode1.setModelMatrix(glm::rotate(wallNode1.getModelMatrix(), 90.0f, glm::vec3(1.0, 0.0, 0.0))); wallNode1.setModelMatrix(glm::scale(wallNode1.getModelMatrix(), glm::vec3(25.0, 2.0, 1.0))); Node wallNode2("wall2"); wallNode2.addGeometry(&plane); wallNode2.addTexture(&bricks); wallNode2.setModelMatrix(glm::translate(wallNode2.getModelMatrix(), glm::vec3(0.0, 0.0, 0.0))); wallNode2.setModelMatrix(glm::scale(wallNode2.getModelMatrix(), glm::vec3(25.0, 2.5, 1.0))); Node teaNode("teaNode"); teaNode.addGeometry(&teapot); teaNode.addTexture(&cvLogo); teaNode.setModelMatrix(glm::translate(teaNode.getModelMatrix(), glm::vec3(0.2, 0.3, 1.0))); teaNode.setModelMatrix(glm::scale(teaNode.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3))); //CREATING A SCENEGRAPH testScene.getScenegraph()->getRootNode()->addChildrenNode(&wallNode1); testScene.getScenegraph()->getRootNode()->addChildrenNode(&wallNode2); testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube1); testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube2); testScene.getScenegraph()->getRootNode()->addChildrenNode(&teaNode); //ADD CAMERA TO SCENEGRAPH testScene.getScenegraph()->addCamera(&cam); testScene.getScenegraph()->getCamera("Pilotview"); testScene.getScenegraph()->setActiveCamera("Pilotview"); //GUI initGUI(); double startCamTime = glfwGetTime(); int outputFrames = 0; float dTime; while (!glfwWindowShouldClose(window.getWindow())) { //CAM dTime = glfwGetTime() - startCamTime; cam.setSensitivity(dTime); startCamTime = glfwGetTime(); //Maximum Particle if (!useMaximumParticle->isActive()){ //SKYBOX glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shaderSkybox.bind(); glDisable(GL_DEPTH_TEST); shaderSkybox.sendMat4("viewMatrix", cam.getViewMatrix()); shaderSkybox.sendMat4("projectionMatrix", cam.getProjectionMatrix()); shaderSkybox.sendSkyboxTexture("testTexture", skybox.getSkyboxTexture()); //skyboxNode.render(); shaderSkybox.unbind(); glEnable(GL_DEPTH_TEST); shaderObject.bind(); shaderObject.sendMat4("viewMatrix", cam.getViewMatrix()); shaderObject.sendMat4("projectionMatrix", cam.getProjectionMatrix()); shaderObject.sendInt("useTexture", 1); teaNode.setModelMatrix(glm::rotate(teaNode.getModelMatrix(), 3.0f, glm::vec3(0.0, 1.0, 0.0))); cube1.setModelMatrix(glm::rotate(cube1.getModelMatrix(), 3.0f, glm::vec3(0.0, 1.0, 0.0))); cube2.setModelMatrix(glm::rotate(cube2.getModelMatrix(), 3.0f, glm::vec3(0.0, 1.0, 0.0))); //testScene.render(shaderObject); shaderObject.unbind(); ///////////////////////////////////////FINAL EMITTER/////////////////////////////////////// glDisable(GL_DEPTH_TEST); //smokeWhite->update(); //smokeWhite->render(cam); //smokeBlack->update(); //smokeBlack->render(cam); fontaine->update(); fontaine->render(cam); //circle->update(); //circle->render(cam); //quad->update(); //quad->render(cam); //glowworm->update(); //glowworm->render(cam); //fruitFlies->update(); //fruitFlies->render(cam); //energyBall->update(); //energyBall->render(cam); //cloud01->update(); //cloud01->render(cam); //cloud02->update(); //cloud02->render(cam); //cloud03->update(); //cloud03->render(cam); //cloud04->update(); //cloud04->render(cam); //cloud05->update(); //cloud05->render(cam); //cloud06->update(); //cloud06->render(cam); //cloud07->update(); //cloud07->render(cam); //cloud08->update(); //cloud08->render(cam); //cloud09->update(); //cloud09->render(cam); //cloud10->update(); //cloud10->render(cam); //cloud11->update(); //cloud11->render(cam); } ////////////////////////////////FINAL SCREEN EMITTER////////////////////////////////////////////////// else{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); maximumParticle->update(); maximumParticle->render(cam); particleCount = particleCountMax; } if (useFruitFliesButton->isActive()){ screenFruitFlies->update(); screenFruitFlies->render(screen); } else{ screenFruitFlies->startTime(); } ////////////////////////////////FINAL GUI EMITTER/////////////////////////////////////////// if (useSnowButton->isActive()){ snow->update(glm::vec3(cam.getPosition())); snow->render(cam); } else{ snow->startTime(); } if (useStrongSnowButton->isActive()){ snowStrong->update(glm::vec3(cam.getPosition())); snowStrong->render(cam); } else{ snowStrong->startTime(); } if (useRainButton->isActive()){ rain->update(glm::vec3(cam.getPosition())); rain->render(cam); }{ rain->startTime(); } ////////////////////////////////WAITING FOR TEXTURES EMITTER//////////////////////////////// //todo: flamme //fireMiddle->update(); //fireMiddle->render(cam); //fireSmoke->update(); //fireSmoke->render(cam); //firefly->update(); //firefly->render(cam); //fireSparkOrange->update(); //fireSparkOrange->render(cam); //fireSparkRed->update(); //fireSparkRed->render(cam); // todo all //firework->update(); //firework->render(cam); //smokeCloud //smokeCloud->update(); //smokeCloud->render(cam); ////////////////////////////////BASICS/////////////////////////////////////////////////////// //renderer->renderGUI(*gui, window); //WINDOW window.swapAndPoll(); //FPS if (!(outputFrames % 30)){ outputFrames = 1; //std::cout << "FPS: " << static_cast<int> (1 / dTime) << "; Up to " << particleCount << " particles"<<std::endl; } outputFrames++; } glfwDestroyWindow(window.getWindow()); glfwTerminate(); return 0; }
//===================================================================// //==================Main Method=====================================// //==================================================================// int main() { //===================================================================// //==================Things you need to start with====================// //==================================================================// glfwInit(); Window testWindow(500, 50, 800, 600, "Demo"); glfwMakeContextCurrent(testWindow.getWindow()); // Callback glfwSetKeyCallback(testWindow.getWindow(), key_callback); cam.setKeySpeed(2.0); cam.setNearFar(0.01, 100); glewInit(); OpenGL3Context context; //renderer = new Renderer(context); Renderer renderer(context); //===================================================================// //==================Shaders for your program========================// //==================================================================// VertexShader vs(loadShaderSource(SHADERS_PATH + std::string("/Vertex-Shaders/TextureShader3D.vert"))); FragmentShader fs(loadShaderSource(SHADERS_PATH + std::string("/Fragment-Shaders/TextureShader3D.frag"))); ShaderProgram shader(vs, fs); VertexShader vsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.vert"))); FragmentShader fsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.frag"))); ShaderProgram shaderGBuffer(vsGBuffer, fsGBuffer); VertexShader vsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.vert"))); FragmentShader fsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.frag"))); ShaderProgram shaderSFQ(vsSfq, fsSfq); VertexShader vsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.vert"))); FragmentShader fsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.frag"))); ShaderProgram shaderSkybox(vsSkybox, fsSkybox); FBO fboGBuffer(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false); SoundFileHandler sfh = SoundFileHandler(1000); Rect screenFillingQuad; screenFillingQuad.loadBufferData(); //===================================================================// //==================Object declarations - Geometry, Texture, Node=== // //==========================Object: Terrain===========================// StaticObject terrainObject; terrainObject.setClassType(ClassType::TERRAIN); Texture terrainTex((char*)RESOURCES_PATH "/Grass2.jpg"); Terrain terrain2((char*)RESOURCES_PATH "/heightmap.jpg", 0.0f, 0.0f); Node terrainNode2("Terrain"); terrainNode2.addGeometry(&terrain2); terrainNode2.addTexture(&terrainTex); terrainNode2.setObject(&terrainObject); //===================================================================// //==================Object declarations - Geometry, Texture, Node=== // //==========================Object: Player===========================// Texture texCV((char*)RESOURCES_PATH "/cv_logo.bmp"); GekoMesh gekoMesh; geko.setExp(0.0); geko.setLevelThreshold(100.0); geko.setLevel(0); Node playerNode("Player"); playerNode.addGeometry(&gekoMesh); playerNode.setObject(&geko); playerNode.addTexture(&texCV); sfh.generateSource(glm::vec3(geko.getPosition()), RESOURCES_PATH "/Sound/Rascheln.wav"); geko.setSoundHandler(&sfh); geko.setSourceName(MOVESOUND, "SpielerFootsteps", RESOURCES_PATH "/Sound/Rascheln.wav"); //geko.setSourceName(BACKGROUNDMUSIC, "Hintergrund", RESOURCES_PATH "/Sound/jingle2.wav"); geko.setSourceName(FIGHTSOUND, "Kampfsound", RESOURCES_PATH "/Sound/punch.wav"); geko.setSourceName(EATSOUND, "Essen", RESOURCES_PATH "/Sound/Munching.wav"); geko.setSourceName(QUESTSOUND, "Quest", RESOURCES_PATH "/Sound/jingle.wav"); geko.setSourceName(ITEMSOUND, "Item", RESOURCES_PATH "/Sound/itempickup.wav"); geko.setSourceName(FIRESOUND, "Fire", RESOURCES_PATH "/Sound/Feuer_kurz.wav"); sfh.disableLooping("Essen"); sfh.disableLooping("Quest"); sfh.disableLooping("Item"); geko.setPosition(glm::vec4(terrain2.getResolutionX() / 2.0f, 10.0f, terrain2.getResolutionY() / 2.0f, 1.0)); //sfh.generateSource("Feuer",posFood, RESOURCES_PATH "/Sound/Feuer kurz.wav"); playerNode.setCamera(&cam); //===================================================================// //==================Setting up the Level and Scene==================// //==================================================================// Level testLevel("testLevel"); Scene testScene("testScene"); testLevel.addScene(&testScene); testLevel.changeScene("testScene"); testLevel.setTerrain(&terrain2); //==================Add Camera to Scene============================// testScene.getScenegraph()->addCamera(&cam); testScene.getScenegraph()->setActiveCamera("PlayerViewCam"); //==================Set Input-Maps and activate one================// iH.setAllInputMaps(*(testScene.getScenegraph()->getActiveCamera())); iH.changeActiveInputMap(MapType::OBJECT); iH.getActiveInputMap()->update(geko); //==================Add Objects to the Scene=======================// //==================Update the Bounding-Sphere 1st time============// /*Node translateNode("Translate"); translateNode.addTranslation(glm::vec3(terrain2.getResolutionX() / 2.0f, 0.0, terrain2.getResolutionY() / 2.0f));*/ testScene.getScenegraph()->getRootNode()->addChildrenNode(&terrainNode2); testScene.getScenegraph()->getRootNode()->addChildrenNode(&playerNode); //testScene.getScenegraph()->getRootNode()->addChildrenNode(&translateNode); //testScene.getScenegraph()->getRootNode()->getChildrenNode("Translate")->addChildrenNode(&playerNode); //===================================================================// //==================Setting up the Observers========================// //==================================================================// ObjectObserver playerObserver(&testLevel); SoundObserver soundPlayerObserver(&testLevel); geko.addObserver(&playerObserver); geko.addObserver(&soundPlayerObserver); // ============================================================== // == Object (Forest) ========================================== // ============================================================== TreeMesh tree; glm::vec3 tmp; std::stringstream name; for (int i = 0; i<TreeData::forest1.size(); i++) { name << "Forest1Tree" << i; std::string stringname = name.str(); StaticObject *treeStatic = new StaticObject(); treeStatic->setTree(50 / TreeData::forest1.size()); Node *treeNode = new Node(stringname); treeNode->addGeometry(&tree); treeNode->setObject(treeStatic); tmp.x = TreeData::forest1[i].x; tmp.z = TreeData::forest1[i].z; tmp.y = terrain2.getHeight(glm::vec2(tmp.x, tmp.z)); treeNode->addTranslation(tmp); treeNode->getBoundingSphere()->radius = 2.5; testScene.getScenegraph()->getRootNode()->addChildrenNode(treeNode); name.str(""); } for (int i = 0; i<TreeData::forest2.size(); i++) { name << "Forest2Tree" << i; std::string stringname = name.str(); StaticObject *treeStatic = new StaticObject(); treeStatic->setTree(50 / TreeData::forest2.size()); Node *treeNode = new Node(stringname); treeNode->addGeometry(&tree); treeNode->setObject(treeStatic); tmp.x = TreeData::forest2[i].x; tmp.z = TreeData::forest2[i].z; tmp.y = terrain2.getHeight(glm::vec2(tmp.x, tmp.z)); treeNode->addTranslation(tmp); treeNode->getBoundingSphere()->radius = 2.5; testScene.getScenegraph()->getRootNode()->addChildrenNode(treeNode); name.str(""); } // ============================================================== // == Object (Anthome) ========================================== // ============================================================== glm::vec3 posFood(10.0, 0.0, -5.0); glm::vec3 posFood2((terrain2.getResolutionX() / 2.0f) + 10.0, 0.0, (terrain2.getResolutionY() / 2.0f) - 5.0); glm::vec3 posSpawn(terrain2.getResolutionX() / 2.0f, 10.0, terrain2.getResolutionY() / 2.0f); glm::vec3 posDefaultPlayer(0.0, 0.0, 0.0); AntMesh antMesh; DecisionTree *aggressivedecisionTree = new DecisionTree(); aggressivedecisionTree->setAntTreeAggressiv(); DecisionTree *afraidDecisionTree = new DecisionTree(); afraidDecisionTree->setAntTreeAfraid(); Graph<AStarNode, AStarAlgorithm>* antAggressiveGraph = new Graph<AStarNode, AStarAlgorithm>(); antAggressiveGraph->setExampleAntAggressiv(posSpawn, posFood2, posDefaultPlayer); Graph<AStarNode, AStarAlgorithm>* antAfraidGraph = new Graph<AStarNode, AStarAlgorithm>(); antAfraidGraph->setExampleAntAfraid2(posSpawn, posDefaultPlayer); AntHome antHome(posSpawn, antMesh, &playerObserver, &texCV, &texCV, aggressivedecisionTree, antAggressiveGraph, afraidDecisionTree, antAfraidGraph); //antHome.generateGuards(5, &aiObserver, testScene.getScenegraph()->getRootNode()); antHome.generateWorkers(5, testScene.getScenegraph()->getRootNode()); /*antHome.addAntsToSceneGraph(testScene.getScenegraph()->getRootNode());*/ //===================================================================// //==================Setting up the Collision=========================// //==================================================================// CollisionTest collision; collision.collectNodes(testScene.getScenegraph()->getRootNode()); CollisionObserver colObserver(&testLevel); collision.addObserver(&colObserver); collision.addObserver(&soundPlayerObserver); GravityObserver gravityObserver(&testLevel); collision.addObserver(&gravityObserver); //===================================================================// //==================Setting up the Gravity===========================// //==================================================================// Gravity gravity; playerNode.addGravity(&gravity); //===================================================================// //==================Setting up the Gravity===========================// //==================================================================// PlayerGUI playerGUI(HUD_WIDTH, HUD_HEIGHT, WINDOW_HEIGHT, WINDOW_WIDTH, QUEST_HEIGHT, QUEST_WIDTH, playerNode.getPlayer()); //===================================================================// //==================The Render-Loop==================================// //==================================================================// float lastTime = glfwGetTime(); sfh.playSource("Hintergrund"); sfh.setGain("Hintergrund", 0.5f); //TODO adjust the Rotation,to match the Terrain glm::vec4 tmpPos; glm::vec3 normalFromTerrain; glm::vec3 rotateAxis; glm::vec4 viewDirFromPlayer; glm::vec3 up(0.0, 1.0, 0.0); float lengthFromNormal; float lengthFromUp; float phi; while (!glfwWindowShouldClose(testWindow.getWindow())) { float currentTime = glfwGetTime(); float deltaTime = currentTime - lastTime; lastTime = currentTime; //===================================================================// //==================Update your Objects per Frame here =============// //==================================================================// collision.update(); //===================================================================// //==================Input and update for the Player==================// //==================================================================// geko.update(); geko.setDeltaTime(currentTime); tmpPos = testScene.getScenegraph()->searchNode("Player")->getPlayer()->getPosition(); viewDirFromPlayer = testScene.getScenegraph()->searchNode("Player")->getPlayer()->getViewDirection(); //ToDo calculate Normal funktioniert evtl falsch normalFromTerrain = terrain2.calculateNormal(tmpPos.x, tmpPos.z); rotateAxis = glm::cross(glm::vec3(viewDirFromPlayer), normalFromTerrain ); // lengthFromNormal = glm::length(normalFromTerrain); // lengthFromUp = glm::length(up); normalFromTerrain = glm::normalize(normalFromTerrain); up = glm::normalize(up); phi = glm::dot(up, normalFromTerrain); phi = glm::atan(phi) * (180 / glm::pi<float>()); // phi = glm::acos(glm::dot(normalFromTerrain, up) / (lengthFromNormal * lengthFromUp)); //ToDo Rotation überschreibt die frühere Rotation testScene.getScenegraph()->searchNode("Player")->addRotation(phi, rotateAxis); antHome.updateAnts(); //===================================================================// //==================Render your Objects==============================// //==================================================================// //renderer.renderScene(testScene, testWindow); fboGBuffer.bind(); glClearColor(0.5, 0.5, 0.5, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shaderGBuffer.bind(); shaderGBuffer.sendMat4("viewMatrix", cam.getViewMatrix()); shaderGBuffer.sendMat4("projectionMatrix", cam.getProjectionMatrix()); testScene.render(shaderGBuffer); shaderGBuffer.unbind(); fboGBuffer.unbind(); //ScreenFillingQuad Render Pass shaderSFQ.bind(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shaderSFQ.sendSampler2D("fboTexture", fboGBuffer.getColorTexture(2)); screenFillingQuad.renderGeometry(); shaderSFQ.unbind(); renderer.renderGUI(*playerGUI.getHUD(), testWindow); glfwSwapBuffers(testWindow.getWindow()); glfwPollEvents(); } glfwDestroyWindow(testWindow.getWindow()); glfwTerminate(); return 0; }
int main() { Player geko("Geko", glm::vec3(10.0, 10.0, 10.0)); // Start Konifguration - Window, Context, Camera and Callbacks // glfwInit(); Window testWindow(500, 50, 800, 600, "testWindow"); glfwMakeContextCurrent(testWindow.getWindow()); cam.setKeySpeed(2.0); cam.setNearFar(0.01, 100); //Callback for Camera and Player glfwSetKeyCallback(testWindow.getWindow(), key_callback); glewInit(); // Shader and Renderer Initialization // //Shader for Objects VertexShader vs(loadShaderSource(SHADERS_PATH + std::string("/Vertex-Shaders/TextureShader3D.vert"))); FragmentShader fs(loadShaderSource(SHADERS_PATH + std::string("/Fragment-Shaders/TextureShader3D.frag"))); ShaderProgram shader(vs, fs); //Shader for a Skybox VertexShader vsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.vert"))); FragmentShader fsSkybox(loadShaderSource(SHADERS_PATH + std::string("/SkyboxShader/SkyboxShader.frag"))); ShaderProgram shaderSkybox(vsSkybox, fsSkybox); //Renderer with context OpenGL3Context context; Renderer renderer(context); //Level and Scene Level testLevel("testLevel"); Scene testScene("testScene"); testLevel.addScene(&testScene); testLevel.changeScene("testScene"); //Add Camera to scenegraph testScene.getScenegraph()->addCamera(&cam); testScene.getScenegraph()->getCamera("PlayerViewCam"); testScene.getScenegraph()->setActiveCamera("PlayerViewCam"); //Set all InputMaps and set one InputMap active iH.setAllInputMaps(*(testScene.getScenegraph()->getActiveCamera())); iH.changeActiveInputMap("Object"); iH.getActiveInputMap()->update(geko); // ============================================================== // == Object (ant, afraid) ====================================== // ============================================================== Teapot teaAnt; Texture texCV((char*)RESOURCES_PATH "/cv_logo.bmp"); //AntMesh antMesh; //Node aiNodeFlick("Flick"); //aiNodeFlick.addGeometry(&teaAnt); //aiNodeFlick.addTexture(&texCV); //testScene.getScenegraph()->getRootNode()->addChildrenNode(&aiNodeFlick); //AI ant_Flick; //ant_Flick.setAntAfraid(); //aiNodeFlick.ssetObject(&ant_Flick); // ============================================================== // == Object (ant, aggressiv) =================================== // ============================================================== AntMesh antMesh; //Node aiNodeFlack("Flack"); //aiNodeFlack.addGeometry(&teaAnt); //aiNodeFlack.addGeometry(&antMesh); //aiNodeFlack.addTexture(&texCV); //testScene.getScenegraph()->getRootNode()->addChildrenNode(&aiNodeFlack); //AI ant_Flack; //ant_Flack.setAntAggressiv(); //aiNodeFlack.setObject(&ant_Flack); // ============================================================== // == Object (Tree) ============================================= // ============================================================== Texture texBrick((char*)RESOURCES_PATH "/brick.bmp"); //TreeMesh treeMesh; Teapot teaTree; TreeMesh treeMesh; Node treeNode("CookieTree"); StaticObject tree; tree.setTree(); treeNode.setObject(&tree); treeNode.addTexture(&texCV); treeNode.addGeometry(&treeMesh); glm::vec3 posFood(10.0, 0.0, -5.0); treeNode.addTranslation(posFood); treeNode.getBoundingSphere()->radius = 2.0; testScene.getScenegraph()->getRootNode()->addChildrenNode(&treeNode); // ============================================================== // == Player ==================================================== // ============================================================== Teapot teaPlayer; GekoMesh gekomesh; // Texture texBrick((char*)RESOURCES_PATH "/brick.bmp"); Node playerNode("Player"); playerNode.addTexture(&texBrick); playerNode.setObject(&geko); //playerNode.addGeometry(&teaPlayer); playerNode.addGeometry(&gekomesh); playerNode.setCamera(&cam); geko.setPosition(glm::vec3(10.0, 0.0, 10.0)); //Add the node to the Scene testScene.getScenegraph()->getRootNode()->addChildrenNode(&playerNode); // ============================================================== // == Questsystem ==================================================== // ============================================================== //QuestHandler questhandler; Quest questCollect(1); questCollect.setActive(true); Goal_Collect goalCollect(1); Goal_Collect goalCollect3(3); questCollect.addGoal(&goalCollect); questCollect.addGoal(&goalCollect3); Quest questCollect2(2); questCollect2.setActive(true); Goal_Collect goalCollect2(2); questCollect2.addGoal(&goalCollect2); goalCollect.setGoalCount(50); goalCollect2.setGoalCount(50); goalCollect3.setGoalCount(50); goalCollect.setItemType(ItemType::BRANCH); goalCollect2.setItemType(ItemType::BRANCH); goalCollect3.setItemType(ItemType::COOKIE); testLevel.getQuestHandler()->addQuest(&questCollect); testLevel.getQuestHandler()->addQuest(&questCollect2); /*questhandler.addQuest(&questCollect); questhandler.addQuest(&questCollect2);*/ //std::cout << "GRÖßE DES QUESTHANDLERS : " << questhandler.getQuests().size() << std::endl; // ============================================================== // == Collision, FightSystem===================================== // ============================================================== // Bounding Box creation for the objects and collision test // CollisionTest collision; FightSystem fight; //===================================================================// //==================Setting up the Observers========================// //==================================================================// ObjectObserver aiObserver(&testLevel); //ant_Flick.addObserver(&aiObserver); //ant_Flack.addObserver(&aiObserver); ObjectObserver playerObserver(&testLevel); geko.addObserver(&playerObserver); CollisionObserver colObserver(&testLevel); collision.addObserver(&colObserver); GravityObserver gravityObserver(&testLevel); collision.addObserver(&gravityObserver); SoundObserver soundObserver(&testLevel); // ============================================================== // == Object (Anthome) ========================================== // ============================================================== //TreeMesh treeMesh; AntHomeMesh homeMesh; Node homeNode("AntHome"); StaticObject home; //home.setTree(); homeNode.setObject(&home); homeNode.addTexture(&texBrick); homeNode.addGeometry(&homeMesh); glm::vec3 posHome(1.0, 0.0, 1.0); homeNode.addTranslation(posHome); homeNode.getBoundingSphere()->radius = 0.5; testScene.getScenegraph()->getRootNode()->addChildrenNode(&homeNode); glm::vec3 posFood2(10.0, 0.0, -5.0); glm::vec3 posSpawn(3.0, 0.0, 3.0); glm::vec3 posDefaultPlayer(0.0, 0.0, 0.0); DecisionTree *aggressivedecisionTree = new DecisionTree(); aggressivedecisionTree->setAntTreeAggressiv(); DecisionTree *afraidDecisionTree = new DecisionTree(); afraidDecisionTree->setAntTreeAfraid(); Graph<AStarNode, AStarAlgorithm>* antAggressiveGraph = new Graph<AStarNode, AStarAlgorithm>(); antAggressiveGraph->setExampleAntAfraid(posSpawn, posFood2, posDefaultPlayer); Graph<AStarNode, AStarAlgorithm>* antAfraidGraph = new Graph<AStarNode, AStarAlgorithm>(); antAfraidGraph->setExampleAntAfraid(posSpawn, posFood, posDefaultPlayer); //AntHome antHome(posSpawn, antMesh, &texCV, &texCV, aggressivedecisionTree, antAggressiveGraph, afraidDecisionTree, antAfraidGraph); ////antHome.generateGuards(5, &aiObserver); //antHome.generateWorkers(1, &aiObserver); SoundFileHandler sfh(1000); AntHome antHome(posSpawn, &sfh, antMesh, &soundObserver, &playerObserver, &texCV, &texCV, aggressivedecisionTree, antAggressiveGraph, afraidDecisionTree, antAfraidGraph); antHome.generateWorkers(5, testScene.getScenegraph()->getRootNode()); antHome.addAntsToSceneGraph(testScene.getScenegraph()->getRootNode()); collision.collectNodes(testScene.getScenegraph()->getRootNode()); float lastTime = glfwGetTime(); int i = 0; while (!glfwWindowShouldClose(testWindow.getWindow())) { i++; if (i == 30){ i++; } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float currentTime = glfwGetTime(); float deltaTime = currentTime - lastTime; lastTime = currentTime; collision.update(); antHome.updateAnts(); antHome.printPosWorkers(); /* ant_Flick.update(); ant_Flack.update();*/ geko.update(); geko.setDeltaTime(currentTime); renderer.renderScene(testScene, testWindow); } glfwDestroyWindow(testWindow.getWindow()); glfwTerminate(); return 0; }