Beispiel #1
0
        public MainViewModel()
        {
            EffectsManager = new DefaultEffectsManager();
            // ----------------------------------------------
            // 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          = Color.FromArgb(1, 12, 12, 12);
            this.DirectionalLightColor      = Colors.White;
            this.DirectionalLightDirection1 = new Vector3D(-0, -20, -20);
            this.DirectionalLightDirection2 = new Vector3D(-0, -1, +50);
            this.DirectionalLightDirection3 = new Vector3D(0, +1, 0);

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

            // ---------------------------------------------
            // model material
            this.DefaultMaterial = new PhongMaterial
            {
                AmbientColor       = Colors.Gray.ToColor4(),
                DiffuseColor       = Colors.Red.ToColor4(), // Colors.LightGray,
                SpecularColor      = Colors.White.ToColor4(),
                SpecularShininess  = 100f,
                DiffuseMap         = TextureModel.Create(new System.Uri(@"./Media/TextureCheckerboard2.dds", System.UriKind.RelativeOrAbsolute).ToString()),
                NormalMap          = TextureModel.Create(new System.Uri(@"./Media/TextureCheckerboard2_dot3.dds", System.UriKind.RelativeOrAbsolute).ToString()),
                EnableTessellation = true, RenderShadowMap = true
            };
            FloorMaterial.RenderShadowMap = true;
            // ---------------------------------------------
            // init model
            this.LoadModel(@"./Media/teapot_quads_tex.obj", this.meshTopology == MeshTopologyEnum.PNTriangles ?
                           MeshFaces.Default : MeshFaces.QuadPatches);
            // ---------------------------------------------
            // floor plane grid
            this.Grid          = LineBuilder.GenerateGrid(10);
            this.GridColor     = Colors.Black;
            this.GridTransform = new Media3D.TranslateTransform3D(-5, -4, -5);

            var builder = new MeshBuilder(true, true, true);

            builder.AddBox(new Vector3(0, -5, 0), 60, 0.5, 60, BoxFaces.All);
            FloorModel = builder.ToMesh();

            Instances = new Matrix[] { Matrix.Identity, Matrix.Translation(10, 0, 10), Matrix.Translation(-10, 0, 10), Matrix.Translation(10, 0, -10), Matrix.Translation(-10, 0, -10), };
        }
        private void buttonEnvironment_Click(object sender, RoutedEventArgs e)
        {
            var texture     = TextureModel.Create("Cubemap_Grandcanyon.dds");
            var environment = new EnvironmentMap3D()
            {
                Texture = texture
            };

            viewport.Items.Add(environment);
            viewmodel.EnableEnvironmentButtons = false;
        }
