private Rect AddSpritesToViewport(Document document) { var globalAabb = Rect.Empty; var visibleSpriteNodes = GetVisibleSpriteNodesInDrawOrder(document); foreach (var spriteNode in visibleSpriteNodes) { SceneViewport.AddSpriteNode(spriteNode.Id, _spriteBitmapStore.Get(spriteNode.SpriteRef.RelativePath)); SceneViewport.SetTransform(spriteNode.Id, spriteNode.GetAnimateTransformation().GlobalTransform.ToWpfMatrix()); var aabb = SceneViewport.GetBoundingBox(spriteNode.Id); globalAabb = CombineAabb(aabb, globalAabb); } return(globalAabb); }
public void UpdateTransform(SceneViewport sceneViewport) { // todo replace with rectangle following transform var bounds = sceneViewport.GetBoundingBox(_nodeId); if (bounds.IsEmpty) { Canvas.SetLeft(_rectangle, -1); Canvas.SetTop(_rectangle, -1); _rectangle.Width = 0; _rectangle.Height = 0; return; } _rectangle.Width = bounds.Width; _rectangle.Height = bounds.Height; Canvas.SetLeft(_rectangle, bounds.X); Canvas.SetTop(_rectangle, bounds.Y); }