Example #1
2
        public override void Draw3D(OpenGL gl)
        {
            float drawCoord = (int)(y * 2) % pieces;

            float size = 2;
            double theta = 0;
            if (fever)
            {
                size = 3f;
                if (xpos < -4)
                    theta = (xpos + 4) * Math.PI / 4;
                else if (xpos > 4)
                    theta = (xpos - 4) * Math.PI / 4;
            }

            gl.Begin(BeginMode.Quads);
            {
                if (fever)
                    gl.Color(1.0f, 0.5f, 0.5f);
                gl.TexCoord(drawCoord / pieces, 1);
                gl.Vertex(xpos * 0.5f - (0.4f * size) * Math.Cos(theta), y - (0.4f * size) * Math.Sin(theta), 0);
                gl.TexCoord(drawCoord / pieces, 0);
                gl.Vertex(xpos * 0.5f - (0.4f * size) * Math.Cos(theta), y - (0.4f * size) * Math.Sin(theta), size);
                gl.TexCoord((drawCoord + 1) / pieces, 0);
                gl.Vertex(xpos * 0.5f + (0.4f * size) * Math.Cos(theta), y + (0.4f * size) * Math.Sin(theta), size);
                gl.TexCoord((drawCoord + 1) / pieces, 1);
                gl.Vertex(xpos * 0.5f + (0.4f * size) * Math.Cos(theta), y + (0.4f * size) * Math.Sin(theta), 0);
                gl.Color(1.0f, 1.0f, 1.0f);
            }
            gl.End();
        }
Example #2
1
 private void DrawQuadsWithTexture(OpenGL gl, int texture, params int[][][] quads)
 {
     gl.BindTexture(OpenGL.GL_TEXTURE_2D, _textures[texture]);
     gl.Begin(OpenGL.GL_QUADS);
     foreach (var quad in quads)
     {
         gl.TexCoord(0.0f, 0.0f); gl.Vertex(quad[0]);
         gl.TexCoord(1.0f, 0.0f); gl.Vertex(quad[1]);
         gl.TexCoord(1.0f, 1.0f); gl.Vertex(quad[2]);
         gl.TexCoord(0.0f, 1.0f); gl.Vertex(quad[3]);
     }
     gl.End();
 }
Example #3
0
 public void paint(OpenGL gl)
 {
     gl.Color(1f, 1f, 1f);
     gl.Begin(OpenGL.GL_TRIANGLE_STRIP);
         gl.Vertex(x, y + height, 0);
         gl.Vertex(x, y, 0);
         gl.Vertex(x+width, y + height, 0);
         gl.Vertex(x+width, y, 0);
     gl.End();
     gl.LineWidth(1);
     gl.Begin(OpenGL.GL_LINES);
     gl.Color(0, 0, 0);
         if (centerCoordinateX <= x + width && centerCoordinateX >= x)
         {
             gl.Vertex4d(centerCoordinateX, y, 0, 1);
             gl.Vertex4d(centerCoordinateX, y + height, 0, 1);
         }
         if (centerCoordinateY <= y + height && centerCoordinateY >= y)
         {
             gl.Vertex4d(x, centerCoordinateY, 0, 1);
             gl.Vertex4d(x+width, centerCoordinateY, 0, 1);
         }
     gl.End();
     for(int i = 0; i < functions.Count; i++)
     {
         drawFunction(gl, functions.ElementAt(i));
     }
 }
Example #4
0
        public static void Draw(OpenGL gl, double height, double length, double width)
        {
            gl.LineWidth(1);
            gl.Color(0.7, 0.7, 0.7);
            gl.Begin(OpenGL.GL_LINE_LOOP);
            gl.Vertex(0, height, 0 );
            gl.Vertex(0, height, width);
            gl.Vertex(length, height, width);
            gl.Vertex(length, height, 0 );
            gl.End();

            gl.Begin(OpenGL.GL_LINES);
            gl.Vertex(0, height, 0);
            gl.Vertex(0, 0, 0);

            gl.Vertex(length, height, 0);
            gl.Vertex(length, 0, 0);

            gl.Vertex(0, height, width);
            gl.Vertex(0, 0, width);

            gl.Vertex(length, height, width);
            gl.Vertex(length, 0, width);
            gl.End();

            gl.Begin(OpenGL.GL_LINE_LOOP);
            gl.Vertex(0, 0, 0);
            gl.Vertex(0, 0, width);
            gl.Vertex(length, 0, width);
            gl.Vertex(length, 0, 0);
            gl.End();
        }
Example #5
0
 public override void Draw(SharpGL.OpenGL gl)
 {
     base.Draw(gl);
     if (_data == null)
     {
     }
     gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
     gl.Begin(OpenGL.GL_QUAD_STRIP);
     for (int i = 0; i < _data.Length; i++)
     {
         gl.Color(_data[i], _data[i], _data[i]);
         _x = ((GetSize().x / 256f) * i) + CamController.X - (GetSize().x / 2f);
         gl.Vertex(_x, GetPosition().y + _data[i] * _height);
         //gl.Vertex(_x, GetPosition().y + _data[i] * _height - 1.0f);
         gl.Vertex(_x, GetPosition().y);
     }
     gl.End();
     gl.Begin(OpenGL.GL_QUAD_STRIP);
     for (int i = 0; i < _data.Length; i++)
     {
         gl.Color(_data[i] - 0.5f, _data[i] - 0.5f, _data[i] - 0.5f);
         _x = ((GetSize().x / 256f) * i) + CamController.X - (GetSize().x / 2f);
         gl.Vertex(_x, GetPosition().y - _data[i] * _height / 10.0f);
         //gl.Vertex(_x, GetPosition().y + _data[i] * _height - 1.0f);
         gl.Color(_data[i], _data[i], _data[i]);
         gl.Vertex(_x, GetPosition().y);
     }
     gl.End();
 }
Example #6
0
        //rysowanie siatki
        private void openGLControl1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
            gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT);

            gl.LoadIdentity();
            gl.Translate(0, 0, tz);
            gl.Rotate(rotX, 1, 0, 0);
            gl.Rotate(rotZ, 0, 0, 1);


            gl.Begin(OpenGL.TRIANGLES);
            gl.Color(1, 0, 0, 1);
            int multt = 1;

            gl.Vertex((minY - (heightArray.Length / 2)) * multt, (minX - (heightArray.Length / 2)) * multt, heightArray[minY][minX]);
            gl.Vertex((minY - (heightArray.Length / 2)) * multt, (minX + 1 - (heightArray.Length / 2)) * multt, heightArray[minY + 1][minX]);
            gl.Vertex((minY + 1 - (heightArray.Length / 2)) * multt, (minX - (heightArray.Length / 2)) * multt, heightArray[minY][minX + 1]);

            gl.End();

            gl.Color(1, 1, 1, 1);
            gl.Begin(OpenGL.LINES);
            for (int i = 0; i < heightArray.Length - 1; i++)
            {
                for (int j = 0; j < heightArray[0].Length - 1; j++)
                {
                    DrawTriangle(gl, i, j);
                }
            }
            gl.End();
        }
Example #7
0
        public static void LocalAxis(SharpGL.OpenGL gl)
        {
            double[] Reddish  = { 0.9, 0.3, 0.4 };
            double[] Greenish = { 0.1, 0.8, 0.3 };
            double[] Bluish   = { 0.1, 0.2, 0.8 };

            gl.PushAttrib(SharpGL.OpenGL.GL_LIGHTING);
            gl.Disable(SharpGL.OpenGL.GL_LIGHTING);
            gl.LineWidth(3);

            gl.Color(Reddish);
            gl.Begin(SharpGL.Enumerations.BeginMode.LineLoop);
            gl.Vertex(0f, 0f, 0f);
            gl.Vertex(1f, 0f, 0f);
            gl.End( );

            gl.Color(Greenish);
            gl.Begin(SharpGL.Enumerations.BeginMode.LineLoop);
            gl.Vertex(0f, 0f, 0f);
            gl.Vertex(0f, 1f, 0f);
            gl.End( );

            gl.Color(Bluish);
            gl.Begin(SharpGL.Enumerations.BeginMode.LineLoop);
            gl.Vertex(0f, 0f, 0f);
            gl.Vertex(0f, 0f, 1f);
            gl.End( );

            gl.PopAttrib( );
        }
