예제 #1
0
        public MainViewModel()
        {
            Title = "ImageViewDemo";
            SubTitle = "WPF & SharpDX";

            this.OpenCommand = new RelayCommand((x) => OnOpenClick());

            // camera setup
            this.defaultPerspectiveCamera = new PerspectiveCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0.5, FarPlaneDistance = 150 };
            this.defaultOrthographicCamera = new OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0, FarPlaneDistance = 100 };
            this.Camera = defaultPerspectiveCamera;

            // setup lighting            
            this.AmbientLightColor = new Color4(0f, 0f, 0f, 0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-0, -0, -10);

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

            // plane
            var b2 = new MeshBuilder();
            b2.AddBox(new Vector3(0, 0, 0), 10, 10, 0, BoxFaces.PositiveZ);
            this.Plane = b2.ToMeshGeometry3D();
            this.PlaneMaterial = PhongMaterials.Blue;
            this.PlaneTransform = new Media3D.TranslateTransform3D(-0, -0, -0);            
            //this.PlaneMaterial.ReflectiveColor = Color.Black;
            this.PlaneTransform = new Media3D.TranslateTransform3D(0, 0, 0);

            this.RenderTechnique = Techniques.RenderBlinn;
        }
예제 #2
0
        public MainViewModel()
        {
            // titles
            this.Title = "Deferred Shading Demo";    
        
            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) };

            // clear color 
            this.BackgroundColor = (Color4)Color.White;

            // default render technique
            this.RenderTechnique = Techniques.RenderDeferred;

            // setup lighting            
            this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
            this.DirectionalLightColor2 = Color.Red;
            this.DirectionalLightColor1 = Color.Green;
            this.DirectionalLightColor3 = Color.Blue;
            this.DirectionalLightDirection1 = new Vector3(-0,  -50, -0);
            this.DirectionalLightDirection2 = new Vector3(-0,  -50,  -50);
            this.DirectionalLightDirection3 = new Vector3(-50, -50,  -0);

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

            // scene model3d
            var b1 = new MeshBuilder(true,true,true);
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All);
            var meshGeometry = b1.ToMeshGeometry3D();
            meshGeometry.Colors = meshGeometry.TextureCoordinates.Select(x => x.ToColor4()).ToArray();
            this.Model = meshGeometry;

            // lines model3d
            var e1 = new LineBuilder();
            e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2);
            this.Lines = e1.ToLineGeometry3D();

            // model trafos
            this.Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0);
            this.Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0);

            // model materials
            this.RedMaterial = PhongMaterials.White;
            this.RedMaterial.DiffuseMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute));
            this.RedMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute));
            this.GreenMaterial = PhongMaterials.DefaultVRML;
            //this.GreenMaterial.TextureMap = this.RedMaterial.TextureMap;
            this.BlueMaterial = PhongMaterials.Silver;
            //this.BlueMaterial.TextureMap = this.RedMaterial.TextureMap;
        }
예제 #3
0
        public MainViewModel()
        {
            Title = "Shadow Map Demo";
            SubTitle = "WPF & SharpDX";

            // setup lighting            
            this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-0, -1, -1);
            this.LightDirectionTransform = CreateAnimatedTransform(-DirectionalLightDirection.ToVector3D(), new Vector3D(0, 1, -1), 24);
            this.ShadowMapResolution = new Vector2(2048, 2048);

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

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

            // scene model3d
            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.25, 2, BoxFaces.All);
            Model = b1.ToMeshGeometry3D();
            //Instances = new[] { Matrix.Translation(0, 0, -1.5f), Matrix.Translation(0, 0, 1.5f) };

            var b2 = new MeshBuilder();
            b2.AddBox(new Vector3(0, 0, 0), 10, 0, 10, BoxFaces.PositiveY);
            Plane = b2.ToMeshGeometry3D();
            PlaneTransform = new Media3D.TranslateTransform3D(-0, -2, -0);
            GrayMaterial = PhongMaterials.LightGray;
            //GrayMaterial.TextureMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)); 

            // lines model3d            
            Lines = LineBuilder.GenerateBoundingBox(Model);

            // model trafos
            Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0);
            Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0);
            Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0);            

            // model materials
            RedMaterial = PhongMaterials.Glass;
            GreenMaterial = PhongMaterials.Green;
            BlueMaterial = PhongMaterials.Blue;
        }
예제 #4
0
        public MainViewModel()
        {
            // titles
            this.Title = "Simple Demo";
            this.SubTitle = "WPF & SharpDX";

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

            // default render technique
            this.RenderTechnique = Techniques.RenderBlinn;

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

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

            // scene model3d
            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All);
            var meshGeometry = b1.ToMeshGeometry3D();
            meshGeometry.Colors = meshGeometry.TextureCoordinates.Select(x => x.ToColor4()).ToArray();
            this.Model = meshGeometry;

            // lines model3d
            var e1 = new LineBuilder();
            e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2);
            this.Lines = e1.ToLineGeometry3D();

            // model trafos
            this.Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0);
            this.Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0);
            
            // model materials
            this.RedMaterial = PhongMaterials.Red;
            this.GreenMaterial = PhongMaterials.Green;
            this.BlueMaterial = PhongMaterials.Blue;
        }
