예제 #1
0
        // Metoda za iscrtavanje kaveza
        public void drawCage(OpenGL gl)
        {
            Cylinder kavez = new Cylinder();

            gl.PushMatrix();
            gl.Translate(0.0f, -300.0f, 0.0f);
            kavez.CreateInContext(gl);
            // Dodavanje teksture na kavez
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Rust]);

            // Skaliranje teksture
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();
            gl.Scale(5.0f, 5.0f, 5.0f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            kavez.NormalGeneration  = Normals.Smooth;
            kavez.NormalOrientation = Orientation.Outside;
            kavez.TextureCoords     = true;
            gl.Scale(160.0f, visinaKaveza, 300.0f);
            kavez.TopRadius = 1;
            gl.Rotate(-90.0f, 0.0f, 0.0f);
            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Lines);
            gl.LineWidth(3.0f);
            kavez.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();
            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Filled);
        }
예제 #2
0
        // Metoda za iscrtavanje kaveza
        public void drawCage(OpenGL gl)
        {
            Cylinder cage = new Cylinder();

            gl.PushMatrix();
            gl.Translate(100.0f, -300.0f, 0.0f);
            cage.CreateInContext(gl);

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Rust]);

            // Skaliranje teksture
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();
            gl.Scale(5.0f, 5.0f, 5.0f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);


            cage.NormalGeneration  = Normals.Smooth;
            cage.NormalOrientation = Orientation.Outside;
            cage.TextureCoords     = true;

            gl.Scale(widthCage, 300.0f, 300.0f);
            cage.TopRadius = 1;
            gl.Rotate(-90.0f, 0.0f, 0.0f);

            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Lines);

            gl.LineWidth(3.0f);
            cage.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Filled);
        }
예제 #3
0
        public void DrawCage(OpenGL gl)
        {
            gl.PushMatrix();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.RUST]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.Scale(.1f, .1f, .1f);
            gl.LoadIdentity();
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            Cylinder cage = new Cylinder();

            cage.TextureCoords = true;
            gl.Translate(0f, cage_height - 245f, 0f);
            gl.Color(0.3f, 0.3f, 0.3f);
            cage.CreateInContext(gl);
            cage.NormalGeneration  = Normals.Smooth;
            cage.NormalOrientation = Orientation.Outside;
            gl.Scale(300f, cage_height, 300f);
            cage.TopRadius = 1;
            gl.Rotate(90.0f, 0.0f, 0.0f);
            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Lines);
            gl.LineWidth(8.0f);
            cage.Render(gl, RenderMode.Render);
            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Filled);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.PopMatrix();
        }
예제 #4
0
        /// <summary>
        /// Iscrtavanje drzaca bureta u vidu cilindra (treba da bude poluotvoren i da se u njemu nalazi bure
        /// </summary>
        /// <param name="gl"></param>
        private void drawCylinder(OpenGL gl)
        {
            gl.PushMatrix();
            gl.Color(1f, 0f, 1f);
            gl.Scale(0.7f, 0.7f, 0.7f);
            gl.Translate(0f, 2f, 0f);
            gl.Rotate(90, 1f, 0f, 0f);
            Cylinder cilindar = new Cylinder();

            cilindar.CreateInContext(gl);
            cilindar.Render(gl, RenderMode.Render);
            gl.PopMatrix();
        }
예제 #5
0
        /// <summary>
        ///     Rampa se crta tako da trenutna pozicija je sredina rampe
        /// </summary>
        /// <param name="gl"></param>
        /// <param name="sirina"></param>
        /// <param name="visina"></param>
        /// <param name="rotateRampu">
        ///     u pocetnom trenutku rampa je paralelna sa pogledom
        /// </param>
        private void drawRampu(OpenGL gl, double sirina, double visina, int rotateRampu, float podignuta)
        {
            resetMaterial(gl);
            gl.Translate(-sirina / 2, 0, 0);
            gl.Rotate(0, rotateRampu, 0);

            gl.Color(0.3, 0.3, 0.3);
            //levi stubic
            gl.PushMatrix();
            {
                gl.Scale(0.02, visina, 0.02);
                Cube cube = new Cube();
                cube.Material          = new SharpGL.SceneGraph.Assets.Material();
                cube.Material.Ambient  = Color.Blue;
                cube.Material.Diffuse  = Color.White;
                cube.Material.Specular = Color.White;
                cube.Render(gl, RenderMode.Render);
            }
            gl.PopMatrix();

            //desni stubic
            gl.PushMatrix();
            {
                gl.Translate(sirina, 0, 0);
                gl.Scale(0.02, visina, 0.02);

                Cube cube = new Cube();
                cube.Render(gl, RenderMode.Render);
            }
            gl.PopMatrix();

            gl.PushMatrix();
            {
                gl.Translate(0, visina, 0);
                gl.Rotate(0, 90, 0);
                gl.Rotate(-90 * podignuta, 1, 0, 0);
                Cylinder cil = new Cylinder();
                //     Axies ax = new Axies();
                //     ax.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Design);
                cil.BaseRadius = 0.01;
                cil.TopRadius  = 0.01;
                cil.Height     = sirina;
                cil.CreateInContext(gl);
                cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            }
            gl.PopMatrix();

            gl.Color(1f, 1f, 1f, 1f);
        }
예제 #6
0
파일: World.cs 프로젝트: rammba/StairsCG
        private void DrawCylinder(OpenGL gl)
        {
            gl.Disable(OpenGL.GL_AUTO_NORMAL);
            gl.PushMatrix();
            gl.Translate(0f, -1f, 0f);
            gl.Rotate(-90f, 0f, 0f);
            Cylinder cil = new Cylinder
            {
                Height     = 10,
                BaseRadius = 2,
                TopRadius  = 2
            };

            cil.NormalGeneration = Normals.Smooth;
            cil.CreateInContext(gl);
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();
            gl.Enable(OpenGL.GL_AUTO_NORMAL);
        }
예제 #7
0
        /// <summary>
        /// TODO 3.3: Draw one port pillar
        /// <summary>
        public void DrawPillar(OpenGL gl, float transX, float transZ)
        {
            gl.PushMatrix();
            gl.Translate(transX, pillarTranslateY, transZ);
            gl.Scale(20f, 170f, 20f);
            gl.Rotate(-90f, 1, 0, 0);

            Glu.gluQuadricTexture(Glu.gluNewQuadric(), 1);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureMaterials.WOOD]);

            gl.Color(0.2f, 0.2f, 0.2f);
            Cylinder pillar = new Cylinder
            {
                TopRadius = 1
            };

            pillar.CreateInContext(gl);
            pillar.Render(gl, RenderMode.Render);
            gl.PopMatrix();
        }
예제 #8
0
        public void TestKockica(OpenGL gl, float a, float b, float c)
        {
            gl.PushMatrix();

            gl.Translate(a, b, c);

            gl.Color(1.0f, 0.0f, 0.0f);



            gl.Rotate(-90.0f, 0.0f, 0.0f);
            gl.Scale(10, 10, 10);
            Cylinder cil = new Cylinder();

            cil.TopRadius = cil.BaseRadius;
            cil.CreateInContext(gl);

            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.PopMatrix();
        }
예제 #9
0
파일: World.cs 프로젝트: hi-imAndy/RG
        private void drawCylinder(OpenGL gl)
        {
            Cylinder cylinder = new Cylinder();

            cylinder.NormalGeneration = Normals.Smooth;
            cylinder.CreateInContext(gl);
            cylinder.Height     = 0.2f;
            cylinder.BaseRadius = 0.9f;
            cylinder.TopRadius  = 0.9f;
            gl.PushMatrix();
            gl.Translate(5.0f + x_cylinder_move, 5.0f + y_cylinder_move, -45.0f + z_cylinder_move);
            gl.Rotate(90.0f, 30.0f, 0.0f);
            gl.Rotate(0.0f, stick_rotation, 0.0f);
            gl.Scale(stick_length, 1.0f, 1.0f);
            //gl.Rotate(m_xRotation, 0.0f, 0.0f);
            //gl.Rotate(0.0f, m_yRotation, 0.0f);
            cylinder.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Stick]);
            cylinder.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
        }
