Esempio n. 1
0
        protected VoronoiMapDemo(IntPtr hInstance) : base(hInstance)
        {
            MainWindowCaption = "Voronoi Map Demo";
            _lastMousePos     = new Point();

            _biomeColors                            = new Dictionary <string, Color4>();
            _biomeColors["Ocean"]                   = Color.DarkBlue;
            _biomeColors["Marsh"]                   = Color.CadetBlue;
            _biomeColors["Ice"]                     = Color.AliceBlue;
            _biomeColors["Lake"]                    = Color.Blue;
            _biomeColors["Beach"]                   = Color.Gold;
            _biomeColors["Snow"]                    = Color.White;
            _biomeColors["Tundra"]                  = Color.OliveDrab;
            _biomeColors["Bare"]                    = Color.DarkGray;
            _biomeColors["Scorched"]                = Color.DarkRed;
            _biomeColors["Taiga"]                   = Color.DarkGreen;
            _biomeColors["Shrubland"]               = Color.DarkOliveGreen;
            _biomeColors["TemperateDesert"]         = Color.SaddleBrown;
            _biomeColors["TemperateRainForest"]     = Color.ForestGreen;
            _biomeColors["TemperateDecidousForest"] = Color.DarkSeaGreen;
            _biomeColors["Grassland"]               = Color.YellowGreen;
            _biomeColors["TropicalRainForest"]      = Color.LawnGreen;
            _biomeColors["TropicalSeasonalForest"]  = Color.Olive;
            _biomeColors["SubtropicalDesert"]       = Color.Khaki;

            _camera = new FpsCamera {
                Position = new Vector3(0, 2, -15)
            };
            _map = new Map(100.0f);
            _map.NewIsland("square", 0, 0);
            _map.Go(0, 0);
        }
Esempio n. 2
0
        public void Update(Vector3 center)
        {
            var targets = new[] {
                new Vector3(center.X + 1, center.Y, center.Z),
                new Vector3(center.X - 1, center.Y, center.Z),
                new Vector3(center.X, center.Y + 1, center.Z),
                new Vector3(center.X, center.Y - 1, center.Z),
                new Vector3(center.X, center.Y, center.Z + 1),
                new Vector3(center.X, center.Y, center.Z - 1)
            };

            var ups = new[] {
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
                new Vector3(0, 0, -1),
                new Vector3(0, 0, 1),
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
            };

            for (var i = 0; i < 6; i++)
            {
                _cameras[i] = new FpsCamera(MathF.PI / 2)
                {
                    NearZ = 0.1f,
                    FarZ  = 100.0f
                };
                _cameras[i].LookAt(center, targets[i], ups[i]);
                _cameras[i].SetLens(1.0f);
                _cameras[i].UpdateViewMatrix();
            }
        }
Esempio n. 3
0
        private void BuildCubeFaceCamera(float x, float y, float z)
        {
            var center  = new Vector3(x, y, z);
            var worldUp = new Vector3(0, 1, 0);
            var targets = new[] {
                new Vector3(x + 1, y, z),
                new Vector3(x - 1, y, z),
                new Vector3(x, y + 1, z),
                new Vector3(x, y - 1, z),
                new Vector3(x, y, z + 1),
                new Vector3(x, y, z - 1)
            };
            var ups = new[] {
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
                new Vector3(0, 0, -1),
                new Vector3(0, 0, 1),
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
            };

            for (int i = 0; i < 6; i++)
            {
                _cubeMapCamera[i] = new FpsCamera();
                _cubeMapCamera[i].LookAt(center, targets[i], ups[i]);
                _cubeMapCamera[i].SetLens(MathF.PI / 2, 1.0f, 0.1f, 1000.0f);
                _cubeMapCamera[i].UpdateViewMatrix();
            }
        }
Esempio n. 4
0
        public ShapesApp(IntPtr hInstance) : base(hInstance)
        {
            shapes = new List <ShapeBase>();

            dirLights = new DirectionalLight
            {
                Ambient   = new Color4(0.8f, 0.8f, 0.8f),
                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)
            };

            texTransform = Matrix.Identity;
            world        = Matrix.Identity;
            view         = Matrix.Identity;
            projection   = Matrix.Identity;

            eyePosW           = new Vector3();
            lastMousePosition = new Point();

            phi    = 0.4f * MathF.PI;
            theta  = 1f * MathF.PI;
            radius = 25;

            camera = new FpsCamera()
            {
                Position = new Vector3(radius, 3, 0)
            };
        }
