public void DrawBullet(OpenGL gl) { gl.PushMatrix(); gl.Translate(0.0f, 400.0f, 450.0f + bulletAnimationPosition); gl.Scale(bulletCaliber, bulletCaliber, 10); gl.Color(1.0f, 0.0f, 1.0f); m_bullet.Draw(); gl.PopMatrix(); }
private void DrawFormula1(OpenGL gl) // Levi bolid { gl.PushMatrix(); if (Anim == 1) { gl.Translate(0f, 0f, PomerajLeve); } gl.Translate(-0.5f, -1f, 4f); // -4 float[] light1pos = new float[] { 0f, 0.9f, 0f, 1.0f }; // iznad levog bolida gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION, light1pos); float[] smer = { 0.0f, -1.0f, 0.0f }; gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_SPOT_DIRECTION, smer); gl.Scale(0.4f, 0.4f, 0.4f); gl.Rotate(0.0f, lb_rotate, 0.0f); // gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_DECAL); // GL_DECAL formula1.Draw(); gl.PopMatrix(); }
/// <summary> /// Draws pistol model /// </summary> /// <param name="gl"></param> public void DrawPistol(OpenGL gl) { gl.PushMatrix(); { gl.MatrixMode(OpenGL.GL_TEXTURE); gl.Disable(OpenGL.GL_TEXTURE_2D); gl.PushMatrix(); { gl.MatrixMode(OpenGL.GL_MODELVIEW); gl.Translate(0.0f, 250.0f, 650.0f + pistolAnimationPosition); gl.Rotate(pistolRotation, 0.0f, 0.0f); gl.Scale(1.2f, 1.2f, 1.2f); gl.TexCoord(1.0f); m_scene.Draw(); gl.MatrixMode(OpenGL.GL_TEXTURE); gl.Enable(OpenGL.GL_TEXTURE_2D); } gl.PopMatrix(); gl.MatrixMode(OpenGL.GL_MODELVIEW); } gl.PopMatrix(); }
private void DrawFormula2(OpenGL gl) { if (Anim == 1) { gl.Translate(0f, 0f, PomerajDesne); } gl.PushMatrix(); gl.Translate(0.5f, -1f, 4f); gl.Translate(db_translate, 0f, 0f); // float[] light2pos = new float[] { 0f, 0.9f, 0f, 1.0f }; // iznad desnog bolida gl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_POSITION, light2pos); float[] smer = { 0.0f, -1.0f, 0.0f }; gl.Light(OpenGL.GL_LIGHT2, OpenGL.GL_SPOT_DIRECTION, smer); gl.Scale(0.003f, 0.003f, 0.003f); gl.Rotate(0.0f, -90f, 0f); // gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_DECAL); // GL_DECAL formula2.Draw(); gl.PopMatrix(); }
public void Draw(OpenGL gl) { tackastiIzvor(gl); reflektorskiIzvor(gl); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); lookAtCam.Position = new Vertex(0, 180, rastojanjeKamere); //gl.Viewport(width / 2, 0, width / 2, height / 2); //gl.MatrixMode(OpenGL.GL_PROJECTION); //gl.LoadIdentity(); ////gl.Ortho(0f,20.0f,0f,20f,-1.0f,1.0f); //gl.Ortho2D(-15.0f, 13f, -4.1f, 12f); //gl.MatrixMode(OpenGL.GL_MODELVIEW); //gl.PushMatrix(); //gl.Color(1.0f, 1.0f, 0f); //gl.DrawText3D("Arial Bold", 25f, 0f, 0f, "Predmet: Racunarska grafika"); //gl.PopMatrix(); //gl.Viewport(width / 2, 0, width / 2, height / 2); //gl.MatrixMode(OpenGL.GL_PROJECTION); //gl.LoadIdentity(); ////gl.Ortho(0f,20.0f,0f,20f,-1.0f,1.0f); //gl.Ortho2D(-15.0f, 13f, -3.1f, 13f); //gl.MatrixMode(OpenGL.GL_MODELVIEW); //gl.PushMatrix(); //gl.Color(1.0f, 1.0f, 0f); //gl.DrawText3D("Arial Bold", 14f, 0f, 0f, "Sk.god: 2016/17"); //gl.PopMatrix(); //gl.Viewport(width / 2, 0, width / 2, height / 2); //gl.MatrixMode(OpenGL.GL_PROJECTION); //gl.LoadIdentity(); ////gl.Ortho(0f,20.0f,0f,20f,-1.0f,1.0f); //gl.Ortho2D(-15.0f, 13f, -2.1f, 14f); //gl.MatrixMode(OpenGL.GL_MODELVIEW); //gl.PushMatrix(); //gl.Color(1.0f, 1.0f, 0f); //gl.DrawText3D("Arial Bold", 14f, 0f, 0f, "Ime: Zlatan"); //gl.PopMatrix(); //gl.Viewport(width / 2, 0, width / 2, height / 2); //gl.MatrixMode(OpenGL.GL_PROJECTION); //gl.LoadIdentity(); ////gl.Ortho(0f,20.0f,0f,20f,-1.0f,1.0f); //gl.Ortho2D(-15f, 13f, -1.1f, 15f); //gl.MatrixMode(OpenGL.GL_MODELVIEW); //gl.PushMatrix(); //gl.Color(1.0f, 1.0f, 0f); //gl.DrawText3D("Arial Bold", 14f, 0f, 0f, "Prezime: Precanica"); //gl.PopMatrix(); //gl.Viewport(width / 2, 0, width / 2, height / 2); //gl.MatrixMode(OpenGL.GL_PROJECTION); //gl.LoadIdentity(); ////gl.Ortho(0f,20.0f,0f,20f,-1.0f,1.0f); //gl.Ortho2D(-15.0f, 13f, -0.1f, 16f); //gl.MatrixMode(OpenGL.GL_MODELVIEW); //gl.PushMatrix(); //gl.Color(1.0f, 1.0f, 0f); //gl.DrawText3D("Arial Bold", 14f, 0f, 0f, "Sifra zad: 13.2"); //gl.PopMatrix(); ////iznad tekst /* * gl.Enable(OpenGL.GL_CULL_FACE); * //barrel * gl.LoadIdentity(); * * gl.PushMatrix(); * * gl.Translate(0.0f, 0.0f, -sceneDistance); * gl.Rotate(xRotation, 1.0f, 0.0f, 0.0f); * gl.Rotate(yRotation, 0.0f, 1.0f, 0.0f); * * gl.PushMatrix(); * * gl.Color(1f, 1f, 1f, 1f); * * tackastiIzvor(gl); * * gl.PushMatrix(); * * gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Drvo]); * gl.Color(0.5f, 0.2f, 0.0f); * Cube kocka = new Cube(); * gl.Translate(400, 100, 0); * gl.Scale(100, 100, 100); * kocka.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); * * gl.Translate(0, 180, -110); * gl.Rotate(90, 1.0f, 0.0f, 0.0f); * scene.Draw(); * * gl.PopMatrix(); * * gl.PushMatrix(); * * gl.Disable(OpenGL.GL_CULL_FACE); * * gl.Translate(-500.0f, 1.0f, 0.0f); * gl.Rotate(-90, 1.0f, 0.0f, 0.0f); * * gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Metal]); * * gl.Color(0, 0, 0); * * Disk obod = new Disk(); * obod.InnerRadius =180f; * obod.OuterRadius = 200.0f; * obod.Slices = 100; * obod.Loops = 100; * * obod.CreateInContext(gl); * obod.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); * * Disk disk = new Disk(); * disk.TextureCoords = true; * disk.InnerRadius = 0.0f; * disk.OuterRadius = 180.0f; * disk.Slices = 100; * disk.Loops = 100; * * disk.CreateInContext(gl); * disk.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); * * gl.PopMatrix(); * * gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Beton]); * gl.Color(0.2f,0.2f,0.2f); * //podloga koja predstavlja more, uvek idu iste dimenzije, i ide -+, ++, +-, -- za x i z * gl.Begin(OpenGL.GL_QUADS); * gl.Normal(0f, 1f, 0f); * //gl.Color(0.0f, 0.7f, 1.0f); * gl.TexCoord(0.0f, 0.0f); * gl.Vertex(-800, -0.0, 800); * gl.TexCoord(0.0f, 1.0f); * gl.Vertex(800, -0.0, 800); * gl.TexCoord(1.0f, 1.0f); * gl.Vertex(800, -0.0, -800); * gl.TexCoord(1.0f, 0.0f); * gl.Vertex(-800, -0.0, -800); * * gl.End(); * * gl.Enable(OpenGL.GL_CULL_FACE); * * gl.PopMatrix(); * * gl.PopMatrix(); * * gl.Flush(); */ //ELEMENTI gl.Viewport(0, 0, width, height); //gl.MatrixMode(OpenGL.GL_PROJECTION); //gl.LoadIdentity(); //gl.Perspective(60f, (double)width / height, 1.0f, 20000f); //gl.MatrixMode(OpenGL.GL_MODELVIEW); gl.PushMatrix(); lookAtCam.Project(gl); gl.MatrixMode(OpenGL.GL_MODELVIEW); //gl.Translate(0.0f, 0.0f, -sceneDistance); gl.Rotate(xRotation, 1.0f, 0.0f, 0.0f); gl.Rotate(yRotation, 0.0f, 1.0f, 0.0f); gl.PushMatrix(); //iscrtavanje Podloge gl.PushMatrix(); //TODO 5 Texture podloge gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Beton]); gl.Color(0.1, 0.1, 0.1); gl.Begin(OpenGL.GL_QUADS); gl.Normal(0f, 1f, 0f); gl.TexCoord(0.0f, 0.0f); gl.Vertex(-800.0f, 0.0f, 800.0f); gl.TexCoord(0.0f, 1.0f); gl.Vertex(800.0f, 0.0f, 800.0f); gl.TexCoord(1.0f, 1.0f); gl.Vertex(800.0f, 0.0f, -800.0f); gl.TexCoord(1.0f, 0.0f); gl.Vertex(-800.0f, 0.0f, -800.0f); gl.End(); gl.PopMatrix(); //iscrtavanje Bureta gl.PushMatrix(); //TODO 10 Način stapanja teksture sa materijalom za model bureta postaviti na GL_ADD gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Drvo]); //Način stapanja teksture sa materijalom za modelburetapostaviti na GL_ADD. gl.TexEnv(OpenGL.GL_TEXTURE_ENV, OpenGL.GL_TEXTURE_ENV_MODE, OpenGL.GL_ADD); gl.Translate(bureX, bureY, -110); gl.Rotate(90, 1.0f, 0.0f, 0.0f); gl.Rotate(rotirajBure, 0.0f, 1.0f, 0.0f); gl.Scale(1.0f, faktorSkaliranjaBureta, 1.0f); gl.Color(0.5f, 0.2f, 0.0f); scene.Draw(); gl.PopMatrix(); //iscrtavanje Kocke //tekstura cube gl.PushMatrix(); //TODO 4 Texture gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Drvo]); gl.Color(0.2f, 0.1f, 0.0f); gl.Translate(420, 100, 30); Cube kocka = new Cube(); gl.Scale(150, 100, 140); kocka.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); gl.PopMatrix(); //padina gl.PushMatrix(); gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Drvo]); gl.Color(0.2f, 0.1f, 0.0f); gl.Translate(-35, 95, 0); gl.Rotate(15, 0.0f, 0.0f, 1.0f); Cube letva = new Cube(); gl.Scale(350, 10, 80); kocka.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); gl.PopMatrix(); //drzac gl.PushMatrix(); gl.Color(0f, 0f, 0f); gl.Translate(360, 180, 30); gl.Rotate(ugaoDrzaca, 0.0, 0.0, 1.0); Cube drzac = new Cube(); gl.Scale(5, 80, 100); drzac.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); gl.PopMatrix(); //iscrtavanje Diska gl.PushMatrix(); gl.BindTexture(OpenGL.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Metal]); gl.Color(0.0f, 0.0f, 0.0f); gl.Translate(-500.0f, 1.0f, 0.0f); gl.Rotate(-90, 1.0f, 0.0f, 0.0f); Disk disk = new Disk(); disk.TextureCoords = true; disk.InnerRadius = 0.0f; disk.OuterRadius = 200.0f; disk.Slices = 100; disk.Loops = 100; disk.CreateInContext(gl); disk.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); gl.PopMatrix(); gl.PushMatrix(); gl.Translate(-500.0f, 1.0f, 0.0f); gl.Rotate(-90, 1.0f, 0.0f, 0.0f); Disk obod = new Disk(); obod.InnerRadius = 200f; obod.OuterRadius = 210.0f; obod.Slices = 100; obod.Loops = 100; obod.CreateInContext(gl); obod.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render); gl.PopMatrix(); gl.PopMatrix(); //iscrtani elementi for (int i = 0; i < m_bitmapText.Length; i++) { gl.DrawText(800, 100 - i * 15, 10.0f, 10.0f, 0.0f, "Arial Bold", 14, m_bitmapText[i]); } gl.PopMatrix(); //rotacije gl.Flush(); }