示例#1
0
        private static Scene CreateScene3()
        {
            Size resolution = new Size(640, 480);
            Point3D position = new Point3D(0, 0, 5000);
            double focus = 1000;
            SizeF projectionWindow = new SizeF(200, 150);
            Rotation rotation = new Rotation(-Math.PI * 0.25, 0, -Math.PI / 2.3);
            PerspectiveCamera camera = new PerspectiveCamera(position, rotation, projectionWindow, resolution, focus);

            Scene scene = new Scene();
            scene.Camera = camera;
            scene.InfinityColor = Color.Black;

            Material mS1 = new Material(Color.Green, 0.3, 0.3, 0.6, 0, 5);
            Material mS2 = new Material(Color.Red, 0.4, 0.4, 0, 0.4, 5);
            Material mS3 = new Material(Color.Yellow, 0.4, 0.3, 0.5, 0, 5);
            Material mS4 = new Material(Color.BlueViolet, 0.4, 0.3, 0.4, 0, 5);

            Material mC1 = new Material(Color.Black, 0.3, 0.3, 0.4, 0, 5);
            Material mC2 = new Material(Color.White, 0.3, 0.3, 0.4, 0, 5);

            Carpet carpet = new Carpet(new Point3D(0, 0, 0), new SizeF(5000, 5000), new Size(50, 50), mC1, mC2);
            double r = 100;
            double h = 2 * r * 0.866;
            double x = -h * 0.66 * 0.7;
            //шары в форме пирамиды
            Sphere sphere1 = new Sphere(new Point3D(x, x, r), r, mS1);
            Sphere sphere2 = new Sphere(new Point3D(x + h * 0.7 - r * 0.7, x + h * 0.7 + r * 0.7, r), r, mS2);
            Sphere sphere3 = new Sphere(new Point3D(x + h * 0.7 + r * 0.7, x + h * 0.7 - r * 0.7, r), r, mS3);
            Sphere sphere4 = new Sphere(new Point3D(x + h * 0.7 * 0.66, x + h * 0.7 * 0.66, 2.5 * r), r, mS4);

            scene.AddGraphicsObject(carpet);

            scene.AddGraphicsObject(sphere1);
            scene.AddGraphicsObject(sphere2);
            scene.AddGraphicsObject(sphere3);
            scene.AddGraphicsObject(sphere4);

            Light L1 = new Light(new Point3D(0, 0, 2000), Color.White);
            Light L2 = new Light(new Point3D(0, 2000, 3000), Color.White);
            Light L3 = new Light(new Point3D(2000, 0, 3000), Color.White);
            Light L4 = new Light(new Point3D(0, -2000, 3000), Color.White);
            Light L5 = new Light(new Point3D(-2000, 0, 3000), Color.White);
            //scene.AddLight(L1);
            scene.AddLight(L2);
            scene.AddLight(L3);
            scene.AddLight(L4);
            scene.AddLight(L5);

            return scene;
        }
示例#2
0
文件: Program.cs 项目: remy22/dx11
        public PickingDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _pickedTriangle = -1;
            MainWindowCaption = "Picking Demo";

            _lastMousePos = new Point();

            _cam = new FpsCamera {
                Position = new Vector3(0, 2, -15)
            };
            _meshWorld = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Matrix.Translation(0, 1, 0);
            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient   = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = Color.Black,
                    Direction = new Vector3(0.0f, -0.707f, -0.707f)
                }
            };
            _meshMat = new Material {
                Ambient = new Color4(0.4f, 0.4f, 0.4f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
            _pickedTriangleMat = new Material {
                Ambient = new Color4(0, 0.8f, 0.4f),
                Diffuse = new Color4(0, 0.8f, 0.4f),
                Specular = new Color4(16.0f, 0.0f, 0.0f, 0.0f)
            };
        }
示例#3
0
        public CrateDemo(IntPtr hInstance) : base(hInstance) {
            MainWindowCaption = "Crate Demo";
            _eyePosW = new Vector3();
            _theta = 1.3f * MathF.PI;
            _phi = 0.4f * MathF.PI;
            _radius = 2.5f;

            _lastMousePos = new Point();

            _boxWorld = Matrix.Identity;
            _texTransform = Matrix.Identity;
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.3f, 0.3f, 0.3f),
                    Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                    Specular = new Color4(16.0f, 0.6f, 0.6f, 0.6f),
                    Direction = new Vector3(0.707f, -0.707f, 0.0f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(1.4f, 1.4f, 1.4f),
                    Specular = new Color4(16.0f, 0.3f, 0.3f, 0.3f),
                    Direction = new Vector3(-0.707f, 0, 0.707f)
                },
            };

            _boxMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = new Color4(1,1,1),
                Specular = new Color4(16.0f, 0.6f, 0.6f, 0.6f)
            };

        }
示例#4
0
        public LightingDemo(IntPtr hInstance) : base(hInstance) {
            _landVB = null;
            _landIB = null;
            _waveVB = null;
            _waveIB = null;
            _fx = null;
            _tech = null;
            _fxWorld = null;
            _fxWIT = null;
            _fxEyePosW = null;
            _fxDirLight = null;
            _fxPointLight = null;
            _fxSpotLight = null;
            _fxMaterial = null;
            _fxWVP = null;
            _inputLayout = null;
            _eyePosW = new Vector3();
            _theta = 1.5f*MathF.PI;
            _phi = 0.1f*MathF.PI;
            _radius = 80.0f;

            MainWindowCaption = "Lighting Demo";

            _lastMousePos = new Point();

            _landWorld = Matrix.Identity;
            _wavesWorld = Matrix.Translation(0, -3.0f, 0);
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _dirLight = new DirectionalLight {
                Ambient = new Color4(0.2f, 0.2f, 0.2f),
                Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                Specular = new Color4(0.5f, 0.5f, 0.5f),
                Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
            };

            _pointLight = new PointLight {
                Ambient = new Color4(0.3f, 0.3f, 0.3f),
                Diffuse = new Color4(0.7f, 0.7f, 0.7f),
                Specular = new Color4(0.7f, 0.7f, 0.7f),
                Attenuation = new Vector3(0.0f, 0.1f, 0.0f),
                Range = 25.0f
            };
            _spotLight = new SpotLight {
                Ambient = new Color4(0,0,0),
                Diffuse = new Color4(1.0f, 1.0f, 0.0f),
                Specular = Color.White,
                Attenuation = new Vector3(1.0f, 0.0f, 0.0f),
                Spot = 96.0f,
                Range = 10000.0f
            };

            // NOTE: must put alpha (spec power) first, rather than last as in book code
            _landMaterial = new Material {
                Ambient = new Color4(1.0f, 0.48f, 0.77f, 0.46f),
                Diffuse = new Color4(1.0f, 0.48f, 0.77f, 0.46f),
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _wavesMaterial = new Material {
                Ambient =  new Color4(0.137f, 0.42f, 0.556f),
                Diffuse = new Color4(0.137f, 0.42f, 0.556f),
                Specular = new Color4(96.0f, 0.8f, 0.8f, 0.8f)
            };

        }
示例#5
0
文件: Program.cs 项目: remy22/dx11
        public InstancingAndCullingDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _skullIndexCount = 0;
            _visibleObjectCount = 0;
            _frustumCullingEnabled = true;
            _instancing = true;
            _skullsOrBoxes = true;

            MainWindowCaption = "Instancing and Culling Demo";

            _lastMousePos = new Point();

            _cam = new FpsCamera {
                Position = new Vector3(0, 2, -15)
            };

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient   = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = Color.Black,
                    Direction = new Vector3(0.0f, -0.707f, -0.707f)
                }
            };
            _skullMat = new Material {
                Ambient = new Color4(0.4f, 0.4f, 0.4f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
        }
示例#6
0
        public CameraDemo(IntPtr hInstance)
            : base(hInstance) {
            _lightCount = 3;
            Enable4XMsaa = true;
            MainWindowCaption = "Camera Demo";

            _lastMousePos = new Point();

            _useFpsCamera = true;

            _cam = new FpsCamera {
                Position = new Vector3(0, 2, -15)
            };

            _cam2 = new LookAtCamera();
            _cam2.LookAt(new Vector3(0, 2, -15), new Vector3(), Vector3.UnitY);

            _gridWorld = Matrix.Identity;

            _boxWorld = Matrix.Scaling(3.0f, 1.0f, 3.0f) * Matrix.Translation(0, 0.5f, 0);

            _skullWorld = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Matrix.Translation(0, 1.0f, 0);
            for (var i = 0; i < 5; i++) {
                _cylWorld[i * 2] = Matrix.Translation(-5.0f, 1.5f, -10.0f + i * 5.0f);
                _cylWorld[i * 2 + 1] = Matrix.Translation(5.0f, 1.5f, -10.0f + i * 5.0f);

                _sphereWorld[i * 2] = Matrix.Translation(-5.0f, 3.5f, -10.0f + i * 5.0f);
                _sphereWorld[i * 2 + 1] = Matrix.Translation(5.0f, 3.5f, -10.0f + i * 5.0f);
            }
            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4( 0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f, 0.2f, 0.2f, 0.2f),
                    Specular = new Color4(1.0f, 0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f,0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0,0,0),
                    Direction = new Vector3(0, -0.707f, -0.707f)
                }
            };
            _gridMat = new Material {
                Ambient = new Color4(0.8f, 0.8f, 0.8f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
            _cylinderMat = new Material {
                Ambient = Color.White,
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
            _sphereMat = new Material {
                Ambient = new Color4(0.6f, 0.8f, 0.9f),
                Diffuse = new Color4(0.6f, 0.8f, 0.9f),
                Specular = new Color4(16.0f, 0.9f, 0.9f, 0.9f)
            };
            _boxMat = new Material {
                Ambient = Color.White,
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
            _skullMat = new Material {
                Ambient = new Color4(0.4f, 0.4f, 0.4f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
        }
示例#7
0
        public MirrorDemo(IntPtr hInstance) : base(hInstance) {
            _skullTranslation = new Vector3(0, 1, -5);
            _eyePosW = new Vector3();
            _renderOptions = RenderOptions.Textures;
            _theta = 1.24f * MathF.PI;
            _phi = 0.42f * MathF.PI;
            _radius = 12.0f;

            MainWindowCaption = "Mirror Demo";

            Enable4XMsaa = false;

            _lastMousePos = new Point();

            _roomWorld = Matrix.Identity;
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient   = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = Color.Black,
                    Direction = new Vector3(0.0f, -0.707f, -0.707f)
                }
            };

            _roomMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f), 
                Diffuse = Color.White, 
                Specular = new Color4(16.0f, 0.4f, 0.4f, 0.4f)
            };

            _skullMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.4f, 0.4f, 0.4f)
            };
            _mirrorMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = new Color4(0.5f, 1,1,1),
                Specular = new Color4(16.0f, 0.4f, 0.4f, 0.4f)
            };
            _shadowMat = new Material {
                Ambient = Color.Black,
                Diffuse = new Color4(0.5f, 0,0,0),
                Specular = new Color4(16.0f, 0, 0, 0)
            };

        }
示例#8
0
文件: SsaoDemo.cs 项目: remy22/dx11
        private SsaoDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _lightRotationAngle = 0.0f;

            MainWindowCaption = "SSAO Demo";

            _lastMousePos = new Point();

            _camera = new FpsCamera {Position = new Vector3(0, 2, -15)};

            _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(10 * 10 + 15 * 15));

            _skullWorld = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Matrix.Translation(0, 1.0f, 0);

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(1f, 1f, 1f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.4f),
                    Specular = new Color4(0.8f, 0.8f, 0.7f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4( 0.4f, 0.4f, 0.4f),
                    Specular = new Color4( 0.2f, 0.2f, 0.2f),
                    Direction = new Vector3(0.707f, -0.707f, 0)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.2f,0.2f,0.2f),
                    Direction = new Vector3(0, 0, -1)
                }
            };

            _originalLightDirs = _dirLights.Select(l => l.Direction).ToArray();

            _skullMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                Specular = new Color4(16.0f, 0.5f, 0.5f, 0.5f),
                Reflect = new Color4(0.3f, 0.3f, 0.3f)
            };
        }
示例#9
0
        public TexturedHillsDemo(IntPtr hInstance) : base(hInstance) {
            _waterTexOffset = new Vector2();
            _eyePosW = new Vector3();
            _theta = 1.3f * MathF.PI;
            _phi = 0.4f * MathF.PI;
            _radius = 80.0f;

            MainWindowCaption = "Textured Hills and Waves Demo";

            _lastMousePos = new Point();

            _landWorld = Matrix.Identity;
            _wavesWorld = Matrix.Translation(0, -3.0f, 0);

            _view = Matrix.Identity;
            _proj = Matrix.Identity;
            
            _grassTexTransform = Matrix.Scaling(5.0f, 5.0f, 0.0f);

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient   = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = Color.Black,
                    Direction = new Vector3(0.0f, -0.707f, -0.707f)
                }
            };
            _landMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _wavesMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(32.0f, 0.8f, 0.8f, 0.8f)
            };


        }
