3D CUBE ========= --------------------------------------------------- | Author: Jari Rytilahti | | Original idea: Jari Rytilahti | | Type of calculator: CASIO fx-9700GE (or similar)| --------------------------------------------------- ----------------------------------------------------------------------------- 1. System requirments 2. A description of the program 3. How to get in contact with me 4. Signtable 5. Source ----------------------------------------------------------------------------- 1. System requirments: --------------------- - a CASIO fx-9700GE (or similar CASIO calculator) - WINDOWS '98 (Not!) 2. A description of the program ------------------------------- A program that draws a rotating 3D cube in real time. Perspective, adjustable rotation speed and 0.5 fps :) Challenge to all CASIO programmers: z-buffer renderer anyone? 3. How to get in contact with me -------------------------------- If you have any comments on the game or if you have made it better or if you have some other programs to the CASIO calculator, send a message to me by email. jari.rytilahti@swipnet.se http://home.swipnet.se/snafu ============================================================================= We want ... ... ... ... ... ... ... ... ... ... ... ... A SHRUBBERY!! ============================================================================= 4. Signtable ------------ > :greater than >= :greater or equal than < :less than <= :less or equal than => :if statement -> :assign * :multiply / :divide _| :fraction. _ :That little black triangle {} :Comment. Just to make it easier to understand ----------------------------------------------------------------------------- 5. Source --------- 001: CUBE 002: Mcl : Deg : Defm 30 003: "Z"?->P {rotation speed around z axis} 004: "X"?->Q {rotation speed around x axis} 005: "Y"?->R {rotation speed around y axis} 006: 0->M~O 007: Range 1,110,0,1,60,0 {CUBE DATA} 008: [[-1,1,1,1][1,1,1,1][-1,-1,1,1][1,-1,1,1][-1,1,-1,1] [1,1,-1,1][-1,-1,-1,1][1,-1,-1,1]]->Mat A {PERSPECTIVE PROJECTION MATRIX} 009: [[1,0,0,0][0,1,0,0][0,0,0,(-0.2)][0,0,0,1]]->Mat E {------- MAIN LOOP -------} 010: Lbl 0 {rotation z axis} 011: [[cos M,sin M,0,0][-sin M,cos M,0,0][0,0,1,0][0,0,0,1]]->Mat B {rotation x axis} 012: [[1,0,0,0][0,cos N,sin N,0][0,-sin N,cos N,0][0,0,0,1]]->Mat C {rotation y axis} 013; [[cos O,0,-sin O,0][0,1,0,0][sin O,0,cos O,0][0,0,0,1]]->Mat D {Here comes the magic: Multiply matrices A to E together and presto, a 3D cube! Well we still have to draw it...} 014: Mat A*Mat B*Mat C*Mat D*Mat E->Mat F {Loop to get the perspective right. Exclude Matrice E and lines 15 to 19 to remove perspective projection} 015: 1->Z:Lbl B 016: 1->W:Lbl C 017: Mat F[Z,W]/Mat F[Z,4]->Mat F[Z,W] 018: Isz W:W<5=>Goto C 019: Isz Z:Z<9=>Goto B {Time to move xy-data from matrix F to proper memory for easier access} {At the same time recalculate coordinates to graphic window} 020: 1->Z 021: Lbl A 022: Mat F[Z,1]*15+55->A[28+2*Z] 023: Mat F[Z,2]*15+30->A[29+2*Z] 024: Isz Z 025: Z<9=>Goto A {DRAW CUBE} 026: Cls {Remove this for fun...} 027: Plot A[30],A[31] 028: Plot A[32],A[33] 029: Line 030: Plot A[32],A[33] 031: Plot A[36],A[37] 032: Line 033: Plot A[36],A[37] 034: Plot A[34],A[35] 035: Line 036: Plot A[34],A[35] 037: Plot A[30],A[31] 038: Line 039: Plot A[38],A[39] 040: Plot A[40],A[41] 041: Line 042: Plot A[40],A[41] 043: Plot A[44],A[45] 044: Line 045: Plot A[44],A[45] 046: Plot A[42],A[43] 047: Line 048: Plot A[42],A[43] 049: Plot A[38],A[39] 050: Line 051: Plot A[30],A[31] 052: Plot A[38],A[39] 053: Line 054: Plot A[32],A[33] 055: Plot A[40],A[41] 056: Line 057: Plot A[34],A[35] 058: Plot A[42],A[43] 059: Line 060: Plot A[36],A[37] 061: Plot A[44],A[45] 062: Line {The last two lines are not necessary but will make the cube look a bit better} 063: Plot A[38],A[39] 064: Plot A[44],A[45] 065: Line 066: Plot A[40],A[41] 067: Plot A[42],A[43] 068: Line {Increase rotation} 069: M+P->M 070: N+Q->N 071: O+R->O 072: Goto 0 073: 'JMR-96