Example #8
0
        private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs args)
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            gl.LoadIdentity();

            gl.Translate(-1.5f, 0f, -6f);

            gl.Begin(OpenGL.GL_TRIANGLES);
            {
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, 0.0f);
            }
            gl.End();

            gl.Translate(3f, 0f, 0f);

            gl.Begin(OpenGL.GL_QUADS);
            {
                gl.Vertex(-1.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 0.0f);
            }
            gl.End();
            gl.Flush();
        }
        //jumpFrame: 一次跳躍資料數
        public static void drawGL_FrameData_Triangle(SharpGL.OpenGL gl_object, FrameData_LJV7 frame, int jumpFrame)
        {
            gl_object.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT);

            //可以不用每次都旋轉,可以滑鼠動作時變更即可
            //不影響效能
            gl_object.LoadIdentity();
            gl_object.Translate(_LX, _LY, _LZ);
            gl_object.Rotate(_RoX, 0.0, 1.0, 0.0);
            gl_object.Rotate(_RoY, 1.0, 0.0, 0.0);
            gl_object.Rotate(_RoZ, 0.0, 0.0, 1.0);

            double x = 0, y = 0;
            double centerx = frame.size_per_frame / 2;
            double centery = frame.LJVcount / 2;
            double diff = frame.Max_Buffer_Compute - frame.Min_Buffer_Compute;
            double r = 0, g = 0, b = 0;
            double Color_H = 0.0;

            for (int j = 0; j < frame.LJVcount - jumpFrame; j += jumpFrame)
            {
                gl_object.Begin(OpenGL.TRIANGLE_STRIP);
                for (int i = 0; i < frame.size_per_frame - jumpFrame; i += jumpFrame)
                {
                    int pos = Convert.ToInt32(i * frame.LJVcount + j);
                    if (frame.buffer_compute[pos] == -999 || frame.buffer_compute[pos + jumpFrame] == -999)
                    {
                        gl_object.End();
                        gl_object.Begin(OpenGL.TRIANGLE_STRIP);
                        continue;
                    }
                    Color_H = (frame.buffer_compute[pos] - frame.Min_Buffer_Compute) / diff;
                    Color_H = Color_H * (MaxColorH - MinColorH) + MinColorH;
                    HsvToRgb(Color_H, 1.0, 1.0, out r, out g, out b);
                    gl_object.Color(r, g, b);

                    x = (Convert.ToDouble(i) - centerx) / Convert.ToDouble(100);
                    y = -(Convert.ToDouble(j) - centery) / Convert.ToDouble(100);
                    gl_object.Vertex(x, y, frame.buffer_compute[pos]);


                    Color_H = (frame.buffer_compute[pos + jumpFrame] - frame.Min_Buffer_Compute) / diff;
                    Color_H = Color_H * (MaxColorH - MinColorH) + MinColorH;
                    HsvToRgb(Color_H, 1.0, 1.0, out r, out g, out b);
                    gl_object.Color(r, g, b);

                    x = (Convert.ToDouble(i) - centerx) / Convert.ToDouble(100);
                    y = -(Convert.ToDouble(j + jumpFrame) - centery) / Convert.ToDouble(100);
                    gl_object.Vertex(x, y, frame.buffer_compute[pos + jumpFrame]);
                }
                gl_object.End();
            }

            //drawAxis(gl_object);
            gl_object.Flush();
            return;
        }
Example #10
0
        public void DrawGrid(OpenGL gl, int camX,int camY)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();

            int MapHeight = tileMap.mapHeight;
            int MapWidth = tileMap.mapWidth;

            float[] darkColor = { 0.2f, 0.2f, 0.2f };
            float[] lightColor = { 0.25f, 0.25f, 0.25f };
            for (int h = 0; h < MapHeight; h++)
            {
                if (h % 10 == 0)
                {
                    gl.LineWidth(2.0f);
                    gl.Color(lightColor);
                }
                else
                {
                    gl.LineWidth(1.0f);
                    gl.Color(darkColor);
                }
                if (h == 0)
                {
                    gl.LineWidth(4.0f);
                    gl.Color(lightColor);
                }
                gl.Begin(OpenGL.GL_LINES);							// Start Drawing Verticle Cell Borders
                gl.Vertex(0 - camX, h * tileSize - camY, 0);// Left Side Of Horizontal Line
                gl.Vertex((MapWidth * tileSize) - camX, (h * tileSize) - camY, 0);// Right Side Of Horizontal Line
                gl.End();
            }
            for (int v = 0; v < MapWidth; v++)
            {
                if (v % 10 == 0)
                {
                    gl.LineWidth(2.0f);
                    gl.Color(lightColor);
                }
                else
                {
                    gl.LineWidth(1.0f);
                    gl.Color(darkColor);
                }
                if (v == 0)
                {
                    gl.LineWidth(4.0f);
                    gl.Color(lightColor);
                }
                gl.Begin(OpenGL.GL_LINES);							// Start Drawing Verticle Cell Borders
                gl.Vertex(v * tileSize - camX, 0 - camY, 0);// Left Side Of Horizontal Line
                gl.Vertex((v * tileSize) - camX, (MapHeight * tileSize) - camY, 0);// Right Side Of Horizontal Line
                gl.End();
            }
        }
Example #11
0
        public static void Draw3DInformation(SharpGL.OpenGL gl_object, float[] X, float[] Y, float[] Z, DetectedRectRegion DetectField)
        {
            double MaxDistance = 0;
            double r = 0, g = 0, b = 0;

            gl_object.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl_object.LoadIdentity();
            gl_object.Translate(_LX, _LY, _LZ);
            gl_object.Rotate(_RoX, 0.0, 1.0, 0.0);
            gl_object.Rotate(_RoY, 1.0, 0.0, 0.0);
            gl_object.Rotate(_RoZ, 0.0, 0.0, 1.0);

            //畫光達自己的位置
            gl_object.Begin(OpenGL.GL_TRIANGLES);
            gl_object.Color(1.0, 1.0, 1.0);
            gl_object.Vertex(-0.2, -0.15, 0);
            gl_object.Vertex(0, 0.2, 0);
            gl_object.Vertex(0.2, -0.15, 0);
            gl_object.End();

            drawAxis(gl_object);

            //畫D場景
            gl_object.Begin(OpenGL.GL_POINTS);
            for (int i = 0; i < 23040; i++)
            {
                if (DetectField.DetectRegionX1 < X[i] && X[i] < DetectField.DetectRegionX2 && DetectField.DetectRegionY1 < Y[i] && Y[i] < DetectField.DetectRegionY2 && DetectField.DetectRegionZ1 < Z[i] && Z[i] < DetectField.DetectRegionZ2)
                {
                    continue;
                }
                if (X[i] != 0 && Y[i] != 0 && Z[i] != 0)
                {
                    //用XY距離計算顯示顏色
                    double XYDistance = Math.Sqrt(X[i] * X[i] + Y[i] * Y[i]);
                    if (XYDistance > MaxDistance)
                    {
                        MaxDistance = XYDistance;
                    }
                    if (XYDistance > 10)
                    {
                        XYDistance = 10;
                    }
                    XYDistance = XYDistance / 10 * (360 - 30) + 30;
                    HsvToRgb(XYDistance, 1, 1, out r, out g, out b);
                    gl_object.Color(r, g, b);
                    //畫上點座標
                    gl_object.Vertex(X[i], Y[i], Z[i]);
                }
            }
            gl_object.End();
            gl_object.Flush();
        }
Example #12
0
        public static void drawGL_FrameData_Triangle(SharpGL.OpenGL gl_object, ModelBuilder builder, int jumpFrame)
        {
            if (builder._ShowPoints == null || builder._ShowPoints.Length <= 0)
            {
                return;
            }

            gl_object.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT);

            //可以不用每次都旋轉,可以滑鼠動作時變更即可
            //不影響效能
            gl_object.LoadIdentity();
            gl_object.Translate(GLDrawObject._LX, GLDrawObject._LY, GLDrawObject._LZ);
            gl_object.Rotate(GLDrawObject._RoX, 0.0, 1.0, 0.0);
            gl_object.Rotate(GLDrawObject._RoY, 1.0, 0.0, 0.0);
            gl_object.Rotate(GLDrawObject._RoZ, 0.0, 0.0, 1.0);

            for (int j = 0; j < builder._LJV7Frame.LJVcount - jumpFrame; j += jumpFrame)
            {
                gl_object.Begin(OpenGL.TRIANGLE_STRIP);
                for (int i = 0; i < builder._LJV7Frame.size_per_frame - jumpFrame; i += jumpFrame)
                {
                    int pos = Convert.ToInt32(i * builder._LJV7Frame.LJVcount + j);
                    if (builder._ShowPoints[pos].Z == -999 || builder._ShowPoints[pos + jumpFrame].Z == -999)
                    {
                        gl_object.End();
                        gl_object.Begin(OpenGL.TRIANGLE_STRIP);
                        continue;
                    }

                    DPoint point = builder._ShowPoints[pos];
                    gl_object.Color(point.r, point.g, point.b);
                    gl_object.Vertex(point.X, point.Y, point.Z);

                    point = builder._ShowPoints[pos + jumpFrame];
                    gl_object.Color(point.r, point.g, point.b);
                    gl_object.Vertex(point.X, point.Y, point.Z);

                    //Console.WriteLine("X:" + point.r);
                    //Console.WriteLine("Y:" + point.g);
                    //Console.WriteLine("Z:" + point.b);
                }
                gl_object.End();
            }

            GLDrawObject.drawAxis(gl_object);
            gl_object.Flush();
            return;
        }
Example #13
0
        void drawTree(SharpGL.OpenGL gl, double dx, double dy, double dz, int index)//树的函数
        {
            gl.Enable(OpenGL.GL_BLEND);
            gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
            gl.Enable(OpenGL.GL_ALPHA_TEST);
            gl.Enable(OpenGL.GL_TEXTURE_2D);

            gl.PushMatrix();   //强制刷新

            gl.Translate(dx, dy, mydem.high[Convert.ToInt32(mydem.m - (dy + 50) / 0.5 - 1), Convert.ToInt32((dx + 50) / 0.5)]);
            texture[treeId[index]].Bind(gl);

            gl.Color(1f, 1f, 1f, 1f);

            gl.Begin(OpenGL.GL_QUADS);
            {
                gl.TexCoord(0, 1);
                gl.Vertex(-0.5f, 0f, 0f);
                gl.TexCoord(1, 1);
                gl.Vertex(0.5f, 0f, 0f);
                gl.TexCoord(1, 0);
                gl.Vertex(0.5f, 0f, 3.0f);
                gl.TexCoord(0, 0);
                gl.Vertex(-0.5f, 0.0f, 3.0f);
            }
            gl.End();

            gl.Rotate(0f, 0f, 90);

            gl.Begin(OpenGL.GL_QUADS);
            {
                gl.TexCoord(0, 1);
                gl.Vertex(-0.5f, 0f, 0f);
                gl.TexCoord(1, 1);
                gl.Vertex(0.5f, 0f, 0f);
                gl.TexCoord(1, 0);
                gl.Vertex(0.5f, 0f, 3.0f);
                gl.TexCoord(0, 0);
                gl.Vertex(-0.5f, 0.0f, 3.0f);
            }
            gl.End();

            gl.PopMatrix();

            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.Disable(OpenGL.GL_BLEND);
            gl.Disable(OpenGL.GL_ALPHA);
        }
Example #14
0
        public static void DrawDetectRectRegion(SharpGL.OpenGL gl_object, DetectedRectRegion DetectField, double ColorR, double ColorG, double ColorB)
        {
            gl_object.LoadIdentity();
            gl_object.Translate(_LX, _LY, _LZ);
            gl_object.Rotate(_RoX, 0.0, 1.0, 0.0);
            gl_object.Rotate(_RoY, 1.0, 0.0, 0.0);
            gl_object.Rotate(_RoZ, 0.0, 0.0, 1.0);

            //畫範圍
            gl_object.Color(ColorR, ColorG, ColorB);
            gl_object.Begin(OpenGL.GL_LINE_STRIP);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY1, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY1, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY2, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY2, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY1, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY1, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY1, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY1, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY1, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY2, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY2, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX2, DetectField.DetectRegionY2, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY2, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY2, DetectField.DetectRegionZ1);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY2, DetectField.DetectRegionZ2);
            gl_object.Vertex(DetectField.DetectRegionX1, DetectField.DetectRegionY1, DetectField.DetectRegionZ2);
            gl_object.End();
        }
Example #15
0
        public override void Draw(SharpGL.OpenGL gl)
        {
            //Process alignment in baseclass
            base.Draw(gl);

            //Draw arms
            _arm1.Draw(gl);
            _arm2.Draw(gl);
            _arm3.Draw(gl);

            //Draw middle triangle. At each vertex of this triangle two arms meet.
            //So for color merging we will give each vertex the average color of the two
            //adjacent arms - precalculated in constructor

            gl.Begin(SharpGL.Enumerations.BeginMode.Triangles);

            gl.Color(_vertex32.R, _vertex32.G, _vertex32.B);
            gl.Vertex(_arm3.Corner1.x, _arm3.Corner1.y);

            gl.Color(_vertex21.R, _vertex21.G, _vertex21.B);
            gl.Vertex(_arm1.Corner4.x, _arm1.Corner4.y);

            gl.Color(_vertex13.R, _vertex13.G, _vertex13.B);
            gl.Vertex(_arm1.Corner1.x, _arm1.Corner1.y);



            gl.End();
        }
Example #16
0
        private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args)
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();

            gl.LookAt(0, 20, 30, 0, 0, 0, 0, 1, 0);

            //desenha o piso
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            grass.Bind(gl);
            gl.Begin(OpenGL.GL_QUADS);
            gl.Color(0.0f, 1.0f, 0.0f);
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-100.0f, 0.0f, -100.0f);
            gl.TexCoord(100.0f, 0.0f); gl.Vertex(100.0f, 0.0f, -100.0f);
            gl.TexCoord(100.0f, 100.0f); gl.Vertex(100.0f, 0.0f, 100.0f);
            gl.TexCoord(0.0f, 100.0f); gl.Vertex(-100.0f, 0.0f, 100.0f);
            gl.End();
            gl.Disable(OpenGL.GL_TEXTURE_2D);

            foreach (Polygon polygon in polygons)
            {
                polygon.PushObjectSpace(gl);
                polygon.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
                polygon.PopObjectSpace(gl);
            }

            gl.Flush();
        }
Example #17
0
        private void CreateDisplayList(OpenGL gl)
        {
            displayList = new DisplayList();

            displayList.Generate(gl);
            displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);

            //Push all attributes, disable lighting and depth testing.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.DepthFunc(OpenGL.GL_ALWAYS);

            //Set line width.
            gl.LineWidth(lineWidth);

            //Draw the line.
            gl.Begin(OpenGL.GL_LINES);
            gl.Color(Convert.ColorToGLColor(c1));
            gl.Vertex(v1.X, v1.Y, v1.Z);
            gl.Color(Convert.ColorToGLColor(c2));
            gl.Vertex(v2.X, v2.Y, v2.Z);
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
Example #18
0
 public override void Draw(SharpGL.OpenGL gl)
 {
     gl.PushAttrib(AttributeMask.All);
     gl.PushMatrix();
     if (texture != null)
     {
         gl.Enable(OpenGL.GL_TEXTURE_2D);
         texture.Push(gl);
     }
     gl.Begin(BeginMode.Quads);
     {
         gl.Color(color.GetInArrWithAlpha());
         gl.Normal(0, 1, 0);
         gl.TexCoord(0, 0);
         gl.Vertex(position.x - lenByX / 2, position.y, position.z + lenByZ / 2);
         gl.TexCoord(lenByX, 0);
         gl.Vertex(position.x + lenByX / 2, position.y, position.z + lenByZ / 2);
         gl.TexCoord(lenByX, lenByZ);
         gl.Vertex(position.x + lenByX / 2, position.y, position.z - lenByZ / 2);
         gl.TexCoord(0, lenByZ);
         gl.Vertex(position.x - lenByX / 2, position.y, position.z - lenByZ / 2);
     }
     gl.End();
     if (texture != null)
     {
         texture.Pop(gl);
     }
     gl.PopMatrix();
     gl.PopAttrib();
 }
Example #19
0
        public override void Draw(SharpGL.OpenGL gl)
        {
            if (_trail > 1)
            {
                for (int t = 0; t < _trail; t++)
                {
                    PointFloat   trailPos  = GetPosition();
                    PointFloat   vel       = GetVelocity();
                    PointFloat   dit       = new PointFloat(trailPos.x - vel.x * t, trailPos.y - vel.y * t);
                    PointFloat[] pointData = RenderLogics.RectPoint(dit, GetSize(), GetRotation());

                    GetTexture().UseTexure(gl);
                    gl.Begin(OpenGL.GL_QUADS);
                    byte[] col = GetColor();
                    gl.Color(col[0], col[1], col[2]);
                    gl.TexCoord(0, 0);
                    gl.Vertex(pointData[1].x, pointData[1].y);
                    gl.TexCoord(0, 1);
                    gl.Vertex(pointData[0].x, pointData[0].y);
                    gl.TexCoord(1, 1);
                    gl.Vertex(pointData[3].x, pointData[3].y);
                    gl.TexCoord(1, 0);
                    gl.Vertex(pointData[2].x, pointData[2].y);
                    gl.End();
                }
            }
            base.Draw(gl);
        }
Example #20
0
        /// <summary>
        /// Creates the display list. This function draws the
        /// geometry as well as compiling it.
        /// </summary>
        void CreateDisplayList(SharpGL.OpenGL gl)
        {
            //  Create the display list.
            this.displayList = new DisplayList();

            //  Generate the display list and
            this.displayList.Generate(gl);
            this.displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);

            //  Push attributes, set the color.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                          OpenGL.GL_LINE_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.LineWidth(1.0f);

            //  Draw the grid lines.
            gl.Begin(SharpGL.OpenGL.GL_LINES);
            for (int i = -10; i <= 10; i++)
            {
                float fcol = ((i % 10) == 0) ? 0.3f : 0.15f;
                gl.Color(fcol, fcol, fcol);
                gl.Vertex(i, -10, 0);
                gl.Vertex(i, 10, 0);
                gl.Vertex(-10, i, 0);
                gl.Vertex(10, i, 0);
            }
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            //  End the display list.
            this.displayList.End(gl);
        }
Example #21
0
        //-------------------------------------
        public override void ConvertPrimitive(I3DPrimitive primitive, SharpGL.OpenGL gl)
        {
            C3DPrimitiveQuad quad = primitive as C3DPrimitiveQuad;

            if (quad == null || quad.Points == null || quad.Points.Length != 4)
            {
                return;
            }
            for (int nTmp = 0; nTmp < 2; nTmp++)
            {
                if (nTmp == 0)
                {
                    gl.PolygonMode(OpenGL.FRONT_AND_BACK, OpenGL.FILL);
                    gl.Color(GetComposantsCouleur(quad.Couleur));
                }
                else
                {
                    gl.PolygonMode(OpenGL.FRONT_AND_BACK, OpenGL.LINE);
                    gl.Color(0.0f, 0.0f, 0.0f, 1.0f);
                }

                gl.Material(OpenGL.FRONT_AND_BACK, OpenGL.SPECULAR, GetComposantsCouleur(quad.Couleur));
                gl.Material(OpenGL.FRONT_AND_BACK, OpenGL.SHININESS, 100.0f);

                gl.Begin(OpenGL.QUADS);
                //Fond
                //gl.Normal3f(0f, 0f, -1.0f);
                for (int n = 0; n < 4; n++)
                {
                    gl.Vertex(quad.Points[n].X, quad.Points[n].Y, quad.Points[n].Z);
                }

                gl.End();
            }
        }
