Skip to content

Instantly share code, notes, and snippets.

@Bigcheese
Created September 18, 2013 09:20
Show Gist options
  • Save Bigcheese/6606668 to your computer and use it in GitHub Desktop.
Save Bigcheese/6606668 to your computer and use it in GitHub Desktop.
Description of why there are 10 unique meshes for cables in MC mods.
/**
* There are 64 possible meshes, as each of the 6 sides can be either connected or not connected. In the following
* the connected state is treated as a 6 bit value where 0 indicates not connected and 1 indicates connected.
*
* 0 1 2 3 4 5
* (+x -x) (+y -y) (+z -z)
*
* To derive all the meshes, we first determine the number combinations of values for each number of bits set from 0
* to 6.
*
* 0 - 1
* 1 - 6
* 2 - 15
* 3 - 20
* 4 - 15
* 5 - 6
* 6 - 1
*
* Note that this is the 6th row of Pascal's triangle.
*
* 0 bits and 6 bits are trivial. They are the not connected and fully connected states.
*
* 00 00 00
* +
*
* 11 11 11
* (up)
* y -z (north)
* |/
* -+- x (east)
* /|
*
* The next two are also simple. with 1 or 5 bits set we have 6 possibilities each. The rotations are also easy to
* calculate for these.
*
* 10 00 00
* +-
*
* 01 11 11
* |/
* -+
* /|
*
* The rest are slightly more complicated and will be handled one at a time.
*
* 2 has two unique meshes. This is because with only two bits set, we have either one or two axes set. Rotations
* for one axis is trivial. ??? Not sure for the other. ???
*
* 11 00 00
* -+-
*
* This mesh has 3 possible orientations. 1 for each +-axis pair.
*
* 10 10 00
* |
* +-
*
* This mesh has 12 possible orientations. 3 for each pair of axes times 4 (2^2) for the combination of +- on the
* two axes.
*
* 3 has two unique meshes. This is because either all axis must have a single bit set, or one axis must have
* both set and another have 1.
*
* 11 01 00
* -+-
* |
*
* This mesh has 12 possible orientations. 3 for each +- axis pair time 4 (2^2) for the combination of +- on the
* second axis.
*
* 10 10 10
* |
* +-
* /
*
* This mesh has 8 possible orientations. One bit may be set in each axis, thus we may treat it as a 3 bit value
* with 2^3 states.
*
* 4 has two unique meshes. There must be at least one +- axis pair, then there is one unique mesh for another
* +- axis pair, and another unique mesh for separate axes.
*
* 11 11 00
* |
* -+-
* |
*
* This mesh has 3 possible orientations. 11 11 00, 11 00 11, 00 11 11.
*
* 10 11 01
* |/
* +-
* |
*
* This mesh has 12 possible orientations. 3 for each +- axis pair times 4 for each of the +- states for the
* remaining 2 axes.
*
* We use the lowest numerical value of each unique mesh as the primary mesh of that type. Rotations are currently
* calculated empirically.
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment