public void SetValuesFrom(IRenderableIpso ipso) { //if(ipso is GraphicalUiElement gue && (gue.RenderableComponent as IRenderableIpso) != null) //{ // ipso = (gue.RenderableComponent as IRenderableIpso); //} this.mX = ipso.GetAbsoluteX(); this.mY = ipso.GetAbsoluteY(); this.mWidth = ipso.Width; this.mHeight = ipso.Height; this.mRotation = ipso.GetAbsoluteRotation(); if (ipso is GraphicalUiElement) { var asGue = ipso as GraphicalUiElement; originDisplay.SetOriginXPosition(asGue); originDisplay.UpdateTo(asGue); } UpdateToProperties(); }
public static Matrix GetAbsoluteRotationMatrix(this IRenderableIpso ipso) { var flipHorizontal = ipso.GetAbsoluteFlipHorizontal(); float rotationDegrees; if (flipHorizontal) { rotationDegrees = -ipso.GetAbsoluteRotation(); } else { rotationDegrees = ipso.GetAbsoluteRotation(); } return(Matrix.CreateRotationZ(-MathHelper.ToRadians(rotationDegrees))); }
public static void UpdateLinePrimitive(LinePrimitive linePrimitive, IRenderableIpso ipso) { Matrix matrix = Matrix.CreateRotationZ(-MathHelper.ToRadians(ipso.GetAbsoluteRotation())); linePrimitive.Replace(0, Vector2.Zero); linePrimitive.Replace(1, Vector2.Transform(new Vector2(ipso.Width, 0), matrix)); linePrimitive.Replace(2, Vector2.Transform(new Vector2(ipso.Width, ipso.Height), matrix)); linePrimitive.Replace(3, Vector2.Transform(new Vector2(0, ipso.Height), matrix)); linePrimitive.Replace(4, Vector2.Zero); // close back on itself }
private void SetLineRectangleAroundIpso(LineRectangle rectangle, IRenderableIpso pso) { float adjustedSelectionBorder = SelectionBorder / Renderer.Self.Camera.Zoom; rectangle.Visible = true; rectangle.X = pso.GetAbsoluteX() - adjustedSelectionBorder; rectangle.Y = pso.GetAbsoluteY() - adjustedSelectionBorder; rectangle.Width = pso.Width + adjustedSelectionBorder * 2; rectangle.Height = pso.Height + adjustedSelectionBorder * 2; rectangle.Rotation = pso.GetAbsoluteRotation(); }
public static bool HasCursorOver(this IRenderableIpso ipso, float x, float y) { float absoluteX = ipso.GetAbsoluteX(); float absoluteY = ipso.GetAbsoluteY(); // put the cursor in object space: x -= absoluteX; y -= absoluteY; // normally it's negative, but we are going to * -1 to rotate the other way var matrix = Matrix.CreateRotationZ(-MathHelper.ToRadians(ipso.GetAbsoluteRotation()) * -1); var relativePosition = new Vector2(x, y); relativePosition = Vector2.Transform(relativePosition, matrix); bool isXInRange = false; if (ipso.Width < 0) { isXInRange = relativePosition.X <0 && relativePosition.X> ipso.Width; } else { isXInRange = relativePosition.X > 0 && relativePosition.X < ipso.Width; } bool isYInRange = false; if (ipso.Height < 0) { isYInRange = relativePosition.Y <0 && relativePosition.Y> ipso.Height; } else { isYInRange = relativePosition.Y > 0 && relativePosition.Y < ipso.Height; } return(isXInRange && isYInRange); }
public static Matrix GetAbsoluteRotationMatrix(this IRenderableIpso ipso) { return(Matrix.CreateRotationZ(-MathHelper.ToRadians(ipso.GetAbsoluteRotation()))); }