public MainWindow() { _resource = new VanillaResource(); _eye = new Eye { DepthFar = 1024F, }; _viewTransformProvider = _eye.GetViewTransformProvider(); _projectionTransformProvider = _eye.GetPerspectiveTransformProvider(); _eyeInput = this.CreatePointerAxisInput(.5F, true).CreateSmoothAxisInput(); _moveInput = this.CreateKeyAxisInput(Keys.D, Keys.Space, Keys.S, Keys.A, Keys.LeftShift, Keys.W, true).CreateScaledAxisInput(10F).CreateSmoothAxisInput(); _world = new EmptyWorld { ChunkProvider = (x, z) => new EmptyChunk { X = x, Z = z, World = _world } }; _world.FillFast(0, 0, 0, 256, 0, 256, "bedrock"); _world.FillFast(0, 1, 0, 256, 10, 256, "iron_block"); _world.FillFast(0, 11, 0, 256, 11, 256, "diamond_block"); _world.Fill(15, 12, 14, 16, 13, 17, "gold_block"); _world.Fill(3, 12, 3, 5, 13, 5, "gold_block"); _playerObject = new() { OriginalAABB = new Box3d(-.5D, -.5D, -.5D, .5D, .5D, .5D), GravityScale = 1D, Position = (0D, 15D, 0) }; _floorObject = new BlockCollisionObject(_world); _boxRenderer = new(_viewTransformProvider, _projectionTransformProvider) { Color = Color4.Blue }; /*_cameraMotivatorRenderer = new CameraMotivatorRenderer(_eye) * { * RotationInput = _eyeInput, * PositionInput = _moveInput, * MovementSpeed = 1F, * Type = CameraType.Fps, * Controlable = true * };*/ this.AddCompletedRenderer(new CloudRenderer(_eye, _viewTransformProvider, _projectionTransformProvider, _resource)); this.AddCompletedRenderer(new WorldRenderer(_world, () => _atlases, _viewTransformProvider, _projectionTransformProvider) { Camera = _eye, AutoSetCenterChunk = true }); this.AddRenderObject(_boxRenderer); PointerGrabbed = true; }
private void Button_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(json) && !string.IsNullOrWhiteSpace(code.Text)) { File.WriteAllText(json, code.Text); if (sprite != null) { sprite.AnimationModule.ClearAnimations(); } } json = json_path.Text; image = sheet_path.Text; if (sprite == null) { sprite = new TempSprite(); } if (world == null) { world = new EmptyWorld(); world.Load(); world.Display(); } if (watcher == null) { WatchImageFile(image); } sprite.TexPath = image; sprite.JsonPath = json; sprite.HitboxConfigPath = hitbox_path.Text; original_texture = null; if (world.Sprites.Contains(sprite)) { world.RemoveSprite(sprite); } world.AddSprite(sprite); Screen.Camera.Z = 200; code.Text = File.ReadAllText(json); }