Beispiel #3
0
        private Tuple <Material, Media3D.Transform3D> LoadNoise()
        {
            var m = new VolumeTextureDDS3DMaterial();

            m.Texture = TextureModel.Create("NoiseVolume.dds");
            m.Color   = new Color4(1, 1, 1, 0.01f);
            m.Freeze();
            var transform = new Media3D.ScaleTransform3D(1, 1, 1);

            transform.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
Beispiel #4
0
        public ViewModel3D()
        {
            var builder = new MeshBuilder(true, true, true);

            builder.AddBox(new Vector3(0, 2.5f, 0), 5, 5, 5);
            builder.AddBox(new Vector3(0, 0, 0), 10, 0.1, 10);
            Model = builder.ToMeshGeometry3D();
            var diffuseMap = TextureModel.Create(new System.Uri(Texture, System.UriKind.RelativeOrAbsolute).ToString());
            var normalMap  = TextureModel.Create(new System.Uri(NormalTexture, System.UriKind.RelativeOrAbsolute).ToString());

            ModelMaterial.DiffuseMap = diffuseMap;
            ModelMaterial.NormalMap  = normalMap;
        }
Beispiel #5
0
        public MainViewModel()
        {
            Title          = "Instancing Demo";
            EffectsManager = new DefaultEffectsManager();
            // camera setup
            Camera = new PerspectiveCamera {
                Position = new Point3D(40, 40, 40), LookDirection = new Vector3D(-40, -40, -40), UpDirection = new Vector3D(0, 1, 0)
            };

            // setup lighting
            this.AmbientLightColor         = Colors.DarkGray;
            this.DirectionalLightColor     = Colors.White;
            this.DirectionalLightDirection = new Vector3D(-2, -5, -2);

            // scene model3d
            var b1 = new MeshBuilder(true, true, true);

            b1.AddBox(new Vector3(0, 0, 0), 1, 1, 1, BoxFaces.All);
            Model = b1.ToMeshGeometry3D();
            for (int i = 0; i < Model.TextureCoordinates.Count; ++i)
            {
                var tex = Model.TextureCoordinates[i];
                Model.TextureCoordinates[i] = new Vector2(tex.X * 0.5f, tex.Y * 0.5f);
            }
            var l1 = new LineBuilder();

            l1.AddBox(new Vector3(0, 0, 0), 1.1, 1.1, 1.1);
            Lines        = l1.ToLineGeometry3D();
            Lines.Colors = new Color4Collection(Enumerable.Repeat(Colors.White.ToColor4(), Lines.Positions.Count));
            // model trafo
            ModelTransform = Media3D.Transform3D.Identity;// new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(0, 0, 1), 45));

            // model material
            ModelMaterial            = PhongMaterials.White;
            ModelMaterial.DiffuseMap = TextureModel.Create(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute).ToString());
            ModelMaterial.NormalMap  = TextureModel.Create(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute).ToString());

            BillboardModel = new BillboardSingleImage3D(ModelMaterial.DiffuseMap, 20, 20);
            Texture        = TextureModel.Create("Cubemap_Grandcanyon.dds");
            CreateModels();
            timer.Interval = TimeSpan.FromMilliseconds(30);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
