Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Halifax on August 29, 2006, 06:59:00 pm

Title: 3D in Basic
Post by: Halifax on August 29, 2006, 06:59:00 pm
I was thinking one day about making a 3d game in TI 83+ BASIC with Xlib, and I have some ideas on how to move the 3d objects but I don't have the equations, so I was wondering if someone could help me find a way to draw a cube and rotate it in all four ways.
Title: 3D in Basic
Post by: lolje on August 30, 2006, 12:48:00 am
If you asked me, I don't know but I think they should integrate this Engine into xLIB:
user posted image
0_os049.gif
Title: 3D in Basic
Post by: DJ Omnimaga on August 30, 2006, 01:17:00 am
O_Oshocked2.gifO_Oshocked2.gif HOLY s***! more and more 3d engines o.oblink.gif I saw the one from benryves on mc but not that one. It could be a good feature indeed

but managing all collision detection may be very slow with all those math/if/then :(sad.gif
Title: 3D in Basic
Post by: lolje on August 30, 2006, 02:38:00 am
No, I mean a function like the shape function, The Input would be coordinates (X,Y,Z) and size (also X,Y,Z). That should not be such a big problem...

You could e.g. use a 2D-Engine, but 3D-Graphics  :lol:bounce2.gif
Title: 3D in Basic
Post by: DJ Omnimaga on August 30, 2006, 03:37:00 am
i c >.<
Title: 3D in Basic
Post by: elfprince13 on August 30, 2006, 09:33:00 am
I did a wall based 3d maze engine in pure basic a while back, it worked pretty well too, and if I optimized it I can probably wrench some more speed out of it.
Title: 3D in Basic
Post by: Halifax on August 30, 2006, 12:43:00 pm
Actually I found the equation to convert 3D points to 2D on a plane from some C documents so I made a copy of the C programs in BASIC for true 3D rendering but sadly it is very slow it takes about 2 seconds to render 8 3D vertices
Title: 3D in Basic
Post by: Dragon__lance on August 30, 2006, 12:48:00 pm
if you want psuedo 3d, be sure to check out CDI's p3d! It's really cool! :Dbiggrin.gif
Title: 3D in Basic
Post by: DJ Omnimaga on August 30, 2006, 01:00:00 pm
if someone have a BASIC routine to do wireframe 3D stuff I would be happy to mess with it a little just for fun :Dbiggrin.gif
Title: 3D in Basic
Post by: kalan_vod on August 30, 2006, 02:31:00 pm
QuoteBegin-xlibman+30 Aug, 2006, 19:0-->
QUOTE (xlibman @ 30 Aug, 2006, 19:00)
if someone have a BASIC routine to do wireframe 3D stuff I would be happy to mess with it a little just for fun :Dbiggrin.gif

 Someone on UTI made one with xLIB.
Title: 3D in Basic
Post by: Halifax on August 30, 2006, 03:06:00 pm
This is a C to BASIC translation so it's not perfect but it is true 3D. Im just posting it so someone can mess with it. I know how to do rotations with it but I haven't implemented that yet but if you want to know then just ask and i'll post it. Although it is sorta hard to understand kinda. Also I have a way to make it solid instead of wireframe which is also hard to explain but if needed to know then just ask.
-Recommended screens settings are -94,94 for X and -94,94 for Y too.



L=list thingy

c1-->
CODE
ec1
Clrdraw
\\This list is used to tell the lines which points to connect
{0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7}->LLin
\\This is used to store 3D vertices to 2D transformations
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}->LSRC
\\This is the work list because you want to keep your orignal list there at all times
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}->LWOR
\\This is the camera in 3D space
{0,0,20}->LCAM
\\This is the center of the screen
{0,0}->LSCC
\\These are your 3D vertices
{-10,-10,-10,10,-10,10,10,10,-10,-10,10,-10,-10,-10,10,10,-10,10,10,10,10,-10,10,10}->LCUB
\\This variable is the distortion
8->D
->B
For(A,1,24
If B<3:Then
B+1->B
Else
1->B
End
LCUB(A->E
LCAM(B->F
\\It is required that you subtract the camera position (x or y or z) depending on B
E-F->LWOR(A
End
-1->B
For(A,1,24,3
B+2->B
LSCC(1->E
LWOR(A->F
LWOR(A+2->G
// coord.x = screen_center.x + (distortion * 3Dcoord.x)/ 3Dcoord.z
E+(D*F)/G->LSRC(B
LSCC(2->E
LWOR(A+1->F
// coord.y = screen_center.y + (distortion * 3Dcoord.y)/ 3Dcoord.z
E-(D*F)]G->LSRC(B+1
End
For(A,1,16,2
round(LSRC(A,->X
round(LSRC(A+1,->Y
Pt-On(X,Y
End
\\Now we draw the lines in to make the cube
For(A,1,24,2
LLIN(A)*2+1->W
LLIN(A+1)*2+1->V
LSRC(W->X
LSRC(W+1->Y
LSRC(V->Z
LSRC(V+1->theta
Line(X,Y,Z,theta
End
c2
ec2
Title: 3D in Basic
Post by: runtogetdone on August 31, 2006, 01:46:00 am
Here's a http://www.rafb.net/paste/results/eKrD7599.html to some basic 3D formulas that might prove useful
(Thank tr1p1ea for the links, not me  ;)wink.gif)
Title: 3D in Basic
Post by: DJ Omnimaga on August 31, 2006, 02:33:00 am
OMG I'll try asap, I hope I can convert code to tigl format tho :(sad.gif, maybe someone could post a 8xp?
Title: 3D in Basic
Post by: Halifax on August 31, 2006, 11:42:00 am
That link doesn't work

Also I'm working on implementing rotation into that source code above, but anyways xlibman the 8xp format is attached.
Title: 3D in Basic
Post by: Alex on August 31, 2006, 03:43:00 pm
I'd like to experiment with a little 3D myself hehe :)smile.gif I wish you guys good luck, pushing calc limits is always fun and admirable :)smile.gif

- Alex
Title: 3D in Basic
Post by: kalan_vod on August 31, 2006, 07:39:00 pm
QuoteBegin-runtogetdone+31 Aug, 2006, 7:46-->
QUOTE (runtogetdone @ 31 Aug, 2006, 7:46)
Here's a http://www.rafb.net/paste/results/eKrD7599.html to some basic 3D formulas that might prove useful
(Thank tr1p1ea for the links, not me
Title: 3D in Basic
Post by: Halifax on August 31, 2006, 09:46:00 pm
sad to say though but the rotation part was to hard to implement for me so maybe someone else can try it.I can not take credit for this because if was taken from the source of Edit3D for TI-89, same with my converted BASIC stuff if was converted from that source file. Also another thing is if you wanted to draw faces then you would have to bubble sort the z axis from lowest to biggest, then the one with the most z value would get it's face drawn in first and so on. SO basically that would be a cover-up routine with the lowest visible solid areas being visible.

This rotation for all axes:
Camera.y = dist * sin(ang_x) ;
Camera.z = dist * cos(ang_x) ;
Camera.z = Camera.z * cos(ang_y) ;
Camera.x = dist * cos(ang_x) ;
Camera.x = Camera.x * sin(ang_y);
//Those are in LCAM, LCAM(1=camera.x and so on
Work_CUBE.z = - Work_CUBE.y * sin(ang_x) + Work_CUBE.z * cos(ang_x)
Work_CUBE.y =  Work_CUBE.y * cos(ang_x)  + intermediate * sin(ang_x)
//rotation around the y axis
Work_CUBE.z = - Work_CUBE.y * sin(ang_x) + Work_CUBE.z * cos(ang_x)
Work_CUBE.y =  Work_CUBE.y * cos(ang_x)  + intermediate * sin(ang_x)
//rotation around the x axis
Work_CUBE.x = Work_CUBE.x * cos(ang_z) - Work_CUBE.y * sin(ang_z)
Work_CUBE.y = Work_CUBE.y * cos(ang_z) + intermediate * sin(ang_z)
//rotation around the z axis