示例#1
0
        protected void DrawScannerTable(Vector3d center)
        {
            List <Vector3d> circT = new List <Vector3d>(360);
            List <Vector3d> circB = new List <Vector3d>(360);
            List <Vector2d> text  = new List <Vector2d>(360);
            double          h     = 5;

            for (int i = 0; i < 361; i++)
            {
                double ang = Utils.DEGREES_TO_RADIANS(i);
                double x   = -Math.Cos(ang);
                double y   = Math.Sin(ang);
                text.Add(new Vector2d(x * TableRadius / 20.0, y * TableRadius / 20.0));
                Vector3d t = new Vector3d(x * TableRadius, 0, y * TableRadius);
                Vector3d b = new Vector3d(x * TableRadius, -h, y * TableRadius);
                circT.Add(t + center);
                circB.Add(b + center);
            }

            using (new GLEnable(EnableCap.Lighting))
            {
                GL.ColorMaterial(MaterialFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse);
                using (new GLEnable(EnableCap.ColorMaterial))
                {
                    GL.ShadeModel(Smooth ? ShadingModel.Smooth : ShadingModel.Flat);
                    GL.Color3(ForeColor.GetStepColor(BackColor, 0.5));
                    using (new GLEnable(EnableCap.CullFace))
                    {
                        GL.CullFace(CullFaceMode.Back);

                        GL.BindTexture(TextureTarget.Texture2D, this.ScannerTextureID);

                        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
                        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);

                        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
                        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

                        using (new GLEnable(EnableCap.Blend))
                        {
                            GL.BlendFunc(BlendingFactorSrc.SrcColor, BlendingFactorDest.SrcColor);

                            using (new GLEnable(EnableCap.Texture2D))
                            {
                                GL.Begin(PrimitiveType.Polygon);
                                GL.Normal3(new Vector3d(0, 1, 0));
                                for (int i = 0; i < circT.Count; i++)
                                {
                                    GL.TexCoord2(text[i]);
                                    //GL.Normal3(new Vector3d(0, 1, 0));
                                    GL.Vertex3(circT[i]);
                                }
                                GL.End();


                                double div = (TableRadius * 16 * Math.PI) / 360;
                                GL.Begin(PrimitiveType.TriangleStrip);
                                for (int i = 0; i < circT.Count; i++)
                                {
                                    GL.Normal3(circT[i].Normalized());
                                    GL.TexCoord2(new Vector2d(i / div, 0));
                                    GL.Vertex3(circT[i]);
                                    GL.TexCoord2(new Vector2d(i / div, 0.5));
                                    GL.Vertex3(circB[i]);
                                }
                                GL.End();


                                GL.Begin(PrimitiveType.Polygon);
                                GL.Normal3(new Vector3d(0, -1, 0));
                                for (int i = circT.Count - 1; i >= 0; i--)
                                {
                                    //GL.Normal3(new Vector3d(0, -1, 0));
                                    GL.TexCoord2(text[i]);
                                    GL.Vertex3(circB[i]);
                                }
                                GL.End();

                                GL.Color3(BackColor.ModifyLuminosity(0.1));
                                GL.Disable(EnableCap.Lighting);
                                GL.Disable(EnableCap.Texture2D);
                                GL.Disable(EnableCap.Blend);

                                GL.Begin(PrimitiveType.TriangleStrip);
                                for (int i = 0; i < circT.Count; i++)
                                {
                                    Vector3d v = new Vector3d(circT[i]);
                                    v.Y     += TableHeight;
                                    circB[i] = v;
                                    GL.Vertex3(circT[i]);
                                    GL.Vertex3(circB[i]);
                                }
                                GL.End();
                                GL.Begin(PrimitiveType.Polygon);
                                GL.Normal3(new Vector3d(0, -1, 0));
                                for (int i = circT.Count - 1; i >= 0; i--)
                                {
                                    GL.Vertex3(circB[i]);
                                }
                                GL.End();
                            }
                        }
                    }
                }
            }
        }