예제 #10
0
        private void Bulk(OpenGL gl)
        {
            gl.PushMatrix();

            gl.PushMatrix();

            gl.PushMatrix();
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();
            gl.Scale(2f, 2f, 2f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            gl.PopMatrix();

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.YellowPlastic]);

            gl.Translate(0.4f + positionHole[0], 0f + positionHole[1], 0.02f);
            gl.Color(1f, 1f, 0.1f);
            Cylinder cil = new Cylinder();

            cil.TextureCoords    = true;
            cil.NormalGeneration = Normals.Smooth;
            cil.BaseRadius       = 0.2f;
            cil.TopRadius        = 0.2f;
            cil.Height           = 15f;
            cil.Stacks           = 300;
            cil.Slices           = 300;
            cil.CreateInContext(gl);
            cil.Render(gl, RenderMode.Render);

            gl.PopMatrix();

            Flag(gl);

            gl.PopMatrix();
        }
예제 #11
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Perspective(45f, (double)m_width / m_height, 1f, 20000f);
            gl.LookAt(0.0f, 10.0f, 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 350.0f, 0.0f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.PushMatrix();

            gl.Translate(0.0f, 0.0f, -m_sceneDistance);
            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);

            Setup_Lighting(gl);

            //kontejner
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            gl.Translate(contPos[0], contPos[1], contPos[2]);
            gl.Rotate(contRotate1[0], contRotate1[1], contRotate1[2]);
            gl.Rotate(contRotate2[0], contRotate2[1], contRotate2[2]);
            gl.Rotate(contRotate3[0], contRotate3[1], contRotate3[2]);
            m_sceneCont.Draw();
            gl.PopMatrix();

            //kamion
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            gl.Translate(truckPos[0], truckPos[1], truckPos[2]);
            gl.Rotate(0, 90, 0);
            m_sceneTruck.Draw();
            gl.PopMatrix();

            //podloga od quada
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Asphalt]);
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();
            gl.Scale(0.02f, 0.02f, 0.02f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Rotate(-90, 0, 0);
            gl.Begin(OpenGL.GL_QUADS);
            gl.Normal(LightingUtilities.FindFaceNormal(-550.0f, -550.0f, 0, 550.0f, -550.0f, 0, 550.0f, 550.0f, 0));
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(-550.0f, -550.0f, 0);
            gl.TexCoord(0.0f, 10.0f);
            gl.Vertex(550.0f, -550.0f, 0);
            gl.TexCoord(15.0f, 15.0f);
            gl.Vertex(550.0f, 550.0f, 0);
            gl.TexCoord(15.0f, 0.0f);
            gl.Vertex(-550.0f, 550.0f, 0);
            gl.End();
            gl.PopMatrix();

            //desni zid
            gl.PushMatrix();
            gl.Color(0.7f, 0.0f, 0.0f);
            gl.Translate(-110, 60, 0);
            gl.Scale(10f, 60f, 70f);

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            Cube zd = new Cube();

            zd.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //zid iza
            gl.PushMatrix();
            //gl.Color(0.7f, 0.0f, 0.0f);
            gl.Translate(-250, 60, -80);
            gl.Rotate(0, 90, 0);
            gl.Scale(10f, 60f, 150f);
            gl.Enable(OpenGL.GL_NORMALIZE);
            Cube zi = new Cube();

            zi.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //zid lijevo
            gl.PushMatrix();
            //gl.Color(0.7f, 0.0f, 0.0f);
            gl.Translate(-390, 60, 0);
            gl.Scale(10f, 60f, 70f);
            Cube zl = new Cube();

            zl.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //cube svjetlo
            gl.PushMatrix();
            gl.Color(1f, 1f, 1f);
            gl.Translate(lightPointPos[0], lightPointPos[1], lightPointPos[2]);
            gl.Scale(fs, fs, fs);
            //gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            Cube sijalica = new Cube();

            sijalica.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();


            //bandera
            gl.PushMatrix();
            //gl.Color(0.0f, 0.0f, 0.0f);
            gl.Translate(-420, 0, 80);
            gl.Rotate(-90, 0, 0);
            gl.Scale(fsx, fsx, fsx);

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Metal]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);

            Cylinder st = new Cylinder();

            st.Height     = lightPointPos[1];
            st.BaseRadius = 7f;
            st.TopRadius  = 7f;
            st.CreateInContext(gl);
            st.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();


            TextDraw3D(gl);

            gl.PopMatrix();
            gl.Flush();
        }
예제 #12
0
파일: World.cs 프로젝트: tasa1998/grafika
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.Viewport(0, 0, m_width, m_height);
            gl.PushMatrix();
            gl.LookAt(0, 0, m_sceneDistance, 0, 0, 0, 0, 1, 0);
            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);

            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPOT_DIRECTION, new float[] { 0.0f, -1.0f, 0.0f });
            float[] pos = { 0f, 300F, 105f, 1.0f };
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, pos);


            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.TRAVA]);
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.PushMatrix();
            gl.Scale(3, 3, 3);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Begin(OpenGL.GL_QUADS);
            gl.Normal(0, 1f, 0);
            gl.Color(0.1f, 0.1f, 0.1f);
            gl.TexCoord(0f, 0f);
            gl.Vertex(300f, 0.0f, -300f);
            gl.TexCoord(0f, 1f);

            gl.Vertex(-300f, 0.0f, -300f);
            gl.TexCoord(1f, 1f);

            gl.Vertex(-300f, 0.0f, 300f);
            gl.TexCoord(1f, 0f);
            gl.Vertex(300f, 0.0f, 300f);
            gl.End();
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(-100.0f, 0.0f, -100.0f - distance);
            gl.Scale(3f, 250f, 3f);
            gl.Rotate(-90f, 1, 0, 0);
            gl.Color(1.0f, 1.0f, 1.0f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.PLASTIKA]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            Cylinder target = new Cylinder();

            target.TextureCoords = true;
            target.TopRadius     = 1;
            target.CreateInContext(gl);
            target.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(100.0f, 0.0f, -100.0f - distance);
            gl.Scale(3f, 250f, 3f);
            gl.Rotate(-90f, 1, 0, 0);
            Cylinder target1 = new Cylinder();

            //target1.NormalGeneration = Normals.Smooth;
            target1.TextureCoords = true;
            target1.TopRadius     = 1;
            target1.CreateInContext(gl);
            target1.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(0f, 100.0f, -100f - distance);
            gl.Scale(100f, 3f, 3f);
            gl.Rotate(90f, 1, 0, 0);
            Cylinder target2 = new Cylinder();

            target2.TextureCoords = true;
            target2.TopRadius     = 1;
            target2.CreateInContext(gl);
            target2.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.PopMatrix();
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);

            gl.PushMatrix();
            gl.Translate(0, jumpH + 10 * size, 100 - ballDistance);

            gl.Rotate(jumpR, 0, 0);
            gl.Translate(0, -10 * size, 0);
            gl.Scale(size, size, size);
            gl.Color(0.3f, 0.3f, 0.3f);
            gl.Rotate(-90, 0, 0);
            m_scene.Draw();
            gl.PopMatrix();

            gl.PopMatrix();



            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.PushMatrix();
            gl.Viewport(m_width / 2, 0, m_width / 2, m_height / 2);
            gl.LoadIdentity();

            gl.Ortho2D(-20.0f, 20.0f, -20.0f, 20.0f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LoadIdentity();
            gl.Color(0.5f, 0.1f, 0.1f);
            gl.PushMatrix();
            gl.Translate(5f, -15f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "Predmet:Racunarska grafika");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -15f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "_______________________");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -16f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "Sk.god:2020/21");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -16f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "_____________");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -17f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "Ime:Nastasja");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -17f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "___________");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -18f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "Prezime:Damjanac");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -18f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "_______________");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -19f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "Sifra zad:7.2");
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(5f, -19f, 0f);
            gl.DrawText3D("Tahoma", 10, 1.0f, 0, "__________");
            gl.PopMatrix();

            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.Viewport(0, 0, m_width, m_height);
            gl.PopMatrix();
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            gl.Flush();
        }
