Hello Guest

Author Topic: ZoomFactor and Updating ScreenToWorldPoint  (Read 3969 times)

ty_alpha

  • Newbie
  • *
  • Posts: 2
    • View Profile
ZoomFactor and Updating ScreenToWorldPoint
« on: March 25, 2014, 08:10:40 pm »
I'm currently using a perspective tk2dCamera in my project and I'm trying to implement zooming through the ZoomFactor, which is so far working exactly as expected.

However, what I want to do is (all within one frame):
  • Find ScreenToWorldPoint of the mouse's screen position for the current ZoomFactor. This is fine
  • Temporarily increase the ZoomFactor
  • Find ScreenToWorldPoint of the mouse's screen position for the newZoomFactor. But ScreenToWorldPoint doesn't seem to be updated
  • Revert back to the original ZoomFactor
  • Do something over the next few frames, using these two world points, to do some zooming in and panning.

I've tried using a new Camera with .CopyFrom(my original tk2dCamera), as well as using .ResetAspect(), .ResetProjectionMatrix(), and .ResetWorldToCameraMatrix(). So far I can't seem to get anything to work. It seems to need the camera to render at the new ZoomFactor, but that's exactly what I'd like to avoid.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: ZoomFactor and Updating ScreenToWorldPoint
« Reply #1 on: March 26, 2014, 10:43:18 am »
The camera matrix is only updated at the end of the frame. You can force an update immediately by calling tk2dCamera.UpdateCameraMatrix()

ty_alpha

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: ZoomFactor and Updating ScreenToWorldPoint
« Reply #2 on: March 26, 2014, 03:55:57 pm »
Thanks - that's exactly what I needed.