Ejemplo n.º 1
0
        public void init(CameraParameters param)
        {
            pointCloud.initialize(param.resolution);
            // Compile and create the shader
            shaderBbox         = new ShaderData();
            shaderBbox.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            shaderBbox.MVP_Mat = Gl.GetUniformLocation(shaderBbox.it.getProgramId(), "u_mvpMatrix");

            //Create Camera
            //setRenderCameraProjection(param, 0.5f, 20f);
            camera_ = new CameraGL(new Vector3(0, 0, 1), new Vector3(0, 0, -1f), Vector3.UnitY);
            camera_.setOffsetFromPosition(new Vector3(0, 0, 1.5f));

            frustum.init();
            frustum.setDrawingType(PrimitiveType.Triangles);
            frustum.createFrustum(param);
            frustum.pushToGPU();

            cam_pose = new Matrix4x4();

            available = true;
        }
Ejemplo n.º 2
0
        public void init(CameraParameters param, MODEL cameraModel)
        {
            mainShader         = new ShaderData();
            mainShader.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            mainShader.MVP_Mat = Gl.GetUniformLocation(mainShader.it.getProgramId(), "u_mvpMatrix");

            shaderLine         = new ShaderData();
            shaderLine.it      = new Shader(Shader.VERTEX_SHADER, Shader.FRAGMENT_SHADER);
            shaderLine.MVP_Mat = Gl.GetUniformLocation(shaderLine.it.getProgramId(), "u_mvpMatrix");

            //Create Camera
            camera_ = new CameraGL(new Vector3(0f, 1f, 1f), new Vector3(0, -1, -4f), Vector3.UnitY);
            camera_.setOffsetFromPosition(new Vector3(0, 0, 1.0f));

            floor_grid.init();
            floor_grid.setDrawingType(PrimitiveType.Lines);

            zedModel.init();
            zedModel.setDrawingType(PrimitiveType.Triangles);
            zedPath.init();

            float  limit = 20;
            float4 clr1  = new float4();

            clr1.x = 0.85f;
            clr1.y = 0.87f;
            clr1.z = 0.88f;
            clr1.w = 1f;

            float4 clr2 = new float4();

            clr2.x = 0.42f;
            clr2.y = 0.48f;
            clr2.z = 0.53f;
            clr2.w = 1f;

            float height = 0.0f;

            for (int i = (int)(limit * -5); i <= (int)(limit * 5); i++)
            {
                float i_f = i / 5.0f;
                if ((i % 5) == 0)
                {
                    addVert(ref floor_grid, i_f, limit, height, clr2);
                }
                else
                {
                    addVert(ref floor_grid, i_f, limit, height, clr1);
                }
            }
            floor_grid.pushToGPU();
            zedPath.setDrawingType(PrimitiveType.LineStrip);

            Model3D model = new Model3D();

            switch (cameraModel)
            {
            case MODEL.ZED:
                model = new Model3D_ZED();
                break;

            case MODEL.ZED2:
                model = new Model3D_ZED2();
                break;

            case MODEL.ZED_M:
                model = new Model3D_ZED();
                break;
            }

            foreach (ModelPart part in model.part)
            {
                fillZED(part.nb_triangles, model.vertices, part.triangles, part.color, ref zedModel);
            }

            zedModel.pushToGPU();
            updateZEDposition = false;

            available = true;
        }