*This is for the CE* (At least, I programmed it for and on the CE)


I've been working on this little sub-project (It's part of a larger thing), but have hit a roadblock. I need to be able to fill in the sides with a single color, and I need it to be somewhat fast. It should also cover up the edges that should be on the back. I'm thinking to use flood fill, but that is not exactly a fast way of doing it. I split the code into several programs for ease-of-development.


Sets the current object being drawn to a cube.
prgmOBJCUBE

Code:
Ans->|LTEMP
|LTEMP(1->A
|LTEMP(2->B
|LTEMP(3->C
|LTEMP(4->W
|LTEMP(5->H
|LTEMP(6->D
[[(A),(B),(C)][(A),(B),(C+D)][(A),(B+H),(C)][(A),(B+H),(C+D)][(A+W),(B),(C)][(A+W),(B),(C+D)][(A+W),(B+H),(C)][(A+W),(B+H),(C+D)]]->[A]
[[1,2][2,4][4,3][3,1][5,6][6,8][8,7][7,5][1,5][2,6][3,7][4,8]]->[B]



Sets the current object to a triangular prism
prgmOBJTRIP

Code:
Ans->|LTEMP
|LTEMP(1->A
|LTEMP(2->B
|LTEMP(3->C
|LTEMP(4->W
|LTEMP(5->H
|LTEMP(6->D
[[(A),(B),(C)][(A+W),(B),(C)][(A+W),(B),(C+D)][(A),(B),(C+D)][(A+W/2),(B+H),(C+D/2)]]->[A]
[[1,2][2,3][3,4][4,1][1,5][2,5][3,5][4,5]]->[B]



Sets the current object to a tetrahedron
prgmOBJTETR

Code:
Ans->|LTEMP
|LTEMP(1->A
|LTEMP(2->B
|LTEMP(3->C
|LTEMP(4->W
|LTEMP(5->H
|LTEMP(6->D
[[(A),(B),(C)][(A+W/2),(B),(C+D)][(A+W),(B),(C)][(A+W/2),(B+H),(C+D/2)]]->[A]
[[1,2][2,3][3,1][1,4][2,4][3,4]]->[B]



Lets you move independently of the object.
prgmMOVE

Code:
Ans->A
(A=0)-(A=2)->B
Xmin+B->Xmin
Xmax+B->Xmax
(A=1)-(A=3)->B
Ymin+B->Ymin
Ymax+B->Ymax



Scaling, used for ‘movement’ on the z axis.
prgmSCALE3D

Code:
Ans->theta
dim([A]->L1
For(A,1,L1(1
For(B,1,L1(2
theta*[A](A,B->[A](A,B
End
End



Translates the object, but interferes with rotation.
prgmTRANSL8

Code:
Ans->L1
L1(1->Z
dim([A]->L2
L2(1->T
For(A,1,T
[A](A,Z)+L1(2->[A](A,Z
End



Draws the object.
prgmDRAW3D

Code:
dim([B]->L1
For(E,1,L1(1
Line([A]([B](E,1),1),[A]([B](E,1),2),[A]([B](E,2),1),[A]([B](E,2),2),1,Black,1
End



Helpful info:
[A] is the list of Vertices, and [B] is the list of edges. A ‘1’ in [B] would correspond to the first row/vertex, a ‘2’ for the second, and so on.

Rotates, in 3 dimensions.
prgmROTATE:

Code:
Ans->L1
Ans(2->theta
sin(theta->A
cos(theta->B
dim([A]->L2
For(N,1,L2(1
[A](N,1->I
[A](N,2->J
[A](N,3->K
If 0=L1(1
Then
JB-KA->[A](N,2
KB+JA->[A](N,3
Else
If 1=L1(1
Then
IB-KA->[A](N,1
KB+IA->[A](N,3
Else
If 2=L1(1
Then
IB-JA->[A](N,1
JB+IA->[A](N,2
End
End
End
End


Renders, and lets you interact:
prgmRENDER3D

Code:
Disp "DIM. OF OBJECT:
Input "X: ",A
Input "Y: ",B
Input "Z: ",C


Input "OFFSETX: ",S
Input "OFFSETY: ",T
Input "OFFSETZ: ",U
ClrDraw:BackgroundOff
0->|N
//change object type by appending "CUBE", "TRIP", or "TETR" to the following line.
{S,T,U,A,B,C:prgmOBJ
prgmDRAW3D
Pause
ClrDraw
Repeat 0
Repeat Ans
getKey
End
Ans->F
//too lazy to optimize this, shouldn’t really affect speed.
If F=73:Then
{0,pi/16:prgmROTATE:Else
If F=93:Then
{0,~pi/16:prgmROTATE:Else
If F=82:Then
{1,pi/16:prgmROTATE:Else
If F=84:Then
{1,~pi/16:prgmROTATE
End
End
End
End
If sum(F={43,52,54,63
Then
1(F=43)+2(F=52)+0(F=54)+3(F=63):prgmMOVE
End
If sum(F={21,31
Then
.8
If F=21
Ans^^-1
prgmSCALE3D
End
ClrDraw
prgmDRAW3D
End



Renders and slowly rotates the object (I’m really inspired by gLib's screenshots)
prgmROTATE3D

Code:
Disp "DIM. OF OBJECT:
Input "X: ",A
Input "Y: ",B
Input "Z: ",C


Input "OFFSETX: ",S
Input "OFFSETY: ",T
Input "OFFSETZ: ",U
ClrDraw:BackgroundOff
//change object type by appending "CUBE", "TRIP", or "TETR" to the following line.
{S,T,U,A,B,C:prgmOBJ
prgmDRAW3D
Pause
For(Z,0,1
{Z,pi/16:prgmROTATE
End
Repeat 0
{1,pi/64:prgmROTATE
ClrDraw
prgmDRAW3D
End



With my luck, I missed a program, but I need help Sad


Most of the changes would be in DRAW3D, presumably, as that is where everything (so far) is drawn.


Controls (for RENDER3D):


Use the numberpad to rotate. 8 and 2 rotate on the ‘y’ axis, 4 and 6 rotate on the ‘x’ axis.
Use [2nd] to zoom in, [alpha] to zoom out (move closer and further)
Use [prgm] to move up, [sin] to move left, [tan] to move right, and [)] to move down.


I think that’s it.
EDIT: No it isn't.
Instructions to run:
Press these exact buttons:
[zoom][6][zoom][5][prgm]
Then you can run the program (either RENDER3D or ROTATE3D). Be sure to change prgmOBJ to the selected shape before running!
I do not know how to do it myself but I did find something that could help you. https://codewalr.us/index.php?topic=1408.0. This gives you basically all the 3D engines for all TI calculators. There is one which is for the CSE and CE.
Yes, but those are written in assembly, like any sensible 3D rendering program on a calculator...
Oh... I didn't realize that. Sorry. Also, just curious, what is the "large thing" going to be?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement