Well Gemini was a raycaster, not a "real" 3D engine. Which I believe is what ben_g wants. Applying textures in raycasting is easy because of the vertical scanline rendering method and the restrictions of the camera.Yes, It's a "real" 3D engine, and it supports both vertical and horizontal rotation, as well as letting the camera rotate along it's axis using the up vector. There's no way to use routines from raycasters for this. I've already checked gemini, and it renders by casting rays, not by calculating the location of points and drawing a texture between them.
Ok, here is my method. I'm literally making it up as I write this post, but in the end it should work. For this you should use triangles.Could you please explain what you mean by the size of a point?
...
2. Calculate the relative size of the leftmost point. (3d window distance thing / distance)
3. Now calculate the relative size of each of the other two points and subtract the original from them.
...
[offtopic] Congrats ben_g: 100th post !Thanks. 100 post sure goes by fast. I didn't knew I was already there :P
Here is the website I was talking about earlier, it works completely of the screen coordinates of the triangle, and uses a method called linear interpolation. It also works in scanlines, which is beneficial to us calculator users since scanlines are special for our screen and can be drawn rather quickly.Are you sure that's the right URL? I got the 'server not found' error
http://www-users.mat.uni.torun.pl/~wrona/3d_tutor/tri_fillers.html
Congrats on that. Could you post screenies when you finish the tex draw routine?Sure, but right now, I'm still trying to do it in a computer language. It's so much easier to first try it in a programming language you know, and then port it.
Note! I find it hard to get good results using fixed point math because of inadequate precisionBut that's not the main problem. The main problem is that I think that it would be way to slow. The normal triangle is fast enough, but on my computer, with 2.8GHz CPU, It takes over 5 secounds to draw the textured triangle. I know that game maker is very slow, but i don't think it's speed can be beaten by a calculator. A game just won't be fun when you have to wait for half an hour for each frame.
Don't give up; I'm pretty sure you can find a way. GM is really inefficient from when I used it. If you use low-res textures you might be able to pull it off on calc.I know. GM is really inefficient with almost everything it can do, but 5 seconds for only one triangle is a very long time, even for GM. And for a resonable gameplay, there should be at least 5 fps, and that while there wil be abouth 150 triangles be drawn. that means that it should be abouth 1000 times as fast as GM (I calculated it), so i really doubt that this is possible.
has it got a routine to draw a textured quad?
Either Calc84 or Runer presented a tilemapping 3d engine while back that had simple textures. I can't seem to find the screenshots, though.I believe you're referencing this: http://ourl.ca/8272
Ummm...that link is to a raycaster, which renders stuff quite differently from a polygon engine.
Ummm...that link is to a raycaster, which renders stuff quite differently from a polygon engine.
/me googles for NostromoUmmm...that link is to a raycaster, which renders stuff quite differently from a polygon engine.
Depends on the particular polygon engine. In any case, it's example code for handling 3d objects. The only really significant difference between polygons and raycasting is how you detect them. Actually, now that I think about it, BenRyves' Nostromo demo used polygons.
CDQ: Convert Double to QuadDouble: is this like the java double (a floating point number)? And what do you mean with quad?
I assume you're not worrying about perspective correctness?I've tried it and the texture is only a bit of near the center. On a screen with a very low resolution, it would only be noticable when you are very close. And becouse the quad isn't made out of two triangles, it would always have almost the same effect as persfective correction.
what method are you using for this?interpolating. A lot of it.
And this | should definitely be this |
Code: [Select] ld a, (_ty) | Code: [Select] ld hl, _ty |
Now that is one of the scariest pieces of code I have ever seen.How do you mean?
But, as to why it's not actually working. Your loop should theoretically work as long as you are giving it valid numbers. (It will actually finish no matter what you give it though) So that leads me to believe that the problem is with your pixel plotting. Most likely, you are trying to plot pixels that are off screen and that is what is causing all of your problems. You end up plotting pixels in your program code, which causes crashes.I tried jumping over the plotting part, and it still crashes. By the way, this is done in an app, and ass variables defined inside the app itself won't work, then isn't the program protected against SMC?
If you are really unlucky, you might even be plotting pixels at _ty.
Edit: I just noticed i tripple posted, but there is more than 6 hours between those posts, so it's ok, right?Yup, it's fine.
AxesOff
ClrDraw
[[1,1,1,1,1,1,1,1][1,0,1,0,1,0,1,1][1,1,0,1,0,1,0,1][1,0,1,0,1,0,1,1][1,1,0,1,0,1,0,1][1,0,1,0,1,0,1,1][1,1,0,1,0,1,0,1][1,1,1,1,1,1,1,1->[A]
4->dim(LDX
4->dim(LDU
4->dim(LDV
2->dim(LTX
2->dim(LTY
2->dim(LTU
2->dim(LTV
{50,40,80,10->LX
{10,11,60,61->LY
{1,8,1,8->LU
{1,1,8,8->LV
(LX(2)-LX(1))/(LY(2)-LY(1->LDX(1
(LX(3)-LX(1))/(LY(3)-LY(1->LDX(2
(LX(4)-LX(2))/(LY(4)-LY(2->LDX(3
(LX(4)-LX(3))/(LY(4)-LY(3->LDX(4
(LU(2)-LU(1))/(LY(2)-LY(1->LDU(1
(LV(2)-LV(1))/(LY(2)-LY(1->LDV(1
(LU(3)-LU(1))/(LY(3)-LY(1->LDU(2
(LV(3)-LV(1))/(LY(3)-LY(1->LDV(2
(LU(4)-LU(2))/(LY(4)-LY(2->LDU(3
(LV(4)-LV(2))/(LY(4)-LY(2->LDV(3
(LU(4)-LU(3))/(LY(4)-LY(3->LDU(4
(LV(4)-LV(3))/(LY(4)-LY(3->LDV(4
LX(1->LTX(1
LX(1->LTX(2
LU(1->LTU(1
LV(1->LTV(1
LU(1->LTU(2
LV(1->LTV(2
LY(1->Y
If [A](LU(1),LV(1
Then
Pxl-On(Y,LX(1
Else
Pxl-Off(Y,LX(1
End
For(Y,LY(1)+1,LY(2
LTX(1)+LDX(1->LTX(1
LTU(1)+LDU(1->LTU(1
LTV(1)+LDV(1->LTV(1
LTX(2)+LDX(2->LTX(2
LTU(2)+LDU(2->LTU(2
LTV(2)+LDV(2->LTV(2
For(X,LTX(1),LTX(2
(X-LTX(1))/(LTX(2)-LTX(1->T
round((1-T)*LTU(1)+T*LTU(2),0)->U
round((1-T)*LTV(1)+T*LTV(2),0)->V
If [A](U,V)
Then
Pxl-On(Y,round(X,0
Else
Pxl-Off(Y,round(X,0
End
End
End
For(Y,LY(2)+1,LY(3
LTX(1)+LDX(3->LTX(1
LTX(2)+LDX(2->LTX(2
LTU(1)+LDU(3->LTU(1
LTV(1)+LDV(3->LTV(1
LTU(2)+LDU(2->LTU(2
LTV(2)+LDV(2->LTV(2
For(X,LTX(1),LTX(2
(X-LTX(1))/(LTX(2)-LTX(1->T
round((1-T)*LTU(1)+T*LTU(2),0->U
round((1-T)*LTV(1)+T*LTV(2),0->V
If [A](U,V
Then
Pxl-On(Y,round(X,0
Else
Pxl-Off(Y,round(X,0
End
End
End
For(Y,LY(3)+1,LY(4)-1
LTX(1)+LDX(3->LTX(1
LTU(1)+LDU(3->LTU(1
LTV(1)+LDV(3->LTV(1
LTX(2)+LDX(4->LTX(2
LTU(2)+LDU(4->LTU(2
LTV(2)+LDV(4->LTV(2
For(X,LTX(1),LTX(2
(X-LTX(1))/(LTX(2)-LTX(1->T
round((1-T)*LTU(1)+T*LTU(2),0->U
round((1-T)*LTV(1)+T*LTV(2),0->V
If [A](U,V
Then
Pxl-On(Y,round(X,0
Else
Pxl-Off(Y,round(X,0
End
End
End
If [A](LU(4),LV(4
Then
Pxl-On(LY(4),LX(4
Else
Pxl-Off(LY(4),LX(4
End
DelVar LX
DelVar LY
DelVar LU
DelVar LV
DelVar [A]
DelVar LDU
DelVar LDV
DelVar LDX
DelVar LTU
DelVar LTV
DelVar LTX
DelVar LTY
Does anybody see what causes the wrong pixels in this program?
Computer | Calculator |
(http://picturestack.com/485/591/ARQUntitled8Pe.png) | (http://picturestack.com/485/770/wpAUntitled3Cu.gif) |
Everything works just the way it's supposed to. | In the first step (TriangleDrawLoop1), it just draws black pixels, and in the secound draw loop, nothing is drawn. |
Spoiler For GML source code: | Spoiler For z80 source: |
did that basic to assembly source conversion thing work at all?nope, I haven't found any program that actually converts anything, so I've ported it manually, but i must have made a mistake, ass this is clearly not doing what it should do.
BTW: this routine draws the triangle from top to bottom, which means that the points needs to be in the right order, so does anybody knows a routine to sort the points based on their Y coordinate?I made a routine thst would work for this in Cube Droid, but that's in Axe so I guess it doesn't help.
Start:
di
call ClearGbuf
call fastCopy
ld a, 64*3
ld (direction), a
in a,($02)
rla
sbc a, a
out ($20), a
ld hl, 0
ld (x), hl
ld hl, $0200
ld (y), hl
SpelLus:
call ClearGBuf
ld a, $FF
ld (plotsscreen), a
ld hl, plotsscreen
ld de, plotsscreen+1
ld bc, 767
ldir
ld hl, (x)
ld (xfrom), hl
ld hl, (y)
ld (yfrom), hl
ld hl, 0
ld (zfrom), hl
ld (zto), hl
ld a, 64
ld b, a
ld a, (direction)
add a, b
call SinA
ld de, (x)
add hl, de
ld (xto), hl
ld a, (direction)
call SinA
ld de, (y)
add hl, de
ld (yto), hl
ld hl, $0100
ld (zup), hl
ld hl, 0
ld (xup), hl
ld (yup), hl
call InitView
ld hl, -256
ld (xpoint), hl
ld hl, 0
ld (ypoint), hl
ld hl, -$0100
ld (zpoint), hl
call C3DTo2D
ld hl, (screenx)
ld (screenx2), hl
ld hl, (screeny)
ld (screeny2), hl
ld hl, 256
ld (xpoint), hl
ld hl, 0
ld (ypoint), hl
ld hl, -$0100
ld (zpoint), hl
call C3DTo2D
ld hl, (screenx)
ld (screenx3), hl
ld hl, (screeny)
ld (screeny3), hl
ld hl, -256
ld (xpoint), hl
ld hl, 0
ld (ypoint), hl
ld hl, $0100
ld (zpoint), hl
call C3DTo2D
ld a, (screenx)
ld (x1), a
ld a, (screeny)
ld (y1), a
ld a, 0
ld (u1), a
ld (v1), a
ld a, (screenx2)
ld (x2), a
ld a, (screeny2)
ld (y2), a
ld a, 0
ld (u2), a
ld a, 8
ld (v2), a
ld a, (screenx3)
ld (x3), a
ld a, (screeny3)
ld (y3), a
ld a, 8
ld (u1), a
ld (v1), a
call DrawTriangle
call FastCopy
;knoppen
ld a, $FE
out (1), a
in a, (1)
bit 0, a
call z, MoveBack
bit 3, a
call z, MoveForward
bit 1, a
call z, TurnLeft
bit 2, a
call z, TurnRight
ld a, %11111101
out ($01), a
in a, ($01)
bit 6, a
jp z, Einde
jp spelLus
MoveBack:
push af
ld a, (direction)
ld b, 64
add a, b
call SinA
call NegHL
ld de, $0A00
call DivFP
ld de, (X)
add hl, de
ld (X), hl
ld a, (direction)
call SinA
call NegHL
ld de, $0A00
call DivFP
ld de, (Y)
add hl, de
ld (Y), hl
pop af
ret
MoveForward:
push af
ld a, (direction)
ld b, 64
add a, b
call SinA
ld de, $0A00
call DivFP
ld de, (X)
add hl, de
ld (X), hl
ld a, (direction)
call SinA
ld de, $0A00
call DivFP
ld de, (Y)
add hl, de
ld (Y), hl
pop af
ret
TurnLeft:
push af
ld a, (direction)
inc a
ld (direction), a
pop af
ret
TurnRight:
ld a, (direction)
dec a
ld (direction), a
ret
Einde:
;Key port resetten
ld a, $FF
out ($01), a
call ClearGbuf
call fastCopy
ld hl, 0
ld (CurRow), hl
EI
bjump(_JForceCmdNoChar)
That looks very nice, though it looks like there is a "seam" between the two triangles you are drawing. Is that intentional?
That looks very nice, good job. Is this for some other project?Yes, for a first person shooter.I'm not giving much information about it (just in case it won't work).
That looks very nice, though it looks like there is a "seam" between the two triangles you are drawing. Is that intentional?It's not intentional. It's caused by the texture being rotated a bit differently on the two triangles. This is just the way affine texture mapping works.
It depends on the situation. When there isn't very many polygons, sorting is faster, but past a certain number, (I think around a hundred) the sorting algorithm becomes too slow and z-buffering wins. Also keep in mind only z buffering is able to correctly show intersecting polygons.I know z buffering is only able to correctely show intersecting polygons, but also: one byte isn't accurate enough for polygons close to each other, so I need two byter for every pixel on the screen, so that would make 1228 bytes, which is really much, and I'm wondering if it's worth it to use that many bytes for only the graphical part.