finit
fldpi
fdiv scale1
fmul angle ;transform angle to radian, scale is a constant
fsincos
fstp scale2 ;scale2=sin
fstp scale3 ;scale3=cos
fldz
fist vf ;zero vf and uf counters
fistp uf
;***********************************************************************************
;* screenx=x/z, screeny=y/z, y=altitude=constant for a plane *
;* which in turn leads z=altitude*screeny, to get first texturecoordinate: *
;* texturesize*z and x=screenx*z *
;***********************************************************************************


mov sy,1 ;screeny
finit

yloop1: ;loop thru all scanlines
fld altitude
fidiv sy
fst z
fadd zcoord
fimul textures
;fmul scale3
fistp ztexture

mov sx,-639
fld z
fimul sx
fstp xdelta ;to exchange a fmul to fadd in innerloop


xloop1: fld xdelta
fistp xtexture
fld z ; not to confuse with the mnemonic fldz
fmul scale2 ;multiply with cos angle in attempt to rotate surface
fadd xdelta
fstp xdelta
;read texture code
mov edi,pMemory
add edi,18
mov ebx,ztexture
and ebx,1023
mov edx,xtexture
and edx,1023
sal ebx,10 ;y*1024
add ebx,edx ;+x
mov eax,ebx
add ebx,ebx ;*2
add ebx,eax ;*3
mov eax,
;read texture code finished
; macro plot= plot eax at position x=ecx,y=edx, with clipping in 1280*1024*32 resultion
mov ecx,sx
add ecx,639

mov edx,sy
add edx,512
plot
fld uf ;uf+cos(angle) ;a try to step thru texture moving in angle direction
fadd scale3
fstp uf
fld vf ;vf+sin(angle)
fadd scale2
fstp uf

inc sx
mov ecx,sx
cmp ecx,640
jne xloop1
fld uf ;uf+sin(angle) ; a try to step thru texture moving in angle+90degrees
fadd scale2
fstp uf
fld vf ;vf+cos(angle)
fadd scale3
fstp uf
inc sy
mov edx,sy
cmp edx,512
jne yloop1

I realized later this must be called floormapping, but I have a problem making rotating working correctly
I can partly look to the left with this code, but it actually do kinda morph the scanlines to the right, not really rotating it, if I remove commenting out multiply with sin in yloop, I only get screen filled with lines
if I turn it to 90degrees I only get lines
here is how it looks like
ok its messy and can be optimized quite a bit, but I want to get the algo right first, and add some more features
Posted on 2004-04-14 13:07:40 by daydreamer
what
Posted on 2005-07-21 08:01:59 by comrade