Example #22
0
        public void drawEnemy(SharpGL.OpenGL gl)
        {
            switch (enemyType)
            {
            case 1:
                texture.Create(gl, "..\\..\\gem1.png");
                break;

            case 2:
                texture.Create(gl, "..\\..\\gem2.png");
                break;

            case 3:
                texture.Create(gl, "..\\..\\gem3.png");
                break;

            case 4:
                texture.Create(gl, "..\\..\\gem4.png");
                break;
            }
            gl.PushMatrix();
            gl.LoadIdentity();
            gl.Translate(0.0f, 0.0f, -19.0f);
            gl.Begin(OpenGL.GL_QUADS);

            gl.TexCoord(0, 0); gl.Vertex(positionX - 1, positionY);
            gl.TexCoord(1, 0); gl.Vertex(positionX, positionY);
            gl.TexCoord(1, 1); gl.Vertex(positionX, positionY - 1);
            gl.TexCoord(0, 1); gl.Vertex(positionX - 1, positionY - 1);
            gl.End();
            gl.PopMatrix();
        }
Example #23
0
        public static void DrawDetectCircleRegion(SharpGL.OpenGL gl_object, DetectCircleRegion DetectField, double ColorR, double ColorG, double ColorB)
        {
            float x = 0;
            float y = 0;

            gl_object.LoadIdentity();
            gl_object.Translate(_LX, _LY, _LZ);
            gl_object.Rotate(_RoX, 0.0, 1.0, 0.0);
            gl_object.Rotate(_RoY, 1.0, 0.0, 0.0);
            gl_object.Rotate(_RoZ, 0.0, 0.0, 1.0);

            //畫範圍
            gl_object.Color(ColorR, ColorG, ColorB);
            gl_object.Begin(OpenGL.GL_LINE_LOOP);
            for (double i = 0; i < 6.28; i += 0.1744)
            {
                x = DetectField.CenterX + DetectField.Radius * (float)Math.Sin(i);
                y = DetectField.CenterY + DetectField.Radius * (float)Math.Cos(i);
                gl_object.Vertex(x, y, DetectField.ZUp);
            }
            gl_object.End();

            gl_object.Color(ColorR, ColorG, ColorB);
            gl_object.Begin(OpenGL.GL_LINE_LOOP);
            for (double i = 0; i < 6.28; i += 0.1744)
            {
                x = DetectField.CenterX + DetectField.Radius * (float)Math.Sin(i);
                y = DetectField.CenterY + DetectField.Radius * (float)Math.Cos(i);
                gl_object.Vertex(x, y, DetectField.ZDown);
            }

            gl_object.End();

            float ang = 0;

            for (double i = 0; i < 4; i++)
            {
                gl_object.Color(ColorR, ColorG, ColorB);
                gl_object.Begin(OpenGL.GL_LINE_LOOP);
                x = DetectField.CenterX + DetectField.Radius * (float)Math.Sin(ang);
                y = DetectField.CenterY + DetectField.Radius * (float)Math.Cos(ang);
                gl_object.Vertex(x, y, DetectField.ZUp);
                gl_object.Vertex(x, y, DetectField.ZDown);
                ang += 1.57f;
                gl_object.End();
            }
        }
Example #24
0
        private void openGLControl1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
            ResetOpenGL(gl, this.openGLControl1.Width, this.openGLControl1.Height);

            int x = 0;
            int y = 0;

            for (int i = 0; i < tileSet.tile.Count; i++)
            {
                if (x + tileSize > this.openGLControl1.Width)
                {
                    x  = 0;
                    y += tileSize;
                }
                //Draw tile imgs
                if (tileSet.tile[i].tileSprite.Count > 0)
                {
                    for (int l = 0; l < tileSet.tile[i].tileSprite.Count; l++)                   // to diplay all layers on tile
                    {
                        tileSet.tileSheet.DrawSprite(x, y, tileSet.tile[i].tileSprite[l], gl);
                    }
                }
                else
                {
                    gl.Color(0.25f, 0.25f, 0.25f);
                    gl.LineWidth(2.0f);
                    gl.Begin(OpenGL.GL_QUADS);
                    gl.Vertex(x, y, 1);
                    gl.Vertex(x, y + tileSize, 1);
                    gl.Vertex(x + tileSize, y, 1);
                    gl.Vertex(x + tileSize, y + tileSize, 1);
                    gl.End();
                }
                gl.LoadIdentity();

                x += tileSize;
            }

            //Draw Selection
            gl.Color(1.25f, 0.25f, 0.25f);
            gl.LineWidth(2.0f);
            gl.Begin(OpenGL.GL_LINES);
            gl.Vertex(control1SelectionX * tileSize, control1SelectionY * tileSize, 1);
            gl.Vertex((control1SelectionX * tileSize) + tileSize, (control1SelectionY * tileSize) + tileSize, 1);
            gl.End();
        }
Example #25
0
        private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e)
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();


            gl.PushMatrix();

            gl.Translate(0.0f, 0.0f, -6.0f);
            gl.Rotate(angle, 1.0f, 1.0f, 1.0f);

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[0]);

            gl.Begin(OpenGL.GL_QUADS);
            gl.Normal(0.0f, 0.0f, -1.0f);
            // Front Face
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Top Left Of The Texture and Quad

            // Back Face
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Bottom Left Of The Texture and Quad

            // Top Face
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f);
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);

            // Bottom Face
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f);
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);

            // Right face
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f);
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, 1.0f);
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f);
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, -1.0f);

            // Left Face
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);
            gl.End();
            gl.PopMatrix();

            gl.Flush();

            angle += rotSpeed;
        }
 private void DrawTrefoilVertices(OpenGL gl)
 {
     //  Render each vertex.
     gl.Begin(BeginMode.Points);
     foreach(var vertex in trefoilKnot.Vertices)
         gl.Vertex(vertex);
     gl.End();
 }
        private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs e)
        {
            //  Get the OpenGL object, for quick access.
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();
            gl.Translate(0.0f, 0.0f, -6.0f);

            gl.Rotate(rtri, 0.0f, 1.0f, 0.0f);

            //  Bind the texture.
            texture.Bind(gl);

            gl.Begin(OpenGL.GL_QUADS);

            // Front Face
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Top Left Of The Texture and Quad

            // Back Face
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Bottom Left Of The Texture and Quad

            // Top Face
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Right Of The Texture and Quad

            // Bottom Face
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Right Of The Texture and Quad

            // Right face
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Left Of The Texture and Quad

            // Left Face
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Left Of The Texture and Quad
            gl.End();

            gl.Flush();

            rtri += 1.0f;// 0.2f;						// Increase The Rotation Variable For The Triangle
        }
Example #28
0
        public override void Draw(SharpGL.OpenGL gl)
        {
            gl.PushMatrix();
            gl.Translate(position.x, position.y + 1f, position.z);
            gl.Scale(scaleKoef, scaleKoef, scaleKoef);
            //  DrawPrimitive a coloured pyramid.
            gl.Begin(OpenGL.GL_TRIANGLES);
            {
                Vector3d d1, d2, norm;
                d1   = new Vector3d(new Point3D(0.0f, 1.0f, 0.0f), new Point3D(-1.0f, -1.0f, 1.0f));
                d2   = new Vector3d(new Point3D(-1.0f, -1.0f, 1.0f), new Point3D(1.0f, -1.0f, 1.0f));
                norm = Vector3d.Product(d1, d2).GetNormalize();
                gl.Normal(norm.ToArray());

                gl.Color(1.0f, 0.0f, 0.0f, 100);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 1.0f, 0.0f, 100);
                gl.Vertex(-1.0f, -1.0f, 1.0f);
                gl.Color(0.0f, 0.0f, 1.0f, 100);
                gl.Vertex(1.0f, -1.0f, 1.0f);

                d1   = new Vector3d(new Point3D(0.0f, 1.0f, 0.0f), new Point3D(1.0f, -1.0f, 1.0f));
                d2   = new Vector3d(new Point3D(1.0f, -1.0f, 1.0f), new Point3D(1.0f, -1.0f, -1.0f));
                norm = Vector3d.Product(d1, d2).GetNormalize();
                gl.Normal(norm.ToArray());
                gl.Color(1.0f, 0.0f, 0.0f, 100);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 0.0f, 1.0f, 100);
                gl.Vertex(1.0f, -1.0f, 1.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, -1.0f);

                d1   = new Vector3d(new Point3D(0.0f, 1.0f, 0.0f), new Point3D(1.0f, -1.0f, -1.0f));
                d2   = new Vector3d(new Point3D(1.0f, -1.0f, -1.0f), new Point3D(-1.0f, -1.0f, -1.0f));
                norm = Vector3d.Product(d1, d2).GetNormalize();
                gl.Normal(norm.ToArray());
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, -1.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(-1.0f, -1.0f, -1.0f);

                d1   = new Vector3d(new Point3D(0.0f, 1.0f, 0.0f), new Point3D(-1.0f, -1.0f, -1.0f));
                d2   = new Vector3d(new Point3D(-1.0f, -1.0f, -1.0f), new Point3D(-1.0f, -1.0f, 1.0f));
                norm = Vector3d.Product(d1, d2).GetNormalize();
                gl.Normal(norm.ToArray());
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(-1.0f, -1.0f, -1.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 1.0f);
            }
            gl.End();
            gl.PopMatrix();
        }
