note that cube.pf does not use this approach, but uses geometry.pf operations on matrices. CUBE ---- cubes are a bit special, since they're simple building blocks more importantly, a cube texture can be used to provide a horizon, when combined with textures. so it is important to talk about it a bit. the cube vertices can be binary encoded n xyz 0 --- 1 --+ 2 -+- 3 -++ 4 +-- 5 +-+ 6 ++- 7 +++ where + indicates for example +1.0, while - indicates -1.0 fixing the Z axis pointing towards us, the X axis to the right and the Y axis up, the face in front of us is ( -++ )'''''( +++ ) : : : : : : : : ( --+ ).....( +-+ ) or in decimal the front face is: 3--7 | | 1--5 denoting the faces with letters F Front L Left R Right A bAck T Top O bOttom it is possible to unfold the cube like this T ALFR O this is of course not unique. using the decimal vertex numbers, the cube is 2---6 3---7 | | 0-|-4 1---5 with 2---6 | | 0---4 the back face. so the unfolding becomes 2---6 | T | 6---2---3---7---6 | A | L | F | R | 4---0---1---5---4 | O | 0---4 the normal of each face, is zero everywhere, except for the coordinate that does not change, where it has the same sign as the constant coefficient. we can enumerate the faces using * the sign of the fixed coordinate (bit0 * the position of the fixed coordinate (bit1-2) this gives L 000 0 (const X) R 001 1 O 010 2 (const Y) T 011 3 A 100 4 (const Z) F 101 5 and 2---6 | 3 | 6---2---3---7---6 | 4 | 0 | 5 | 1 | 4---0---1---5---4 | 2 | 0---4 this gives all the information to generate everything from numbers ( see script/shapes.pf )