| |
LHS
Registered: Dec 2002 Posts: 66 |
rotating chessboard
Hello, how to code a "simple" monochrome rotating (+zooming) chessboard, like the part after intro in Deus Ex Machina?
I'm thinking on line rutines for filled vector (when x' = x+1). Just draw on screen a few lines, then a few lines rotated 90dgrs, it gives a "chessboard net". But then the EOR filling doesn't fill corectly, because the first (upper) line isn't prepared. This first line is filled only by end-points of vector lines. Is this a right thought? How to prepare the upper line? |
|
... 19 posts hidden. Click here to view all posts.... |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
SHUT UP ALL OF YOU.. :)
(got some code cooking on the back burner here)
LHS: Thanks :)
Jackasser, HCL: Er, i got the source here, but back in the days i thought i was too leet for comments.. :) What Oswald said is basically right, some modified zoom-table approach for lda eor sta code, which comes with all the good and bad parts. Like speed and visual artefacts and such. :) |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Thanks for the explaination Oswald, I think I'm starting to get it. Pretty clever, as with everything Graham has invented.
|
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Yeah. |
| |
LHS
Registered: Dec 2002 Posts: 66 |
Hey Oswald, I often wondered about this zoom technique, Krill explained it to me at a Padua meeting, but only from your example I understand it ;-) |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: Hey Oswald, I often wondered about this zoom technique, Krill explained it to me at a Padua meeting, but only from your example I understand it ;-)
Now generalize that technique in two dimensions and you understand that you can zoom in the y-direction aswell.
Further more, realize that if you can pick chars to zoom you can also pick the chars so the display rotate just a tiny bit, f.e. by letting the adjacent char be one line down you get a slope of 1/8.
Now do some calculus how much you can slope using the same charset before too many errors occur and figure out when and how to switch charsets and you're extremly close to how the rotator in f.e. Amplifire and Mekanix work (i.e. the one in the beginning, not the chess zoomer). |
| |
WVL
Registered: Mar 2002 Posts: 902 |
Good, now i don't have to explain it any longer :D |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: Good, now i don't have to explain it any longer :D
Well, still havn't explained why connecting rotation to zooming is a speed optimization, but it's quite simple:
A general roto-zoomer steps along Ux,Uy,Vx and Vy in the texture, per pixel. The U- and V- vectors are most often perpendicular to each other (i.e. the texture is just rotated/zoomed and not scewed or sheared).
Now to calculate the vectors one usually do something like:
Ux = cos(a)/zoom
Uy = sin(a)/zoom
Vx = Uy
Vy = -Vx
And the code in the plot loop:
for (int y=0; y<height; y++)
for (int x=0; x<width; x++)
{
int tx = x*Ux + y*Uy;
int ty = x*Vx + y*Vy;
screen[x+y*screenStride] = texture[tx+ty*textureStride];
}
But if you ignore zoom for a moment and consider the following vectors instead (imagine we move the vector around a square instead, the following code applies for moving along the top-edge):
Ux = a
Uy = 1
Vx = Uy = 1
Vy = -Vx = -a
Now, moving like this will result in differently scaled vectors, i.e. not unit size (or 1/zoom as in the previous example). I.e. there is an implicit zooming connected to the rotation like in PFP and Mekanix.
Plot code:
for (int y=0; y<height; y++)
for (int x=0; x<width; x++)
{
int tx = x*a + y;
int ty = -x + y*a;
screen[x+y*screenStride] = texture[tx+ty*textureStride];
}
As you see, one of the multiplications per component has been optimized away. Yay! Per pixel/char/unit/bum tx and ty only changes additively by a.
@WVL: Now I know you don't explain it like this, but this is what it becomes if you take it from the normal roto zoomer perspective.
|
| |
Skate
Registered: Jul 2003 Posts: 494 |
I know a different approach for rotators like these but I'm still working on it to add a flexable zoom ability. I don't know if my approach will work or not. I'm not actively working on it, either. But if it works, I'll tell you the details in the demo note file. ;) |
| |
LHS
Registered: Dec 2002 Posts: 66 |
About the mentioned texture mapper in Dawnfall, which rastertimer uses this efect?
One logo about 30*10 chars, two logos about 30*5 chars, zooming by the duplication of the edge pixels, any line of these logos however zoomed in arbitrary line of screen... FPP or FPD timer doesn't give this resolution. Or not?
Footnote: specially in the Dawnfall, this part is one of the early in onefile demo, I don't suppose use of all 4 VIC banks. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
it's lda sta code. also dont forget you can also shrink by hiding the "edge" pixels. but better not think about it this way or it will fool you. the whole texture can be shifted trough the bytes and any pixel can be doubled, depends on the shift&zoom. |
Previous - 1 | 2 | 3 - Next |