Esempio n. 5
0
        private AssimpModelDemo(IntPtr hInstance)
            : base(hInstance)
        {
            MainWindowCaption = "Assimp Model Demo";
            _lastMousePos     = new Point();
            Enable4XMsaa      = true;

            _camera = 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   = 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)
                }
            };
        }
Esempio n. 6
0
        private ParticlesDemo(IntPtr hInstance) : base(hInstance)
        {
            MainWindowCaption = "Particles Demo";

            _camera = new FpsCamera {
                Position = new Vector3(0, 2, 100)
            };
            _dirLights = new[] {
                new DirectionalLight {
                    Ambient   = new Color4(0.3f, 0.3f, 0.3f),
                    Diffuse   = new Color4(1f, 1f, 1f),
                    Specular  = new Color4(0.8f, 0.8f, 0.8f),
                    Direction = new Vector3(0, -0.707f, -0.707f)//
                },
                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.2f, 0.2f, 0.2f),
                    Direction = new Vector3(0.57735f, -0.57735f, 0.57735f)
                },
                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.57735f, -0.57735f, 0.57735f)
                }
            };
        }
Esempio n. 7
0
        private ShapeModelsDemo(IntPtr hInstance)
            : base(hInstance)
        {
            MainWindowCaption = "ShapeModels Demo";

            _lastMousePos = new Point();

            _camera = 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.7f, 0.7f, 0.7f),
                    Specular  = new Color4(0.8f, 0.8f, 0.8f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient   = new Color4(0, 0, 0),
                    Diffuse   = new Color4(1.0f, 0.4f, 0.4f, 0.4f),
                    Specular  = new Color4(1.0f, 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(1.0f, 0.2f, 0.2f, 0.2f),
                    Specular  = new Color4(0.2f, 0.2f, 0.2f),
                    Direction = new Vector3(0, 0, -1)
                }
            };
        }
Esempio n. 8
0
        private BallisticDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _currentShotType = ShotType.Laser;

            MainWindowCaption = "Ballistic Demo";

            _lastMousePos = new Point();

            _camera = new FpsCamera();
            _camera.LookAt(new Vector3(10, 2, -10), new Vector3(0, 1, 0), Vector3.UnitY);

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient   = new Color4(0.2f, 0.2f, 0.2f),
                    Diffuse   = new Color4(0.7f, 0.7f, 0.7f),
                    Specular  = new Color4(0.8f, 0.8f, 0.8f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient   = new Color4(0, 0, 0),
                    Diffuse   = new Color4(1.0f, 0.4f, 0.4f, 0.4f),
                    Specular  = new Color4(1.0f, 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(1.0f, 0.2f, 0.2f, 0.2f),
                    Specular  = new Color4(0.2f, 0.2f, 0.2f),
                    Direction = new Vector3(0, 0, -1)
                }
            };
        }
Esempio n. 9
0
        protected override void InitializeInternal()
        {
            base.InitializeInternal();

            var clientSize = ControlWindow.ClientSize;

            _camera = new FpsCamera(MathUtil.DegreesToRadians(45), (float)clientSize.Width / clientSize.Height, 0.1f, 1000);
            NoireConfiguration.ResourceBase = "resources";
        }
Esempio n. 10
0
        public ShadowsSpot(int mapSize) : base(mapSize)
        {
            _camera = new FpsCamera(1f)
            {
                NearZ = 0.02f
            };

            _buffer = TargetResourceDepthTexture.Create();
        }
Esempio n. 11
0
        public MainWindow(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            Camera = new FpsCamera(Size.X, Size.Y);

            Camera.CameraPosition = new OpenToolkit.Mathematics.Vector3(0, -80, 40);
            Camera.CameraYaw      = -90;
            Camera.CameraPitch    = 90;
            Camera.RecalculateCamera(0, 0);
        }
Esempio n. 12
0
            public FpsCamera ToCamera()
            {
                var camera = new FpsCamera(Fov.ToRadians())
                {
                    Position = Position
                };

                camera.LookAt(Position, Position + Look, Up);
                return(camera);
            }