示例#10
0
        protected NormalDisplacementMapsDemo(IntPtr hInstance) : base(hInstance) {
            _renderOptions = RenderOptions.NormalMap;
            MainWindowCaption = "Normal-Displacement Map Demo";

            Enable4XMsaa = true;
            _lastMousePos = new Point();

            _camera = new FpsCamera { Position = new Vector3(0, 2, -15) };
            _gridWorld = Matrix.Identity;

            _boxWorld = Matrix.Scaling(3.0f, 1.0f, 3.0f) * Matrix.Translation(0, 0.5f, 0);
            _skullWorld = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Matrix.Translation(0, 1.0f, 0);

            for (var i = 0; i < 5; i++) {
                _cylWorld[i * 2] = Matrix.Translation(-5.0f, 1.5f, -10.0f + i * 5.0f);
                _cylWorld[i * 2 + 1] = Matrix.Translation(5.0f, 1.5f, -10.0f + i * 5.0f);

                _sphereWorld[i * 2] = Matrix.Translation(-5.0f, 3.5f, -10.0f + i * 5.0f);
                _sphereWorld[i * 2 + 1] = Matrix.Translation(5.0f, 3.5f, -10.0f + i * 5.0f);
            }
            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4( 0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f, 0.2f, 0.2f, 0.2f),
                    Specular = new Color4(1.0f, 0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f,0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0,0,0),
                    Direction = new Vector3(0, -0.707f, -0.707f)
                }
            };
            _gridMat = new Material {
                Ambient = new Color4(0.8f, 0.8f, 0.8f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _cylinderMat = new Material {
                Ambient = Color.White,
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _sphereMat = new Material {
                Ambient = new Color4(0.6f, 0.8f, 0.9f),
                Diffuse = new Color4(0.6f, 0.8f, 0.9f),
                Specular = new Color4(16.0f, 0.9f, 0.9f, 0.9f),
                Reflect = new Color4(0.4f, 0.4f, 0.4f)
            };
            _boxMat = new Material {
                Ambient = Color.White,
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _skullMat = new Material {
                Ambient = new Color4(0.4f, 0.4f, 0.4f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = new Color4(0.5f, 0.5f, 0.5f)
            };
        }
示例#11
0
        public TreeBillboardDemo(IntPtr hInstance) : base(hInstance) {
            _alphaToCoverageEnabled = true;
            _waterTexOffset = new Vector2();
            _eyePosW = new Vector3();
            _landIndexCount = 0;
            _renderOptions = RenderOptions.TexturesAndFog;
            _theta = 1.3f * MathF.PI;
            _phi = 0.4f * MathF.PI;
            _radius = 80.0f;

            MainWindowCaption = "Tree Billboard Demo";
            Enable4XMsaa = true;

            _lastMousePos = new Point();

            _landWorld = Matrix.Identity;
            _wavesWorld = Matrix.Translation(0, -3.0f, 0);
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _boxWorld = Matrix.Scaling(15.0f, 15.0f, 15.0f) * Matrix.Translation(8.0f, 5.0f, -15.0f);

            _grassTexTransform = Matrix.Scaling(5, 5, 5);

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                }, 
                new DirectionalLight {
                    Ambient   = Color.Black,
                    Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                    Specular = Color.Black,
                    Direction = new Vector3(0.0f, -0.707f, -0.707f)
                }
            };
            _landMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _wavesMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = new Color4(0.6f, 1.0f, 1.0f, 1.0f),
                Specular = new Color4(32.0f, 0.8f, 0.8f, 0.8f)
            };
            _boxMat = new Material {
                Ambient = new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.4f, 0.4f, 0.4f)
            };
            _treeMat = new Material {
                Ambient =  new Color4(0.5f, 0.5f, 0.5f),
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
        }
示例#12
0
文件: Program.cs 项目: remy22/dx11
        public DynamicCubeMapDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _lightCount = 3;
            _lastMousePos = new Point();
            MainWindowCaption = "Dynamic CubeMap Demo";

            _camera = new FpsCamera { Position = new Vector3(0, 2, -15) };

            BuildCubeFaceCamera(0.0f, 2.0f, 0.0f);
            for (int i = 0; i < 6; i++) {
                _dynamicCubeMapRTV[i] = null;
            }
            _gridWorld = Matrix.Identity;

            _boxWorld = Matrix.Scaling(3.0f, 1.0f, 3.0f) * Matrix.Translation(0, 0.5f, 0);
            _centerSphereWorld = Matrix.Scaling(new Vector3(2.0f)) * Matrix.Translation(0, 2, 0);

            //_skullWorld = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Matrix.Translation(0, 1.0f, 0);
            for (var i = 0; i < 5; i++) {
                _cylWorld[i * 2] = Matrix.Translation(-5.0f, 1.5f, -10.0f + i * 5.0f);
                _cylWorld[i * 2 + 1] = Matrix.Translation(5.0f, 1.5f, -10.0f + i * 5.0f);

                _sphereWorld[i * 2] = Matrix.Translation(-5.0f, 3.5f, -10.0f + i * 5.0f);
                _sphereWorld[i * 2 + 1] = Matrix.Translation(5.0f, 3.5f, -10.0f + i * 5.0f);
            }
            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4( 0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f, 0.2f, 0.2f, 0.2f),
                    Specular = new Color4(1.0f, 0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f,0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0,0,0),
                    Direction = new Vector3(0, -0.707f, -0.707f)
                }
            };
            _gridMat = new Material {
                Ambient = new Color4(0.8f, 0.8f, 0.8f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _cylinderMat = new Material {
                Ambient = Color.White,
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _sphereMat = new Material {
                Ambient = new Color4(0.6f, 0.8f, 0.9f),
                Diffuse = new Color4(0.6f, 0.8f, 0.9f),
                Specular = new Color4(16.0f, 0.9f, 0.9f, 0.9f),
                Reflect = Color.Black
            };
            _boxMat = new Material {
                Ambient = Color.White,
                Diffuse = Color.White,
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _skullMat = new Material {
                Ambient = new Color4(0.4f, 0.4f, 0.4f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _centerSphereMat = new Material {
                Ambient = new Color4(0.2f, 0.2f, 0.2f),
                Diffuse = new Color4(0.2f, 0.2f, 0.2f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = new Color4(0.8f, 0.8f, 0.8f)
            };
        }
示例#13
0
文件: Program.cs 项目: remy22/dx11
        public LitSkullDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _lightCount = 1;
            _eyePosW = new Vector3();
            _theta = 1.5f * MathF.PI;
            _phi = 0.1f * MathF.PI;
            _radius = 15.0f;

            MainWindowCaption = "Lit Skull Demo";

            _lastMousePos = new Point();

            _gridWorld = Matrix.Identity;
            _view = Matrix.Identity;
            _proj = Matrix.Identity;

            _boxWorld = Matrix.Scaling(3.0f, 1.0f, 3.0f) * Matrix.Translation(0, 0.5f, 0);

            _skullWorld = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Matrix.Translation(0, 1.0f, 0);

            for (var i = 0; i < 5; i++) {
                _cylWorld[i * 2] = Matrix.Translation(-5.0f, 1.5f, -10.0f + i * 5.0f);
                _cylWorld[i * 2 + 1] = Matrix.Translation(5.0f, 1.5f, -10.0f + i * 5.0f);

                _sphereWorld[i * 2] = Matrix.Translation(-5.0f, 3.5f, -10.0f + i * 5.0f);
                _sphereWorld[i * 2 + 1] = Matrix.Translation(5.0f, 3.5f, -10.0f + i * 5.0f);
            }
            _dirLights = new[] {
                new DirectionalLight {
                    Ambient = new Color4( 0.2f, 0.2f, 0.2f),
                    Diffuse = new Color4(0.5f, 0.5f, 0.5f),
                    Specular = new Color4(0.5f, 0.5f, 0.5f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f, 0.2f, 0.2f, 0.2f),
                    Specular = new Color4(1.0f, 0.25f, 0.25f, 0.25f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient = new Color4(0,0,0),
                    Diffuse = new Color4(1.0f,0.2f, 0.2f, 0.2f),
                    Specular = new Color4(0,0,0),
                    Direction = new Vector3(0, -0.707f, -0.707f)
                }
            };
            _gridMat = new Material {
                Ambient = new Color4(0.48f, 0.77f, 0.46f),
                Diffuse = new Color4(0.48f, 0.77f, 0.46f),
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _cylinderMat = new Material {
                Ambient = new Color4(0.7f, 0.85f, 0.7f),
                Diffuse = new Color4(0.7f, 0.85f, 0.7f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
            _sphereMat = new Material {
                Ambient = new Color4(0.1f, 0.2f, 0.3f),
                Diffuse = new Color4(0.2f, 0.4f, 0.6f),
                Specular = new Color4(16.0f, 0.9f, 0.9f, 0.9f)
            };
            _boxMat = new Material {
                Ambient = new Color4(0.651f, 0.5f, 0.392f),
                Diffuse = new Color4(0.651f, 0.5f, 0.392f),
                Specular = new Color4(16.0f, 0.2f, 0.2f, 0.2f)
            };
            _skullMat = new Material {
                Ambient = new Color4(0.8f, 0.8f, 0.8f),
                Diffuse = new Color4(0.8f, 0.8f, 0.8f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f)
            };
        }