Beispiel #6
0
        public MainViewModel()
        {            // titles
            this.Title     = "DynamicTexture Demo";
            this.SubTitle  = "WPF & SharpDX";
            EffectsManager = new DefaultEffectsManager();
            this.Camera    = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera
            {
                Position      = new Point3D(10, 10, 10),
                LookDirection = new Vector3D(-10, -10, -10),
                UpDirection   = new Vector3D(0, 1, 0)
            };
            this.Light1Color       = Colors.White;
            this.Light1Direction   = new Vector3D(-10, -10, -10);
            this.AmbientLightColor = Colors.Black;

            var b2 = new MeshBuilder(true, true, true);

            b2.AddSphere(new Vector3(0f, 0f, 0f), 4, 64, 64);
            this.Model      = b2.ToMeshGeometry3D();
            Model.IsDynamic = true;
            this.InnerModel = new MeshGeometry3D()
            {
                Indices            = Model.Indices,
                Positions          = Model.Positions,
                Normals            = Model.Normals,
                TextureCoordinates = Model.TextureCoordinates,
                Tangents           = Model.Tangents,
                BiTangents         = Model.BiTangents,
                IsDynamic          = true
            };

            var image = TextureModel.Create(new System.Uri(@"test.png", System.UriKind.RelativeOrAbsolute).ToString());

            this.ModelMaterial = new PhongMaterial
            {
                AmbientColor      = Colors.Gray.ToColor4(),
                DiffuseColor      = Colors.White.ToColor4(),
                SpecularColor     = Colors.White.ToColor4(),
                SpecularShininess = 100f,
                DiffuseAlphaMap   = image,
                DiffuseMap        = TextureModel.Create(new System.Uri(@"TextureCheckerboard2.dds", System.UriKind.RelativeOrAbsolute).ToString()),
                NormalMap         = TextureModel.Create(new System.Uri(@"TextureCheckerboard2_dot3.dds", System.UriKind.RelativeOrAbsolute).ToString()),
            };

            this.InnerModelMaterial = new PhongMaterial
            {
                AmbientColor      = Colors.Gray.ToColor4(),
                DiffuseColor      = new Color4(0.75f, 0.75f, 0.75f, 1.0f),
                SpecularColor     = Colors.White.ToColor4(),
                SpecularShininess = 100f,
                DiffuseAlphaMap   = image,
                DiffuseMap        = TextureModel.Create(new System.Uri(@"TextureNoise1.jpg", System.UriKind.RelativeOrAbsolute).ToString()),
                NormalMap         = ModelMaterial.NormalMap
            };


            initialPosition = Model.Positions;
            initialIndicies = Model.Indices;
            #region Point Model
            PointModel = new PointGeometry3D()
            {
                IsDynamic = true, Positions = Model.Positions
            };
            int count  = PointModel.Positions.Count;
            var colors = new Color4Collection(count);
            for (int i = 0; i < count / 2; ++i)
            {
                colors.Add(new Color4(0, 1, 1, 1));
            }
            for (int i = 0; i < count / 2; ++i)
            {
                colors.Add(new Color4(0, 0, 0, 0));
            }
            PointModel.Colors = colors;
            #endregion

            #region Line Model
            LineModel = new LineGeometry3D()
            {
                IsDynamic = true, Positions = new Vector3Collection(PointModel.Positions)
            };
            LineModel.Positions.Add(Vector3.Zero);
            var indices = new IntCollection(count * 2);
            for (int i = 0; i < count; ++i)
            {
                indices.Add(count);
                indices.Add(i);
            }
            LineModel.Indices = indices;
            colors            = new Color4Collection(LineModel.Positions.Count);
            for (int i = 0; i < count; ++i)
            {
                colors.Add(new Color4((float)i / count, 1 - (float)i / count, 0, 1));
            }
            colors.Add(Colors.Blue.ToColor4());
            LineModel.Colors = colors;
            LineMaterial     = new LineArrowHeadMaterial()
            {
                Color = Colors.White, Thickness = 0.5, ArrowSize = 0.02
            };
            #endregion
            var token = cts.Token;
            Task.Run(() =>
            {
                while (!token.IsCancellationRequested)
                {
                    Timer_Tick();
                    Task.Delay(16).Wait();
                }
            }, token);
            //timer.Interval = TimeSpan.FromMilliseconds(16);
            //timer.Tick += Timer_Tick;
            //timer.Start();
        }
Beispiel #7
0
        public MainViewModel()
        {
            this.Title    = "Environment Mapping Demo";
            this.SubTitle = "HelixToolkitDX";

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

            // lighting setup
            this.AmbientLightColor         = new Color4(0.5f, 0.5f, 0.5f, 1.0f);
            this.DirectionalLightColor     = Color.White;
            this.DirectionalLightDirection = new Vector3(-2, -1, 1);

            // scene model3d
            LoadModel("teapot_quads_tex.obj", MeshFaces.Default);
            this.ModelTransform = new Media3D.TranslateTransform3D();
            this.ModelMaterial  = PhongMaterials.PolishedSilver;
            this.ModelMaterial.ReflectiveColor      = Color.Silver;
            this.ModelMaterial.RenderEnvironmentMap = true;
            var b1 = new MeshBuilder(true);

            b1.AddSphere(new Vector3(0, 0, 0), 1.0, 64, 64);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 3, BoxFaces.All);
            this.Model1 = b1.ToMeshGeometry3D();

            EffectsManager = new DefaultEffectsManager();

            SkyboxTexture = TextureModel.Create("Cubemap_Grandcanyon.dds");
            int t = 5;

            for (int i = 0; i < 10; ++i)
            {
                Instances1.Add(Matrix.Translation(new Vector3(t, t, (i - 5) * t)));
            }
            for (int i = 0; i < 10; ++i)
            {
                Instances2.Add(Matrix.Translation(new Vector3(t, (i - 5) * t, t)));
            }
            for (int i = 0; i < 10; ++i)
            {
                Instances3.Add(Matrix.Translation(new Vector3(-(i - 5) * t, t, (i - 5) * t)));
            }
            //int t = 5;
            //Instances.Add(Matrix.Translation(new Vector3(t, t, t)));
            //Instances.Add(Matrix.Translation(new Vector3(-t, t, t)));
            //Instances.Add(Matrix.Translation(new Vector3(-t, -t, t)));
            //Instances.Add(Matrix.Translation(new Vector3(-t, -t, -t)));
            //Instances.Add(Matrix.Translation(new Vector3(t, -t, t)));
            //Instances.Add(Matrix.Translation(new Vector3(t, -t, -t)));
            //Instances.Add(Matrix.Translation(new Vector3(-t, t, -t)));
            //Instances.Add(Matrix.Translation(new Vector3(t, t, -t)));
            this.ModelMaterial1 = PhongMaterials.Red;
            this.ModelMaterial1.AmbientColor         = Color.Red;
            this.ModelMaterial1.RenderEnvironmentMap = true;
            this.ModelMaterial2 = PhongMaterials.Green;
            this.ModelMaterial2.AmbientColor         = Color.Green;
            this.ModelMaterial2.RenderEnvironmentMap = true;
            this.ModelMaterial3 = PhongMaterials.Blue;
            this.ModelMaterial3.AmbientColor         = Color.Blue;
            this.ModelMaterial3.RenderEnvironmentMap = true;
        }
