當前位置: 首頁>>代碼示例>>C#>>正文


C# Canvas.Translate方法代碼示例

本文整理匯總了C#中Canvas.Translate方法的典型用法代碼示例。如果您正苦於以下問題:C# Canvas.Translate方法的具體用法?C# Canvas.Translate怎麽用?C# Canvas.Translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Canvas的用法示例。


在下文中一共展示了Canvas.Translate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ToBitmap

        public static System.Drawing.Bitmap ToBitmap(this UniversalEditor.ObjectModels.Multimedia3D.Model.ModelObjectModel model, int width, int height, UniversalEditor.ObjectModels.Multimedia3D.Pose.PoseObjectModel pose)
        {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
            graphics.Clear(System.Drawing.Color.Black);

            IntPtr hdc = graphics.GetHdc();

            Canvas canvas = new Canvas(hdc, bitmap.PixelFormat);

            canvas.MakeCurrent();
            canvas.Matrix.Mode = MatrixMode.Projection;
            canvas.Matrix.Reset();

            Internal.GLU.Methods.gluPerspective(45.0, 640 / 480, 0.0, 45.0);

            canvas.EnableDepthTesting = true;
            canvas.EnableNormalization = true;
            canvas.EnableTexturing = true;

            Internal.OpenGL.Methods.glTexEnv(Internal.OpenGL.Constants.TextureEnvironmentTarget.TextureEnvironment, Internal.OpenGL.Constants.TextureEnvironmentParameterName.TextureEnvironmentMode, Internal.OpenGL.Constants.TextureEnvironmentParameterValue.Modulate);

            canvas.CullingMode = CullingMode.Front;

            canvas.EnableBlending = true;
            Internal.OpenGL.Methods.glBlendFunc(Internal.OpenGL.Constants.GLBlendFunc.SourceAlpha, Internal.OpenGL.Constants.GLBlendFunc.OneMinusSourceAlpha);

            Internal.OpenGL.Methods.glEnable(Internal.OpenGL.Constants.GLCapabilities.AlphaTesting);
            Internal.OpenGL.Methods.glAlphaFunc(Internal.OpenGL.Constants.GLAlphaFunc.GreaterOrEqual, 0.05f);

            World.Lights[0].Position = new PositionVector4(0.45f, 1.45f, -4.0f, 0.0f);
            World.Lights[0].DiffuseColor = Color.FromRGBA(0.9f, 0.9f, 0.9f, 1.0f);
            World.Lights[0].AmbientColor = Color.FromRGBA(0.7f, 0.7f, 0.7f, 1.0f);
            World.Lights[0].SpecularColor = Color.FromRGBA(0.7f, 0.7f, 0.7f, 1.0f);
            World.Lights[0].Enabled = true;

            canvas.Matrix.Mode = MatrixMode.Projection;
            canvas.Reset();
            canvas.Translate(0.0, -1, 0.5);
            canvas.Scale(0.05, 0.08, 0.1);

            canvas.Matrix.Mode = MatrixMode.ModelView;
            canvas.DrawModel(model);

            graphics.ReleaseHdc();
            graphics.Flush();

            bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);

            if (pose != null)
            {
            }

            return bitmap;
        }
開發者ID:Narinyir,項目名稱:Sanjigen,代碼行數:55,代碼來源:ExtensionMethods.cs


注:本文中的Canvas.Translate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。