Author Topic: polygon-based 3D engine (with textures)  (Read 6217 times)

0 Members and 1 Guest are viewing this topic.

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
polygon-based 3D engine (with textures)
« on: December 11, 2011, 03:23:20 pm »
I have been working on a polygon-based 3D engine for a while, and the 3D itself works, and the textures work too, there are still some bugs, but I already know what is causing them.

This is how it looks like:


I decided to keep it open-scource. I'll try to update the source often.
The source code is included in the post. A compiled version is also included. If you use any code in your own project, you don't have to give me credits, and you can always ask for help for using it on this topic.

Source is not fully commented, but I'll try to do that in a few days.

Credits:

This is everybody who helped me:
Hot_Dog
jacobly
thepenguin77
timoty
Runer112
leafiness0
Builderboy
Qwerty.55
t0xic_kitt3n
ztrumpet
calc84maniac
shmibs
p2
chattahippie
christop (cemetech)
KermMartian (cemetech)
benryves (cemetect)
Dr. Best (Ultimate 3D)

If you helped me but I forgot to ad you, please tell. If I put you in this list but you don't want to be in the credits,please tell too.
« Last Edit: December 12, 2011, 01:13:21 pm by ben_g »
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 Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: [discontinued] polygon-based 3D engine (with textures)
« Reply #1 on: December 11, 2011, 03:27:44 pm »
Looks pretty sweet. Too bad you had too many problems.


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: [discontinued] polygon-based 3D engine (with textures)
« Reply #2 on: December 11, 2011, 04:33:17 pm »
Aww, too bad.  I'm very impressed in the progress, though.
ld a, 0
ld a, a

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: [discontinued] polygon-based 3D engine (with textures)
« Reply #3 on: December 11, 2011, 05:00:15 pm »
Umm... so I *just* figured out the problem. (There are actually two bugs, but one hides the other)

First of all, you cannot call GetPixel with a negative column, and expect meaningful results. The first step in fixing this, is to change negative columns to zero, with the code such as the following, before call GetPixel.
Code: [Select]
 bit 7,a
  jr z,TGetPixel
  xor a
TGetPixel:
The second step is to change horizontal clipping. When the col is negative, (pointer) and (mask) should not change, so that when col becomes zero, they are already set up correctly.
Code: [Select]
 ld a, (temp)
  bit 7, a
  jr nz, TNoCarry ;instead of TEndPlot

If you just change the above code, there are still problems because there is an even more subtle and tricky bug. When you order the start and end of the scanline, so the start is before the end, you do an unsigned compare, which causes the wrong result if start and end have opposite signs (which is the case when there is clipping).
Code: [Select]
;Initialize variables for the scanline
  ld hl, (tu1)
  ld (tmpu), hl
  ld hl, (tv1)
  ld (tmpv), hl
  ld hl, (tu2)
  ld (temp2), hl
  ld hl, (tv2)
  ld (temp3), hl
  ld a, (tx2+1)
  ld (temp+1), a
  add a,128 ;!added!
  ld b, a
  ld a, (tx1+1)
  ld (temp), a
  add a,128 ;!added!
  cp b
  jr c, TOrdered
  ;jp po, TOrdered
  ld hl, (tu2)
  ld (tmpu), hl
  ld hl, (tv2)
  ld (tmpv), hl
  ld hl, (tu1)
  ld (temp2), hl
  ld hl, (tv1)
  ld (temp3), hl
  ld a, (tx2+1)
  ld (temp), a
  ld a, (tx1+1)
  ld (temp+1), a
TOrdered:
« Last Edit: December 11, 2011, 05:00:53 pm by jacobly »

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [discontinued] polygon-based 3D engine (with textures)
« Reply #4 on: December 11, 2011, 08:48:22 pm »
Wow, good eye on catching those bugs so quickly! =)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [discontinued] polygon-based 3D engine (with textures)
« Reply #5 on: December 11, 2011, 08:57:53 pm »
I think there is a reason why jacobly has an average of more than 1 uprate per 2 posts O.O Good eye.

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: [discontinued] polygon-based 3D engine (with textures)
« Reply #6 on: December 11, 2011, 09:27:40 pm »
Wow, good eye on catching those bugs so quickly! =)
I wouldn't exactly call it quick. I've been wondering about this since November. :/

I think there is a reason why jacobly has an average of more than 1 uprate per 2 posts O.O Good eye.
Yeah, I tried posting more, but then I just ended up with more uprates. :P

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: polygon-based 3D engine (with textures)
« Reply #7 on: December 12, 2011, 01:16:23 pm »
I just tried this: It works!

Thank you jacobly, you are awesome!

I'm still going to keep it open-source, hoping to make 3D game development easier to anyone who wants to try.

Now, I'll just use this thread as a project thread.
« Last Edit: December 13, 2011, 01:23:12 pm by ben_g »
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 Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: polygon-based 3D engine (with textures)
« Reply #8 on: December 12, 2011, 06:57:04 pm »
Now, I'll just use this threat as a project thread.
Oh dear, there is no need to threaten O.O
Freudian slip? :P

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: polygon-based 3D engine (with textures)
« Reply #9 on: December 12, 2011, 08:35:25 pm »
wait is this being worked on again?
This used to contain a signature.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: polygon-based 3D engine (with textures)
« Reply #10 on: December 13, 2011, 06:27:43 am »
Wow, good eye on catching those bugs so quickly! =)
I wouldn't exactly call it quick. I've been wondering about this since November. :/

I think there is a reason why jacobly has an average of more than 1 uprate per 2 posts O.O Good eye.
Yeah, I tried posting more, but then I just ended up with more uprates. :P

That may be so, but I meant quick in regads to the fact that you found the bugs on the very same day the source was made public. :D It's still quite nice that you did so.

@annoying calc: Yes, apparently it's being worked on again since the bugs were fixed. :D

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: polygon-based 3D engine (with textures)
« Reply #11 on: August 24, 2012, 07:39:56 pm »
I just decided to pick this back up, using routines and experience from my racing game. The improvements so far are: Wireframe model support (copied from racing game), support from models with both textures and wireframe, and support for solid triangles (not supported in models yet), and support for multiple textures (but a model can't have more than 1 texture). I also removed some outdated comments (stoff like TODO:'s which have already been done) and removed huge parts of useless code. It now also runs slightely faster.

Included is a screenshot showcasing the support for wireframe and wireframe-texture combination models.
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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: polygon-based 3D engine (with textures)
« Reply #12 on: August 24, 2012, 08:46:23 pm »
Looks nice, but question: Seeing this thick outline on one side, is that a texture with transparency support? O.O

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: polygon-based 3D engine (with textures)
« Reply #13 on: August 25, 2012, 04:54:33 pm »
It's not really transparency, but in this picture, the texture was rendered before the wireframe, which means that everything that is white on the texture looks transparent in the final result. If the texture is rendered after the wireframe, white on the texture will be fully white.

also, to give an impression of the resolution of the textures: the tick border is 3 texels (pixels of the texture) wide.
« Last Edit: August 25, 2012, 04:55:25 pm by ben_g »
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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: polygon-based 3D engine (with textures)
« Reply #14 on: August 27, 2012, 10:48:23 pm »
Ok thanks for the info :). The resolution should probably be fine I guess, considering it's a calculator. If it's too high, stuff looks crappy when far away.