Example #29
0
        private void openGLControl2_OpenGLDraw(object sender, PaintEventArgs e)
        {
            if (tileSetImgLoaded)
            {
                //  Get the OpenGL object, for quick access.
                SharpGL.OpenGL gl = this.openGLControl2.OpenGL;

                ResetOpenGL(gl, this.openGLControl2.Width, this.openGLControl2.Height);
                gl.Translate(-hScrollBar2.Value, -vScrollBar2.Value, 0);
                //  Bind the texture.
                tileSetImg.Bind(gl);                 // commenting this out doesnt change anything but it should.why?

                gl.Begin(OpenGL.GL_QUADS);
                gl.TexCoord(0.0f, 0.0f); gl.Vertex(0.0f, 0.0f, 0.0f);                   // Bottom Left Of The Texture and Quad
                gl.TexCoord(1.0f, 0.0f); gl.Vertex(imgWidth, 0.0f, 0.0f);               // Bottom Right Of The Texture and Quad
                gl.TexCoord(1.0f, 1.0f); gl.Vertex(imgWidth, imgHeight, 0.0f);          // Top Right Of The Texture and Quad
                gl.TexCoord(0.0f, 1.0f); gl.Vertex(0.0f, imgHeight, 0.0f);              // Top Left Of The Texture and Quad
                gl.End();

                //Draw Selection
                gl.Color(1.25f, 0.25f, 0.25f);
                gl.LineWidth(2.0f);
                gl.Begin(OpenGL.GL_LINES);
                gl.Vertex(control2SelectionX * tileSize, control2SelectionY * tileSize, 1);
                gl.Vertex(control2SelectionW, control2SelectionH, 1);
                gl.End();

                //DrawGrid
                for (int y = 0; y < imgWidth / tileSize; y++)
                {
                    gl.Begin(OpenGL.GL_LINES);                        // Start Drawing Verticle Cell Borders
                    gl.Vertex(y * tileSize, 0, 1);                    // Left Side Of Horizontal Line
                    gl.Vertex(y * tileSize, imgHeight, 1);            // Right Side Of Horizontal Line
                    gl.End();
                }
                for (int x = 0; x < imgHeight / tileSize; x++)
                {
                    gl.Begin(OpenGL.GL_LINES);                        // Start Drawing Verticle Cell Borders
                    gl.Vertex(0, x * tileSize, 1);                    // Left Side Of Horizontal Line
                    gl.Vertex(imgWidth, x * tileSize, 1);             // Right Side Of Horizontal Line
                    gl.End();
                }
            }
        }
Example #30
0
 private void RenderVertices_Immediate(OpenGL gl)
 {
     gl.Color(1f, 0f, 0f);
     gl.Begin(OpenGL.GL_POINTS);
     for(uint i=0;i<vertices.Length; i++)
     {
         gl.Vertex(vertices[i]);
     }
     gl.End();
 }
Example #31
0
 public static void Draw(OpenGL gl, IEnumerable<double[]> bolt)
 {
     gl.Begin(OpenGL.GL_LINE_STRIP);
     gl.Color(0, 1, 0);
     foreach (var point in bolt)
     {
         gl.Vertex(point);
     }
     gl.End();
 }
Example #32
0
 public override void Draw(SharpGL.OpenGL gl)
 {
     gl.PushAttrib(AttributeMask.Point);
     gl.PointSize(10);
     gl.Color(1f, 1f, 1f, 1f);
     gl.Begin(BeginMode.Points);
     gl.Vertex(position.ToArray());
     gl.End();
     gl.PopAttrib();
 }
        private void openGLControl1_OpenGLDraw(object sender, SharpGL.RenderEventArgs args)
        {
            SharpGL.OpenGL gl = this.openGLControl1.OpenGL;
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();
            gl.Translate(0.0f, 0.0f, -6.0f);

            //绘制正方体,Rotate The Quad On The X, Y, And Z Axes
            gl.Rotate(x, -1.0f, 0.0f, 0.0f);
            gl.Rotate(y, 0.0f, 0.0f, 1.0f);
            gl.Rotate(z, 0.0f, 1.0f, 0.0f);

            gl.BindTexture(OpenGL.GL_TEXTURE_2D, textures[0]);

            gl.Begin(OpenGL.GL_QUADS);

            // Front Face
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Top Left Of The Texture and Quad

            // Back Face
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Bottom Left Of The Texture and Quad

            // Top Face
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Right Of The Texture and Quad

            // Bottom Face
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Right Of The Texture and Quad

            // Right face
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(1.0f, -1.0f, -1.0f);     // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(1.0f, 1.0f, -1.0f);      // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(1.0f, 1.0f, 1.0f);       // Top Left Of The Texture and Quad
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(1.0f, -1.0f, 1.0f);      // Bottom Left Of The Texture and Quad

            // Left Face
            gl.TexCoord(0.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, -1.0f);    // Bottom Left Of The Texture and Quad
            gl.TexCoord(1.0f, 0.0f); gl.Vertex(-1.0f, -1.0f, 1.0f);     // Bottom Right Of The Texture and Quad
            gl.TexCoord(1.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, 1.0f);      // Top Right Of The Texture and Quad
            gl.TexCoord(0.0f, 1.0f); gl.Vertex(-1.0f, 1.0f, -1.0f);     // Top Left Of The Texture and Quad
            gl.End();

            gl.Flush();
        }
Example #34
0
        private void drawCoordinateAxes(OpenGL gl)
        {
            gl.Color(OpenGlUtility.GetOpenGlColor(Color.Red));
            gl.Begin(OpenGL.GL_LINES);
            gl.Vertex(0, 0, 0);
            gl.Vertex(100, 0, 0);
            gl.End();

            gl.Color(OpenGlUtility.GetOpenGlColor(Color.Green));
            gl.Begin(OpenGL.GL_LINES);
            gl.Vertex(0, 0, 0);
            gl.Vertex(0, 100, 0);
            gl.End();

            gl.Color(OpenGlUtility.GetOpenGlColor(Color.Blue));
            gl.Begin(OpenGL.GL_LINES);
            gl.Vertex(0, 0, 0);
            gl.Vertex(0, 0, 100);
            gl.End();
        }
Example #35
0
        public static double ang2 = Math.PI / 6; //Угол поворота на 30 градусов



        public static void DrawTree(SharpGL.OpenGL gl, Tree tree)
        {
            gl.Begin(OpenGL.GL_LINE_STRIP);
            gl.Color(tree.Color.R, tree.Color.G, tree.Color.B);
            foreach (var point in tree.Points)
            {
                TreeDraw((float)point.X, (float)point.Y, (float)point.X, (float)point.Y + (float)0.3, (float)120.0, 5, gl);
            }
            //gl.Vertex(point.X, point.Y);

            //gl.End();
        }
Example #36
0
        private void Bed(OpenGL gl, double x, double y, double z, double width, double height)
        {
            gl.Begin(OpenGL.GL_QUADS);

            gl.Color(1f, 1f, 1f, 1f);
            gl.Vertex(x, y + height, -6.0f);
            gl.Vertex(x, y, -6.0f);
            gl.Vertex(x + width, y, -6.0f);
            gl.Vertex(x + width, y + height, -6.0f);

            gl.End();
        }
Example #37
0
        private void Ball(OpenGL gl)
        {
            gl.Begin(OpenGL.GL_LINE_LOOP);
            for (int i = 0; i <= 10; i++)
            {
                double angle = (2 * Math.PI * i / 10);
                double x = Math.Cos(angle) - ballX;
                double y = Math.Sin(angle) - ballY;

                gl.Vertex(x, y, ballz);
            }
            gl.End();
        }
Example #38
0
        private void openGLControl_OpenGLDraw(object sender, OpenGLEventArgs e)
        {
            SharpGL.OpenGL gl = e.OpenGL;

            gl.MatrixMode(SharpGL.OpenGL.GL_PROJECTION);

            gl.LoadIdentity();

            const float left   = -5;
            const float right  = 5;
            const float bottom = -5;
            const float top    = 5;

            gl.Ortho2D(left, right, bottom, top);

            gl.Color(1, 1, 1);

            gl.Begin(SharpGL.OpenGL.GL_LINES);

            gl.Vertex(0, bottom);
            gl.Vertex(0, top);
            gl.Vertex(left, 0);
            gl.Vertex(right, 0);

            gl.End();

            gl.Color(0.0f, 0.0f, 1.0f);
            gl.Begin(SharpGL.OpenGL.GL_LINE_STRIP);

            for (var x = -4.0; x < 4; x += 0.1)
            {
                gl.Vertex(x, Math.Sin(x));
            }

            gl.Viewport(20, 20, 200, 200);

            gl.End();
            gl.Flush();
        }
Example #39
0
        public void Render(SharpGL.OpenGL gl, RenderMode renderMode)
        {
            gl.PushAttrib(AttributeMask.Lighting);
            LightingAttributes lighting = new LightingAttributes();

            lighting.Enable = false;
            lighting.SetAttributes(gl);


            gl.Color(lineColor);
            gl.Begin(BeginMode.LineLoop);
            gl.Vertex(lbn.X, lbn.Y, lbn.Z);
            gl.Vertex(rtf.X, lbn.Y, lbn.Z);
            gl.Vertex(rtf.X, lbn.Y, rtf.Z);
            gl.Vertex(lbn.X, lbn.Y, rtf.Z);
            gl.End();

            gl.Begin(BeginMode.LineLoop);
            gl.Vertex(lbn.X, rtf.Y, lbn.Z);
            gl.Vertex(rtf.X, rtf.Y, lbn.Z);
            gl.Vertex(rtf.X, rtf.Y, rtf.Z);
            gl.Vertex(lbn.X, rtf.Y, rtf.Z);
            gl.End();

            gl.Begin(BeginMode.Lines);
            gl.Vertex(lbn.X, lbn.Y, lbn.Z);
            gl.Vertex(lbn.X, rtf.Y, lbn.Z);
            gl.Vertex(rtf.X, lbn.Y, lbn.Z);
            gl.Vertex(rtf.X, rtf.Y, lbn.Z);
            gl.Vertex(rtf.X, lbn.Y, rtf.Z);
            gl.Vertex(rtf.X, rtf.Y, rtf.Z);
            gl.Vertex(lbn.X, lbn.Y, rtf.Z);
            gl.Vertex(lbn.X, rtf.Y, rtf.Z);
            gl.End();

            gl.PopAttrib();
        }