Beispiel #8
0
        public PBRViewModel(IEffectsManager manager)
        {
            EffectsManager = manager;
            this.Camera    = new PerspectiveCamera {
                Position = new Point3D(0, 60, 60), LookDirection = new Vector3D(0, -60, -60), UpDirection = new Vector3D(0, 1, 0)
            };
            var builder = new MeshBuilder();

            builder.AddSphere(Vector3.Zero, 2);
            SphereModel = builder.ToMesh();
            var normalMap = TextureModel.Create(new System.Uri("TextureNoise1_dot3.dds", System.UriKind.RelativeOrAbsolute).ToString());

            for (int i = -Row; i < Row; ++i)
            {
                for (int j = -Col; j < Col; ++j)
                {
                    var m = new PBRMaterial()
                    {
                        AlbedoColor          = albedoColor.ToColor4(),
                        RoughnessFactor      = 1.0 / (2 * Row) * Math.Abs(i + Row),
                        MetallicFactor       = 1.0 / (2 * Col) * Math.Abs(j + Col),
                        RenderEnvironmentMap = true,
                        EnableAutoTangent    = true,
                        NormalMap            = normalMap,
                        RenderShadowMap      = true
                    };
                    materials.Add(m);
                    Models.Add(new MeshGeometryModel3D()
                    {
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        Geometry         = SphereModel,
                        Material         = m,
                        IsThrowingShadow = true,
                        Transform        = new Media3D.TranslateTransform3D(new Vector3D(i * 6, 0, j * 6))
                    });
                }
            }
            builder = new MeshBuilder();
            builder.AddSphere(Vector3.Zero, 8, 12, 12);
            Model    = builder.ToMesh();
            Material = new PBRMaterial()
            {
                AlbedoColor              = albedoColor.ToColor4(),
                RenderEnvironmentMap     = true,
                AlbedoMap                = TextureModel.Create("Engraved_Metal_COLOR.jpg"),
                NormalMap                = TextureModel.Create("Engraved_Metal_NORM.jpg"),
                DisplacementMap          = TextureModel.Create("Engraved_Metal_DISP.png"),
                RoughnessMetallicMap     = TextureModel.Create("Engraved_Metal_RMC.png"),
                DisplacementMapScaleMask = new Vector4(0.1f, 0.1f, 0.1f, 0),
                EnableAutoTangent        = true, EnableTessellation = true, MaxDistanceTessellationFactor = 2, MinDistanceTessellationFactor = 4
            };
            ModelTransform = new Media3D.MatrixTransform3D(Matrix.Translation(0, 30, 0).ToMatrix3D());

            builder = new MeshBuilder();
            builder.AddBox(Vector3.Zero, 100, 0.5, 100);
            var floorGeo = builder.ToMesh();

            for (int i = 0; i < floorGeo.TextureCoordinates.Count; ++i)
            {
                floorGeo.TextureCoordinates[i] *= 5;
            }
            FloorModel    = floorGeo;
            FloorMaterial = new PBRMaterial()
            {
                AlbedoMap                = TextureModel.Create("Wood_Planks_COLOR.jpg"),
                NormalMap                = TextureModel.Create("Wood_Planks_NORM.jpg"),
                DisplacementMap          = TextureModel.Create("Wood_Planks_DISP.png"),
                RoughnessMetallicMap     = TextureModel.Create("Wood_Planks_RMA.png"),
                AmbientOcculsionMap      = TextureModel.Create("Wood_Planks_RMA.png"),
                DisplacementMapScaleMask = new Vector4(1f, 1f, 1f, 0),
                RoughnessFactor          = 0.8,
                MetallicFactor           = 0.2,
                RenderShadowMap          = true,
                EnableAutoTangent        = true,
            };
            FloorModelTransform = new Media3D.MatrixTransform3D(Matrix.Translation(0, -5, 0).ToMatrix3D());
        }
