TL;DR

Another changelog is out, showing off the new three dimensional input system.

This week…

Watch The Video!

  • Projecting mouse input into 3D
  • Rebuilt the entire UI input system to be more flexible for future changes

Under The Hood

It took me a while to get this exactly right because there are a lot of little details to take into consideration for projecting input onto a UI panel. Here’s the things to think of:

  • The resolution of the webpage (defines coordinate frame for webpage injected mouse)
  • The resolution of the screen (defines coordinate frame for real mouse)
  • The position, rotation and scale of the UI display due to model transform
  • The position and rotation of the UI display due to physics transform

That’s quite a lot to take into account!

Fundamentally, though, this is quite a simple problem. Imagine that we have some plane (the UI display) with some size/rotation/position in the world and a ray which we want to find the 2D coordinates of intersection with the plane. What we really want to do is transform the ray into plane local space. So if we first rotate the everything so that the plane is axis aligned, then transform everything so that the plane is at the origin, and then scale everything so that the plane is 1x1 it’s suddenly dead easy to find the plane coordinates - just apply the same transformation to the 3D intersection and then ignore the Z component!