WPF 最基本的前后台代码对照

2021-01-30 10:12

阅读:694

标签:san   ffffff   oid   --   class   tco   ini   host   dir   

最基本的3D代码对照

xaml代码

"0, 0, 4"/>
            "40" Axis="0, 1, 0" />
                        "-1,1,0 -1,-1,0 1,-1,0 1,1,0"
                                    TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
                "True" Brush="White"/>
                
            "#FFFFFFFF" Direction="0,0,-1"/>
                

cs后台对照写法

private void Init_Draw()
        {
            Viewport3D viewport3D = new Viewport3D();
            PerspectiveCamera perspectiveCamera = new PerspectiveCamera()
            {
                Position = new Point3D(0, 0, 4),
            };
            viewport3D.Camera = perspectiveCamera;

            Viewport2DVisual3D viewport2DVisual3D = new Viewport2DVisual3D();
            RotateTransform3D rotateTransform3D = new RotateTransform3D();
            AxisAngleRotation3D axisAngleRotation3D = new AxisAngleRotation3D()
            {
                Angle = 40,
                Axis = new Vector3D(0, 1, 0),
            };
            rotateTransform3D.Rotation = axisAngleRotation3D;
            viewport2DVisual3D.Transform = rotateTransform3D;

            MeshGeometry3D meshGeometry3D = new MeshGeometry3D()
            {
                Positions = new Point3DCollection(new Point3D[] { new Point3D(-1, 1, 0), new Point3D(-1, -1, 0), new Point3D(1, -1, 0), new Point3D(1, 1, 0) }),
                TextureCoordinates = new PointCollection { new Point(0, 0), new Point(0, 1), new Point(1, 1), new Point(1, 0) },
                TriangleIndices = new Int32Collection(new int[] { 0, 1, 2, 0, 2, 3 }),
            };
            viewport2DVisual3D.Geometry = meshGeometry3D;

            DiffuseMaterial diffuseMaterial = new DiffuseMaterial();
            Viewport2DVisual3D.SetIsVisualHostMaterial(diffuseMaterial, true);
            viewport2DVisual3D.Material = diffuseMaterial;


            Button button = new Button()
            {
                Content = "Hello,3D",
          Direction = new Vector3D(0, 0, -1), }; viewport2DVisual3D.Visual
= button; ModelVisual3D modelVisual3D = new ModelVisual3D(); DirectionalLight directionalLight = new DirectionalLight() { Color = Color.FromRgb(255, 255, 255),
Direction = new Vector3D(0, 0, -1), }; modelVisual3D.Content
= directionalLight; viewport3D.Children.Add(viewport2DVisual3D); viewport3D.Children.Add(modelVisual3D); Grid组件.Children.Add(viewport3D); }

 

WPF 最基本的前后台代码对照

标签:san   ffffff   oid   --   class   tco   ini   host   dir   

原文地址:https://www.cnblogs.com/qiaoke/p/11664775.html


评论


亲,登录后才可以留言!