Beispiel #9
0
        public MainViewModel()
        {
            EffectsManager = new DefaultEffectsManager();
            // ----------------------------------------------
            // titles
            this.Title    = "Lighting Demo";
            this.SubTitle = "WPF & SharpDX";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(100, 100, 100), LookDirection = new Vector3D(-100, -100, -100), UpDirection = new Vector3D(0, 1, 0)
            };
            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = Colors.DimGray;
            this.Light1Color       = Colors.LightGray;


            this.Light1Direction = new Vector3D(-100, -100, -100);
            SetupCameraBindings(Camera);
            // ----------------------------------------------
            // ----------------------------------------------
            // scene model3d
            this.ModelMaterial = PhongMaterials.Silver;

            // ----------------------------------------------
            // floor model3d
            var b2 = new MeshBuilder(true, true, true);

            b2.AddBox(new Vector3(0.0f, 0, 0.0f), 150, 1, 150, BoxFaces.All);
            b2.AddBox(new Vector3(0, 25, 70), 150, 50, 20);
            b2.AddBox(new Vector3(0, 25, -70), 150, 50, 20);
            this.Floor                    = b2.ToMeshGeometry3D();
            this.FloorMaterial            = PhongMaterials.Bisque;
            this.FloorMaterial.DiffuseMap = TextureModel.Create(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute).ToString());
            this.FloorMaterial.NormalMap  = TextureModel.Create(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute).ToString());

            var caritems = Load3ds("leone.3DBuilder.obj").Select(x => x.Geometry as MeshGeometry3D).ToArray();
            var scale    = new Vector3(1f);

            foreach (var item in caritems)
            {
                for (int i = 0; i < item.Positions.Count; ++i)
                {
                    item.Positions[i] = item.Positions[i] * scale;
                }
            }
            Model = MeshGeometry3D.Merge(caritems);

            ModelTransform = new Media3D.RotateTransform3D()
            {
                Rotation = new Media3D.AxisAngleRotation3D(new Vector3D(1, 0, 0), -90)
            };

            Instances = new Matrix[6];
            for (int i = 0; i < Instances.Length; ++i)
            {
                Instances[i] = Matrix.Translation(new Vector3(15 * i - 30, 15 * (i % 2) - 30, 0));
            }

            OutlineInstances = new Matrix[6];
            for (int i = 0; i < Instances.Length; ++i)
            {
                OutlineInstances[i] = Matrix.Translation(new Vector3(15 * i - 30, 15 * (i % 2), 0));
            }

            var blendDesc = new BlendStateDescription();

            blendDesc.RenderTarget[0] = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                BlendOperation        = BlendOperation.Add,
                AlphaBlendOperation   = BlendOperation.Add,
                SourceBlend           = BlendOption.One,
                DestinationBlend      = BlendOption.One,
                SourceAlphaBlend      = BlendOption.Zero,
                DestinationAlphaBlend = BlendOption.One,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };
            BlendDescription        = blendDesc;
            DepthStencilDescription = new DepthStencilStateDescription()
            {
                IsDepthEnabled  = true,
                DepthComparison = Comparison.LessEqual,
                DepthWriteMask  = DepthWriteMask.Zero
            };
        }
