Example #1
0
        private void GCtrl_Paint(object sender, PaintEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // Глобальные оси координат
            //GL.LineWidth(2);
            //GL.Begin(PrimitiveType.Lines);
            //GL.Color3(Color.Red);
            //GL.Vertex3(0, 0, 0);
            //GL.Vertex3(100, 0, 0);

            //GL.Color3(Color.Green);
            //GL.Vertex3(0, 0, 0);
            //GL.Vertex3(0, 100, 0);

            //GL.Color3(Color.Blue);
            //GL.Vertex3(0, 0, 0);
            //GL.Vertex3(0, 0, 100);
            //GL.End();

            GL.Color3(Color.White);
            MyOl.Cube(-FieldWidth, -FieldWidth, -FieldWidth, FieldWidth, FieldWidth, FieldWidth);

            foreach (var crg in electricField.GetChargeArray)
            {
                var pos = crg.GetPosition;

                if (crg.GetValue > 0d)
                {
                    GL.Color3(PositiveColor);
                }
                else
                {
                    GL.Color3(NegativeColor);
                }

                MyOl.Sphere(5, 16, 16, (int)pos.X, (int)pos.Y, (int)pos.Z);
            }

            GL.Color3(LineColor);
            GL.Begin(PrimitiveType.Lines);

            for (int i = 0; i < vertex.Length; i++)
            {
                int columnCount = vertex[i].Length;

                for (int j = 0; j < columnCount; j += 3)
                {
                    GL.Vertex3(vertex[i][j], vertex[i][j + 1], vertex[i][j + 2]);
                }
            }

            GL.End();

            gCtrl.SwapBuffers();
        }
Example #2
0
        private void GCtrl_Paint(object sender, PaintEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //GL.LineWidth(2);
            //GL.Begin(PrimitiveType.Lines);
            //GL.Color3(Color.Red);
            //GL.Vertex3(0, 0, 0);
            //GL.Vertex3(100, 0, 0);

            //GL.Color3(Color.Green);
            //GL.Vertex3(0, 0, 0);
            //GL.Vertex3(0, 100, 0);

            //GL.Color3(Color.Blue);
            //GL.Vertex3(0, 0, 0);
            //GL.Vertex3(0, 0, 100);
            //GL.End();
            GL.Color3(Color.White);
            MyOl.Cube(-width, -width, -width, width, width, width);

            GL.LineWidth(1);

            GL.Color3(Color.Red);
            MyOl.Sphere(5, 16, 16);
            GL.Color3(Color.Blue);
            MyOl.Sphere(5, 16, 16, 20);

            GL.Color3(Color.Yellow);
            GL.Begin(PrimitiveType.Lines);
            var crg = electricField.GetChargeArray.Where(chrg => chrg.GetValue > 0d).First();

            electricField.DrawLines(crg, 0, 8, GL.Vertex3);
            GL.End();

            gCtrl.SwapBuffers();
        }