/* * FOLLOWING CODE HAS BEEN DIRECTLY ADDED FROM * TOPIC4, WHICH WAS FOUND ON LEARNIT! * Only very minor changes has been made to adjust * for a change in programming language. */ private void DrawObjs() { Vertex v1, v2, v3; Vertex n1, n2, n3; var TexCoord = new double[2]; // Enable Texturing and setup. GL.Enable(EnableCap.Texture2D); var skyGraphics = skybox.GraphicsObj; List <Triangle> skyboxTriangles = graphController.GetShape(skyGraphics.ShapeIndex); //DrawSkyBox(); // Currently a background (not working) GL.Enable(EnableCap.Lighting); for (int j = 0; j < drawObjList.Count; j++) { var curSimObj = drawObjList[j]; Graphics.GraphicsObject curGraphObj = curSimObj.GraphicsObj; List <Triangle> shape = graphController.GetShape(curGraphObj.ShapeIndex); if (j < 7) { GL.BindTexture(TextureTarget.Texture2D, textureIds[j]); } else { GL.BindTexture(TextureTarget.Texture2D, textureIds[7]); } for (int i = 0; i < shape.Count; i++) { v1 = curGraphObj.vertices[shape[i].vi1]; v2 = curGraphObj.vertices[shape[i].vi2]; v3 = curGraphObj.vertices[shape[i].vi3]; n1 = curGraphObj.normals[shape[i].ni1]; n2 = curGraphObj.normals[shape[i].ni2]; n3 = curGraphObj.normals[shape[i].ni3]; GL.Begin(PrimitiveType.Triangles); GL.TexCoord2(v1.u, v1.v); GL.Normal3(n1.x, n1.y, n1.z); GL.Vertex3(v1.x, v1.y, v1.z); GL.TexCoord2(v2.u, v2.v); GL.Normal3(n2.x, n2.y, n2.z); GL.Vertex3(v2.x, v2.y, v2.z); GL.TexCoord2(v3.u, v3.v); GL.Normal3(n3.x, n3.y, n3.z); GL.Vertex3(v3.x, v3.y, v3.z); GL.End(); } } }