Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Matrefeytontias on October 26, 2012, 05:16:02 am

Title: [Axe] Messing with 3D
Post by: Matrefeytontias on October 26, 2012, 05:16:02 am
Hi guys !

I'm working on 3D with vertices ("vertex" or "vertices" ?) and I'm having precision problems (well, I think that's it). Just see :

(http://mattias.refeyton.fr/espace-ti/vertex3d/vertexOmni.gif)

Here's my code :

The main program :
Code: [Select]
:.VERTEX3D
:
:Fill(L3,768,0
:
:ᴱ90D3→°ScrP+2→°AngX+2→°AngY+2→°AngZ
:L3→ScrP
:
:0→AngX→AngY→AngZ
:
:‾1
:For(256)
:sin(+1→r1)→{r1+L1
:cos(r1)→{r1+L2
:r1
:End
:
:Data(‾10,‾10,‾10)→GDB1VERT
:Data(‾10,‾10,10
:Data(10,‾10,10
:Data(10,‾10,‾10
:Data(0,10,0
:
:Data(0,1,1,2,2,3,3,0,0,4,1,4,2,4,3,4)→GDB1LINE
:
:Data(0r,0r,0r)→GDB1WORK
:Data(0r,0r,0r)→GDB1CAM
:
:5→V
:8→L
:32→D
:32→F
:
:While 1
:
:prgmVERTEX
:
:DispGraphClrDraw
:getKey(4)-getKey(1)*2+AngX·255→AngX
:getKey(3)-getKey(2)*2+AngY·255→AngY
:getKey(49)-getKey(53)*2+AngZ·255→AngZ
:EndIf getKey(15)

The 3D engine :
Code: [Select]
:.Vertex and shape drawing
:
:D*sign{AngX+L1}//128→{GDB1CAM+2}r
:D*sign{AngX+L2}//128→{GDB1CAM+4}r
:{GDB1CAM+4}r*sign{AngY+L2}//128→{GDB1CAM+4}r
:D*sign{AngX+L2}//128→{GDB1CAM}r
:{GDB1CAM}r*sign{AngY+L1}//128→{GDB1CAM}r
:
:For(r1,0,V-1)
:sign{r1*3+GDB1VERT}-{GDB1CAM}r→{GDB1WORK}r
:sign{r1*3+GDB1VERT+1}-{GDB1CAM+2}r→{GDB1WORK+2}r
:sign{r1*3+GDB1VERT+2}-{GDB1CAM+4}r→{GDB1WORK+4}r
:
:.Y rotation
:{GDB1WORK+4}r→H
:‾{GDB1WORK}r*sign{AngY+L1}-({GDB1WORK+4}r*sign{AngY+L2})//128→{GDB1WORK+4}r
:‾{GDB1WORK}r*sign{AngY+L2}+(H*sign{AngY+L1})//128→{GDB1WORK}r
:
:{GDB1WORK+4}r→H
:.X rotation
:‾{GDB1WORK+2}r*sign{AngX+L1}+({GDB1WORK+4}r*sign{AngX+L2})//128→{GDB1WORK+4}r
:{GDB1WORK+2}r*sign{AngX+L2}+(H*sign{AngX+L1})//128→{GDB1WORK+2}r
:
:.Z rotation
:{GDB1WORK}r→H
:{GDB1WORK}r*sign{AngZ+L2}-({GDB1WORK+2}r*sign{AngZ+L1})//128→{GDB1WORK}r
:{GDB1WORK+2}r*sign{AngZ+L2}+(H*sign{AngZ+L1})//128→{GDB1WORK+2}r
:
:F*{GDB1WORK}r*32//{GDB1WORK+4}r→{r1*4+ScrP}r
:F*{GDB1WORK+2}r*32//{GDB1WORK+4}r→{r1*4+ScrP+2}r
:End
:
:For(r1,0,L-1)
:r1*2+GDB1LINE→A
:{{A}*4+ScrP}r//32+48→X
:{{A}*4+ScrP+2}r//32+32→Y
:{{A+1}*4+ScrP}r//32+48→Z
:{{A+1}*4+ScrP+2}r//32+32→T
:Line(X,Y,Z,T
:End

If you see anything wrong ...
Title: Re: Messing up with 3D
Post by: TheMachine02 on October 26, 2012, 12:40:34 pm
Well.. in most case the lose of precision in 3d came from the mutiple divisions you have to do : don't forget that axe round to minus.
So, check if you haven't something like that.

anyway it's look very great  :thumbsup:

(and also I think it's vertices but I am not sure)

Title: Re: Messing up with 3D
Post by: ben_g on October 26, 2012, 01:50:29 pm
It looks good so far, but I would recommend to lower the field of view, so you get less perspective distortion, which makes it look a bit more realistic.

Also, a single 3D point is called a vertex, and multiple points are called vertices.
Title: Re: Messing up with 3D
Post by: Matrefeytontias on October 27, 2012, 06:08:49 am
I tried with 16→D and 16→F, and got something weird O.o :

(http://mattias.refeyton.fr/espace-ti/vertex3d/vertexBug1.gif)

I only changed distance (D) and distortion (F) ???
Title: Re: Messing up with 3D
Post by: Adriweb on October 27, 2012, 06:31:36 am
Nice :D

(btw, it's  "Messing with 3d" and not "messing up" :P)
Title: Re: Messing up with 3D
Post by: Matrefeytontias on October 27, 2012, 04:19:34 pm
Nobody can help me ?
Title: Re: [Axe] Messing with 3D
Post by: leafy on October 27, 2012, 09:28:25 pm
I tried with 16→D and 16→F, and got something weird O.o :

(http://mattias.refeyton.fr/espace-ti/vertex3d/vertexBug1.gif)

I only changed distance (D) and distortion (F) ???

That's because it's so distorted that you get somewhat of a "fisheye" lens effect. The glitching happens because Axe can't draw clipped lines, so whenever the lines get so long they go offscreen, they vanish. (If I understand correctly)
Title: Re: [Axe] Messing with 3D
Post by: _Nicco_ on October 27, 2012, 10:05:46 pm
That's because it's so distorted that you get somewhat of a "fisheye" lens effect. The glitching happens because Axe can't draw clipped lines, so whenever the lines get so long they go offscreen, they vanish. (If I understand correctly)

Can you fix that by making a line just a series of points or would that be too hard to do?  Instead of having lines you would just have a bunch of points that make a straight line.
Title: Re: [Axe] Messing with 3D
Post by: Hayleia on October 28, 2012, 02:18:15 am
That's because it's so distorted that you get somewhat of a "fisheye" lens effect. The glitching happens because Axe can't draw clipped lines, so whenever the lines get so long they go offscreen, they vanish. (If I understand correctly)

Can you fix that by making a line just a series of points or would that be too hard to do?  Instead of having lines you would just have a bunch of points that make a straight line.
You can make it that way, but I think that would quickly become slow, especially for a 3D engine.
MGOS wrote a clipped line routine here (http://ourl.ca/16928/315520) but it only works for the bottom of the screen if I understand correctly.
I also found this one (http://ourl.ca/4129/251821) by Darl181
Title: Re: [Axe] Messing with 3D
Post by: Matrefeytontias on October 28, 2012, 08:47:26 am
So in fact, to decrease distortion I have to increase F ? ???