
Voici un code qui va vous ravire (mettez l'image que vous voulez sinon : bug) :
Code : Tout sélectionner
If InitSprite() And InitMouse() And InitKeyboard()
Else
MessageRequester("Erreur", "InitSprite() And InitMouse() And InitKeyboard() : impossible")
End
EndIf
UseJPEGImageDecoder()
;* Ouverture de la l'écran *;
OpenScreen(1024,768,32,"")
LoadSprite(1,"d:\1.jpg")
;* definition de quelques valeurs, et des coordonnées des points *;
Dim PX2(5) : Dim PY2(5) : Dim PZ2(5)
Dim PX3(5) : Dim PY3(5) : Dim PZ3(5) : Dim ink(5)
PX3(0)=150 : PY3(0)=0 : PZ3(0)=0
PX3(1)=-150 : PY3(1)=0 : PZ3(1)=0
PX3(2)=0 : PY3(2)=0 : PZ3(2)=150
PX3(3)=0 : PY3(3)=0 : PZ3(3)=-150
PX3(4)=0 : PY3(4)=150 : PZ3(4)=0
PX3(5)=0 : PY3(5)=-150 : PZ3(5)=0
angx.f=0 : angy.f=0 : angz.f=0
;* boucle principale *;
Repeat
DisplaySprite(1,0,0);ClearScreen(RGB(255, 255, 255))
;* rotation et projection des points, non optimisée mais compréhensible *;
For u=0 To 5
x0=PX3(u)
y0=PY3(u)
z0=PZ3(u)
x1=x0
y1=Cos(angx)*y0+Sin(angx)*z0
z1=Sin(angx)*y0-Cos(angx)*z0
x2=Cos(angy)*x1+Sin(angy)*z1
y2=y1
z2=Sin(angy)*x1-Cos(angy)*z1
x3=Cos(angz)*x2+Sin(angz)*y2
y3=Sin(angz)*x2-Cos(angz)*y2
z3=z2
x4=(x3*256)/(z3-256)+520
y4=(y3*256)/(z3-256)+440
PX2(u)=x4
PY2(u)=y4
PZ2(u)=z3
Next
;* traçage *;
StartDrawing(ScreenOutput())
posx=PX2(0) : posy=PY2(0) : posz=(PZ2(0)+256)/2
;Debug posz
posy=posy-posz
sizex=posz*posz ;: sizey=posz*2
; hy.f=(180/sizey)/57.297795
hy.f=(90/posz)/57.297795
For n=0 To posz;sizey-1
ang.f=n*hy
x=Sqr(Sin(ang)*sizex)
DisplayRGBFilter(posx-x,posy+n,x*2,1,posz/2,0,0)
DisplayRGBFilter(posx-x,posy+posz*2+1-n,x*2,1,posz/2,0,0)
Next
posx=PX2(1) : posy=PY2(1) : posz=(PZ2(1)+256)/2
posy=posy-posz
sizex=posz*posz ;: sizey=posz*2
; hy.f=(180/sizey)/57.297795
hy.f=(90/posz)/57.297795
For n=0 To posz;sizey-1
ang.f=n*hy
x=Sqr(Sin(ang)*sizex)
DisplayRGBFilter(posx-x,posy+n,x*2,1,0,posz/2,0)
DisplayRGBFilter(posx-x,posy+posz*2+1-n,x*2,1,0,posz/2,0)
Next
posx=PX2(2) : posy=PY2(2) : posz=(PZ2(2)+256)/2
posy=posy-posz
sizex=posz*posz ;: sizey=posz*2
; hy.f=(180/sizey)/57.297795
hy.f=(90/posz)/57.297795
For n=0 To posz;sizey-1
ang.f=n*hy
x=Sqr(Sin(ang)*sizex)
DisplayRGBFilter(posx-x,posy+n,x*2,1,0,0,posz/2+40)
DisplayRGBFilter(posx-x,posy+posz*2+1-n,x*2,1,0,0,posz/2+40)
Next
posx=PX2(3) : posy=PY2(3) : posz=(PZ2(3)+256)/2
posy=posy-posz
sizex=posz*posz ;: sizey=posz*2
; hy.f=(180/sizey)/57.297795
hy.f=(90/posz)/57.297795
For n=0 To posz;sizey-1
ang.f=n*hy
x=Sqr(Sin(ang)*sizex)
DisplayRGBFilter(posx-x,posy+n,x*2,1,posz/2,posz/2,0)
DisplayRGBFilter(posx-x,posy+posz*2+1-n,x*2,1,posz/2,posz/2,0)
Next
posx=PX2(4) : posy=PY2(4) : posz=(PZ2(4)+256)/2
posy=posy-posz
sizex=posz*posz ;: sizey=posz*2
; hy.f=(180/sizey)/57.297795
hy.f=(90/posz)/57.297795
For n=0 To posz;sizey-1
ang.f=n*hy
x=Sqr(Sin(ang)*sizex)
DisplayRGBFilter(posx-x,posy+n,x*2,1,0,posz/2,posz/2+30)
DisplayRGBFilter(posx-x,posy+posz*2+1-n,x*2,1,0,posz/2,posz/2+30)
Next
posx=PX2(5) : posy=PY2(5) : posz=(PZ2(5)+256)/2
posy=posy-posz
sizex=posz*posz ;: sizey=posz*2
; hy.f=(180/sizey)/57.297795
hy.f=(90/posz)/57.297795
For n=0 To posz;sizey-1
ang.f=n*hy
x=Sqr(Sin(ang)*sizex)
DisplayRGBFilter(posx-x,posy+n,x*2,1,posz/2,0,posz/2)
DisplayRGBFilter(posx-x,posy+posz*2+1-n,x*2,1,posz/2,0,posz/2)
Next
angx+0.04
angy+0.034
angz-0.03
StopDrawing()
FlipBuffers()
;* On quite ! *;
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