예제 #13
0
        //ostale metode
        public void drawScene(OpenGL gl)
        {
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            //gl.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            //gl.Color(1.0f, 1.0f, 1.0f, 1.0f);
            //gl.Color(0.0f, 0.0f, 0.0f, 1.0f);

            //pocetak iscrtavanja
            gl.PushMatrix();

            //kamion
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            gl.Translate(10.0f + pozicijaKamiona[0], -5.0f + pozicijaKamiona[1], -80.0f + pozicijaKamiona[2]);
            gl.Rotate(0.0f, rotacijaKamiona, 0.0f);
            m_scene.Draw();
            gl.PopMatrix();


            //kontejner
            gl.PushMatrix();
            //gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            //gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL);
            gl.Translate(pozicijaKontejnera[0] - 10.0f, pozicijaKontejnera[1] - 5.0f, -80.0f + pozicijaKontejnera[2]);
            gl.Scale(0.05f, 0.05f, 0.05f);
            gl.Rotate(rotacijaKontejnera[0], rotacijaKontejnera[1], rotacijaKontejnera[2]);
            gl.Rotate(rotacijaKontejnera2[0], rotacijaKontejnera2[1], rotacijaKontejnera2[2]);
            gl.Rotate(rotacijaKontejnera3[0], rotacijaKontejnera3[1], rotacijaKontejnera3[2]);
            m_scene2.Draw();
            gl.PopMatrix();


            //gl.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);


            //podloga
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Asphalt]);
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();
            gl.Scale(faktorSkaliranjaPodloge, faktorSkaliranjaPodloge, faktorSkaliranjaPodloge);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            gl.Translate(-80.0f, -5.0f, 0.0f);
            gl.Begin(OpenGL.GL_QUADS);
            gl.Normal(0, 1, 0);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(0.0f, 0.0f, 0.0f);
            gl.TexCoord(0.0f, brojPonavljanjaTeksturePuta);
            gl.Vertex(200.0f, 0.0f, 0.0f);
            gl.TexCoord(brojPonavljanjaTeksturePuta, brojPonavljanjaTeksturePuta);
            gl.Vertex(200.0f, 0.0f, -200.0f);
            gl.TexCoord(brojPonavljanjaTeksturePuta, 0.0f);
            gl.Vertex(0.0f, 0.0f, -200.0f);
            gl.End();
            gl.PopMatrix();


            //zidovi sa strana kontejnera
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Empty]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            gl.Translate(0.0f, 0.0f, -80.0f);
            gl.Scale(1f, 8f, 10f);
            cube = new Cube();
            cube.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            gl.PushMatrix();
            gl.Translate(-25.0f, 0.0f, -80.0f);
            gl.Scale(1f, 8f, 10f);
            cube = new Cube();
            cube.Render(gl, RenderMode.Render);
            gl.PopMatrix();


            //bandera
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Metal]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);

            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();
            gl.Scale(faktorSkaliranjaBandere, faktorSkaliranjaBandere, faktorSkaliranjaBandere);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);


            gl.Translate(20.0f, -5.0f, -80.0f);
            gl.Rotate(-90.0f, 0.0f, 0.0f);
            gl.Scale(cylinderFactor, cylinderFactor, cylinderFactor);
            cylinder            = new Cylinder();
            cylinder.Height     = lampLightPos[1];
            cylinder.BaseRadius = 0.5f;
            cylinder.TopRadius  = 0.5f;
            cylinder.CreateInContext(gl);
            cylinder.Render(gl, RenderMode.Render);
            cylinder.CreateInContext(gl);

            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(lampLightPos[0], lampLightPos[1] - 5.0f, lampLightPos[2]);
            gl.Scale(cubeFactor, cubeFactor, cubeFactor);
            cube = new Cube();
            cube.Render(gl, RenderMode.Render);
            gl.PopMatrix();


            //kraj iscrtavanja
            gl.PopMatrix();
        }
예제 #14
0
        public void DrawCilinder(OpenGL gl)
        {
            float specificCubeHeight;

            specificCubeHeight = targetAnimationHeight;
            //crtanje prve konzerve
            gl.PushMatrix();
            gl.Translate(0.0f, 300.0f + specificCubeHeight, -700.0f);
            gl.Color(0.0f, 0.0f, 0.0f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Rust]);
            gl.Rotate(-90.0f, 0.0f, 0.0f);
            gl.Scale(50, 50, targetValueHeight);
            Cylinder cil = new Cylinder();

            cil.TextureCoords = true;
            cil.TopRadius     = cil.BaseRadius;
            cil.CreateInContext(gl);

            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.PopMatrix();

            //crtanje druge konzerve

            gl.PushMatrix();
            gl.Translate(150.0f, 300.0f + specificCubeHeight, -700.0f);
            gl.Rotate(-90.0f, 0.0f, 0.0f);
            //gl.Color(0.5f, 0.5f, 1.0f);
            gl.Scale(50, 50, targetValueHeight);


            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Rust]);


            Cylinder cil1 = new Cylinder();

            cil1.TopRadius     = cil.BaseRadius;
            cil1.TextureCoords = true;
            cil1.CreateInContext(gl);

            cil1.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);


            gl.PopMatrix();

            //crtanje trece konzerve

            gl.PushMatrix();
            gl.Translate(-150.0f, 300.0f + specificCubeHeight, -700.0f);
            gl.Rotate(-90.0f, 0.0f, 0.0f);
            //gl.Color(0.5f, 0.5f, 1.0f);
            gl.Scale(50, 50, targetValueHeight);

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Rust]);

            gl.TexCoord(1.0f, 0.0f);
            //gl.Translate(0.0f, 200.0f, -1000.0f);
            Cylinder cil2 = new Cylinder();

            cil2.TextureCoords = true;
            cil2.TopRadius     = cil.BaseRadius;
            cil2.CreateInContext(gl);

            cil2.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.PopMatrix();
        }
