Example #1
0
        public void updatePlanet()
        {
            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, imagePathID);

            GL.PushMatrix();
            Vertex[] SphereVertices = CalculateVertices2(this.radius, 25, 25);
            ushort[] SphereElements = CalculateElements(this.radius, 25, 25);
            //First rotation to rotate the Planet on it`s orbit
            GL.Rotate(orbitRotation, 0, 1, 0);
            //Then translate to the given Position
            GL.Translate(position);
            //Second Rotation for the Planet itself
            GL.Rotate(planetRotation, 0, 1, 0);

            //Start drwaing the sphere
            GL.Begin(PrimitiveType.Triangles);
            foreach (var element in SphereElements)
            {
                var vertex = SphereVertices[element];
                GL.TexCoord2(vertex.TexCoord);
                GL.Normal3(vertex.Normal);
                GL.Vertex3(vertex.Position);
            }
            GL.End();
            //To draw the rings of Saturn
            if (name.Equals("Saturn"))
            {
                for (int i = 0; i <= 15; i++)
                {
                    //Call drawOrbit two time because of the diffrent density of the rings, and the gap!
                    drawOrbit(150 + i * 2);
                    drawOrbit(190 + i * 3);
                }
            }

            if (hasMoon)
            {
                moon.updateMoon();
            }
            GL.PopMatrix();

            orbitRotation  += orbitSpeed / 2;
            planetRotation += 0.6f;
            drawOrbit(this.position.X);
        }