satoshinm / NetCraft

Web-based fork of fogleman/Craft ⛺
https://satoshinm.github.io/NetCraft/
MIT License
57 stars 13 forks source link

Hit test cube face number for mining target and info text #112

Closed satoshinm closed 7 years ago

satoshinm commented 7 years ago

Get the face on which a block is being targeted, using hit_test_face().

Cube faces numbers:

# face
0 front
1 back
2 left
3 right
4 top
5 bottom

Current problems:

satoshinm commented 7 years ago

hit_test_face maps faces as:

dx dy dz face
-1 0 0 0
+1 0 0 1
0 0 -1 2
0 0 +1 3
0 +1 0 4 to 7

The top face has three different values depending on the rotation (for writing text on top of blocks from each side). Could add another:

dx dy dz face
0 -1 0 8 to 11

but elsewhere in the code will have to be updated (_gen_sign_buffer and make_character_3d). Maybe a new function, hit_test_normal, to simply get the normal vector instead of encoded face?

satoshinm commented 7 years ago
screen shot 2017-05-08 at 11 00 40 pm

Now shows the normal, although not too fond of showing it as 0,+1,0 (or even 0+0), would prefer a single integer. The face encoding generated in hit_test_face and consumed in _gen_sign_buffer and make_character_3d covers the first 4 side faces (0-3), but overloads 4-7 for top face plus a 90º rotation. Change it to split out rotation into its own variable, and use face=4 as top, 5 as bottom, for consistency throughout the game? It is important to get it correct here since this is in debug text.


Or, go all the way and keep four "faces" for the top (and bottom) + rotation?

satoshinm commented 7 years ago

Cube faces numbers:

# face
0 front
1 back
2 left
3 right
4 top
5 bottom

Example of showing the info line on face 4, looking at the top of a block:

screen shot 2017-05-09 at 8 10 13 pm
satoshinm commented 7 years ago

This necessarily changes some of the functions used by signs, since they were the only user of face hit testing (which side of the block the user was on. But for compatibility, the database and protocol still encode the face + rotation, and it is only possible to write on the sides or top of a block, same as before.