示例#1
0
        public MainViewModel()
        {
            RenderTechniquesManager = new TessellationTechniquesManager();
            RenderTechnique         = RenderTechniquesManager.RenderTechniques[TessellationRenderTechniqueNames.PNQuads];
            EffectsManager          = new TessellationEffectsManager(RenderTechniquesManager);

            // ----------------------------------------------
            // titles
            this.Title    = "Hardware Tessellation Demo";
            this.SubTitle = "WPF & SharpDX";

            // ---------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(7, 10, 12), LookDirection = new Vector3D(-7, -10, -12), UpDirection = new Vector3D(0, 1, 0)
            };

            // ---------------------------------------------
            // setup lighting
            this.AmbientLightColor          = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
            this.DirectionalLightColor      = Color.White;
            this.DirectionalLightDirection1 = new Vector3(-0, -50, -20);
            this.DirectionalLightDirection2 = new Vector3(-0, -1, +50);
            this.DirectionalLightDirection3 = new Vector3(0, +1, 0);

            // ---------------------------------------------
            // model trafo
            this.DefaultTransform = new Media3D.TranslateTransform3D(0, -0, 0);

            // ---------------------------------------------
            // model material
            this.DefaultMaterial = new PhongMaterial
            {
                AmbientColor      = Color.Gray,
                DiffuseColor      = new Color4(0.75f, 0.75f, 0.75f, 1.0f), // Colors.LightGray,
                SpecularColor     = Color.White,
                SpecularShininess = 100f,
                DiffuseMap        = LoadFileToMemory(new System.Uri(@"./Media/TextureCheckerboard2.dds", System.UriKind.RelativeOrAbsolute).ToString()),
                NormalMap         = LoadFileToMemory(new System.Uri(@"./Media/TextureCheckerboard2_dot3.dds", System.UriKind.RelativeOrAbsolute).ToString()),
                //DisplacementMap = new BitmapImage(new Uri(@"path", UriKind.RelativeOrAbsolute)),
            };

            // ---------------------------------------------
            // init model
            this.MeshTopologyList = new[] { "Triangles", "Quads" };
            this.MeshTopology     = "Triangles";

            // ---------------------------------------------
            // floor plane grid
            this.Grid          = LineBuilder.GenerateGrid();
            this.GridColor     = SharpDX.Color.Black;
            this.GridTransform = new Media3D.TranslateTransform3D(-5, -4, -5);
        }
        public MainViewModel()
        {
            RenderTechniquesManager = new TessellationTechniquesManager();
            RenderTechnique = RenderTechniquesManager.RenderTechniques[TessellationRenderTechniqueNames.PNQuads];
            EffectsManager = new TessellationEffectsManager(RenderTechniquesManager);

            // ----------------------------------------------
            // titles
            this.Title = "Hardware Tessellation Demo";
            this.SubTitle = "WPF & SharpDX";

            // ---------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(7, 10, 12), LookDirection = new Vector3D(-7, -10, -12), UpDirection = new Vector3D(0, 1, 0) };

            // ---------------------------------------------
            // setup lighting
            this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection1 = new Vector3(-0, -50, -20);
            this.DirectionalLightDirection2 = new Vector3(-0, -1 , +50);
            this.DirectionalLightDirection3 = new Vector3(0, +1, 0);

            // ---------------------------------------------
            // model trafo
            this.DefaultTransform = new Media3D.TranslateTransform3D(0, -0, 0);

            // ---------------------------------------------
            // model material
            this.DefaultMaterial = new PhongMaterial
            {
                AmbientColor = Color.Gray,
                DiffuseColor = new Color4(0.75f, 0.75f, 0.75f, 1.0f), // Colors.LightGray,
                SpecularColor = Color.White,
                SpecularShininess = 100f,
                DiffuseMap = new BitmapImage(new System.Uri(@"./Media/TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)),
                NormalMap = new BitmapImage(new System.Uri(@"./Media/TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute)),
                //DisplacementMap = new BitmapImage(new Uri(@"path", UriKind.RelativeOrAbsolute)),
            };

            // ---------------------------------------------
            // init model
            this.MeshTopologyList = new[] { "Triangles", "Quads" };
            this.MeshTopology = "Triangles";

            // ---------------------------------------------
            // floor plane grid
            this.Grid = LineBuilder.GenerateGrid();
            this.GridColor = SharpDX.Color.Black;
            this.GridTransform = new Media3D.TranslateTransform3D(-5, -4, -5);
        }