Beispiel #1
0
void testCube(Vec<GenDescriptor>& vec, long widthBound)
{
  GeneratorTrees trees;
  long cost = trees.buildOptimalTrees(vec, widthBound);
  if (!noPrint) {
    cout << "@TestCube: trees=" << trees << endl;
    cout << " cost =" << cost << endl;
  }
  Vec<long> dims;
  trees.getCubeDims(dims);
  CubeSignature sig(dims);

  for (long cnt=0; cnt<3; cnt++) {
    Permut pi;
    randomPerm(pi, trees.getSize());

    PermNetwork net;
    net.buildNetwork(pi, trees);

    HyperCube<long> cube1(sig), cube2(sig);
    for (long i=0; i<cube1.getSize(); i++) cube1[i] = i;
    HyperCube<long> cube3 = cube1;
    applyPermToVec(cube2.getData(), cube1.getData(), pi); // direct application
    net.applyToCube(cube3); // applying permutation netwrok
    if (cube2==cube3) cout << "GOOD\n";
    else {
      cout << "BAD\n";
      if (cube1.getSize()<100 && !noPrint) {
	cout << "in="<<cube1.getData() << endl;
	cout << "out1="<<cube2.getData()<<", out2="
	     << cube3.getData()<<endl<<endl;
      }
    }
  }
}
Beispiel #2
0
/**
 * Input:
 BATCH 0 DEPTH 0
 a1 d1 g1
 b1 e1 h1
 c1 f1 i1
 BATCH 0 DEPTH 1
 a1' d1' g1'
 b1' e1' h1'
 c1' f1' i1'
 BATCH 1 DEPTH 0
 a2 d2 g2
 b2 e2 h2
 c2 f2 i2
 BATCH 1 DEPTH 1
 a2' d2' g2'
 b2' e2' h2'
 c2' f2' i2'
 *
 * Expect output with Kernel size 3x3:
 *
 BATCH 0 DEPTH 0
 a1 d1 b1 e1 a1' d1' b1' e1'
 d1 g1 e1 h1 d1' g1' e1' h1'
 b1 e1 c1 f1 b1' e1' c1' f1'
 e1 h1 f1 i1 e1' h1' f1' i1'
 a2 d2 b2 e2 a2' d2' b2' e2'
 d2 g2 e2 h2 d2' g2' e2' h2'
 b2 e2 c2 f2 b2' e2' c2' f2'
 e2 h2 f2 i2 e2' h2' f2' i2'
 *
 **/