Esempio n. 13
0
            public FpsCamera ToCamera(Matrix transform)
            {
                var camera = new FpsCamera(Fov.ToRadians());

                camera.LookAt(
                    Vector3.TransformCoordinate(Position, transform),
                    Vector3.TransformCoordinate(Position + Look, transform),
                    Vector3.TransformNormal(Up, transform));
                return(camera);
            }
Esempio n. 14
0
    public override void Initialize()
    {
        // camera 3D init
        camera = new FpsCamera(Core.screen.size);
        camera.SetPosition(new Vector3f(-20, 10, 20));
        camera.SetRotation(-Math.Pi / 10f, 3f / 4f * Math.Pi);

        // core init
        Core.mainCamera = camera;         // See "UnityBootstrap.Update()" method
        Core.graphics.ClearAuto(true, new Color32(71));

        // camera 2D init
        hudCamera = new Camera2D(Core.screen.size);
        hudCamera.SetZoom(2f);

        // materials init
        shapesMaterial  = Core.resource.CreateMaterial("Lines/Colored Blended");
        spritesMaterial = Core.resource.CreateMaterial("Unlit/Transparent");

        // grid init
        gridMesh = Models.CreateGrid(100);

        // model test init
        testtransform = new Transform3D();
        testtransform.Rotate(new Vector3f(-90f * Math.Deg2Rad, 0f, 0f));
        testmesh     = Core.resource.LoadMesh("Models/Test");
        testtexture  = Core.resource.LoadTexture("Models/lightmap");
        testmaterial = Core.resource.CreateMaterial("Unlit/Texture");
        testmaterial.Set("_MainTex", testtexture);

        // billboard init
        testtransformbillboard = new Transform3D();
        testtransformbillboard.SetPosition(new Vector3f(0, 0, 10));
        testtransformbillboard.SetLocalScale(Vector3f.one * 0.01f);
        billboard = Core.resource.LoadTexture("Sprites/tree_billboard");

        // procedural texture init
        {
            proceduralTexture = Core.resource.CreateTexture(256, 256);

            for (int x = 0; x < proceduralTexture.GetWidth(); ++x)
            {
                for (int y = 0; y < proceduralTexture.GetHeight(); ++y)
                {
                    var baseColor    = new Color((float)x / proceduralTexture.GetWidth(), 0.5f, (float)y / proceduralTexture.GetHeight());
                    var checkerColor = (new Color(1f, 1f, 1f, 0f)) * (y % 32 > 15 ? (x % 32 > 15 ? 0 : 0.2f) : (x % 32 <= 15 ? 0 : 0.2f));

                    proceduralTexture.SetPixel(x, y, baseColor - checkerColor);
                }
            }

            proceduralTexture.Apply();
        }
    }
Esempio n. 15
0
        private PointLightDemo(IntPtr hInstance) : base(hInstance)
        {
            MainWindowCaption        = "Point Light Demo";
            _lastMousePos            = new Point();
            Enable4XMsaa             = true;
            GammaCorrectedBackBuffer = true;

            _camera = new FpsCamera();
            _camera.LookAt(new Vector3(71, 41, 71), Vector3.Zero, Vector3.UnitY);

            _dirLightDirection.Normalize();
        }
Esempio n. 16
0
        public void SetCamera(Vector3 from, Vector3 to, float fovRadY)
        {
            UseFpsCamera = true;
            Camera       = new FpsCamera(fovRadY);

            _cameraTo = to;
            Camera.LookAt(from, to, Vector3.UnitY);
            Camera.SetLens(AspectRatio);
            //Camera.UpdateViewMatrix();

            PrepareCamera(Camera);
            IsDirty = true;
        }
        public override void Init()
        {
            internalCamera = Camera as FpsCamera;

            CollisionMeshes = new List <ItemModel>();

            collisionCylinder = new TgcBoundingCylinder(Camera.LookAt, 50f, 200f);
            updownRot         = Geometry.DegreeToRadian(90f) + (FastMath.PI / 10.0f);
            collisionCylinder.rotateZ(updownRot);
            collisionCylinder.setRenderColor(Color.LimeGreen);
            collisionCylinder.updateValues();

            pickUpSound.loadSound(MediaDir + "\\Sounds\\pickUpItem.wav", DirectSound.DsDevice);
        }
