private PathCamera CreatePathCamera(Matrix[] cameraTrack) { var camera = new PathCamera(Resolve <Device>(), Resolve <Window>(), new CameraPath(cameraTrack)); Assert.IsTrue(camera.IsPauseable); return(camera); }
public void SetCurrentFramePastEnd() { PathCamera camera = CreatePathCamera(GetLinearViewMatrixTrack(GridDimension)); camera.CurrentFrame = 1000; Assert.AreEqual(99, camera.CurrentFrame); }
public void CurrentFrameDoesNotChangeWhenNotMoving() { PathCamera camera = CreatePathCamera(GetLinearViewMatrixTrack(GridDimension)); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(0, camera.CurrentFrame); }
private void MoveCameraAutomatedOnTrack(Matrix[] track) { new Grid3D(new Size(GridDimension)); PathCamera camera = CreatePathCamera(track); new Command(Command.MiddleClick, () => { camera.IsMoving = !camera.IsMoving; }); new Command(Command.RightClick, () => camera.CurrentFrame = 0); }
public void CameraCanBeMovedOnLinearTrackWithScrollWheel() { new Grid3D(new Size(GridDimension)); PathCamera camera = CreatePathCamera(GetLinearViewMatrixTrack(GridDimension)); Command.Register(Command.Zoom, new MouseZoomTrigger()); new Command(Command.Zoom, zoomAmount => camera.CurrentFrame += (int)(zoomAmount * 10)); }
public void GetCurrentViewMatrix() { var matrices = GetLinearViewMatrixTrack(GridDimension); PathCamera camera = CreatePathCamera(matrices); camera.CurrentFrame = 5; Assert.AreEqual(matrices[5], camera.GetCurrentViewMatrix()); }
public void CurrentFrameChangesWhenMoving() { PathCamera camera = CreatePathCamera(GetLinearViewMatrixTrack(GridDimension)); camera.IsMoving = true; AdvanceTimeAndUpdateEntities(); Assert.IsTrue(camera.CurrentFrame > 0); }
public Scene(App app) : base(app) { camera = new PathCamera(App); camera.NearPlane = 0.3f; camera.FarPlane = 1024; camera.Rotation.Yaw = 0; camera.Rotation.Pitch = 0; const int m = 25; camera.AddWayPoint(new WayPoint(0 * m, -232, 32, -232, 45, 45, 0)); camera.AddWayPoint(new WayPoint(1 * m, 180, 64, 180, 45, 25, 0)); camera.AddWayPoint(new WayPoint(2 * m, -240, 40, 240, 135, 45, 0)); camera.AddWayPoint(new WayPoint(3 * m, 0, 40, 0, 135, 30, 0)); camera.AddWayPoint(new WayPoint(4 * m, 230, 50, 180, 0, 0, 0)); camera.AddWayPoint(new WayPoint(5 * m, -232, 32, -232, -675, 45, 0)); lightBuffer = new Buffer(Device, 64, ResourceUsage.Dynamic, BindFlags.ConstantBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0); worldBuffer = new Buffer(Device, 192, ResourceUsage.Dynamic, BindFlags.ConstantBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0); world = new World(App, worldBuffer, 16, 9); basicShader = ResourceManager.BasicShader; instanceShader = ResourceManager.InstanceShader; geometryShader = ResourceManager.GeometryShader; lightSetup = new LightBuffer(); lightSetup.AmbientColor = Color.White.ToVector4(); lightSetup.AmbientIntensity = 0.1f; lightSetup.LightColor = Color.White.ToVector4(); lightSetup.LightDirection = Vector3.Normalize(new Vector3(0.25f, -1, 2)); using (Heightmap heightmap = new Heightmap(App, 64, "IP_HEIGHTMAP")) using (ColorMap colormap = new ColorMap(App, "IP_COLOR")) { MapGenerator chunkGenerator = new MapGenerator(heightmap, colormap, world.ChunkSize, 8); IEnumerator <BlockInsert[]> enumerator = chunkGenerator.GetEnumerator(); while (enumerator.MoveNext()) { world.SetBlocks(enumerator.Current.Select(insert => { insert.Position -= new Vector3(heightmap.Width, 0, heightmap.Height) / 2; return(insert); })); } } }
protected override void CreateScene() { var pointList = new List <CameraPoint>() { new CameraPoint() { Position = new Vector3(0f, 0f, 15f), LookAt = Vector3.Zero, Up = Vector3.Up }, new CameraPoint() { Position = new Vector3(30f, 0f, 15f), LookAt = Vector3.Zero, Up = Vector3.Up }, new CameraPoint() { Position = new Vector3(30f, 30f, 15f), LookAt = new Vector3(-15f, 0f, 0f), Up = Vector3.UnitX }, new CameraPoint() { Position = new Vector3(-30f, 0f, 15f), LookAt = new Vector3(-15f, 0f, 0f), Up = Vector3.Up }, new CameraPoint() { Position = new Vector3(0f, 0f, 15f), LookAt = Vector3.Zero, Up = Vector3.Up } }; PathCamera pathCamera = new PathCamera("path", new Vector3(0, 15f, 15f), Vector3.Zero, pointList, 500) { Speed = 0.5f, }; RenderManager.SetActiveCamera(pathCamera.Entity); EntityManager.Add(pathCamera.Entity); CreateCube("Cube1", Vector3.Zero); CreateCube("Cube2", new Vector3(15f, 0f, 0f)); CreateCube("Cube3", new Vector3(-15f, 0f, 0f)); CreateCube("Cube4", new Vector3(0f, 0f, 15f)); CreateCube("Cube5", new Vector3(0f, 0f, -15f)); RenderManager.BackgroundColor = Color.CornflowerBlue; }