コード例 #1
0
ファイル: sphere.hpp プロジェクト: mseefelder/tucano
	/**
	* @brief Render sphere
	*/
	void render (const Tucano::Camera& camera, const Tucano::Camera& light)
	{
		Eigen::Vector4f viewport = camera.getViewport();
		glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

		sphere_shader.bind();

       	sphere_shader.setUniform("modelMatrix", model_matrix);
		sphere_shader.setUniform("viewMatrix", camera.getViewMatrix());
       	sphere_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
		sphere_shader.setUniform("lightViewMatrix", light.getViewMatrix());
       	sphere_shader.setUniform("in_Color", color);

		vector <string> attribs;
		sphere_shader.getActiveAttributes(attribs);

 		this->setAttributeLocation(&sphere_shader);

		glEnable(GL_DEPTH_TEST);
		this->bindBuffers();
		this->renderElements();
		this->unbindBuffers();
		glDisable(GL_DEPTH_TEST);

       	sphere_shader.unbind();

		#ifdef TUCANODEBUG
		errorCheckFunc(__FILE__, __LINE__);
		#endif
		
	}
コード例 #2
0
ファイル: depthMap.hpp プロジェクト: brunoferraz/project
    /** * @brief Render the mesh given a camera and light, using a Phong shader 
     * @param mesh Given mesh
     * @param camera Given camera 
     * @param lightTrackball Given light camera 
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {

        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        depthmap_shader.bind();

        // sets all uniform variables for the phong shader
        depthmap_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        depthmap_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        depthmap_shader.setUniform("viewMatrix", camera.getViewMatrix());
        depthmap_shader.setUniform("near", 0.1);
        depthmap_shader.setUniform("far", 10000.0);

//        std::cout << "Model" << std::endl;
//        std::cout << mesh.getModelMatrix().matrix() << std::endl;

//        std::cout << "View" << std::endl;
//        std::cout << camera.getViewMatrix().matrix() << std::endl;

        mesh.setAttributeLocation(depthmap_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();

        depthmap_shader.unbind();
    }
コード例 #3
0
    /** * @brief Render the mesh given a camera and light, using a Phong shader 
     * @param mesh Given mesh
     * @param camera Given camera 
     * @param lightTrackball Given light camera 
     */
    void render (PointCloud& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        particletf_shader.bind();

        glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, 0);

        // Transform feedback 0
        glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedback[0]);
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,mesh.getAttribute("in_Position")->getBufferID());
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,1,mesh.getAttribute("in_Velocity")->getBufferID());
        // posBuf[0] -> mesh.getAttribute("in_Position")->getBufferID()

        // Transform feedback 1
        glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedback[1]);
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,mesh.getAttribute("in_Position")->getBufferID());
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,1,mesh.getAttribute("in_Velocity")->getBufferID());
//        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,1,velBuf[1]);
//        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,2,startTime[1]);

        // sets all uniform variables for the phong shader
        particletf_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        particletf_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        particletf_shader.setUniform("viewMatrix", camera.getViewMatrix());
        particletf_shader.setUniform("lightViewMatrix", lightTrackball.getViewMatrix());
        particletf_shader.setUniform("has_color", mesh.hasAttribute("in_Color"));
        particletf_shader.setUniform("default_color", default_color);

        // Disable rendering
        glEnable(GL_RASTERIZER_DISCARD);
        int drawBuf = 0;
        // Bind the feedback object for the buffers to be drawn next
        glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedback[drawBuf]);

        mesh.setAttributeLocation(particletf_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();

        particletf_shader.unbind();
//        glEndTransformFeedback();
    }
