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 bool Init() { if (!base.Init()) { return(false); } Effects.InitAll(Device); InputLayouts.InitAll(Device); RenderStates.InitAll(Device); _sky = new Sky(Device, "Textures/desertcube1024.dds", 5000.0f); _sMap = new ShadowMap(Device, SMapSize, SMapSize); _camera.SetLens(0.25f * MathF.PI, AspectRatio, 1.0f, 1000.0f); _ssao = new Ssao(Device, ImmediateContext, ClientWidth, ClientHeight, _camera.FovY, _camera.FarZ); BuildShapeGeometryBuffers(); BuildSkullGeometryBuffers(); BuildScreenQuadGeometryBuffers(); return(true); }
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 bool Update(Vector3 position, Vector3 direction, float range, float angle) { var result = _dirty; _dirty = false; if (result || _camera.FovY != angle || _camera.FarZ != range) { _camera.FovY = angle; _camera.FarZ = range; _camera.SetLens(1f); result = true; } if (result || _camera.Position != position || Vector3.Dot(_camera.Look, direction) < 0.99) { _camera.LookAt(position, position + direction, Math.Abs(direction.Y - 1f) < 0.01f || Math.Abs(direction.Y - (-1f)) < 0.01f ? Vector3.UnitX : Vector3.UnitY); _camera.UpdateViewMatrix(); result = true; } if (result) { ShadowTransform = _camera.ViewProj * new Matrix { M11 = 0.5f, M22 = -0.5f, M33 = 1.0f, M41 = 0.5f, M42 = 0.5f, M44 = 1.0f }; } return(result); }
public override void OnResize() { base.OnResize(); _camera.SetLens(0.25f * MathF.PI, AspectRatio, 1.0f, 1000.0f); }