void TEST_LOWERING(){
    Cube<DataType_String, Layout_RCDB> cube1(3, 3, 2, 2);
    
    Cube<DataType_String, Layout_RCDB> cube2(2*2*2, (3-2+1)*(3-2+1)*2, 1, 1);
    
    LoweringConfig lconfig;
    lconfig.kernel_size = 2;
    
    Connector<DataType_String, Layout_RCDB, DataType_String, Layout_RCDB, Connector_Lowering_R1C1>
        connector(&cube1, &cube2, &lconfig);
    
    size_t ct = 0;
    cube1.p_data[ct++] = "a1"; cube1.p_data[ct++] = "b1";
    cube1.p_data[ct++] = "c1"; cube1.p_data[ct++] = "d1";
    cube1.p_data[ct++] = "e1"; cube1.p_data[ct++] = "f1";
    cube1.p_data[ct++] = "g1"; cube1.p_data[ct++] = "h1";
    cube1.p_data[ct++] = "i1";
    
    cube1.p_data[ct++] = "a2"; cube1.p_data[ct++] = "b2";
    cube1.p_data[ct++] = "c2"; cube1.p_data[ct++] = "d2";
    cube1.p_data[ct++] = "e2"; cube1.p_data[ct++] = "f2";
    cube1.p_data[ct++] = "g2"; cube1.p_data[ct++] = "h2";
    cube1.p_data[ct++] = "i2";
    
    cube1.p_data[ct++] = "a1'"; cube1.p_data[ct++] = "b1'";
    cube1.p_data[ct++] = "c1'"; cube1.p_data[ct++] = "d1'";
    cube1.p_data[ct++] = "e1'"; cube1.p_data[ct++] = "f1'";
    cube1.p_data[ct++] = "g1'"; cube1.p_data[ct++] = "h1'";
    cube1.p_data[ct++] = "i1'";
    
    cube1.p_data[ct++] = "a2'"; cube1.p_data[ct++] = "b2'";
    cube1.p_data[ct++] = "c2'"; cube1.p_data[ct++] = "d2'";
    cube1.p_data[ct++] = "e2'"; cube1.p_data[ct++] = "f2'";
    cube1.p_data[ct++] = "g2'"; cube1.p_data[ct++] = "h2'";
    cube1.p_data[ct++] = "i2'";
    
    connector.transfer(&cube1, &cube2);
    
    cube2.logical_print();
    
    connector.report_last_transfer.print();
    connector.report_history.print();
    connector.transfer(&cube1, &cube2);
    connector.report_last_transfer.print();
    connector.report_history.print();
}
Beispiel #3
0
void CubeScene::setupObjects()
{
	NodePointer rootNode(new TransformNode(getCamera().getTransform()));

	MaterialNodePointer material(new MaterialNode(rootNode));
	Color white(1, 1, 1);
	material->setAmbient(Color(0.5, 0, 0));
	material->setDiffuse(white * .5);
	material->setSpecular(Color(0.5, 0, 1.0));
	material->setShininess(20);

	RayObjectPointer cube(new Cube(material));
	addObject(cube);

	NodePointer translation(new TranslationNode(-2.5, 0, 0, material));
	RayObjectPointer cube2(new Cube(translation));
	addObject(cube2);
}
Beispiel #4
0
void TEST_TIMER(){
    LoweringConfig lconfig;
    lconfig.kernel_size = 3;
    
    Cube<DataType_SFFloat, Layout_RCDB> cube1(64, 64, 96, 12);
    
    Cube<DataType_SFFloat, Layout_RCDB> cube2(lconfig.kernel_size*lconfig.kernel_size*96,
                        (64-lconfig.kernel_size+1)*(64-lconfig.kernel_size+1)*12, 1, 1);
    
    Connector<DataType_SFFloat, Layout_RCDB, DataType_SFFloat, Layout_RCDB, Connector_Lowering_R1C1>
    connector(&cube1, &cube2, &lconfig);
    
    connector.transfer(&cube1, &cube2);
    
    connector.report_last_transfer.print();
    connector.report_history.print();
    connector.transfer(&cube1, &cube2);
    connector.report_last_transfer.print();
    connector.report_history.print();

}
Beispiel #5
0
void testCube(Vec<GenDescriptor>& vec, long widthBound)
{
  GeneratorTrees trees;
  long cost = trees.buildOptimalTrees(vec, widthBound);
  cout << "@TestCube: trees=" << trees << endl;
  cout << " cost =" << cost << endl;
  Vec<long> dims;
  trees.getCubeDims(dims);
  CubeSignature sig(dims);

  for (long cnt=0; cnt<3; cnt++) {
    Permut pi;
    randomPerm(pi, trees.getSize());
    //    if (pi.length()<100)  cout << "pi="<<pi<<endl;

    PermNetwork net;
    net.buildNetwork(pi, trees);
    //    if (pi.length()<100) {
    //      cout << "permutations network {[gIdx,e,isID,shifts]} = " << endl;
    //      cout << net << endl;
    //    }

    HyperCube<long> cube1(sig), cube2(sig);
    for (long i=0; i<cube1.getSize(); i++) cube1[i] = i;
    HyperCube<long> cube3 = cube1;
    applyPermToVec(cube2.getData(), cube1.getData(), pi); // direct application
    net.applyToCube(cube3); // applying permutation netwrok
    if (cube2==cube3) cout << "yay\n";
    else {
      cout << "blech\n";
      if (cube1.getSize()<100) {
	cout << "in="<<cube1.getData() << endl;
	cout << "out1="<<cube2.getData()<<", out2="
	     << cube3.getData()<<endl<<endl;
      }
    }
  }
}
Beispiel #6
0
int main()
{
    glfwInit();

    Window testWindow(50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, "Deferred Shading");
    glfwMakeContextCurrent(testWindow.getWindow());
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);


    // You have to set a camera name
    cam.setName("PilotviewCam");
    cam.setPosition(glm::vec4(0.0, 0.5, 3.0, 1.0));
    cam.setNearFar(0.01f, 100.0f);

    iH.setAllInputMaps(cam);
    iH.changeActiveInputMap("Pilotview");

    //Callback
    glfwSetKeyCallback(testWindow.getWindow(), key_callback);

    glewInit();

    //our shader
    VertexShader vsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.vert")));
    FragmentShader fsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.frag")));
    ShaderProgram shaderGBuffer(vsGBuffer, fsGBuffer);

    //load shader here
    VertexShader vsDsLighting(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsLighting.vert")));
    FragmentShader fsDsLighting(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsLighting.frag")));
    ShaderProgram shaderDsLightingShader(vsDsLighting, fsDsLighting);

    VertexShader vsDsCompositing(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsFinalCompositing.vert")));
    FragmentShader fsDsCompositing(loadShaderSource(SHADERS_PATH + std::string("/DeferredShading/dsFinalCompositing.frag")));
    ShaderProgram shaderDsCompositingShader(vsDsCompositing, fsDsCompositing);

    VertexShader vsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.vert")));
    FragmentShader fsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.frag")));
    ShaderProgram shaderSFQ(vsSfq, fsSfq);

    //our renderer
    OpenGL3Context context;
    Renderer renderer(context);

    FBO fboGBuffer(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
    FBO fboDeferredShading(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
    FBO fboCompositing(WINDOW_WIDTH, WINDOW_HEIGHT, 3, false, false);

    //our object
    Cube cube;

    Teapot teapot;

    Rect plane;
    Rect screenFillingQuad;
    screenFillingQuad.loadBufferData();

    //our textures
    Texture bricks((char*)RESOURCES_PATH "/bricks_diffuse.png");
    Texture bricks_normal((char*)RESOURCES_PATH "/bricks_normal.png");
    Texture bricks_height((char*)RESOURCES_PATH "/bricks_height.png");

    Texture chrome((char*)RESOURCES_PATH "/chrome.jpg");
    Texture cvLogo((char*)RESOURCES_PATH "/cv_logo.bmp");

    //Scene creation
    Level testLevel("testLevel");
    Scene testScene("testScene");
    testLevel.addScene(&testScene);
    testLevel.changeScene("testScene");

    //Add Camera to scenegraph
    testScene.getScenegraph()->addCamera(&cam);
    testScene.getScenegraph()->getCamera("PilotviewCam");
    testScene.getScenegraph()->setActiveCamera("PilotviewCam");

    Rect rect;

    Node cube1("cube1");
    cube1.addGeometry(&cube);
    cube1.addTexture(&bricks);
    cube1.addNormalMap(&bricks_normal);
    cube1.addHeightMap(&bricks_height);
    cube1.setModelMatrix(glm::translate(cube1.getModelMatrix(), glm::vec3(-1.0, 0.5, -0.5)));
    cube1.setModelMatrix(glm::scale(cube1.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node cube2("cube2");
    cube2.addGeometry(&cube);
    cube2.addTexture(&bricks);
    cube2.addNormalMap(&bricks_normal);
    cube2.setModelMatrix(glm::translate(cube2.getModelMatrix(), glm::vec3(-1, 0.5, 0.5)));
    cube2.setModelMatrix(glm::scale(cube2.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node cube3("cube3");
    cube3.addGeometry(&cube);
    cube3.addTexture(&bricks);
    cube3.setModelMatrix(glm::translate(cube3.getModelMatrix(), glm::vec3(0, 0.5, -0.5)));
    cube3.setModelMatrix(glm::scale(cube3.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node cube4("cube4");
    cube4.addGeometry(&cube);
    cube4.addTexture(&bricks);
    cube4.addNormalMap(&bricks_normal);
    cube4.addHeightMap(&bricks_height,0.07,0.1,true);
    cube4.setModelMatrix(glm::translate(cube4.getModelMatrix(), glm::vec3(0, 0.5, 0.5)));
    cube4.setModelMatrix(glm::scale(cube4.getModelMatrix(), glm::vec3(0.7, 0.7, 0.7)));

    Node wallNode1("wall1");
    wallNode1.addGeometry(&plane);
    wallNode1.addTexture(&cvLogo);
    wallNode1.setModelMatrix(glm::translate(wallNode1.getModelMatrix(), glm::vec3(0.0, 0.1, 0.2)));
    wallNode1.setModelMatrix(glm::rotate(wallNode1.getModelMatrix(), 90.0f, glm::vec3(1.0, 0.0, 0.0)));
    wallNode1.setModelMatrix(glm::scale(wallNode1.getModelMatrix(), glm::vec3(10.5, 10.5, 10.5)));


    Node teaNode("teaNode");
    teaNode.addGeometry(&teapot);
    teaNode.addTexture(&chrome);
    teaNode.setModelMatrix(glm::translate(teaNode.getModelMatrix(), glm::vec3(0.2, 0.4, 0.7)));
    teaNode.setModelMatrix(glm::scale(teaNode.getModelMatrix(), glm::vec3(0.5, 0.5, 0.5)));


    //Creating a scenegraph
    testScene.getScenegraph()->getRootNode()->addChildrenNode(&wallNode1);
    testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube1);
    testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube2);
    testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube3);
    testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube4);
    //testScene.getScenegraph()->getRootNode()->addChildrenNode(&teaNode);

    double startTime = glfwGetTime();
    //Renderloop

    //create Light spheres for DS
    Node lights = Node("Root");
    Sphere lightSphere = Sphere();

    for (int i = -4; i < 4; i++)
        for (int j = -4; j < 4; j++)
        {
            Node *newLight = new Node(std::string("Node_"+std::to_string(i)+std::to_string(j)));
            newLight->addGeometry(&lightSphere);
            newLight->setModelMatrix(glm::translate(glm::mat4(1.0f), glm::vec3(i*1.5, 1.0f, j*1.5)));
            //newLight.setModelMatrix(glm::translate(glm::mat4(1.0f), glm::vec3(0, 1, 1.0f)));
            newLight->setModelMatrix(glm::scale(newLight->getModelMatrix(), glm::vec3(2.0, 2.0, 2.0)));
            lights.addChildrenNode(newLight);
        }

    int outputFPS = 0;

    while (!glfwWindowShouldClose(testWindow.getWindow()))
    {
        // You have to compute the delta time

        float deltaTime = glfwGetTime() - startTime;
        cam.setSensitivity(deltaTime);

        //if (!(outputFPS % 20))
        //std::cout << "FPS: " << static_cast<int>(1 / (glfwGetTime() - startTime)) << std::endl;

        std::cout << "FPS: " << static_cast<double>(glfwGetTime() - startTime) * 100 << std::endl;


        outputFPS++;
        startTime = glfwGetTime();

        //update Model Matrix
        lights.setModelMatrix(glm::rotate(lights.getModelMatrix(), 10.0f * deltaTime, glm::vec3(0.0, 1.0, 0.0)));


        fboGBuffer.bind();
        glClearColor(0, 0, 0, 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();

        //DEFERRED SHADING TEIL============================

        fboDeferredShading.bind();

        glCullFace(GL_FRONT);
        glEnable(GL_CULL_FACE);
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_BLEND);
        glBlendFunc(GL_ONE, GL_ONE);
        glClearColor(0, 0, 0, 0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        shaderDsLightingShader.bind();

        shaderDsLightingShader.sendMat4("viewMatrix", cam.getViewMatrix());
        shaderDsLightingShader.sendMat4("projectionMatrix", cam.getProjectionMatrix());

        shaderDsLightingShader.sendSampler2D("positionMap", fboGBuffer.getColorTexture(0),0);
        shaderDsLightingShader.sendSampler2D("normalMap", fboGBuffer.getColorTexture(1),1);

        shaderDsLightingShader.sendInt("windowWidth", testWindow.getWidth());
        shaderDsLightingShader.sendInt("windowHeight", testWindow.getHeight());

        shaderDsLightingShader.sendVec3("lightColor", glm::fvec3(0.7f,0.7f,0.4f));

        lights.render(shaderDsLightingShader);

        glDisable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
        glDisable(GL_BLEND);
        glClearColor(1.0, 1.0, 1.0, 0.0);
        shaderDsLightingShader.unbind();
        fboDeferredShading.unbind();

        //COMPOSITING TEIL ===============================
        fboCompositing.bind();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        shaderDsCompositingShader.bind();

        shaderDsCompositingShader.sendSampler2D("colorMap", fboGBuffer.getColorTexture(2),0);
        shaderDsCompositingShader.sendSampler2D("lightMap", fboDeferredShading.getColorTexture(2),1);

        screenFillingQuad.renderGeometry();

        shaderDsCompositingShader.unbind();
        fboCompositing.unbind();

        //================================================

        //ScreenFillingQuad Render Pass
        shaderSFQ.bind();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        if (glfwGetKey(testWindow.getWindow(), GLFW_KEY_F1))
            shaderSFQ.sendSampler2D("fboTexture", fboDeferredShading.getColorTexture(2));
        else
            shaderSFQ.sendSampler2D("fboTexture", fboCompositing.getColorTexture(2));

        screenFillingQuad.renderGeometry();
        shaderSFQ.unbind();


        glfwSwapBuffers(testWindow.getWindow());
        glfwPollEvents();
    }

    glfwDestroyWindow(testWindow.getWindow());
    glfwTerminate();

    return 0;
}
Beispiel #7
0
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;
}
int _tmain(int argc, _TCHAR* argv[])
{
	Context &c = Context::getInstance();
	Cube cube1(Vector3d(1.0f, 1.0f, 1.0f),
				Vector3d(0.0f, 0.0f, -10.0f),
				Vector3d(0.0f, 0.0f, 0.0f));

	Cube cube2(Vector3d(0.3f, 0.3f, 0.3f),
				Vector3d(0.4f, 1.0f, -9.7f),
				Vector3d(0.0f, 0.0f, 0.0f));

	SDL_Event ev;
	Vector3d move;
	Grid grid(40, 40, Vector3d(30.0f, 0.0f, 30.0f), Vector3d(-15.0f, 0.0f, -30.0f));
	int current = 0;

	poignet.push(&finger1);
	poignet.push(&finger2);
	poignet.push(&finger3);
	avantPoignet.push(&poignet);
	bras.push(&avantPoignet);

	if (!c.init())
		return -1;

	while (c.run(ev))
	{
		SDL_PollEvent(&ev);
		/*while(SDL_PollEvent(&ev))
		{*/
		move = Vector3d(0.0f, 0.0f, 0.0f);
		
		if (ev.type == SDL_KEYDOWN)
		{
			switch(ev.key.keysym.sym)
			{
			case SDLK_LEFT:
				move.x -= 0.5f;
				break;
			case SDLK_RIGHT:
				move.x +=0.5f;
				break;
			default:
				break;
			}
			switch(ev.key.keysym.sym)
			{
			case SDLK_UP:
				move.z -= 0.5f;
				break;
			case SDLK_DOWN:
				move.z += 0.5f;
				break;
			default:
				break;
			}
		}

		else if (ev.type == SDL_KEYUP)
		{
				switch(ev.key.keysym.sym)
				{
				case SDLK_LEFT:
					move.x = 0.0f;
					break;
				case SDLK_RIGHT:
					move.x = 0.0f;
					break;
				default:
					break;
				}
				switch(ev.key.keysym.sym)
				{
				case SDLK_UP:
					move.z = 0.0f;
					break;
				case SDLK_DOWN:
					move.z = 0;
					break;
				default:
					break;
				}
		}

		cube1.move(move);
		cube2.move(move);

		if (ev.type == SDL_QUIT || ev.key.keysym.sym == SDLK_ESCAPE)
		{
			c.stop();
		}
	
	
		/*}*/
		cube2.draw();
		cube1.draw();
		grid.draw();
		cube1.rotate(Vector3d(0.0f, 2.0f, 0.0f));
		cube2.rotate(Vector3d(3.0f, 2.0f, 1.0f));
		c.endOfLoop();
	}
	c.uninit();
	return 0;
}
Beispiel #9
0
int main()
{
    glfwInit();

    Window testWindow(50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, "Reflections");
    glfwMakeContextCurrent(testWindow.getWindow());
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);


    cam.setRadius(2.0);
    cam.setPosition(glm::vec4(0.0, 1.0, 1.0, 1.0));
    cam.setName("TrackballCam");
    cam.setNearFar(0.1f, 50.0f);
    cam.moveDown();

    iH.setAllInputMaps(cam);
    iH.changeActiveInputMap("Trackball");

    //Callback
    glfwSetKeyCallback(testWindow.getWindow(), key_callback);

    glewInit();

    //our shader
    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 vsRLR(loadShaderSource(SHADERS_PATH + std::string("/RealtimeLocalReflections/RealtimeLocalReflections.vert")));
    FragmentShader fsRLR(loadShaderSource(SHADERS_PATH + std::string("/RealtimeLocalReflections/RealtimeLocalReflections.frag")));
    ShaderProgram shaderRLR(vsRLR, fsRLR);

    VertexShader vsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.vert")));
    FragmentShader fsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.frag")));
    ShaderProgram shaderSFQ(vsSfq, fsSfq);

    //our renderer
    OpenGL3Context context;
    Renderer renderer(context);

    FBO fboGBuffer(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
    FBO fboSSR(WINDOW_WIDTH, WINDOW_HEIGHT, 3, false, false);

    //our object
    Cube cube;
    Teapot teapot;
    teapot.loadBufferData();

    Rect plane;
    Rect screenFillingQuad;
    screenFillingQuad.loadBufferData();

    //our textures
    Texture bricks((char*)RESOURCES_PATH "/brick.bmp");
    Texture marble((char*)RESOURCES_PATH "/seamless_marble.jpg");
    Texture chrome((char*)RESOURCES_PATH "/chrome.jpg");

    //Scene creation
    Level testLevel("testLevel");
    Scene testScene("testScene");
    testLevel.addScene(&testScene);
    testLevel.changeScene("testScene");

    //Add Camera to scenegraph
    testScene.getScenegraph()->addCamera(&cam);
    testScene.getScenegraph()->getCamera("TrackballCam");
    testScene.getScenegraph()->setActiveCamera("TrackballCam");

    Node cube1("cube1");
    cube1.addGeometry(&cube);
    cube1.addTexture(&bricks);
    cube1.setModelMatrix(glm::translate(cube1.getModelMatrix(), glm::vec3(-0.3, 0.25, 0.2)));
    cube1.setModelMatrix(glm::scale(cube1.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3)));

    Node cube2("cube2");
    cube2.addGeometry(&cube);
    cube2.addTexture(&bricks);
    cube2.setModelMatrix(glm::translate(cube2.getModelMatrix(), glm::vec3(0.7, 0.25, 0.3)));
    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, 0.1, 0.2)));
    wallNode1.setModelMatrix(glm::rotate(wallNode1.getModelMatrix(), 90.0f, glm::vec3(1.0, 0.0, 0.0)));
    wallNode1.setModelMatrix(glm::scale(wallNode1.getModelMatrix(), glm::vec3(1.5, 1.5, 1.5)));

    Node wallNode2("wall2");
    wallNode2.addGeometry(&plane);
    wallNode2.addTexture(&marble);
    wallNode2.setModelMatrix(glm::translate(wallNode2.getModelMatrix(), glm::vec3(0.0, 1.0, -0.2)));
    wallNode2.setModelMatrix(glm::scale(wallNode2.getModelMatrix(), glm::vec3(1.5, 1.5, 1.5)));


    Node teaNode("teaNode");
    teaNode.addGeometry(&teapot);
    teaNode.addTexture(&chrome);
    teaNode.setModelMatrix(glm::translate(teaNode.getModelMatrix(), glm::vec3(0.2, 0.3, 0.7)));
    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);

    double startTime = glfwGetTime();
    //Renderloop
    while (!glfwWindowShouldClose(testWindow.getWindow()))
    {
        // You have to compute the delta time
        cam.setSensitivity(glfwGetTime() - startTime);

        startTime = glfwGetTime();

        fboGBuffer.bind();
        glClearColor(0, 0, 0, 0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        shaderGBuffer.bind();
        shaderGBuffer.sendMat4("viewMatrix", cam.getViewMatrix());
        shaderGBuffer.sendMat4("projectionMatrix", cam.getProjectionMatrix());
        shaderGBuffer.sendInt("useTexture", 1);
        testScene.render(shaderGBuffer);
        shaderGBuffer.unbind();
        fboGBuffer.unbind();

        fboSSR.bind();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        shaderRLR.bind();

        shaderRLR.sendSampler2D("positionTexture", fboGBuffer.getColorTexture(0), 0);
        shaderRLR.sendSampler2D("normalTexture", fboGBuffer.getColorTexture(1), 1);
        shaderRLR.sendSampler2D("colorTexture", fboGBuffer.getColorTexture(2), 2);
        shaderRLR.sendSampler2D("depthBuffer", fboGBuffer.getDepthTexture(), 3);

        shaderRLR.sendMat4("projectionMatrix", cam.getProjectionMatrix());

        shaderRLR.sendInt("screenWidth", WINDOW_WIDTH);
        shaderRLR.sendInt("screenHeight", WINDOW_HEIGHT);

        shaderRLR.sendFloat("zNear", cam.getNear());
        shaderRLR.sendFloat("zFar", cam.getFar());
        shaderRLR.sendFloat("reflectivity", 0.2f);

        screenFillingQuad.renderGeometry();

        shaderRLR.unbind();
        fboSSR.unbind();

        //ScreenFillingQuad Render Pass
        shaderSFQ.bind();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        shaderSFQ.sendSampler2D("fboTexture", fboSSR.getColorTexture(2));
        screenFillingQuad.renderGeometry();
        shaderSFQ.unbind();


        glfwSwapBuffers(testWindow.getWindow());
        glfwPollEvents();
    }

    glfwDestroyWindow(testWindow.getWindow());
    glfwTerminate();

    return 0;
}
bool Buffered::Initialize( Renderer* renderer )
{
    // create offscreen
    int width(512);
    int height(512);
    bool r = m_FrameBuffer.Allocate( width, height );
    ASSERT( r, "Cannot allocate offscreen buffer!");
    m_Texture = m_FrameBuffer.GetTexture();

#if 0
    // Add a cube
    Viewport *viewport(new Viewport(width, height));
    viewport->SetClearColor( {1.0f, 1.0f, 1.0f } );
    AddEntity( EntityPtr(viewport) );

    EntityPtr particleEmitter( new Emitter(renderer) );
    particleEmitter->GetRenderState()->Translate( Vector(0.0, 0.0, -60), Vector(1.0f, 1.0f, 1.0f) );
    viewport->AddEntity( particleEmitter );
#endif
    boost::shared_ptr<BmpBrush> bmpBrush( new BmpBrush );
    ASSERT( bmpBrush->Load( "data/Floor_D.bmp"), "BMP Load error!" );

    ////////////////////////////////////////////////////////////////////////////
    // Compose our scene

    // Add a cube
    EntityPtr viewport(new Viewport(width, height));
    // this entity renders
    AddEntity(viewport);

    // Add the camera
    EntityPtr camera(new Camera(NULL));
    // this entity renders
    viewport->AddEntity(camera, 0);

    EntityPtr cube( new Cube() );
    cube->GetRenderState()->Translate( Vector(-8.0, 0, 10), Vector(2.0f, 2.0f, 2.0f) );
    cube->GetRenderState()->Rotate( Vector(0.0f, 0.0f, 0.0f ) );
    // this entity renders
    camera->AddEntity(cube, 20 );

    EntityPtr cube2( new Cube( bmpBrush ) );
    cube2->GetRenderState()->Translate( Vector(+8.0, 0, 10), Vector(2.0f, 2.0f, 2.0f) );
    cube2->GetRenderState()->Rotate( Vector(0.0f, 0.0f, 0.0f ) );
    // this entity renders
    camera->AddEntity(cube2, 20 );

    if ( --rec > 0 ) {
        // this creates a recursion
        EntityPtr buffered( new Cube );
        buffered->GetRenderState()->Translate( Vector(0.0, 0.0, 15.0), Vector(3.0f, 3.0f, 3.0f) );
        // this entity renders
        camera->AddEntity(buffered, 30 );

    }

#define PARTICLES
#ifdef PARTICLES
    EntityPtr particleEmitter( new Emitter( renderer ) );
    particleEmitter->GetRenderState()->Translate( Vector(0.0, 0.0, -30.0), Vector(1.0f, 1.0f, 1.0f) );
    // this entity renders
    camera->AddEntity(particleEmitter, 100 );
#endif

    // Subtree will be initialized here:
    return Cube::Initialize( renderer );
}