mattrdowney / planetaria

A Unity framework for Euclidean 2-sphere games (e.g. 2D virtual reality games) [quasi-MIT license]
Other
10 stars 2 forks source link

NormalizedCubeCoordinates and CubeUVCoordinates #81

Closed mattrdowney closed 6 years ago

mattrdowney commented 6 years ago

Originally I was just programming SkyboxCoordinates, but I realized I should use a similar process (and naming convention) to NormalizedOctahedralCoordinates and OctahedronUVCoordinates.

The goal here is to use a good mapping (e.g. http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html).

Unity Skyboxes look like: -|-- (for the six faces), to be more specific:

U LFRB D

where LFRBUD represent up, left, front, right, back, down

So the CubeUVCoordinates should take that mapping into account.

mattrdowney commented 6 years ago

Blind commit on e150915ebe75e86b410271be4bf1a335884738fe

mattrdowney commented 6 years ago

After thinking about this, the right way to do NormalizedCartesianCoordinates -> NormalizedCubeCoordinates (and inverse) is to normalize the vector in the sphere direction and do a raycast against the plane coincident with the sign of the magnitude of the largest coordinate of the vector.

CubeUVCoordinates should be fine.

mattrdowney commented 6 years ago

Done and verified as of 54ec8ca75fba5615d843b1fcbf79644c7c7cc49a