Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: ben_g 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:
(http://img.removedfromgame.com/imgs/pic6.gif)
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.
-
Looks pretty sweet. Too bad you had too many problems.
-
Aww, too bad. I'm very impressed in the progress, though.
-
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.
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.
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).
;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:
-
Wow, good eye on catching those bugs so quickly! =)
-
I think there is a reason why jacobly has an average of more than 1 uprate per 2 posts O.O Good eye.
-
Wow, good eye on catching those bugs so quickly! =)
I wouldn't exactly call it quick. I've been wondering about this since November (http://ourl.ca/13818/260419). :/
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
-
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.
-
Now, I'll just use this threat as a project thread.
Oh dear, there is no need to threaten O.O
Freudian slip? :P
-
wait is this being worked on again?
-
Wow, good eye on catching those bugs so quickly! =)
I wouldn't exactly call it quick. I've been wondering about this since November (http://ourl.ca/13818/260419). :/
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
-
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.
-
Looks nice, but question: Seeing this thick outline on one side, is that a texture with transparency support? O.O
-
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.
-
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.