예제 #15
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.MatrixMode(OpenGL.GL_PROJECTION);

            gl.PushMatrix();

            gl.Viewport(0, 0, m_width, m_height);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            gl.PushMatrix();

            gl.LoadIdentity();
            gl.LookAt(-300, 150, m_sceneDistance, 0, 0, 0, 0, 1, 0); //Pozicioniranje kamere (gore levo ne mnogo od podloge) (6)
            float[] pos = { 0, 120, 0, 1.0f };                       //STACIONARNO SVETLO
            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, pos);     //POZICIJA STACIONARNOG SVETLA


            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);

            #region Bure
            gl.PushMatrix();
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPOT_DIRECTION, new float[] { 0.0f, -1.0f, 0.0f }); //REFLETOR BACA SVETLO NA DOLE, ZASTO OVDE A NE U METODI Z ASVETLO? DA BI SE ROTACIJE PROMENILE I NA OVO

            float[] pos2 = { 200 + lightPositionX, 150, 0f, 1.0f };                                  //IZNAD BURETA I POSOTLJA, ALI SE DODAJE I VREDNOST SLAJDERA KOJI POMERA SVETLO (7)
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, pos2);                                    //REFLEKTOR, POZICIJA
            float[] COLOR = { r, g, b };                                                             //VREDNOST SLAJDERA

            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, COLOR);                                    //SVE KOMPONENTE REFLEKTORSKOG IZVORA PODESI NA ONO STO SLADJERI POKAZUJU (7)
            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, COLOR);
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPECULAR, COLOR);

            gl.Translate(200f + barrelX, 90 + barrelY + barrelY_Free, 0);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD); //EZIM STAPANJA ZA MODEL BURETA : ADD (10)
            gl.Scale(barrelScale, barrelScale, barrelScale);                             //UNIFORMNO SKLAIRANJE ZA PARAMETAR  SA SLAJDERA (7)
            gl.Translate(0, 13.575, 0);                                                  //DONJI DEO U KOORINATNI POCETAK
            gl.Rotate(0f, 0, barrelRotation);                                            //OKRENI ZBOG KOTRLJANJA, barrelRotation JE 0 KAD NEMA ANIMACIJE
            gl.Translate(0, -13.575, 0);                                                 //CENTAR U KOORDIANTNI POCETAK
            m_scene.Draw();
            gl.PopMatrix();
            #endregion

            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);//DECAL ZA SVE OSTALE TEKSTURE

            #region Podloga
            gl.PushMatrix();

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[(int)TextureObjects.Concrete]); //Podloga od betona (5)
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();                                                            // prazna matrica (da se poniste prethodne)

            gl.Scale(6, 6, 6);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Normal(0, 1, 0); // normala na podlogu (2)

            // gl.Translate(-400.0f, -60.0f, 0.0f);
            gl.Rotate(0, 0, 10);
            gl.Scale(55, 1, 55);

            gl.Begin(OpenGL.GL_QUADS);
            gl.Color(0.5f, 0.5f, 0.5f);

            gl.TexCoord(0f, 0f);
            gl.Vertex(-5f, 0.0f, -5f);
            gl.TexCoord(0f, 1f);
            gl.Vertex(-5.0f, 0.0f, 5.0f);
            gl.TexCoord(1f, 1f);
            gl.Vertex(5.0f, 0.0f, 5.0f);
            gl.TexCoord(1f, 0f);
            gl.Vertex(5.0f, 0.0f, -5.0f);
            gl.End();
            gl.PopMatrix();
            #endregion


            #region Rupa
            gl.PushMatrix();

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[(int)TextureObjects.Metal]); //IZABERI METAL
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();                                                         //UCITAJ PRAZNU TEXTURE MATRICU, DA SE PONISTE TRANSFORMACIJE OD RANIEJ AKO IH IMA
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            //gl.Translate(300f, -50f, 250f);
            gl.Translate(-200f, -35f, 0f);
            //gl.Scale(20f, 12f, -20f);
            gl.Rotate(-90, 1, 0, 0);
            gl.Rotate(-10, 0, 1, 0);

            Disk disk = new Disk();
            disk.TextureCoords    = true;
            disk.NormalGeneration = Normals.Smooth;
            disk.Loops            = 120;
            disk.Slices           = 30;
            disk.InnerRadius      = 0f;
            disk.OuterRadius      = 70;
            disk.CreateInContext(gl);
            disk.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.PopMatrix();
            #endregion

            #region Postolje
            gl.PushMatrix();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[(int)TextureObjects.Wood]); //IZABERI DRVO
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.LoadIdentity();                                                        //UCITAJ PRAZNU TEXTURE MATRICU, DA SE PONISTE TRANSFORMACIJE OD RANIEJ AKO IH IMA
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Translate(200, 20, 0);
            gl.Rotate(holderRotation, 0, 0, 1);//ROTIRANJE PRILIKOM ANIMACIJE, U SUPROTNOM JE holderRotation 0
            gl.Rotate(-90f, 0f, 0f);

            Cylinder cil = new Cylinder();
            cil.TextureCoords    = true;
            cil.NormalGeneration = Normals.Smooth;
            cil.BaseRadius       = 70;
            cil.Slices           = 4;
            cil.Height           = 80;
            cil.CreateInContext(gl);
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);

            gl.PopMatrix();
            #endregion

            #region Tekst
            gl.PushMatrix();
            gl.Viewport(0, 0, m_width / 2, m_height / 2);     //donji desni ugao
            gl.DrawText3D("Helvetica", 14, 0, 0, "");
            gl.DrawText(Sirina_prozora - 250, 100, 1.0f, 1.0f, 0.0f, "Helvetica ", 14, "Predmet: Racunarska grafika");
            gl.DrawText(Sirina_prozora - 250, 80, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Sk.god:  2019/20.");
            gl.DrawText(Sirina_prozora - 250, 60, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Ime: Veljko");
            gl.DrawText(Sirina_prozora - 250, 40, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Prezime: Vukovic");
            gl.DrawText(Sirina_prozora - 250, 20, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Sifra zad: 13.1");
            gl.DrawText(Sirina_prozora - 250, 100, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "_______________________");
            gl.DrawText(Sirina_prozora - 250, 80, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "______________");
            gl.DrawText(Sirina_prozora - 250, 60, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "________");
            gl.DrawText(Sirina_prozora - 250, 40, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "______________");
            gl.DrawText(Sirina_prozora - 250, 20, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "___________");
            gl.PopMatrix();
            #endregion


            gl.PopMatrix();
            // Oznaci kraj iscrtavanja
            gl.Flush();
        }
예제 #16
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            // gl.Scale(3.5f, 3.5f, 3.5f);

            gl.PushMatrix();
            SetupLighting(gl);

            // gl.Translate(0.0f, 1.0f, -m_sceneDistance);
            gl.Translate(0.0f, 1.0f, m_sceneDistance);
            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);

            //faza 2 : tacka 6
            gl.LookAt(1.0f, 1.0f, 4.0f,
                      0.0f, 0.0f, 0.0f,
                      0.0f, 5.0f, 0.0f);


            //postolje
            gl.PushMatrix();
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Translate(0.0f, visinaPodloge, 0.0f);
            gl.Rotate(180, 0, 0);
            cylinder.Height     = 1;
            cylinder.BaseRadius = 3.0f;
            cylinder.TopRadius  = 3.0f;
            gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            gl.Color(0.2265625f, 0f, 0.0f);
            gl.Rotate(-90f, 0f, 0f);
            cylinder.CreateInContext(gl);
            gl.FrontFace(OpenGL.GL_CCW);
            cylinder.Render(gl, RenderMode.Render);

            //zatvara se postolje
            gl.PushMatrix();
            // gl.Translate(0.0f, 0.0f, 4.0f);
            gl.Rotate(0.0f, 180.0f, 0.0f);
            Disk disk = new Disk();

            gl.Color(0.2265625f, 0f, 0.0f);
            disk.InnerRadius = 0;
            disk.OuterRadius = 3.0f;
            disk.CreateInContext(gl);
            // faza 2 : tacka 5
            gl.FrontFace(OpenGL.GL_CCW);
            disk.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.PopMatrix();

            //sto
            gl.PushMatrix();
            gl.Translate(0.0f, visinaTable, 0.0f);
            gl.Scale(3.5f, 0.5f, 3.5f);
            gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            gl.Color(0.30859375f, 0.1484375f, 0.07421875f);
            // faza 2 : tacka 4
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Wood]);
            gl.FrontFace(OpenGL.GL_CCW);
            cube.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            Cube c = new Cube();

            gl.Translate(0.0f, -5.0f, 0.0f);
            gl.Scale(0.5f, visinaStola, 0.5f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Wood]);
            gl.FrontFace(OpenGL.GL_CCW);
            c.Render(gl, RenderMode.Render);
            gl.PopMatrix();


            //ono dole, hehe
            gl.PushMatrix();
            Cube s = new Cube();

            gl.Translate(0.0f, visinaPostolja, 0.0f);
            gl.Scale(3.5f, 0.4, 3.5f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Wood]);
            gl.FrontFace(OpenGL.GL_CCW);
            s.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //tepih?


            gl.PushMatrix();
            gl.Translate(5.0f, visinaTepiha, 5.0f);
            gl.Rotate(-90.0f, 180.0f, 0.0f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Carpet]);
            gl.Begin(OpenGL.GL_QUADS);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(0.0f, 0.0f);
            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(0.0f, 5.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(5.0f, 5.0f);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(5.0f, 0.0f);
            gl.End();

            gl.Begin(OpenGL.GL_QUADS);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(0.0f, 5.0f);
            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(0.0f, 10.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(5.0f, 10.0f);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(5.0f, 5.0f);
            gl.End();

            gl.Begin(OpenGL.GL_QUADS);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(5.0f, 5.0f);
            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(5.0f, 10.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(10.0f, 10.0f);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(10.0f, 5.0f);
            gl.End();

            gl.Begin(OpenGL.GL_QUADS);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(5.0f, 0.0f);
            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(5.0f, 5.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(10.0f, 5.0f);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(10.0f, 0.0f);
            gl.End();
            // gl.Enable(OpenGL.GL_CULL_FACE);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Translate(0.0f, visinaMikrotalasne, 0.0f);
            gl.Scale(scale_x, scale_x, scale_x);
            gl.FrontFace(OpenGL.GL_CCW);
            m_scene.Draw();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.PopMatrix();

            // crtanje pljeskavice
            gl.PushMatrix();
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Translate(hranaX, visinaHrane, hranaZ);
            //gl.Translate(5.0f, 0.0f, 0.0f);
            gl.Scale(scale_x, scale_x, scale_x);
            gl.PushMatrix();
            gl.Rotate(0.0f, rotacijaHrane, 0.0f);
            gl.PopMatrix();
            m_scene2.Draw();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Translate(vrataX, visinaVrati, vrataZ);
            gl.Rotate(0.0f, vrataY, 0.0f);
            gl.Scale(scale_x, scale_x, scale_x);
            m_scene_door.Draw();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.PopMatrix();

            gl.PopMatrix();
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Viewport(0, m_width / 2, m_width / 2, m_height / 2);
            gl.PushMatrix();
            gl.Translate(2.0f, -3.5f, 0.0f);
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Ortho2D(-15.0f, 15.0f, -12.0f, 12.0f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            //poruka

            gl.PushMatrix();
            gl.Color(1.0f, 1f, 0.0f);
            gl.Translate(1.5f, -4.0f, 0.0f);


            gl.DrawText3D("Times New Roman Bold", 10, 0.0f, 0.0f, "Predmet: Racunarska grafika");
            gl.Translate(-11.5f, -1.0f, 0.0f);
            gl.DrawText3D("Times New Roman Bold", 10, 1f, 1f, "Sk.god: 2017/18.");
            gl.Translate(-6.370f, -1.0f, 0.0f);
            gl.DrawText3D("Times New Roman Bold", 10, 1f, 1f, "Ime: Vladimir");
            gl.Translate(-5.55f, -1.0f, 0.0f);
            gl.DrawText3D("Times New Roman Bold", 10, 1f, 1f, "Prezime: Jovicic");
            gl.Translate(-6.3f, -1.10f, 0.0f);
            gl.DrawText3D("Times New Roman Bold", 10, 1f, 1f, "Sifra zad: 16.1");
            gl.PopMatrix();

            gl.Viewport(0, 0, m_width, m_height);
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Perspective(45f, (float)m_width / m_height, 1.0f, 20000f);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            // gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.PopMatrix();
            gl.Flush();
        }
예제 #17
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.Viewport(0, 0, m_width, m_height);
            gl.ClearColor(0.2f, 0.2f, 0.2f, 1.0f);

            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            WriteText2(gl);
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.Enable(OpenGL.GL_LIGHTING);

            gl.PushMatrix();

            gl.LookAt(0.0f, 0f, 100.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
            gl.Translate(0.0f, 0.0f, -m_sceneDistance);

            gl.Scale(10f, 10f, 10f);
            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);
            gl.Rotate(m_zRotation, 0.0f, 0.0f, 1.0f);

            gl.Translate(40f, 200f, 0.0f);
            //reflektor
            SetupLighting1(gl);


            //iscrtavanje 1/2jabuke
            //nacin stapanja teksture sa modelom ( sabira teksel sa bojom materijala)
            gl.Color(0.0f, 0.1f, 0.0f, 1.0f);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            gl.PushMatrix();
            gl.Rotate(0.0f + leftFruitRotation, 0.0f, 0.0f);
            gl.PushMatrix();
            gl.Translate(35, -80f, -40f + fruitHeight);
            gl.Rotate(90f - fruitRotation, 0.0f, 0.0f);
            gl.Scale(200f, 200f, 200f);
            m_scene.Draw();
            gl.PopMatrix();


            //iscrtavanje 2/2jabuke
            gl.PushMatrix();
            gl.Rotate(90f, 180f - fruitRotation, 0f);
            gl.Translate(50f, -40f + fruitHeight, -130f);
            gl.Scale(200f, 200f, 200f);
            m_scene.Draw();
            gl.PopMatrix();
            gl.PopMatrix();

            gl.PushMatrix();
            // gl.Rotate(0.0f, 0.0f + leftFruitRotation, 0.0f);
            //iscrtavanje narandza gore
            gl.PushMatrix();

            gl.Rotate(180f, 0f, 0f);
            gl.Translate(-125f, 137f, -50f - fruitHeight);
            gl.Scale(150f, 150f, 150f);
            m_scene2.Draw();
            gl.PopMatrix();
            //iscrtavanje narandza dole
            gl.PushMatrix();
            gl.Rotate(0f, 0f, 0f);
            gl.Translate(-125f, -258f, 12f + fruitHeight);
            gl.Scale(150f, 150f, 150f);
            m_scene2.Draw();
            gl.PopMatrix();
            gl.PopMatrix();
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            //postolja
            gl.PushMatrix();
            gl.Translate(-5.0f, -100.0f, 0.0f);
            gl.Color(0.0f, 0.7f, 0.0f);
            Cylinder cyl = new Cylinder
            {
                TopRadius  = 20f,
                BaseRadius = 20f,
                Height     = 20f + fruitHeight
            };

            cyl.CreateInContext(gl);
            gl.Normal(0.0f, 1.0f, 0.0f);
            cyl.Render(gl, RenderMode.Render);
            Disk disk = new Disk();

            disk.InnerRadius = 0f;
            disk.OuterRadius = 20f;
            disk.CreateInContext(gl);
            gl.Normal(0.0f, 1.0f, 0.0f);
            gl.Translate(0.0f, 0.0f, 20f + fruitHeight);
            disk.Render(gl, RenderMode.Render);
            gl.Normal(0.0f, 1.0f, 0.0f);
            gl.Translate(-150f, -100f, -20f - fruitHeight);
            cyl.Render(gl, RenderMode.Render);
            gl.Translate(0.0f, 0.0f, 20f + fruitHeight);
            gl.Normal(0.0f, 1.0f, 0.0f);
            disk.Render(gl, RenderMode.Render);
            gl.PopMatrix();


            //iscrtavanje podloge

            drawFloor(gl);



            //gl.Color(0.0f, 0.0f, 0.7f);

            //dole zid
            gl.PushMatrix();
            Cube wall = new Cube();

            gl.Translate(-45.0f, 150.0f, 10.0f);
            gl.Scale(200f, 5f, 10f);
            gl.Normal(0f, 1f, 0f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[0]);
            wall.Render(gl, RenderMode.Render);
            //skidanje tekstura
            gl.PopMatrix();
            //gore zid
            gl.PushMatrix();
            gl.Translate(-45.0f, 430.0f, 10.0f);
            gl.Scale(200f, 5f, 10f);
            wall.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //levo zid
            gl.PushMatrix();
            gl.Rotate(0.0f, 0.0f, 90.0f);
            gl.Translate(290.0f, 240.0f, 10.0f);
            gl.Scale(135f, 5f, 10f);
            wall.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //desni zid
            gl.PushMatrix();
            gl.Rotate(0.0f, 0.0f, 90.0f);
            gl.Translate(290.0f, -150.0f, 10.0f);
            gl.Scale(135f, 5f, 10f);
            wall.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //crtanje grid mreze
            gl.PushMatrix();
            gl.Translate(-50f, 250f, 0);
            gl.Scale(40f, 30f, 0f);
            Grid grid = new Grid();

            grid.Render(gl, RenderMode.Design);
            gl.PopMatrix();

            gl.PopMatrix();


            // Oznaci kraj iscrtavanja
            gl.Flush();
        }
예제 #18
0
        private void drawShooting(OpenGL gl)
        {
            if (step == 15)
            {
                step     = 1;
                shooting = false;
                gore     = true;
                dole     = false;
                count    = 0;
                main.animationDone();
                main = null;
            }
            if (zoom >= 600)
            {
                zoom = 600;
            }
            if (zoom <= -300)
            {
                zoom = -300;
            }
            if (m_xRotation <= -20)
            {
                m_xRotation = -17;
            }
            else if (m_xRotation >= 50)
            {
                m_xRotation = 50;
            }

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.MatrixMode(OpenGL.GL_PROJECTION);      // selektuj Projection Matrix

            gl.LoadIdentity();
            gl.Perspective(50.0, (double)m_width / (double)m_height, 0.5, 1500.0);
            gl.LookAt(0f, 0f, 200f, 0f, 0f, -600, 0f, 1f, 0f);

            // Sacuvaj stanje modelview matrice i primeni transformacije
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.PushMatrix();

            gl.PushMatrix();


            gl.Translate(0, 0, zoom);
            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);
            gl.PushMatrix();

            SetupLighting(gl);

            gl.Viewport(0, 0, m_width, m_height);
            gl.PushMatrix();


            //kamera

            #region PODLOGA
            gl.PushMatrix();
            gl.Translate(0.0f, 0f, 0f);
            gl.Color(0.42f, 0.81f, 0.67f);
            //da li treba ovde da se postavi za normalizaciju, ili u inicijalizaciji
            gl.Enable(OpenGL.GL_NORMALIZE);

            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Grass]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);

            gl.LoadIdentity();
            gl.Scale(10, 10, 10);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);

            gl.Begin(OpenGL.GL_QUADS);
            gl.TexCoord(0.0f, 0.0f); gl.Vertex4f(600f, -200f, 1000, 1);
            gl.TexCoord(0.0f, 1.0f); gl.Vertex4f(-600f, -200f, 1000, 1);
            gl.TexCoord(1.0f, 1.0f); gl.Vertex4f(-600f, -200f, -1200, 1);
            gl.TexCoord(1.0f, 0.0f); gl.Vertex4f(600f, -200f, -1200, 1);
            gl.End();
            gl.PopMatrix();
            #endregion
            #region MODEL
            gl.PushMatrix();
            gl.Translate(10.0f, (-191 + scaleBall / 2) + count, -300);
            gl.Translate(-180f / 15 * step, (-20 - ((-191 + scaleBall / 2) + count)) / 15 * step, -430 / 15 * step);
            step++;
            if (gore)
            {
                count += 3;
            }
            if (dole)
            {
                count -= 3;
            }
            rotateBall += rotateBall0;
            gl.Rotate(rotateBall, 0, 1, 0);
            gl.Color(1f, 1f, 1f);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Ball]);
            gl.Scale(scaleBall, scaleBall, scaleBall);
            m_scene.Draw();
            gl.PopMatrix();
            #endregion
            #region GOL
            //levo

            gl.PushMatrix();
            gl.Translate(-180f, -200f, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Rotate(-90, 1.0f, 0.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil1 = new Cylinder();
            cil1.Slices        = 50;
            cil1.Height        = 40;
            cil1.BaseRadius    = 2;
            cil1.TopRadius     = 2;
            cil1.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil1.CreateInContext(gl);
            cil1.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //desno
            gl.PushMatrix();
            gl.Translate(180f, -200, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Rotate(-90, 1.0f, 0.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil2 = new Cylinder();
            cil2.Slices        = 50;
            cil2.Height        = 40;
            cil2.BaseRadius    = 2;
            cil2.TopRadius     = 2;
            cil2.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil2.CreateInContext(gl);
            cil2.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //gore
            gl.PushMatrix();
            gl.Translate(-192f, 0f, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil3 = new Cylinder();
            cil3.Height        = 76.8;
            cil3.Slices        = 50;
            cil3.BaseRadius    = 2;
            cil3.TopRadius     = 2;
            cil3.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil3.CreateInContext(gl);
            cil3.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //iza levo dole
            gl.PushMatrix();
            gl.Translate(-180f, -190f, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(180, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil4 = new Cylinder();
            cil4.Height        = 20;
            cil4.Slices        = 50;
            cil4.BaseRadius    = 2;
            cil4.TopRadius     = 2;
            cil4.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil4.CreateInContext(gl);
            cil4.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //iza desno dole
            gl.PushMatrix();
            gl.Translate(180f, -190f, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(180, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil5 = new Cylinder();
            cil5.Height        = 20;
            cil5.Slices        = 50;
            cil5.BaseRadius    = 2;
            cil5.TopRadius     = 2;
            cil5.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil5.CreateInContext(gl);
            cil5.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //iza dole
            gl.PushMatrix();
            gl.Translate(-190f, -195f, -700);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil6 = new Cylinder();
            cil6.Height        = 74.5;
            cil6.Slices        = 50;
            cil6.BaseRadius    = 1;
            cil6.TopRadius     = 1;
            cil6.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil6.CreateInContext(gl);
            cil6.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //iza gore
            gl.PushMatrix();
            gl.Translate(-190f, -25f, -700);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil11 = new Cylinder();
            cil11.Height        = 74.5;
            cil11.Slices        = 50;
            cil11.BaseRadius    = 1;
            cil11.TopRadius     = 1;
            cil11.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil11.CreateInContext(gl);
            cil11.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //levo iza dole
            gl.PushMatrix();
            gl.Translate(-180f, -200f, -690);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Rotate(-90, 1.0f, 0.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil7 = new Cylinder();
            cil7.Slices        = 50;
            cil7.Height        = 35;
            cil7.BaseRadius    = 1;
            cil7.TopRadius     = 1;
            cil7.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil7.CreateInContext(gl);
            cil7.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            //desno iza dole
            gl.PushMatrix();
            gl.Translate(180f, -200f, -690);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Rotate(-90, 1.0f, 0.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil8 = new Cylinder();
            cil8.Slices        = 50;
            cil8.Height        = 35;
            cil8.BaseRadius    = 1;
            cil8.TopRadius     = 1;
            cil8.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil8.CreateInContext(gl);
            cil8.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //desno iza gore
            gl.PushMatrix();
            gl.Translate(180f, 0, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Rotate(90, 1.0f, 0.0f, 0.0f);
            gl.Rotate(75, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil9 = new Cylinder();
            cil9.Slices        = 50;
            cil9.Height        = 22;
            cil9.BaseRadius    = 1;
            cil9.TopRadius     = 1;
            cil9.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil9.CreateInContext(gl);
            cil9.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //desno iza gore
            gl.PushMatrix();
            gl.Translate(-180f, 0, -600);
            gl.Scale(5, 5, 5);
            gl.Rotate(90, 0.0f, 1.0f, 0.0f);
            gl.Rotate(90, 1.0f, 0.0f, 0.0f);
            gl.Rotate(75, 0.0f, 1.0f, 0.0f);
            gl.Color(0.5f, 0.5f, 0.5f);

            Cylinder cil10 = new Cylinder();
            cil10.Slices        = 50;
            cil10.Height        = 22;
            cil10.BaseRadius    = 1;
            cil10.TopRadius     = 1;
            cil10.TextureCoords = true;
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Plastic]);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD);
            cil10.CreateInContext(gl);
            cil10.Render(gl, RenderMode.Render);
            gl.PopMatrix();
            gl.PopMatrix();
            #endregion
            #region TEKST
            gl.PushMatrix();
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            gl.Color(0, 0, 0);
            gl.Viewport(m_width - 200, m_height - 150, 200, 150);
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Ortho2D(-5.0, 10.0, 0, 6.0);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LoadIdentity();
            gl.PushMatrix();
            gl.Color(0, 0, 0);
            String[] tekst = { "Predmet: Racunarska grafika", "Sk.god: 2017/18", "Ime: Nina", "Prezime: Miladinovic", "Sifra zad: 9.2" };
            for (int i = 0; i < tekst.Length; i++)
            {
                gl.PushMatrix();
                gl.Translate(-5.0f, 5.0f - i, 0f);
                gl.DrawText3D("Arial Bold", 10f, 1f, 0.1f, tekst[i]);
                gl.PopMatrix();
            }
            gl.PopMatrix();
            gl.PopMatrix();

            #endregion
            gl.PopMatrix();
            gl.PopMatrix();
            gl.PopMatrix();
            gl.Flush();
        }
예제 #19
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.Viewport(0, 0, m_width, m_height);

            gl.PushMatrix();
            gl.LookAt(-m_sceneDistance, 0f, 0f, 0f, 0f, 0, 0f, 1f, 0f);//sa leve strane je - deo X-ose
            // gl.Translate(0.0f, 0.0f, -m_sceneDistance);
            gl.Rotate(m_xRotation, 0.0f, 0.0f, 1.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);

            ///REFLEKTOR
            float[] rc = new float[] { r, g, b, 1.0f };

            //BOJA REGLEKTORA
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, rc);
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, rc);
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPECULAR, rc);

            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, new float[] { 0, 100, 195, 1.0f });       //svetlo iznad mola
            gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPOT_DIRECTION, new float[] { 0.0f, -1.0f, 0.0f }); //sija na dole

            //podloga vode
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.WATER]); //VODA ZA PODLOGU
            //bindujemo teksturu
            gl.MatrixMode(OpenGL.GL_TEXTURE);                                            // UINUTAR TEXT MATRICE SE SKALIRA ,mora da bi mogle transformacije sa teksturama
            gl.PushMatrix();                                                             //unutar texture space se sad sve ovo radi
            gl.Scale(10, 10, 1);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);                                          //vracamo na model view

            gl.PushMatrix();
            //gl.Translate(0.0f, 0.0f, -120f);
            gl.Begin(OpenGL.GL_QUADS);
            gl.Normal(0f, 1f, 0f); //normala za podlogu
            gl.Color(0.0f, 0.0f, 1.0f);
            gl.TexCoord(0f, 0f);   //koordinate teksture za podlogu
            gl.Vertex(200f, -0.5f, -200f);
            gl.TexCoord(0f, 1f);
            gl.Vertex(-200f, -0.5f, -200f);
            gl.TexCoord(1f, 1f);
            gl.Vertex(-200f, -0.5f, 200f);
            gl.TexCoord(1f, 0f);
            gl.Vertex(200f, -0.5f, 200f);
            gl.End();
            gl.PopMatrix();
            gl.MatrixMode(OpenGL.GL_TEXTURE);
            gl.PopMatrix();
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.WOOD]); //drvo za mol i stubove

            if (Modulate)
            {
                gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            }


            gl.Translate(0.0f, 0.0f, 120f);
            //cube
            Cube cube = new Cube();

            gl.PushMatrix();
            gl.Color(0.5f, 0.5f, 0.5f);
            gl.Translate(0.0f, 20.0f, 70.0f);
            gl.Scale(30.0f, 5.0f, 30.0f); //dimenzije
            cube.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            //gl.Scale(size, size, size); //dimenzije

            //cilindar1
            gl.PushMatrix();
            gl.Translate(-20.0f, -2.0f, 90.0f);
            gl.Translate(0, 25, 0);     //I VRATI ZA 25 NA GORE DA GORNNJA IVICA BUDE ISPOD KOCKE (3)
            gl.Scale(size, size, size); //SKLIARA SE ZA ONO SA SLEJDERA (2)
            gl.Translate(0, -25, 0);    //VISINA IM JE 25, ZATO -25 DA BUDE GORANJA IVICA NA 0 JER TADA SKALIRANJE SIRI STUB SAMO DOLE (1)

            gl.Rotate(-90f, 0f, 0f);

            gl.Scale(5.0f, 5.0f, 5.0f); //dimenzije
            Cylinder cil = new Cylinder();

            cil.TextureCoords = true;//KOORDIANTE TEKSTURA ZA CILINDRE
            cil.CreateInContext(gl);
            cil.BaseRadius = 0.5;
            cil.Height     = 5;
            cil.TopRadius  = 0.5;
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //cilindar2
            gl.PushMatrix();
            gl.Translate(20.0f, -2.0f, 90.0f);
            gl.Translate(0, 25, 0);
            gl.Scale(size, size, size);//SKALIRANJE
            gl.Translate(0, -25, 0);
            gl.Rotate(-90f, 0f, 0f);
            gl.Scale(5.0f, 5.0f, 5.0f); //dimenzije
            cil.CreateInContext(gl);
            cil.BaseRadius = 0.5;
            cil.Height     = 5;
            cil.TopRadius  = 0.5;
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //cilindar3
            gl.PushMatrix();
            gl.Translate(20.0f, -2.0f, 50.0f);
            gl.Translate(0, 25, 0);
            gl.Scale(size, size, size);//SKALIRANJE
            gl.Translate(0, -25, 0);
            gl.Rotate(-90f, 0f, 0f);
            gl.Scale(5.0f, 5.0f, 5.0f); //dimenzije
            cil.CreateInContext(gl);
            cil.BaseRadius = 0.5;
            cil.Height     = 5;
            cil.TopRadius  = 0.5;
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //cilindar4
            gl.PushMatrix();
            gl.Translate(-20.0f, -2.0f, 50.0f);
            gl.Translate(0, 25, 0);
            gl.Scale(size, size, size);//SKALIRANJE
            gl.Translate(0, -25, 0);
            gl.Rotate(-90f, 0f, 0f);
            gl.Scale(5.0f, 5.0f, 5.0f); //dimenzije
            cil.CreateInContext(gl);
            cil.BaseRadius = 0.5;
            cil.Height     = 5;
            cil.TopRadius  = 0.5;
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();


            //cube stepenice(vrata)
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.METAL]); //metal za stepenice
            gl.PushMatrix();
            gl.Translate(0.0f + shipOffsetX, 0.0f, 50.0f + shipOffsetZ);                 //pomera brod
            gl.Rotate(0, shipRotation, 0);
            Cube cubeStairs = new Cube();

            gl.PushMatrix();
            gl.Color(0.5f, 0.50f, 0.50f);
            gl.Translate(0.0f, stairsY, -53.0f); //poemri da se ivica poklopi sa brodom, stairsY KAD NEMA ANIMACIJE JE 40, TOKOM ANIMACIJE JE NA POCETKU -20 KASNIJE SE PODIZE
            gl.Rotate(-stairs, 1f, 0.0f, 0.0f);  //ROTIRA ZA ONO SA SLAJDERA, TOKOM ANIMACIJE SE ISTO OVO MENJA
            gl.Scale(30.0f, 1.0f, 30.0f);        //dimenzije
            gl.Translate(0, 1, 1);               //pomeri se da bi se skalirao samo na gore u prema molu
            cube.Render(gl, RenderMode.Render);
            gl.PopMatrix();

            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD); //za brod je stapanje ADD
            gl.Translate(-20.0f, 0f, 0.0f);                                              //priblizi se brod molu
            gl.Color(0.5f, 0.50f, 0.50f);

            gl.Scale(0.2f, 0.32f, 0.32f);
            m_scene.Draw();

            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_DECAL); //ZA OSTALO OPET VRATIMO NA DECAL
            gl.PopMatrix();



            gl.PopMatrix();
            // Oznaci kraj iscrtavanja
            //Tekst
            gl.PushMatrix();
            gl.DrawText(m_width - 200, 90, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Predmet:Racunarska grafika");
            gl.DrawText(m_width - 200, 90, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "_______________________");
            gl.DrawText(m_width - 200, 70, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Sk.god: 2020/21.");
            gl.DrawText(m_width - 200, 70, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "______________");
            gl.DrawText(m_width - 200, 50, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Ime: Maja ");
            gl.DrawText(m_width - 200, 50, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "________");
            gl.DrawText(m_width - 200, 30, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Prezime: Dragojlovic");
            gl.DrawText(m_width - 200, 30, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "________________");
            gl.DrawText(m_width - 200, 10, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "Sifra zad: 10.1");
            gl.DrawText(m_width - 200, 10, 1.0f, 1.0f, 0.0f, "Helvetica", 14, "____________");
            gl.PopMatrix();
            gl.Flush();
        }
예제 #20
0
        public void loadTarget(OpenGL gl)
        {
            gl.PushMatrix();
            gl.Translate(targetX, targetY, 600f);
            gl.Scale(30f + skaliranjeMeta, 100f + skaliranjeMeta, 30f + skaliranjeMeta);
            gl.Rotate(-90f, 1, 0, 0);

            Glu.gluQuadricTexture(gluObject, 1);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.METAL]);

            gl.Color(0.184f, 0.310f, 0.310);
            Cylinder target = new Cylinder();

            target.NormalOrientation = Orientation.Outside;
            target.TopRadius         = 1;
            target.CreateInContext(gl);
            target.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();


            gl.PushMatrix();
            gl.Translate(1300f, 150f, 350f);
            gl.Scale(30f + skaliranjeMeta, 100f + skaliranjeMeta, 30f + skaliranjeMeta);
            gl.Rotate(-90f, 1, 0, 0);
            gl.Color(0.184f, 0.310f, 0.310);
            Cylinder target1 = new Cylinder();

            target1.NormalOrientation = Orientation.Outside;
            target1.TopRadius         = 1;
            target1.CreateInContext(gl);
            target1.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(1300f, 150f, 100f);
            gl.Scale(30f + skaliranjeMeta, 100f + skaliranjeMeta, 30f + skaliranjeMeta);
            gl.Rotate(-90f, 1, 0, 0);
            gl.Color(0.184f, 0.310f, 0.310);
            Cylinder target2 = new Cylinder();

            target2.NormalOrientation = Orientation.Outside;
            target2.TopRadius         = 1;
            target2.CreateInContext(gl);
            target2.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(targetX1, targetY1, 950f);
            gl.Scale(30f + skaliranjeMeta, 100f + skaliranjeMeta, 30f + skaliranjeMeta);
            gl.Rotate(-90f, 1, 0, 0);
            gl.Color(0.184f, 0.310f, 0.310);
            Cylinder target3 = new Cylinder();

            target3.NormalOrientation = Orientation.Outside;
            target3.TopRadius         = 1;
            target3.CreateInContext(gl);
            target3.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();


            gl.PushMatrix();
            gl.Translate(targetX2, targetY2, 1200f);
            gl.Scale(30f + skaliranjeMeta, 100f + skaliranjeMeta, 30f + skaliranjeMeta);
            gl.Rotate(-90f, 1, 0, 0);
            gl.Color(0.184f, 0.310f, 0.310);
            Cylinder target4 = new Cylinder();

            target4.NormalOrientation = Orientation.Outside;
            target4.TopRadius         = 1;
            target4.CreateInContext(gl);
            target4.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();
        }
예제 #21
0
        public void Draw(OpenGL gl)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();


            //gl.Translate(m_spotPosition[0], m_spotPosition[1], m_spotPosition[2]);

            if (perspectiveFPS == false)
            {
                gl.Translate(0.0f, 0.0f, -m_sceneDistance);
                gl.Rotate(35, 0, 0);
            }
            else
            {
                gl.LookAt(xx, yy, zz, lookAtCenterX, 0, lookAtCenterZ, 0, 1, 0);
            }


            //lamp
            gl.PushMatrix();
            sphereLamp = new Sphere();
            sphereLamp.CreateInContext(gl);
            sphereLamp.Radius = 0.5f;
            gl.Color(Color.Yellow);
            gl.Translate(0, 300, 0);
            gl.Scale(20, 20, 20);
            sphereLamp.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();


            gl.Rotate(m_xRotation, 1.0f, 0.0f, 0.0f);
            gl.Rotate(m_yRotation, 0.0f, 1.0f, 0.0f);


            //cylinder
            gl.PushMatrix();
            cil = new Cylinder();
            gl.Translate(-110, 0, 60);
            gl.Rotate(-90f, 0f, 0f);
            gl.Scale(30, 30, 30);
            cil.TopRadius = 0;
            gl.Color(0.1, 0.4, 0.4);
            cil.CreateInContext(gl);
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //cylinder 2
            gl.PushMatrix();
            cil = new Cylinder();
            gl.Translate(140, 0, -110);
            gl.Rotate(-90f, 0f, 0f);
            gl.Scale(20, 30, 30);
            cil.TopRadius = 0;
            gl.Color(0.2, 0.4, 0.7);
            cil.CreateInContext(gl);
            cil.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();



            //backing
            gl.PushMatrix();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Pod]);
            gl.Begin(OpenGL.GL_QUADS);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(-200.0f, 0, 200.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(200.0f, 0, 200.0f);
            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(200.0f, 0, -200.0f);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(-200.0f, 0, -200.0f);
            gl.Disable(OpenGL.GL_TEXTURE_2D);

            gl.Vertex(-200.0f, -1, -200.0f);
            gl.Vertex(200.0f, -1, -200.0f);
            gl.Vertex(200.0f, -1, 200.0f);
            gl.Vertex(-200.0f, -1, 200.0f);


            gl.End();
            gl.PopMatrix();

            //right wall
            gl.PushMatrix();
            cube = new Cube();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Zid]);
            gl.Translate(180, 45, -2);
            gl.Scale(5, 45, 182.5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //desni mali zid - desna soba
            gl.PushMatrix();
            cube = new Cube();
            gl.Translate(80, 45, -95);
            gl.Scale(5, 45, 20);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            cube = new Cube();
            gl.Translate(80, 45, 60);
            gl.Scale(5, 45, 70);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            cube = new Cube();
            gl.Translate(20, 45, -20);
            gl.Scale(5, 45, 90);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //left wall
            gl.PushMatrix();
            gl.Translate(-180, 45, -2);
            gl.Scale(5, 45, 182.5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //drugi levi - leva sobe
            gl.PushMatrix();
            gl.Translate(-40, 45, 60);
            gl.Scale(5, 45, 70);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //back wall
            gl.PushMatrix();
            gl.Translate(2, 45, 180);
            gl.Scale(182.5, 45, 5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //zadnji - leva soba
            gl.PushMatrix();
            gl.Translate(-110, 45, -5);
            gl.Scale(70, 45, 5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();



            //zadnji - desna soba
            gl.PushMatrix();
            gl.Translate(130, 45, -80);
            gl.Scale(50, 45, 5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            //front wall
            gl.PushMatrix();
            gl.Translate(2, 45, -180);
            gl.Scale(182.5, 45, 5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(-18, 45, -110);
            gl.Scale(100, 45, 5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(20, 45, 130);
            gl.Scale(65, 45, 5);
            cube.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();
            gl.Disable(OpenGL.GL_TEXTURE_2D);



            //candle lamp
            gl.PushMatrix();
            sphereCandle = new Sphere();
            gl.Translate(xCandle, yCandle + 29, zCandle);
            sphereCandle.CreateInContext(gl);
            sphereCandle.Material         = new SharpGL.SceneGraph.Assets.Material();
            sphereCandle.Material.Diffuse = Color.Orange;
            sphereCandle.Radius           = 0.2f;
            gl.Color(Color.Orange);
            gl.Scale(15 * scaleCandleSphere, 15 * scaleCandleSphere, 15 * scaleCandleSphere);
            sphereCandle.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(xCandle, yCandle - 1, zCandle);
            gl.Scale(0.1, 0.1, 0.1);
            //gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_MODULATE);
            plate_scene.Draw();
            gl.PopMatrix();

            gl.PushMatrix();
            gl.Translate(xCandle, yCandle, zCandle);
            gl.Rotate(0, rotateCandle, 0);
            candle_scene.Draw();
            gl.PopMatrix();



            gl.DrawText(m_width - 250, 100, 1, 0, 0, "Arial bold", 14, "Predmet: Racunarska grafika");
            gl.DrawText(m_width - 250, 80, 1, 0, 0, "Arial bold", 14, "Skolska godina: 2018/19");
            gl.DrawText(m_width - 250, 60, 1, 0, 0, "Arial bold", 14, "Ime: Srecko");
            gl.DrawText(m_width - 250, 40, 1, 0, 0, "Arial bold", 14, "Prezime: Stojic");
            gl.DrawText(m_width - 250, 20, 1, 0, 0, "Arial bold", 14, "Sifra zadatka: 14.1");


            gl.Flush();
        }