TEXTURE MAPPING (Walls only) I have been testing and trying to do texture mapping and I finaly found out the basics and got it to work. So I have first written down the matimatical basics and then a easy to understand basic code. Hope you find it useful And if you do then please write me a note and dont forget to give me some credit in your production... First you got your picture in memory, wich I describe like this: Xm +--------+ | | | | Ym | | +--------+ And this picture shall be putted out in this polygone: X1,Y1 +---___ x2,y2 | ---+ | | | | | ___---+ +--- X3,Y3 X4,Y4 Now you only got to do this procedure every pixel in the polygone: PLOT X, Y, POINT(Xp, Yp) Well what is Xp and Yp then? Well you only got to use theese two formulas: Ä Ä ÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄ Ä Ä Xm*(X-X1) Xp = ÄÄÄÄÄÄÄÄÄÄÄ X2 -x1 Ä Ä ÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄ Ä Ä (Y2-Y1)*(X-X1) Ym*(y-ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ) X2 -x1 Yp = ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ X*(Y3-Y2-Y4+Y1) Y4-Y2+ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ X2 -x1 Ä Ä ÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄ Ä Ä As a little hint I could say that you better do this in assembler and that yoy draw the polygone in columns not by lines. And make some kind of delta values and just add in the inner loops. Well I maybe shall help you started with a little test in Basic. You maybe dont recognise the formula but if you dont then you better dont try to code any Texture mapping at all!!! FOR X = x1 TO X2 Xp = (Xm * (X - x1)) / (X2 - x1) Ys = Y1 + ((y2 - Y1) / (X2 - x1) * (X - x1)) Ye = Y4 + ((Y3 - Y4) / (X2 - x1) * (X - x1)) FOR Y = Ys TO Ye Yp = (Ym * (Y - Y1)) / (Ye - Ys) PLOT X, Y, POINT(Xp, Yp) NEXT Y NEXT X Some more hints is to make the original picture in a length and width of 32, 64 128 or something equaly easy to ROL instead of MULU. Then I in my own code (On ST) got one seperate precalculated code for every colour to plot, and one extra for transparent picture. (Windows) And the transparent cod is one line long and includes a RTS so guess what P-time that one takes!?! Well thats it, good luck from PeyloW of T.O.Y.S. Greetz goes to: TaM, Thanx for all but coding Me, Say helo to Josefin. AIO (Pseudo), Thanx for all muzix. Hydrogen, Hey there. Eagle, Havent seen you for a long... OB, I look forward to SUB STAION. MF, Min sladd tack !!! And to all others... My address if you need it ?!? PeyloW of T.O.Y.S. Greby 59042 Horn Sweden And phone #: 0494-30404 (I love a long chat but only 18-21) See ya...