public void drawMap() { GList = new List <Int32>(); GList.Add(0); foreach (Objects.Plane plane in map.planes) { GL.NewList(GList.Count, ListMode.Compile); GL.BindTexture(TextureTarget.Texture2D, Engine.Texture.LoadTexture(plane.textureName, plane.repeat, plane.rotate)); GL.Color3(plane.color); foreach (Objects.Rectangle rectangle in plane.rectangles) { GL.Begin(BeginMode.Polygon); for (int i = 0; i < rectangle.points.Count; i++) { if (i == 0) { GL.TexCoord2(0, 0); } if (i == 1) { GL.TexCoord2(1, 0); } if (i == 2) { GL.TexCoord2(1, 1); } if (i == 3) { GL.TexCoord2(0, 1); } GL.Vertex3(rectangle.points[i][0], rectangle.points[i][1], rectangle.points[i][2]); } GL.End(); } GL.EndList(); GList.Add(GList.Count); } foreach (Objects.Sphere sphere in map.spheres) { GL.NewList(GList.Count, ListMode.Compile); GL.PushMatrix(); GL.Color3(sphere.color); IntPtr q = Glu.NewQuadric(); GL.Translate(sphere.position[0], sphere.position[1], sphere.position[2]); Glu.Sphere(q, sphere.radio, 100, 100); GL.Translate(-sphere.position[0], -sphere.position[1], -sphere.position[2]); GL.PopMatrix(); GL.EndList(); GList.Add(GList.Count); } foreach (Objects.Cone cone in map.cones) { GL.NewList(GList.Count, ListMode.Compile); GL.PushMatrix(); GL.Color3(cone.color); IntPtr q = Glu.NewQuadric(); GL.Translate(cone.position[0], cone.position[1], cone.position[2] - (cone.height / 2)); Glu.Cylinder(q, 0, cone.radio, cone.height, Engine.Constant.QUALITY, Engine.Constant.QUALITY); GL.Translate(-cone.position[0], -cone.position[1], -cone.position[2] + (cone.height / 2)); GL.PopMatrix(); GL.EndList(); GList.Add(GList.Count); } gl_Paint(gl, null); loaded = true; }
public void narisi() { #region simple model if (!modelOK) //če so bile napake pri nalaganju modela, potem nariši osnovno obliko robota { GL.Begin(BeginMode.Quads); GL.PushMatrix(); GL.LoadIdentity(); //spordaj osnova GL.Color3(Color.Blue); GL.Translate(0.0f, 0.0f, -6.0f); IntPtr quadric = GLU.NewQuadric(); GL.Rotate(-90, 1.0f, 0.0f, 0.0f); GLU.Cylinder(quadric, 2.0, 2.0, 1.0, 32, 32); GL.Translate(0.0f, 0.0f, 1.0f); quadric = GLU.NewQuadric(); GLU.PartialDisk(quadric, 0.1, 2.0, 32, 32, 0, 360); // 1 del zgoraj GL.Rotate(rotacija1 + 90, 0.0f, 0.0f, 1.0f); quadric = GLU.NewQuadric(); GLU.Cylinder(quadric, 0.5, 0.5, 2.0, 32, 32); GL.Translate(0.0f, 0.0f, 2.0f); GL.Color3(Color.SkyBlue); quadric = GLU.NewQuadric(); GLU.Sphere(quadric, 0.5, 32, 32); GL.Color3(Color.Blue); GL.Rotate(-90, 1.0f, 0.0f, 0.0f); GL.Translate(0.0f, 0.0f, 0.0f); quadric = GLU.NewQuadric(); GLU.Cylinder(quadric, 0.5f, 0.5f, 1.0f, 32, 32); GL.Color3(Color.SkyBlue); GL.Translate(0.0f, 0.0f, 1.0f); quadric = GLU.NewQuadric(); GLU.Sphere(quadric, 0.5, 32, 32); //2 del GL.Color3(Color.Blue); quadric = GLU.NewQuadric(); GL.Rotate(-90, 0.0f, 1.0f, 0.0f); GL.Rotate(rotacija2, 1.0f, 0.0f, 0.0f); GLU.Cylinder(quadric, 0.5f, 0.5f, 7.0f, 32, 32); GL.Color3(Color.SkyBlue); GL.Translate(0.0f, 0.0f, 7.0f); quadric = GLU.NewQuadric(); GLU.Sphere(quadric, 0.5, 32, 32); GL.Color3(Color.Blue); GL.Rotate(-90, 0.0f, 1.0f, 0.0f); GL.Translate(0.0f, 0.0f, 0.0f); quadric = GLU.NewQuadric(); GLU.Cylinder(quadric, 0.5f, 0.5f, 1.0f, 32, 32); //3del GL.Color3(Color.SkyBlue); GL.Translate(0.0f, 0.0f, 1.0f); quadric = GLU.NewQuadric(); GLU.Sphere(quadric, 0.5, 32, 32); GL.Color3(Color.Blue); quadric = GLU.NewQuadric(); GL.Rotate(-90, 0.0f, 1.0f, 0.0f); GL.Rotate((rotacija3 * -1), 1.0f, 0.0f, 0.0f); GLU.Cylinder(quadric, 0.5f, 0.5f, 2.3f, 32, 32); GL.Color3(Color.SkyBlue); quadric = GLU.NewQuadric(); GL.Translate(0.0f, 0.0f, 2.3f); GLU.Cylinder(quadric, 0.7f, 0.7f, 1.0f, 32, 32); quadric = GLU.NewQuadric(); GLU.PartialDisk(quadric, 0.1, 0.7f, 32, 32, 0, 360); GL.Translate(0.0f, 0.0f, 1.0f); quadric = GLU.NewQuadric(); GLU.PartialDisk(quadric, 0.1, 0.7f, 32, 32, 0, 360); //4 del GL.Color3(0.0f, 0.0f, 1.0f); quadric = GLU.NewQuadric(); GL.Rotate(rotacija4, 0.0f, 0.0f, 1.0f); GLU.Cylinder(quadric, 0.4f, 0.4f, 2.5f, 32, 32); GL.Translate(0.0f, 0.3f, 2.7f); GL.Color3(1.0f, 0.0f, 0.0f); quadric = GLU.NewQuadric(); GL.Rotate(90, 1.0f, 0.0f, 0.0f); GLU.Cylinder(quadric, 0.1f, 0.1f, 0.6f, 32, 32); GL.Translate(0.0f, 0.0f, 0.3f); GL.Color3(1.0f, 0.0f, 0.0f); quadric = GLU.NewQuadric(); GL.Rotate(-90, 1.0f, 0.0f, 0.0f); GL.Rotate(rotacija5, 0.0f, 1.0f, 0.0f); GLU.Cylinder(quadric, 0.01f, 0.01f, 1.0f, 32, 32); GL.End(); } #endregion else //če pa ni bilo napak pa nariši naložen LWO objekt { GL.Rotate(90, 1.0f, 0.0f, 0.0f); /* okolica robota */ GL.PushMatrix(); GL.Translate(0.0f, -3.2f, 0.0f); risi_model(okolica[2]); GL.Translate(-5.0f, 0.0f, -50.0f); risi_model(okolica[0]); GL.Translate(7.0f, 0.0f, 0.0f); risi_model(okolica[0]); GL.Translate(-3.5f, 10.0f, 0.0f); risi_model(okolica[0]); GL.PopMatrix(); GL.PushMatrix(); GL.Translate(0.0f, -3.0f, 0.0f); risi_model(okolica[1]); GL.PopMatrix(); // robot GL.PushMatrix(); //dolžine posameznih objektov //podstavek: 0, -3.2, 0; //prvi zglob: 3.75, 8.3, -1.6; rot: z : rot1+90 //prva roka: 0, 15.35, -0.4; rot: z //drugi zglob: 5.2, 3.9, 2.0; rot: x, pa -90 po x //druga roka: 10.8, 0, 0; rot: z //zadnji zglob: 2.2, 0, 0; rot: x //oni krogec za orodja montirat: 0.4, 0, 0 risi_model(robot_model[0]); //podstavek GL.Rotate(rotacija1 + 90, 0.0f, 1.0f, 0.0f); risi_model(robot_model[1]); // prvi motor GL.Translate(3.75f, 8.30f, -1.60f); // prva roka GL.Rotate(rotacija2, 0.0f, 0.0f, 1.0f); risi_model(robot_model[2]); GL.Translate(0.0f, 15.35f, -0.4f); GL.Rotate(rotacija3, 0.0f, 0.0f, 1.0f); risi_model(robot_model[3]); GL.Translate(5.2f, 3.9f, 2.0f); GL.Rotate(rotacija4, 1.0f, 0.0f, 0.0f); GL.Rotate(-90.0f, 1.0f, 0.0f, 0.0f); risi_model(robot_model[4]); GL.Translate(10.8f, 0.0f, 0.0f); GL.Rotate(rotacija5, 0.0f, 0.0f, 1.0f); risi_model(robot_model[5]); GL.Translate(2.2f, 0.0f, 0.0f); GL.Rotate(rotacija6, 1.0f, 0.0f, 0.0f); risi_model(robot_model[6]); if (set_tool) { GL.Translate(0.4f, 0.0f, 0.0f); risi_model(robot_model[7]); } GL.PopMatrix(); } }