Exemple #1
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();
        }
Exemple #2
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);
        }
Exemple #3
0
        public static void Draw3DInformation(SharpGL.OpenGL gl_object, float[] X, float[] Y, float[] Z)
        {
            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_3D(gl_object);

            //畫D場景
            gl_object.Begin(OpenGL.GL_POINTS);
            for (int i = 0; i < 23040; i++)
            {
                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();
        }
        public static void drawAxis(SharpGL.OpenGL gl_object)
        {
            //畫Z軸
            gl_object.Color(1.0, 1.0, 1.0);
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, -0.02, -0.02);
            gl_object.Vertex(-0.02, -0.02, 10);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(0.02, -0.02, 10);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, 10);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 0.02, 10);
            gl_object.Vertex(-0.02, -0.02, -0.02);
            gl_object.Vertex(-0.02, -0.02, 10);
            gl_object.End();
            //up
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, -0.02, 10);
            gl_object.Vertex(0.02, -0.02, 10);
            gl_object.Vertex(-0.02, 0.02, 10);
            gl_object.Vertex(0.02, 0.02, 10);
            gl_object.End();

            //down
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, -0.02, -0.02);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.End();

            //畫X軸
            gl_object.Color(0, 1.0, 0);
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(10, -0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(10, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.Vertex(10, 0.02, 0.02);
            gl_object.Vertex(0.02, -0.02, 0.02);
            gl_object.Vertex(10, -0.02, 0.02);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(10, -0.02, -0.02);
            gl_object.End();
            //up
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(10, -0.02, -0.02);
            gl_object.Vertex(10, 0.02, -0.02);
            gl_object.Vertex(10, -0.02, 0.02);
            gl_object.Vertex(10, 0.02, 0.02);
            gl_object.End();

            //down
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, -0.02, 0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.End();

            //畫Y軸
            gl_object.Color(0, 0, 1.0);
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 10, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 10, -0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.Vertex(0.02, 10, 0.02);
            gl_object.Vertex(-0.02, 0.02, 0.02);
            gl_object.Vertex(-0.02, 10, 0.02);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 10, -0.02);
            gl_object.End();
            //up
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, 10, -0.02);
            gl_object.Vertex(0.02, 10, -0.02);
            gl_object.Vertex(-0.02, 10, 0.02);
            gl_object.Vertex(0.02, 10, 0.02);
            gl_object.End();

            //down
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 0.02, 0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.End();
        }
Exemple #5
0
        public static void drawAxis_3D(SharpGL.OpenGL gl_object)
        {
            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);

            //畫Z軸
            gl_object.Color(1.0, 1.0, 1.0);
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, -0.02, -0.02);
            gl_object.Vertex(-0.02, -0.02, 10);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(0.02, -0.02, 10);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, 10);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 0.02, 10);
            gl_object.Vertex(-0.02, -0.02, -0.02);
            gl_object.Vertex(-0.02, -0.02, 10);
            gl_object.End();
            //up
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, -0.02, 10);
            gl_object.Vertex(0.02, -0.02, 10);
            gl_object.Vertex(-0.02, 0.02, 10);
            gl_object.Vertex(0.02, 0.02, 10);
            gl_object.End();

            //down
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, -0.02, -0.02);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.End();

            //畫X軸
            gl_object.Color(0, 1.0, 0);
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(10, -0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(10, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.Vertex(10, 0.02, 0.02);
            gl_object.Vertex(0.02, -0.02, 0.02);
            gl_object.Vertex(10, -0.02, 0.02);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(10, -0.02, -0.02);
            gl_object.End();
            //up
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(10, -0.02, -0.02);
            gl_object.Vertex(10, 0.02, -0.02);
            gl_object.Vertex(10, -0.02, 0.02);
            gl_object.Vertex(10, 0.02, 0.02);
            gl_object.End();

            //down
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(0.02, -0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, -0.02, 0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.End();

            //畫Y軸
            gl_object.Color(0, 0, 1.0);
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 10, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 10, -0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.Vertex(0.02, 10, 0.02);
            gl_object.Vertex(-0.02, 0.02, 0.02);
            gl_object.Vertex(-0.02, 10, 0.02);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 10, -0.02);
            gl_object.End();
            //up
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, 10, -0.02);
            gl_object.Vertex(0.02, 10, -0.02);
            gl_object.Vertex(-0.02, 10, 0.02);
            gl_object.Vertex(0.02, 10, 0.02);
            gl_object.End();

            //down
            gl_object.Begin(OpenGL.GL_TRIANGLE_STRIP);
            gl_object.Vertex(-0.02, 0.02, -0.02);
            gl_object.Vertex(0.02, 0.02, -0.02);
            gl_object.Vertex(-0.02, 0.02, 0.02);
            gl_object.Vertex(0.02, 0.02, 0.02);
            gl_object.End();

            //gl_object.Flush();
        }