internal protected override bool PartialHitTest(ref HitTestArgs args) { if (Widget == null) { return(false); } var plane = GetPlane(); var ray = args.Ray; var distance = ray.Intersects(plane); if (distance.HasValue && distance <= args.Distance) { var oldPoint = args.Point; try { args.Point = (Vector2)GlobalTransform.CalcInverted().TransformVector(ray.Position + ray.Direction * distance.Value) * new Vector2(1, -1); Widget.RenderChainBuilder?.AddToRenderChain(renderChain); if (renderChain.HitTest(ref args)) { args.Distance = distance.Value; return(true); } } finally { args.Point = oldPoint; renderChain.Clear(); } } return(false); }
public void Generate(int frame, Action <ITexture> callback) { var sceneSize = sceneViewFrame.Size; var thumbSize = new Vector2(200); if (sceneSize.X > sceneSize.Y) { thumbSize.Y *= sceneSize.Y / sceneSize.X; } else { thumbSize.X *= sceneSize.X / sceneSize.Y; } var ap = new AnimationPositioner(); var savedTime = document.Animation.Time; var savedIsRunning = Document.Current.Animation.IsRunning; renderChain.Clear(); ap.SetAnimationFrame(document.Animation, frame, stopAnimations: true); sceneViewFrame.RenderChainBuilder?.AddToRenderChain(renderChain); renderList.Clear(); renderChain.GetRenderObjects(renderList); ap.SetAnimationTime(document.Animation, savedTime, stopAnimations: true); Document.Current.Animation.IsRunning = savedIsRunning; Window.Current.InvokeOnRendering(() => RenderThumbnail(callback)); }
public static void RenderToTexture(this Widget widget, ITexture texture, RenderChain renderChain, bool clearRenderTarget = true) { if (widget.Width > 0 && widget.Height > 0) { texture.SetAsRenderTarget(); Renderer.PushState( RenderState.ScissorState | RenderState.View | RenderState.World | RenderState.View | RenderState.Projection | RenderState.DepthState | RenderState.CullMode | RenderState.Transform2); Renderer.ScissorState = ScissorState.ScissorDisabled; Renderer.Viewport = new Viewport(0, 0, texture.ImageSize.Width, texture.ImageSize.Height); if (clearRenderTarget) { Renderer.Clear(new Color4(0, 0, 0, 0)); } Renderer.World = Matrix44.Identity; Renderer.View = Matrix44.Identity; Renderer.SetOrthogonalProjection(0, 0, widget.Width, widget.Height); Renderer.DepthState = DepthState.DepthDisabled; Renderer.CullMode = CullMode.None; Renderer.Transform2 = widget.LocalToWorldTransform.CalcInversed(); try { for (var node = widget.FirstChild; node != null; node = node.NextSibling) { node.RenderChainBuilder?.AddToRenderChain(renderChain); } renderChain.Render(); } finally { renderChain.Clear(); } Renderer.PopState(); texture.RestoreRenderTarget(); } }
public static void RenderAndClear(this RenderChain renderChain) { renderChain.Render(); renderChain.Clear(); }