예제 #5
0
        public MainViewModel()
        {
            this.Title = "Manipulator Demo";
            this.SubTitle = null;
            
            // camera setup
            this.Camera = new OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), 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.DirectionalLightDirection = new Vector3(-2, -5, -2);

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

            // scene model3d
            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 1.5, BoxFaces.All);
            this.Model = b1.ToMeshGeometry3D();

            // lines model3d
            var e1 = new LineBuilder();
            e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 1.5);
            this.Lines = e1.ToLineGeometry3D();
            
            // model trafos
            this.Model1Transform = CreateAnimatedTransform(new Vector3D(0, 0, 0), new Vector3D(1, 1, 1), 20);
            this.Model2Transform = new TranslateTransform3D(-3, 0, 0);
            this.Model3Transform = new TranslateTransform3D(+3, 0, 0);

            // model materials
            this.Material1 = PhongMaterials.Orange;
            this.Material2 = PhongMaterials.Orange;
            this.Material3 = PhongMaterials.Red;

            var dr = Color.DarkRed;
            Console.WriteLine(dr);
        }
예제 #6
0
        public MainViewModel()
        {
            Title = "Instancing Demo";            

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

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

            // scene model3d
            var b1 = new MeshBuilder(); 
            b1.AddBox(new Vector3(0, 0, 0), 0.8, 0.8, 0.5, BoxFaces.All);
            Model = b1.ToMeshGeometry3D();

            var l1 = new LineBuilder();
            l1.AddBox(new Vector3(0, 0, 0), 0.8, 0.8, 0.5);
            Lines = l1.ToLineGeometry3D();   

            int num = 10;
            var instances = new List<Matrix>();
            for (int i = -num; i < num; i++)
            {
                for (int j = -num; j < num; j++)
                {
                    instances.Add(Matrix.Translation(new Vector3(i / 1.0f, j / 1.0f, 0f)));
                }
            }
            ModelInstances = instances;
            SubTitle = "Number of Instances: " + instances.Count.ToString();

            // model trafo
            ModelTransform = Media3D.Transform3D.Identity;// new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(0, 0, 1), 45));

            // model material
            ModelMaterial = PhongMaterials.Glass;
        }
예제 #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
            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.Model = b1.ToMeshGeometry3D();
            this.ModelTransform = new Media3D.TranslateTransform3D();
            this.ModelMaterial = PhongMaterials.Copper;            
        }
예제 #8
0
        public MainViewModel(Viewport3DX view)
        {
            this.view = view;            

            // ----------------------------------------------
            // set windows text
            Title = "Lighting Demo (WPF & SharpDX)";
            SubTitle = string.Format("Model: {0}, Number Lights: {1}", RenderTechnique, Light3D.LightCount);

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

            // ----------------------------------------------
            // setup scene
            AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);

            Light1Color = (Color4)Color.White;
            Light2Color = (Color4)Color.Red;
            Light3Color = (Color4)Color.LightYellow;
            Light4Color = (Color4)Color.LightBlue;

            Light2Attenuation = new Vector3(1.0f, 0.5f, 0.10f);
            Light3Attenuation = new Vector3(1.0f, 0.1f, 0.05f);
            Light4Attenuation = new Vector3(1.0f, 0.2f, 0.0f);

            Light1Direction = new Vector3(0, -10, -10);
            Light1Transform = new Media3D.TranslateTransform3D(-Light1Direction.ToVector3D());
            Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction.ToVector3D(), new Vector3D(0, 1, -1), 24);
            //Light1DirectionTransform = Media3D.Transform3D.Identity;// CreateAnimatedTransform(new Vector3D(0, 1, 0), new Vector3D(1, 0, 1), 8);
            
            Light2Transform = CreateAnimatedTransform1(new Vector3D(-4, 0, 0), new Vector3D(0, 0, 1), 3);
            Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 0, 4), new Vector3D(0, 1, 0), 5);
            Light4Transform = new Media3D.TranslateTransform3D(new Vector3D(0, 5, 0));
            Light4DirectionTransform = CreateAnimatedTransform1(new Vector3D(0, 1, 0), new Vector3D(1, 0, 1), 4);

            // ----------------------------------------------
            // light model3d
            var sphere = new MeshBuilder();
            sphere.AddSphere(new Vector3(0, 0, 0), 0.2);
            Sphere = sphere.ToMeshGeometry3D();
            LightModelMaterial = new PhongMaterial
            {
                AmbientColor = Color.Gray,
                DiffuseColor = Color.Gray,
                EmissiveColor = Color.Yellow,
                SpecularColor = Color.Black,
            };

            // ----------------------------------------------
            // scene model3d
            var b1 = new MeshBuilder(true, true, true);
            b1.AddSphere(new Vector3(0.25f, 0.25f, 0.25f), 0.75, 64, 64);
            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, 64, 64);
            b1.AddCylinder(new Vector3(0f, -3f, -5f), new Vector3(0f, 3f, -5f), 1.2, 64);

            Model = b1.ToMeshGeometry3D();
            ModelTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            ModelMaterial = PhongMaterials.Chrome;
            //ModelMaterial.TextureMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute));
            ModelMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute));
            //odelMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureNoise1_dot3.jpg", System.UriKind.RelativeOrAbsolute));


            // ----------------------------------------------
            // floor model3d
            var b2 = new MeshBuilder(true, true, true);
            b2.AddBox(new Vector3(0.0f, -5.0f, 0.0f), 15, 0.1, 15, BoxFaces.All);
            b2.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 64, 64);
            b2.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64);
            Floor = b2.ToMeshGeometry3D();
            FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            FloorMaterial = 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(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)),
                NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute)),
            };
        }
예제 #9
0
파일: Cube.cs 프로젝트: BEEden/Diplomarbeit
 static Cube()
 {
     var b1 = new MeshBuilder();
     b1.AddBox(new Vector3(0, 0, 0), 1, 1, 1);
     geometry = b1.ToMeshGeometry3D();
 }