Example #40
0
        private void drawMaze(OpenGL gl)
        {
            if (dataModel.MazeStructure.Origin != null)
            {
                //  Draw a coloured pyramid.
                gl.Begin(OpenGL.GL_TRIANGLES);

                gl.Color(0.0f, 1.0f, 0.0f);

                float x = dataModel.MazeStructure.Origin.Coordinates.X;
                float y = dataModel.MazeStructure.Origin.Coordinates.Y;
                float z = 1.0f;

                gl.Vertex(x, y, z);

                gl.DrawText(0, 0, 128.0f, 128.0f, 128.0f, "Arial", 12.0f, "Drawing maze");

                /*
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 1.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(1.0f, -1.0f, 1.0f);
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(1.0f, -1.0f, 1.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, -1.0f);
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, -1.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(-1.0f, -1.0f, -1.0f);
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(-1.0f, -1.0f, -1.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 1.0f);
                */
                gl.End();
            }

            if (dataModel != null)
                gl.DrawText(0, 0, 128.0f, 128.0f, 128.0f, "Arial", 12.0f, dataModel.SolverAgentList.Count.ToString());
        }
Example #41
0
        public override void Draw(SharpGL.OpenGL gl)
        {
            base.Draw(gl);

            //approximate circle using a triangle fan
            //the more triangles are drawn (the lower the degree step)
            //the smoother the circle will be
            float angleStep = (float)(2 * Math.PI / SegmentCount);

            //All circles will be drawn concentric around the origin
            //starting with the outermost circle (otherwise we would overpaint
            //the inner circles)

            // we draw the circles extending to a larger area than the viewport
            float radiusMax = Math.Max(1.5f * ViewportHalfSizeX, 1.5f * ViewportHalfSizeY);
            int   nCircles  = (int)(radiusMax / StripeWidth);



            //prevent changes to our inner diameter while we draw
            float innerDiam = _innerDiameter;


            //loop over circles
            for (int i = nCircles - 1; i >= 0; i--)
            {
                float Radius = i * StripeWidth + innerDiam;
                if (Radius <= 0)//don't draw inner circles if they are currently collapsed into the center
                {
                    break;
                }
                FColor Color;
                if (i % 2 == 0)
                {
                    Color = ColorStripe1;
                }
                else
                {
                    Color = ColorStripe2;
                }
                gl.Begin(BeginMode.TriangleFan);
                for (float angle = 0; angle <= (float)(2 * Math.PI); angle += angleStep)
                {
                    gl.Color(Color.R, Color.G, Color.B);
                    gl.Vertex(Math.Sin(angle) * Radius, Math.Cos(angle) * Radius);
                }
                gl.End();
            }
        }
Example #42
0
        public override void Draw(SharpGL.OpenGL gl)
        {
            //Process alignment in baseclass
            base.Draw(gl);

            //Draw the square on screen
            gl.Begin(OpenGL.GL_QUADS);
            gl.Color(Color.R, Color.G, Color.B);
            gl.Vertex(-15f, -15f);
            gl.Vertex(-15f, 15f);
            gl.Vertex(15f, 15f);
            gl.Vertex(15f, -15f);
            gl.End();
            gl.Flush();
        }
Example #43
0
        public void DrawCube(SharpGL.OpenGL gl)
        {
            gl.PushMatrix( );
            gl.LoadIdentity( );
            gl.Translate(1.5f, 1.0f, -7.0f);                    // Move Right And Into The Screen

            gl.Rotate(this.rquad, 1.0f, 1.0f, 1.0f);            // Rotate The Cube On X, Y & Z

            gl.Begin(OpenGL.GL_QUADS);                          // Start Drawing The Cube

            gl.Color(0.0f, 1.0f, 0.0f);                         // Set The Color To Green
            gl.Vertex(1.0f, 1.0f, -1.0f);                       // Top Right Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, -1.0f);                      // Top Left Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, 1.0f);                       // Bottom Left Of The Quad (Top)
            gl.Vertex(1.0f, 1.0f, 1.0f);                        // Bottom Right Of The Quad (Top)

            gl.Color(1.0f, 0.5f, 0.0f);                         // Set The Color To Orange
            gl.Vertex(1.0f, -1.0f, 1.0f);                       // Top Right Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, 1.0f);                      // Top Left Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, -1.0f);                     // Bottom Left Of The Quad (Bottom)
            gl.Vertex(1.0f, -1.0f, -1.0f);                      // Bottom Right Of The Quad (Bottom)

            gl.Color(1.0f, 0.0f, 0.0f);                         // Set The Color To Red
            gl.Vertex(1.0f, 1.0f, 1.0f);                        // Top Right Of The Quad (Front)
            gl.Vertex(-1.0f, 1.0f, 1.0f);                       // Top Left Of The Quad (Front)
            gl.Vertex(-1.0f, -1.0f, 1.0f);                      // Bottom Left Of The Quad (Front)
            gl.Vertex(1.0f, -1.0f, 1.0f);                       // Bottom Right Of The Quad (Front)

            gl.Color(1.0f, 1.0f, 0.0f);                         // Set The Color To Yellow
            gl.Vertex(1.0f, -1.0f, -1.0f);                      // Bottom Left Of The Quad (Back)
            gl.Vertex(-1.0f, -1.0f, -1.0f);                     // Bottom Right Of The Quad (Back)
            gl.Vertex(-1.0f, 1.0f, -1.0f);                      // Top Right Of The Quad (Back)
            gl.Vertex(1.0f, 1.0f, -1.0f);                       // Top Left Of The Quad (Back)

            gl.Color(0.0f, 0.0f, 1.0f);                         // Set The Color To Blue
            gl.Vertex(-1.0f, 1.0f, 1.0f);                       // Top Right Of The Quad (Left)
            gl.Vertex(-1.0f, 1.0f, -1.0f);                      // Top Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, -1.0f);                     // Bottom Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, 1.0f);                      // Bottom Right Of The Quad (Left)

            gl.Color(1.0f, 0.0f, 1.0f);                         // Set The Color To Violet
            gl.Vertex(1.0f, 1.0f, -1.0f);                       // Top Right Of The Quad (Right)
            gl.Vertex(1.0f, 1.0f, 1.0f);                        // Top Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, 1.0f);                       // Bottom Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, -1.0f);                      // Bottom Right Of The Quad (Right)
            gl.End( );                                          // Done Drawing The Q
            gl.PopMatrix( );
        }
Example #44
0
        public virtual void Draw3D(OpenGL gl)
        {
            float drawCoord = (int)(y * 2) % pieces;

            gl.Begin(BeginMode.Quads);
            {
                gl.TexCoord(drawCoord / pieces, 1);
                gl.Vertex(xpos * 0.5f - 1, y, 0);
                gl.TexCoord(drawCoord / pieces, 0);
                gl.Vertex(xpos * 0.5f - 1, y + 2 * Math.Sin(falling * Math.PI / 180), 2 * Math.Cos(falling * Math.PI / 180));
                gl.TexCoord((drawCoord + 1) / pieces, 0);
                gl.Vertex(xpos * 0.5f + 1, y + 2 * Math.Sin(falling * Math.PI / 180), 2 * Math.Cos(falling * Math.PI / 180));
                gl.TexCoord((drawCoord + 1) / pieces, 1);
                gl.Vertex(xpos * 0.5f + 1, y, 0);
            }
            gl.End();
        }
Example #45
0
 public override void Draw(OpenGL gl)
 {
     PointFloat _size = GetSize();
     PointFloat[] pointData = RenderLogics.RectPoint(GetPosition(), _size, GetRotation());
     byte[] color = GetColor();
     GetTexture().UseTexure(gl);
     gl.Begin(OpenGL.GL_QUADS);
     gl.Color(color[0], color[1], color[2]);
     gl.TexCoord(0, 0);
     gl.Vertex(pointData[1].x, pointData[1].y);
     gl.TexCoord(0, 1);
     gl.Vertex(pointData[0].x, pointData[0].y);
     gl.TexCoord(1, 1);
     gl.Vertex(pointData[3].x, pointData[3].y);
     gl.TexCoord(1, 0);
     gl.Vertex(pointData[2].x, pointData[2].y);
     gl.End();
 }