Esempio n. 18
0
        private ShadowsDemo(IntPtr hInstance)
            : base(hInstance)
        {
            _lightRotationAngle = 0;

            MainWindowCaption = "Shadows 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(0.2f, 0.2f, 0.2f),
                    Diffuse   = new Color4(0.7f, 0.7f, 0.7f),
                    Specular  = new Color4(0.8f, 0.8f, 0.8f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient   = new Color4(0, 0, 0),
                    Diffuse   = new Color4(1.0f, 0.4f, 0.4f, 0.4f),
                    Specular  = new Color4(1.0f, 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(1.0f, 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.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)
            };
        }
Esempio n. 19
0
        public void SetCamera(Vector3 lookFrom, Vector3 lookAt, float fovRadY, float tiltRad)
        {
            UseFpsCamera = true;
            AutoRotate   = false;
            Camera       = new FpsCamera(fovRadY);

            _cameraTo = lookAt;
            Camera.LookAt(lookFrom, lookAt, tiltRad);
            Camera.SetLens(AspectRatio);
            //Camera.UpdateViewMatrix();

            PrepareCamera(Camera);
            IsDirty           = true;
            _cameraIgnoreNext = true;
        }
        public override void Init()
        {
            internalCamera = Camera as FpsCamera;

            ShowInventory  = false;
            ShowFatherNote = false;
            ShowCraft      = false;
            CanShowCraft   = false;
            CanUseShipHelm = false;
            ShowHistory    = true;
            Win            = false;

            InventoryModel.Init();
            fatherNoteModel.Init();
            craftModel.Init();
        }
Esempio n. 21
0
        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)
            };
        }
Esempio n. 22
0
        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)
            };
        }
Esempio n. 23
0
        public void Update(Vector3 center)
        {
            if (_cameras[0] != null && (center - _previousCenter).LengthSquared() < 0.01)
            {
                return;
            }

            var targets = new[] {
                new Vector3(center.X + 1, center.Y, center.Z),
                new Vector3(center.X - 1, center.Y, center.Z),
                new Vector3(center.X, center.Y + 1, center.Z),
                new Vector3(center.X, center.Y - 1, center.Z),
                new Vector3(center.X, center.Y, center.Z + 1),
                new Vector3(center.X, center.Y, center.Z - 1)
            };

            var ups = new[] {
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
                new Vector3(0, 0, -1),
                new Vector3(0, 0, 1),
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
            };

            for (var i = 0; i < 6; i++)
            {
                _cameras[i] = new FpsCamera(MathF.PI / 2)
                {
                    FarZ   = 500.0f,
                    RhMode = false
                };
                _cameras[i].LookAt(center, targets[i], ups[i]);
                _cameras[i].SetLens(1f);
                _cameras[i].UpdateViewMatrix();
            }

            _previousCenter = center;
            SetDirty();
        }
Esempio n. 24
0
        public Level1Model(UnderseaModel gameModel, TgcCamera camera, TgcD3dInput input, string mediaDir, string shadersDir, TgcFrustum frustum, TgcText2D drawText, TgcDirectSound directSound)
            : base(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText)
        {
            hudModel = new HUDModel(MediaDir, D3DDevice.Instance.Device);

            initialLookAt   = new TGCVector3(6000, 4120f, 6600f);
            initialPosition = new TGCVector3(6000, 4120f, 6600f);

            //Camara
            Camera = new FpsCamera(initialLookAt, Input);

            //Player
            playerModel = new PlayerModel(surfacePosition.Y, initialPosition, gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText, directSound);

            //Collect Model
            collectModel = new CollectModel(gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText, directSound);

            // History Model
            historyModel = new HistoryModel(gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText);

            // You Win Model
            youWinModel = new YouWinModel(gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText, directSound);
        }
Esempio n. 25
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)
            };
        }
Esempio n. 26
0
 public CameraController(Vector3 position, Vector3 lookAt)
 {
     camera = new FpsCamera(position, lookAt);
 }
Esempio n. 27
0
        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)
            };
        }
Esempio n. 28
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)
            };
        }