starkernel: item 4.3.4 -- checkpoint, draw a cube (no new bugs)
Adds VERT/EDGE/CUBE to capsules/fabric.4th (blocks 4913-4915). VERT ( n -- x y z ) reads bits 0/1/2 of a corner index as the X/Y/Z sign (+-CS from center), so all 8 cube corners come from one word. EDGE resolves both corners via VERT and calls LINE; CUBE is 12 EDGE calls (4 bottom, 4 top, 4 vertical). First item in the 4.3.3.x sequence with no new bug found -- a small signal that Q.TO-INT, the VARIABLE alignment fix, and the LINE-STUCK? cap were the real gaps rather than something still lurking in LINE/PROJECT/CART-Y. Verified live on amd64: a centered, half-size-100 cube renders correctly -- front/back face squares, back face offset diagonally up-right by exactly the 45-degree cavalier projection's depth term, all 12 edges connecting at the right corners. All three architectures boot clean to ok> with the DoE completing; dict_hash identical across all three and unchanged from 4.3.3a/4.3.3b. FABRIC.md item 4.3.4 marked done. This is the checkpoint -- 4.3.x groundwork stops here for review per this item's own acceptance criterion.
This commit is contained in:
@@ -150,3 +150,30 @@ Block 4912
|
||||
CZ @ CCOLOR @
|
||||
LINE
|
||||
LOOP ;
|
||||
|
||||
Block 4913
|
||||
( CUBE: wireframe, 8 vertices via bit-coded corner index n )
|
||||
( (bit0=x, bit1=y, bit2=z; set=+CS, clear=-CS from center). )
|
||||
VARIABLE CS
|
||||
: VERT ( n -- x y z )
|
||||
DUP 1 AND IF CS @ ELSE CS @ NEGATE THEN CX @ +
|
||||
SWAP DUP 2 AND IF CS @ ELSE CS @ NEGATE THEN CY @ +
|
||||
SWAP DUP 4 AND IF CS @ ELSE CS @ NEGATE THEN CZ @ +
|
||||
SWAP DROP ;
|
||||
|
||||
Block 4914
|
||||
( EDGE: draws one cube edge between vertex indices n1,n2. )
|
||||
VARIABLE EN2
|
||||
: EDGE ( n1 n2 color -- )
|
||||
>R EN2 ! VERT EN2 @ VERT R> LINE ;
|
||||
|
||||
Block 4915
|
||||
( CUBE: 12 edges -- 4 bottom, 4 top, 4 vertical. )
|
||||
: CUBE ( cx cy cz s color -- )
|
||||
CCOLOR ! CS ! CZ ! CY ! CX !
|
||||
0 1 CCOLOR @ EDGE 1 3 CCOLOR @ EDGE
|
||||
3 2 CCOLOR @ EDGE 2 0 CCOLOR @ EDGE
|
||||
4 5 CCOLOR @ EDGE 5 7 CCOLOR @ EDGE
|
||||
7 6 CCOLOR @ EDGE 6 4 CCOLOR @ EDGE
|
||||
0 4 CCOLOR @ EDGE 1 5 CCOLOR @ EDGE
|
||||
2 6 CCOLOR @ EDGE 3 7 CCOLOR @ EDGE ;
|
||||
|
||||
Reference in New Issue
Block a user