Example #46
0
        private void CreateDisplayList(OpenGL gl)
        {
            displayList = new DisplayList();

            displayList.Generate(gl);
            displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);

            //Push all attributes, disable lighting and depth testing.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.DepthFunc(OpenGL.GL_ALWAYS);

            //Set line width.
            gl.LineWidth(lineWidth);

            //Draw the line.
            gl.Begin(OpenGL.GL_LINES);
            for (float i = (size * -1); i < size; i+=0.4f)
            {
                float add = 0.2f;
                if (i > 0) add = 0.4f;
                if (i < 0 && i > -0.2f) add = 0.4f;
                gl.Color(1f, 0f, 0f, 1f);
                gl.Vertex(i, 0, 0);
                gl.Vertex(i + add, 0, 0);
                gl.Color(0f, 1f, 0f, 1f);
                gl.Vertex(0, i, 0);
                gl.Vertex(0, i + add, 0);
                gl.Color(0f, 0f, 1f, 1f);
                gl.Vertex(0, 0, i);
                gl.Vertex(0, 0, i + add);
            }
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
Example #47
0
        private void CreateDisplayList(OpenGL gl)
        {
            displayList = new DisplayList();

            displayList.Generate(gl);
            displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);

            //Push all attributes, disable lighting and depth testing.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.DepthFunc(OpenGL.GL_ALWAYS);

            //Set line width.
            gl.LineWidth(lineWidth);

            //Draw the line.
            gl.Begin(OpenGL.GL_LINES);
            for (int i = (size * -1); i <= size; i++)
            {
                if (i != 0)
                {
                    if ((i % 4) == 0)
                        gl.Color(Convert.ColorToGLColor(darkColor));
                    else
                        gl.Color(Convert.ColorToGLColor(lightColor));
                    gl.Vertex(i, (size * -1), 0);
                    gl.Vertex(i, size, 0);
                    gl.Vertex((size * -1), i, 0);
                    gl.Vertex(size, i, 0);
                }
            }
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
Example #48
0
        public void Draw(OpenGL gl)
        {
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, TextureID);

            int[] amb_diff = { Colour.A, Colour.B, Colour.G, Colour.A };
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT_AND_DIFFUSE, amb_diff);

            gl.Begin(OpenGL.GL_TRIANGLES);

            for (int i = 0; i < 3; i++)
            {
                Position point = Verts[i].Point;
                UV uv = Verts[i].UV;

                if (uv != null)
                    gl.TexCoord(uv.U, uv.V);

                gl.Vertex(point.X, point.Y, point.Z);
            }

            gl.End();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
        }
Example #49
0
File: D3D.cs Project: lxzylllsl/fox
 private void triangle(OpenGL gl, double x1, double y1, double x2, double y2, double x3, double y3, int n)
 {
     gl.PolygonMode(OpenGL.GL_FRONT, OpenGL.GL_FILL);
     gl.Begin(OpenGL.GL_TRIANGLES);
     gl.Color(ColorR[n], ColorG[n], ColorB[n]);
     gl.Vertex(x1, y1, 0);
     gl.Vertex(x2, y2, 0);
     gl.Vertex(x3, y3, 0);
     gl.End();
 }
        /// <summary>
        /// Draw a mesh.
        /// </summary>
        /// <param name="gl">OpenGL handler.</param>
        /// <param name="buildingObj">The mesh.</param>BuildingObjectLib3DS _object,
        private void DrawMesh(OpenGL gl,  Lib3dsMesh thisMesh, Hashtable textures, List<Lib3dsMaterial> matrials, DrawType type)
        {
            if (thisMesh == null || thisMesh.nfaces == 0)
                return;

            // Draw all the faces in this mesh.
            for (int j = 0; j < thisMesh.faces.Count; j++)
            {
                Lib3dsFace thisFace = thisMesh.faces[j];
                float transparency = matrials[thisFace.material].transparency;
                //float[] fogColor = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f };
                //float[] LightAmbient = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f };
                //float[] LightDiffuse = new float[4] { 1.0f, 1.0f, 1.0f, 1.0f };
                //float[] LightPosition = new float[4] { 0.0f, 0.0f, 2.0f, 1.0f };

                switch (type)
                {
                    case DrawType.WireFrame:
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE);
                        IsDrawTexture = false;
                        gl.Color(0.5f, 0.5f, 0.5f, 0.5f);
                        gl.LineWidth(1.5f);
                        break;
                    case DrawType.Full:
                        IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name);
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        break;
                    case DrawType.Face:
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        IsDrawTexture = false;
                        break;
                    case DrawType.Translucent:
                        IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name);
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        gl.Enable(OpenGL.GL_BLEND);
                        gl.BlendFunc(OpenGL.GL_SRC_ALPHA,OpenGL.GL_ONE_MINUS_SRC_ALPHA);

                        //gl.Enable(OpenGL.GL_TEXTURE_2D);							// Enable Texture Mapping
                        //gl.ShadeModel(OpenGL.GL_SMOOTH);							// Enable Smooth Shading
                        //gl.ClearColor(0.5f,0.5f,0.5f,1.0f);					// We'll Clear To The Color Of The Fog
                        //gl.ClearDepth(1.0f);									// Depth Buffer Setup
                        //gl.Enable(OpenGL.GL_DEPTH_TEST);							// Enables Depth Testing
                        //gl.DepthFunc(OpenGL.GL_LEQUAL);								// The Type Of Depth Testing To Do
                        //gl.Hint(OpenGL.GL_PERSPECTIVE_CORRECTION_HINT, OpenGL.GL_NICEST);	// Really Nice Perspective Calculations

                        //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, LightAmbient);		// Setup The Ambient Light
                        //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, LightDiffuse);		// Setup The Diffuse Light
                        //gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION,LightPosition);	// Position The Light
                        //gl.Enable(OpenGL.GL_LIGHT1);

                        //gl.Fog(OpenGL.GL_FOG_COLOR, fogColor);//设置雾颜色,f是一个指定颜色的数组float f[4]
                        //gl.Fog(OpenGL.GL_FOG_DENSITY, 0.85f); // 设置雾的密度
                        //gl.Hint(OpenGL.GL_FOG_HINT, OpenGL.GL_DONT_CARE); // 设置系统如何计算雾气
                        //gl.Fog(OpenGL.GL_FOG_START, 0.01f);//设置雾从多远开始
                        //gl.Fog(OpenGL.GL_FOG_END, 100.0f);//设置雾从多远结束
                        //gl.Fog(OpenGL.GL_FOG_MODE, OpenGL.GL_LINEAR);//设置使用哪种雾,共有三中雾化模式
                        //gl.Enable(OpenGL.GL_FOG);//打开雾效果

                        transparency = 0.2f;
                        break;
                    default:
                        gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
                        IsDrawTexture = false;
                        break;
                }
                if (type != DrawType.WireFrame)
                {
                    gl.Color(matrials[thisFace.material].diffuse[0], matrials[thisFace.material].diffuse[1],
                        matrials[thisFace.material].diffuse[2], matrials[thisFace.material].transparency);
                }

                gl.Begin(OpenGL.GL_TRIANGLES);

                for (int k = 0; k != 3; ++k)
                {
                    int index = thisFace.index[k];

                    if (IsDrawTexture)
                        gl.TexCoord(thisMesh.texcos[index].s, thisMesh.texcos[index].t);
                    gl.Vertex(thisMesh.vertices[index].x / 20, thisMesh.vertices[index].z / 20, -thisMesh.vertices[index].y / 20);
                }

                gl.End();
                if(type == DrawType.Translucent)
                   gl.Disable(OpenGL.GL_BLEND);
            }
        }
Example #51
0
        public void Draw3DFlying(OpenGL gl)
        {
            double theta = (-flying * 50 + 45) * Math.PI / 180;
            float a = (float)(Math.Sqrt(2) * Math.Cos(theta));
            float b = (float)(Math.Sqrt(2) * Math.Sin(theta));

            gl.Begin(BeginMode.Quads);
            {
                gl.TexCoord(0, 1);
                gl.Vertex(xpos * 0.5f - a + flying, y, 1 - b + Math.Sqrt(Math.Abs(flying / 2)));
                gl.TexCoord(0, 0);
                gl.Vertex(xpos * 0.5f - b + flying, y, 1 + a + Math.Sqrt(Math.Abs(flying / 2)));
                gl.TexCoord(1, 0);
                gl.Vertex(xpos * 0.5f + a + flying, y, 1 + b + Math.Sqrt(Math.Abs(flying / 2)));
                gl.TexCoord(1, 1);
                gl.Vertex(xpos * 0.5f + b + flying, y, 1 - a + Math.Sqrt(Math.Abs(flying / 2)));
            }
            gl.End();
        }
Example #52
0
File: D3D.cs Project: lxzylllsl/fox
 //上色四边形
 private void quadrangle(OpenGL gl, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4, int n)
 {
     gl.PolygonMode(OpenGL.GL_FRONT, OpenGL.GL_FILL);
     gl.Begin(OpenGL.GL_QUADS);
     gl.Color(ColorR[n], ColorG[n], ColorB[n]);
     gl.Vertex(x1, y1, z1);
     gl.Vertex(x2, y2, z2);
     gl.Vertex(x3, y3, z3);
     gl.Vertex(x4, y4, z4);
     gl.End();
     //  info.AppendText(n.ToString() + "\r\n");
 }
Example #53
0
File: D3D.cs Project: lxzylllsl/fox
 private void quadrangle(OpenGL gl, double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
 {
     gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE);
     gl.Begin(OpenGL.GL_QUADS);
     gl.Color(0f, 0f, 0f);
     gl.Vertex(x1, y1, 0);
     gl.Vertex(x2, y2, 0);
     gl.Vertex(x3, y3, 0);
     gl.Vertex(x4, y4, 0);
     gl.End();
 }