コード例 #4
0
ファイル: simpleTF.hpp プロジェクト: brunoferraz/advRendering
    /** * @brief Render the mesh given a camera and light, using a Phong shader
     * @param mesh Given mesh
     * @param camera Given camera
     * @param lightTrackball Given light camera
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {

        if (read_va == NULL)
        {
            read_va = mesh.getAttribute("positions1");
            write_va = mesh.getAttribute("positions2");
        }

        if (read_va == NULL || write_va == NULL)
            qDebug() << "AHHH morri";

        updateTF(mesh, camera, lightTrackball);
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
        simple.bind();
        // sets all uniform variables for the phong shader

        simple.setUniform("projectionMatrix", camera.getProjectionMatrix());
        simple.setUniform("modelMatrix", mesh.getModelMatrix());
        simple.setUniform("viewMatrix", camera.getViewMatrix());

        glEnable(GL_DEPTH_TEST);
        //mesh.setAttributeLocation(simple);
        mesh.bindBuffers();
//            mesh.resetLocations();
        //qDebug() << mesh.getAttribute("nPos")->getLocation();
        read_va->disable();
        write_va->enable(simple.getAttributeLocation("inPos"));


        mesh.setAttributeLocation("nColor",  simple.getAttributeLocation("inColor"));

        mesh.renderPoints();
        mesh.unbindBuffers();

        simple.unbind();

        VertexAttribute *tmp_va;
        tmp_va = read_va;
        read_va = write_va;
        write_va = tmp_va;
    }
コード例 #5
0
ファイル: normalvector.hpp プロジェクト: mseefelder/tucano
    /**
     * @brief Render the mesh given a camera trackball
     * @param mesh Given mesh
     * @param cameraTrackball Given camera trackball     
     */
	virtual void render(Tucano::Mesh& mesh, const Tucano::Camera& camera)
    {
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        normalvec_shader.bind();

        // sets all uniform variables for the phong shader
        normalvec_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        normalvec_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        normalvec_shader.setUniform("viewMatrix", camera.getViewMatrix());

        mesh.setAttributeLocation(normalvec_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();
        glDisable(GL_DEPTH_TEST);

        normalvec_shader.unbind();
    }
コード例 #6
0
ファイル: tfTest.hpp プロジェクト: brunoferraz/advRendering
    /** * @brief Render the mesh given a camera and light, using a Phong shader 
     * @param mesh Given mesh
     * @param camera Given camera 
     * @param lightTrackball Given light camera 
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        tftest_shader.bind();
            // sets all uniform variables for the phong shader
            tftest_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
            tftest_shader.setUniform("modelMatrix", mesh.getModelMatrix());
            tftest_shader.setUniform("viewMatrix", camera.getViewMatrix());
            tftest_shader.setUniform("lightViewMatrix", lightTrackball.getViewMatrix());
            tftest_shader.setUniform("has_color", mesh.hasAttribute("in_Color"));
            tftest_shader.setUniform("default_color", default_color);
            tftest_shader.setUniform("tf", 1.0);

            cout << "set attrib TF\n";
            mesh.setAttributeLocation(tftest_shader);
            glEnable(GL_RASTERIZER_DISCARD);


            mesh.bindBuffers();

                glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.getAttribute("nPos")->getBufferID());

                glBeginTransformFeedback(GL_POINTS);
                glEnable(GL_DEPTH_TEST);
                mesh.renderPoints();

                glEndTransformFeedback();
                glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
                mesh.unbindBuffers();
            glDisable(GL_RASTERIZER_DISCARD);
        tftest_shader.unbind();
    printActiveAttribs(tftest_shader.getShaderProgram(), "TF");
    printActiveAttribs(tfrender.getShaderProgram(), "RENDER");
//        RENDERING

        tfrender.bind();
            // sets all uniform variables for the phong shader
            tfrender.setUniform("projectionMatrix", camera.getProjectionMatrix());
            tfrender.setUniform("modelMatrix", mesh.getModelMatrix());
            tfrender.setUniform("viewMatrix", camera.getViewMatrix());
            tfrender.setUniform("lightViewMatrix", lightTrackball.getViewMatrix());
            tfrender.setUniform("has_color", mesh.hasAttribute("in_Color"));
            tfrender.setUniform("default_color", default_color);
//            tfrender.setUniform("tf", 1.0);

            cout << "set attrib RENDER\n";
            mesh.setAttributeLocation(tfrender);
            mesh.bindBuffers();
            mesh.renderElements();
            mesh.unbindBuffers();
        tfrender.unbind();


    }
コード例 #7
0
ファイル: directcolor.hpp プロジェクト: LCG-UFRJ/tucano
    /** * @brief Render the mesh given a camera 
     * @param mesh Given mesh
     * @param camera Given camera
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera)
    {

        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

        directcolor_shader.bind();

        // sets all uniform variables for the phong shader
        directcolor_shader.setUniform("projectionMatrix", camera.getProjectionMatrix());
        directcolor_shader.setUniform("modelMatrix", mesh.getModelMatrix());
        directcolor_shader.setUniform("viewMatrix", camera.getViewMatrix());
        directcolor_shader.setUniform("has_color", mesh.hasAttribute("in_Color"));
		directcolor_shader.setUniform("default_color", default_color);

        mesh.setAttributeLocation(directcolor_shader);

        glEnable(GL_DEPTH_TEST);
        mesh.render();

        directcolor_shader.unbind();
    }