/// <summary> /// sets the position of the cross hair in the environment /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="panel"></param> /// <param name="v"></param> public void setPointerPosition(float x, float y, OpenGLCellPlacementPanel panel, Views v) { Vector2 viewOffset; Vector2 viewTempOffset; float viewZoom; switch(v) { case Views.XY: viewOffset = XY.ViewOffset; viewTempOffset = XY.ViewTempOffset; viewZoom = XY.ViewZoom; break; case Views.XZ: viewOffset = XZ.ViewOffset; viewTempOffset = XZ.ViewTempOffset; viewZoom = XZ.ViewZoom; break; default: return; } x -= panel.Padding.Left; y -= panel.Padding.Top; x -= 4; y -= 2; x /= panel.GetWidth(); y /= panel.GetHeight(); x *= 100; y *= 100; x -= 50; x *= viewZoom; x += viewOffset.x + viewTempOffset.x; //spatialViewState.CrossHairPosition.x = 10; if (v == Views.XY) { y = 50 - y; y *= viewZoom; y += viewOffset.y + viewTempOffset.y; crossHairPosition.x = x; crossHairPosition.y = y; } else if (v == Views.XZ) { y -= 50; y *= viewZoom; y -= viewOffset.y + viewTempOffset.y; crossHairPosition.x = x; crossHairPosition.z = y; } UpdateCursorOutOfBounds(); }
/// <summary> /// Updates the scroll offset /// </summary> /// <param name="px"></param> /// <param name="py"></param> /// <param name="panel"></param> public void UpdateScrollOffset(int px, int py, OpenGLCellPlacementPanel panel) { float x = (float)px; float y = (float)py; x /= panel.GetWidth(); y /= panel.GetHeight(); x *= -100; y *= 100; viewTempOffset.x = 0; viewTempOffset.y = 0; viewOffset.x += x * viewZoom; viewOffset.y += y * viewZoom; }