Example #54
0
File: D3D.cs Project: lxzylllsl/fox
 private void quadrangle(OpenGL gl, double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, int n)
 {
     gl.PolygonMode(OpenGL.GL_FRONT, OpenGL.GL_FILL);
     gl.Begin(OpenGL.GL_QUADS);
     gl.Color(ColorR[n], ColorG[n], ColorB[n]);
     gl.Vertex(x1, y1, 0);
     gl.Vertex(x2, y2, 0);
     gl.Vertex(x3, y3, 0);
     gl.Vertex(x4, y4, 0);
     gl.End();
 }
Example #55
0
        /// <summary>
        /// Renders the scene in immediate mode.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        public void RenderImmediateMode(OpenGL gl)
        {
            //  Setup the modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LoadIdentity();
            gl.MultMatrix(modelviewMatrix.to_array());

            //  Go through each group.
            foreach (var mesh in meshes)
            {
                var texture = meshTextures.ContainsKey(mesh) ? meshTextures[mesh] : null;
                if(texture != null)
                    texture.Bind(gl);

                uint mode = OpenGL.GL_TRIANGLES;
                if (mesh.indicesPerFace == 4)
                    mode = OpenGL.GL_QUADS;
                else if(mesh.indicesPerFace > 4)
                    mode = OpenGL.GL_POLYGON;

                //  Render the group faces.
                gl.Begin(mode);
                for (int i = 0; i < mesh.vertices.Length; i++ )
                {
                    gl.Vertex(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
                    if(mesh.normals != null)
                        gl.Normal(mesh.normals[i].x, mesh.normals[i].y, mesh.normals[i].z);
                    if(mesh.uvs != null)
                        gl.TexCoord(mesh.uvs[i].x, mesh.uvs[i].y);
                }
                gl.End();

                if(texture != null)
                    texture.Unbind(gl);
            }
        }
        public override void Draw(ref OpenGL gl)
        {
            if (!TexturesInitialised)
            {
                InitializeTexture(ref gl);
            }
            //  Clear the color and depth buffer.
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

            //  Load the identity matrix.
            gl.LoadIdentity();
            gl.Enable(OpenGL.GL_TEXTURE_2D);
            gl.Enable(OpenGL.GL_LIGHTING);
            gl.Enable(OpenGL.GL_LIGHT0);
            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.Enable(OpenGL.GL_NORMALIZE);
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, gtexture[0]);
            gl.Color(1.0f, 1.0f, 1.0f, 0.1f);

            gl.Begin(OpenGL.GL_QUADS);
            gl.FrontFace(OpenGL.GL_FRONT_FACE);

            gl.TexCoord(1.0f, 1.0f);
            gl.Vertex(gImage1.Width, gImage1.Height, 1.0f);
            gl.TexCoord(0.0f, 1.0f);
            gl.Vertex(0.0f, gImage1.Height, 1.0f);
            gl.TexCoord(0.0f, 0.0f);
            gl.Vertex(0.0f, 0.0f, 1.0f);
            gl.TexCoord(1.0f, 0.0f);
            gl.Vertex(gImage1.Width, 0.0f, 1.0f);
            gl.End();

            gl.Disable(OpenGL.GL_TEXTURE_2D);

            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Ortho(0.0, (double)gImage1.Width, (double)gImage1.Height, 0.0, -1.0, 1.0);
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.Disable(OpenGL.GL_DEPTH_TEST);
        }
Example #57
0
        /// <summary>
        /// Sets the background color, using a gradient existing from 2 colors
        /// </summary>
        /// <param name="gl"></param>
        private static void SetVerticalGradientBackground(OpenGL gl, ColorF colorTop, ColorF colorBot)
        {
            float topRed = colorTop.R;// / 255.0f;
            float topGreen = colorTop.G;// / 255.0f;
            float topBlue = colorTop.B;// / 255.0f;
            float botRed = colorBot.R;// / 255.0f;
            float botGreen = colorBot.G;// / 255.0f;
            float botBlue = colorBot.B;// / 255.0f;

            gl.Begin(OpenGL.GL_QUADS);

            //bottom color
            gl.Color(botRed, botGreen, botBlue);
            gl.Vertex(-1.0, -1.0);
            gl.Vertex(1.0, -1.0);

            //top color
            gl.Color(topRed, topGreen, topBlue);
            gl.Vertex(1.0, 1.0);
            gl.Vertex(-1.0, 1.0);

            gl.End();
        }
Example #58
0
File: D3D.cs Project: lxzylllsl/fox
 //以下是二维平面的处理
 private void triangle(OpenGL gl, double x1, double y1, double x2, double y2, double x3, double y3)
 {
     gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE);
     gl.Begin(OpenGL.GL_TRIANGLES);
     gl.Color(0f, 0f, 0f);
     gl.Vertex(x1, y1, 0);
     gl.Vertex(x2, y2, 0);
     gl.Vertex(x3, y3, 0);
     gl.End();
 }
Example #59
0
        private void SampleRendering(OpenGL gl, float rX, float rY, float rZ)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
            gl.LoadIdentity();					// Reset The View
            gl.Translate(-1.5f, 0.0f, -6.0f);				// Move Left And Into The Screen

            gl.Rotate(rtri, rX, rY, rZ);				// Rotate The Pyramid On It's Y Axis

            gl.Begin(OpenGL.GL_TRIANGLES);					// Start Drawing The Pyramid

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Front)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Left Of Triangle (Front)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Right Of Triangle (Front)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Right)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Left Of Triangle (Right)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Right Of Triangle (Right)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Back)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Left Of Triangle (Back)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Right Of Triangle (Back)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Left)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Left Of Triangle (Left)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Right Of Triangle (Left)
            gl.End();						// Done Drawing The Pyramid

            gl.LoadIdentity();
            gl.Translate(1.5f, 0.0f, -7.0f);				// Move Right And Into The Screen

            gl.Rotate(rquad, rX, rY, rZ);			// Rotate The Cube On X, Y & Z

            gl.Begin(OpenGL.GL_QUADS);					// Start Drawing The Cube

            gl.Color(0.0f, 1.0f, 0.0f);			// Set The Color To Green
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Bottom Left Of The Quad (Top)
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Bottom Right Of The Quad (Top)


            gl.Color(1.0f, 0.5f, 0.0f);			// Set The Color To Orange
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Top Right Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Top Left Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Bottom)
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Bottom)

            gl.Color(1.0f, 0.0f, 0.0f);			// Set The Color To Red
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Front)
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Front)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Bottom Left Of The Quad (Front)
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Bottom Right Of The Quad (Front)

            gl.Color(1.0f, 1.0f, 0.0f);			// Set The Color To Yellow
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Back)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Back)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Back)
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Back)

            gl.Color(0.0f, 0.0f, 1.0f);			// Set The Color To Blue
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Left)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Bottom Right Of The Quad (Left)

            gl.Color(1.0f, 0.0f, 1.0f);			// Set The Color To Violet
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Right)
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Bottom Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Right)
            gl.End();						// Done Drawing The Q

            gl.Flush();

            rtri += 1.0f;// 0.2f;						// Increase The Rotation Variable For The Triangle 
            rquad -= 1.0f;// 0.15f;						// Decrease The Rotation Variable For The Quad 
        }
        private void RecursiveRender(Assimp.Scene scene, Node node, ref OpenGL gl)
        {
            Matrix4 m = FromMatrix(node.Transform);
            m.Transpose();
            gl.PushMatrix();
            gl.MultMatrix(FloatFromMatrix(m));

            if (node.HasMeshes)
            {
                foreach (int index in node.MeshIndices)
                {
                    Mesh mesh = scene.Meshes[index];
                    ApplyMaterial(m_model.Materials[mesh.MaterialIndex], ref gl);

                    if (mesh.HasNormals)
                    {

                        gl.Enable(OpenGL.GL_LIGHTING);
                    }
                    else
                    {
                        gl.Disable(OpenGL.GL_LIGHTING);
                    }

                    bool hasColors = mesh.HasVertexColors(0);
                    if (hasColors)
                    {
                        gl.Enable(OpenGL.GL_COLOR_MATERIAL);
                    }
                    else
                    {
                        gl.Disable(OpenGL.GL_COLOR_MATERIAL);
                    }

                    bool hasTexCoords = mesh.HasTextureCoords(0);

                    foreach (Assimp.Face face in mesh.Faces)
                    {
                        BeginMode faceMode;
                        switch (face.IndexCount)
                        {
                            case 1:
                                faceMode = BeginMode.Points;
                                break;
                            case 2:
                                faceMode = BeginMode.Lines;
                                break;
                            case 3:
                                faceMode = BeginMode.Triangles;
                                break;
                            default:
                                faceMode = BeginMode.Polygon;
                                break;
                        }

                        gl.Begin(faceMode);
                        for (int i = 0; i < face.IndexCount; i++)
                        {
                            int indice = face.Indices[i];
                            if (hasColors)
                            {
                                Color4 vertColor = FromColor(mesh.VertexColorChannels[0][indice]);
                                if (mesh.HasNormals)
                                {
                                    Vector3 normal = FromVector(mesh.Normals[indice]);
                                    gl.Normal(normal.X, normal.Y, normal.Z);
                                }
                                if (hasTexCoords)
                                {
                                    Vector3 uvw = FromVector(mesh.TextureCoordinateChannels[0][indice]);
                                    gl.TexCoord(uvw.X, 1 - uvw.Y);
                                }
                                Vector3 pos = FromVector(mesh.Vertices[indice]);
                                gl.Vertex(pos.X, pos.Y, pos.Z);
                            }
                            gl.End();
                        }
                    }
                }

                for (int i = 0; i < node.ChildCount; i++)
                {
                    RecursiveRender(m_model, node.Children[i], ref gl);
                }
            }
        }