Beispiel #10
0
        public MainViewModel()
        {
            EffectsManager = new DefaultEffectsManager();
            Title          = "Material Demo";
            this.Camera    = new PerspectiveCamera {
                Position = new Point3D(-30, 30, -30), LookDirection = new Vector3D(30, -30, 30), UpDirection = new Vector3D(0, 1, 0)
            };

            var builder = new MeshBuilder();

            builder.AddBox(new Vector3(0, -6, 0), 200, 2, 100);

            Floor = builder.ToMesh();

            builder = new MeshBuilder();
            builder.AddSphere(Vector3.Zero, 2);

            LoadObj(@"shaderBall\shaderBall.obj");

            EnvironmentMap = TextureModel.Create("Cubemap_Grandcanyon.dds");

            ColorStripeMaterial.ColorStripeX = GetGradients(new Color4(1, 0, 0, 1), new Color4(0, 1, 0, 1), new Color4(0, 0, 1, 1), 48).ToList();
            ColorStripeMaterial.ColorStripeY = GetGradients(new Color4(1, 1, 0, 1), new Color4(0, 1, 1, 1), new Color4(1, 0, 1, 1), 48).ToList();

            MeshTitles = new BillboardText3D();
            MeshTitles.TextInfo.Add(new TextInfo("Blinn", Transform1.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            MeshTitles.TextInfo.Add(new TextInfo("Normal", Transform2.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            MeshTitles.TextInfo.Add(new TextInfo("Diffuse", Transform3.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            MeshTitles.TextInfo.Add(new TextInfo("Position", Transform4.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            MeshTitles.TextInfo.Add(new TextInfo("VertexColor", Transform5.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            MeshTitles.TextInfo.Add(new TextInfo("ColorStripe", Transform6.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            MeshTitles.TextInfo.Add(new TextInfo("PBR", Transform7.ToVector3())
            {
                Scale = 0.08f, Background = new Color4(1, 1, 1, 1)
            });
            (FloorMaterial as PhongMaterial).RenderShadowMap = true;

            OpenPBRSampleCommand = new RelayCommand((o) =>
            {
                PBRWindow w = new PBRWindow()
                {
                    DataContext = new PBRViewModel(this.EffectsManager)
                    {
                        EnvironmentMap = this.EnvironmentMap
                    }
                };
                w.Show();
            });
        }
        private TextureModel LoadTexture(string file)
        {
            var packageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

            return(TextureModel.Create(packageFolder + @"\" + file));
        }
Beispiel #12
0
        public MainViewModel()
        {
            //    RenderTechniquesManager = new DefaultRenderTechniquesManager();
            EffectsManager = new DefaultEffectsManager();
            // ----------------------------------------------
            // titles
            this.Title    = "Lighting Demo";
            this.SubTitle = "WPF & SharpDX";

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

            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = Colors.DarkGray;

            this.RenderLight1 = true;
            this.RenderLight2 = true;
            this.RenderLight3 = true;
            this.RenderLight4 = true;

            this.Light1Color = Colors.White;
            this.Light2Color = Colors.Red;
            this.Light3Color = Colors.LightYellow;
            this.Light4Color = Colors.LightBlue;

            this.Light2Attenuation = new Vector3D(1.0f, 0.5f, 0.10f);
            this.Light3Attenuation = new Vector3D(1.0f, 0.1f, 0.05f);
            this.Light4Attenuation = new Vector3D(0.1f, 0.1f, 0.0f);

            this.Light1Direction          = new Vector3D(0, -10, 0);
            this.Light1Transform          = CreateAnimatedTransform1(-Light1Direction, new Vector3D(1, 0, 0), 24);
            this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction, new Vector3D(0, 1, -1), 24);

            this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-4, 0, 0), new Vector3D(0, 0, 1), 3);
            this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 0, 4), new Vector3D(0, 1, 0), 5);

            this.Light4Direction          = new Vector3D(0, -5, -1);
            this.Light4Transform          = CreateAnimatedTransform2(-Light4Direction * 2, new Vector3D(0, 1, 0), 24);
            this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction, new Vector3D(1, 0, 0), 12);

            var transformGroup = new Media3D.Transform3DGroup();

            transformGroup.Children.Add(new Media3D.ScaleTransform3D(10, 10, 10));
            transformGroup.Children.Add(new Media3D.TranslateTransform3D(2, -4, 2));
            Model1Transform = transformGroup;
            // ----------------------------------------------
            // light model3d
            var sphere = new MeshBuilder();

            sphere.AddSphere(new Vector3(0, 0, 0), 0.2);
            Sphere = sphere.ToMeshGeometry3D();
            this.LightModelMaterial = new PhongMaterial
            {
                AmbientColor  = Colors.Gray.ToColor4(),
                DiffuseColor  = Colors.Gray.ToColor4(),
                EmissiveColor = Colors.Yellow.ToColor4(),
                SpecularColor = Colors.Black.ToColor4(),
            };

            // ----------------------------------------------
            // scene model3d
            var b1 = new MeshBuilder(true, true, true);

            b1.AddSphere(new Vector3(0.25f, 0.25f, 0.25f), 0.75, 24, 24);
            b1.AddBox(-new Vector3(0.25f, 0.25f, 0.25f), 1, 1, 1, BoxFaces.All);
            b1.AddBox(-new Vector3(5.0f, 0.0f, 0.0f), 1, 1, 1, BoxFaces.All);
            b1.AddSphere(new Vector3(5f, 0f, 0f), 0.75, 24, 24);
            b1.AddCylinder(new Vector3(0f, -3f, -5f), new Vector3(0f, 3f, -5f), 1.2, 24);
            b1.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 24, 64);
            b1.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64);
            this.Model          = b1.ToMeshGeometry3D();
            this.ModelTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.ModelMaterial  = PhongMaterials.Chrome;

            this.ModelMaterial.NormalMap = TextureModel.Create(new System.Uri(SelectedNormalTexture, System.UriKind.RelativeOrAbsolute).ToString());

            // ----------------------------------------------
            // floor model3d
            var b2 = new MeshBuilder(true, true, true);

            //b2.AddRectangularMesh(BoxFaces.Left, 10, 10, 10, 10);
            b2.AddBox(new Vector3(0.0f, -5.0f, 0.0f), 15, 1, 15, BoxFaces.All);
            //b2.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 24, 64);
            //b2.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64);
            this.Floor          = b2.ToMeshGeometry3D();
            this.FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.FloorMaterial  = new PhongMaterial
            {
                AmbientColor      = Colors.Gray.ToColor4(),
                DiffuseColor      = new Color4(0.75f, 0.75f, 0.75f, 1.0f),
                SpecularColor     = Colors.White.ToColor4(),
                SpecularShininess = 100f,
                DiffuseMap        = TextureModel.Create(new System.Uri(SelectedDiffuseTexture, System.UriKind.RelativeOrAbsolute).ToString()),
                NormalMap         = ModelMaterial.NormalMap,
                RenderShadowMap   = true
            };
            ModelMaterial.DiffuseMap = FloorMaterial.DiffuseMap;

            ReflectMaterial = PhongMaterials.PolishedSilver;
            ReflectMaterial.ReflectiveColor      = global::SharpDX.Color.Silver;
            ReflectMaterial.RenderEnvironmentMap = true;
            InitialObjectTransforms();
        }