Author Topic: [Axe] Messing with 3D  (Read 4360 times)

0 Members and 1 Guest are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
[Axe] Messing with 3D
« 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 :



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 ...
« Last Edit: October 27, 2012, 04:21:20 pm by Matrefeytontias »

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Messing up with 3D
« Reply #1 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)

AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Messing up with 3D
« Reply #2 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.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Messing up with 3D
« Reply #3 on: October 27, 2012, 06:08:49 am »
I tried with 16→D and 16→F, and got something weird O.o :



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

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Messing up with 3D
« Reply #4 on: October 27, 2012, 06:31:36 am »
Nice :D

(btw, it's  "Messing with 3d" and not "messing up" :P)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Messing up with 3D
« Reply #5 on: October 27, 2012, 04:19:34 pm »
Nobody can help me ?

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: [Axe] Messing with 3D
« Reply #6 on: October 27, 2012, 09:28:25 pm »
I tried with 16→D and 16→F, and got something weird O.o :



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)
« Last Edit: October 27, 2012, 09:28:59 pm by leafy »
In-progress: Graviter (...)

Offline _Nicco_

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +6/-0
    • View Profile
Re: [Axe] Messing with 3D
« Reply #7 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.
They say that your signature is supposed to go here...

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [Axe] Messing with 3D
« Reply #8 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 but it only works for the bottom of the screen if I understand correctly.
I also found this one by Darl181
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Axe] Messing with 3D
« Reply #9 on: October 28, 2012, 08:47:26 am »
So in fact, to decrease distortion I have to increase F ? ???