Mouse X,Y, Bouton gauche et droit...
Enjoy :
Code : Tout sélectionner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SPH(2024) --- Projection de points dans un autre plan ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Error", "Can't open the sprite system", 0)
End
EndIf
ddw=1024
ddh=768
If OpenWindow(0, 0, 0, ddw, ddh, "SPH Déformation", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0,ddw,ddh, 0, 0, 0)
MouseLocate(ddw/2, ddh/2)
nb=400
Dim pxv(nb)
Dim pyv(nb)
ici=0
freeze=1
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Event = 0
ExamineKeyboard()
ExamineMouse()
MouseX=MouseX()
MouseY=MouseY()
Lmb=MouseButton(#PB_MouseButton_Left)
Rmb=MouseButton(#PB_MouseButton_Right)
If Rmb And freeze=0
freeze=1
EndIf
If Rmb=0 And freeze=1
freeze=2
EndIf
If Rmb And freeze=2
freeze=3
EndIf
If Rmb=0 And freeze=3
freeze=0
EndIf
;;;;;;;;;;;;;;;;;
If freeze=1 Or freeze=2
axe1f.f+0.052
axe1x.f=101+Cos(axe1f.f)*101
axe1y.f=101+Sin(axe1f.f)*101
axe2f.f+0.041
axe2x.f=ddw-101+Cos(axe2f.f)*101
axe2y.f=101+Sin(axe2f.f)*101
axe3f.f+0.044
axe3x.f=ddw-101+Cos(axe3f.f)*101
axe3y.f=ddh-101+Sin(axe3f.f)*101
axe4f.f+0.038
axe4x.f=101+Cos(axe4f.f)*101
axe4y.f=ddh-101+Sin(axe4f.f)*101
EndIf
;;;;;;;;;;;;;;;;;
sph_xxx.f=MouseX
sph_yyy.f=MouseY
fx.f=sph_xxx/ddw
fy.f=sph_yyy/ddh
axe12xf.f=(axe2x-axe1x)*fx+axe1x
axe12yf.f=(axe2y-axe1y)*fx+axe1y
axe34xf.f=(axe3x-axe4x)*fx+axe4x
axe34yf.f=(axe3y-axe4y)*fx+axe4y
fx01.f=(axe34xf-axe12xf)*fy+axe12xf
fy01.f=(axe34yf-axe12yf)*fy+axe12yf
;====
; 1--------2
; | |
; 4--------3
axe14xf.f=(axe4x-axe1x)*fy+axe1x
axe14yf.f=(axe4y-axe1y)*fy+axe1y
axe23xf.f=(axe3x-axe2x)*fy+axe2x
axe23yf.f=(axe3y-axe2y)*fy+axe2y
fx02.f=(axe23xf-axe14xf)*fx+axe14xf
fy02.f=(axe23yf-axe14yf)*fx+axe14yf
ClearScreen(RGB(255, 255, 200))
;;;;;;;;;;;;;
StartDrawing(ScreenOutput())
LineXY(axe12xf-5, axe12yf-5, axe12xf+5, axe12yf+5, RGB(0,0,255))
LineXY(axe12xf-5, axe12yf+5, axe12xf+5, axe12yf-5, RGB(0,0,255))
LineXY(axe34xf-5, axe34yf-5, axe34xf+5, axe34yf+5, RGB(0,0,255))
LineXY(axe34xf-5, axe34yf+5, axe34xf+5, axe34yf-5, RGB(0,0,255))
LineXY(axe14xf-5, axe14yf-5, axe14xf+5, axe14yf+5, RGB(0,0,255))
LineXY(axe14xf-5, axe14yf+5, axe14xf+5, axe14yf-5, RGB(0,0,255))
LineXY(axe23xf-5, axe23yf-5, axe23xf+5, axe23yf+5, RGB(0,0,255))
LineXY(axe23xf-5, axe23yf+5, axe23xf+5, axe23yf-5, RGB(0,0,255))
LineXY(axe12xf, axe12yf, axe34xf, axe34yf, RGB(255, 200,180))
LineXY(axe14xf, axe14yf, axe23xf, axe23yf, RGB(255, 200,180))
LineXY(fx01, fy01-8, fx01, fy01+8, RGB(200, 90,90))
LineXY(fx01-8, fy01, fx01+8, fy01, RGB(200, 90,90))
LineXY(MouseX, MouseY,MouseX+16, MouseY+11, RGB(0,0,0))
LineXY(MouseX, MouseY,MouseX+11, MouseY+16, RGB(0,0,0))
LineXY(MouseX+16, MouseY+11,MouseX+11, MouseY+16, RGB(0,0,0))
;;;;
LineXY(axe1x, axe1y, axe2x, axe2y, RGB(255, 0,0))
LineXY(axe1x, axe1y, axe4x, axe4y, RGB(255, 0,0))
LineXY(axe3x, axe3y, axe2x, axe2y, RGB(255, 0,0))
LineXY(axe3x, axe3y, axe4x, axe4y, RGB(255, 0,0))
;;;
For i=0 To nb
Plot(pxv(i),pyv(i),RGB(0,150,0)) ; points verts
Next
;;;
For i=0 To nb
fx.f=pxv(i)/ddw
fy.f=pyv(i)/ddh
axe12xf.f=(axe2x-axe1x)*fx+axe1x
axe12yf.f=(axe2y-axe1y)*fx+axe1y
axe34xf.f=(axe3x-axe4x)*fx+axe4x
axe34yf.f=(axe3y-axe4y)*fx+axe4y
fx01.f=(axe34xf-axe12xf)*fy+axe12xf
fy01.f=(axe34yf-axe12yf)*fy+axe12yf
Plot(fx01,fy01,RGB(240,0,0)) ; points rouges
Next
;;;;;
StopDrawing()
If Lmb
pxv(ici)=MouseX
pyv(ici)=MouseY
ici+1
ici%nb
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
EndIf
EndIf