I'm almost done with my script to set OOP easily (if Fabrice you see this, it's what I was talking about at School). It's already working but I need some help as I'm stuck in compensating the rotation to calculate the new translation value.
Basically you launch it, and you click on a point of your current image, one on the lightable image before and one on the lightable image after and the points you clicked on your lightable images will jump to the click of your current image.
If you clicked with your left mouse button it's finished. It also works on OOp that already have some values.
But if you click with your right mouse button for the first clic, you'll also synchronise rotation and if you use your right mouse button on the second click you'll synchronize scale. If you clicked at least one once on your RMB you'll have to click on three new points to choose a second reference point (current image then prev then next image) to match the rotation and scale of your three images.
For now because of the problem I'm talking about below, if you used one right mouse button you'll then have to do 2 more clicks on the first synchronized points of your prev and next image (they moved because of the new scale/rotation transformation(s)) to compensate translate again. What I aim is to automate this step so you'll need only 6 clicks (the minimum).
The Script :
Code: Select all
tv_lightTableMode
parse result q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q PrevState q q OPrevX OPrevY q q OPrevA q q OPrevS q q NextState q q ONextX ONextY q q ONextA q q ONextS q
tv_waitbutton
parse result CurButA CurAX CurAY
tv_waitbutton
tv_waitbutton
parse result PrevButA PrevAX PrevAY
tv_waitbutton
PrevX = CurAX - PrevAX + OPrevX
PrevY = CurAY - PrevAY + OPrevY
tv_lightTableMode OopValueActivate -1 1 OoPValuePosition -1 PrevX PrevY
tv_waitbutton
parse result NextButA NextAX NextAY
tv_waitbutton
NextX = CurAX - NextAX + ONextX
NextY = CurAY - NextAY + ONextY
tv_lightTableMode OopValueActivate 1 1 OoPValuePosition 1 NextX NextY
IF CurButA==3 || PrevButA==3
tv_waitbutton
parse result CurButB CurBX CurBY
tv_waitbutton
tv_getWidth
parse result ProjW
tv_getHeight
parse result ProjH
CentW=ProjW/2
CentH=ProjH/2
PrevA=0
NextA=0
NextS=100
PrevS=100
tv_waitbutton
parse result PrevButB PrevBX PrevBY
tv_waitbutton
IF CurButA==3
BAx = (PrevBX-PrevX)-PrevAX
BAy = (PrevBY-PrevY)-PrevAY
BCx = curBX-curAX
BCy = curBY-curAY
PrevNegTest = (BAx*BCy)-(BAy*BCx)
IF PrevNegtest > 0
PrevNeg=-1
ELSE
PrevNeg=1
END
PrevA=PrevNeg*ACOS(((BAx)*(BCx)+(BAy)*(BCy))/(SQR((BAx)*(BAx)+(BAy)*(BAy))*SQR((BCx)*(BCx)+(BCy)*(BCy))))
tv_lightTableMode OoPValueAngle -1 PrevA
END
IF PrevButA==3
CurSize = SQR((CurBX-CurAX)*(CurBX-CurAX)+(CurBY-CurAY)*(CurBY-CurAY))
PrevSize = SQR(((PrevBX-PrevX)-PrevAX)*((PrevBX-PrevX)-PrevAX)+((PrevBY-PrevY)-PrevAY)*((PrevBY-PrevY)-PrevAY))
PrevS = (CurSize*100/prevSize)*(OprevS/100)
tv_lightTableMode OopValueScale -1 PrevS
END
//Buggy Rotate+Scale Image Calculation and Compensation for Prev Image
tv_lightTableMode
parse result q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q PrevState q q OPrevX OPrevY q q OPrevA q q OPrevS q q NextState q q ONextX ONextY q q ONextA q q ONextS q
RotPrevX = (PrevAX-CentW)*COS(PrevA)-(PrevAY-CentH)*SIN(PrevA)+CentW
ScaPrevX = CurAX-((RotPrevX-CentW+OPrevY)*PrevS/100+CentW)
RotPrevY = (PrevAY-CentW)*COS(PrevA)-(PrevAX-CentH)*SIN(PrevA)+CentW
ScaPrevY = CurAY-((RotPrevY-CentW+OPrevX)*PrevS/100+CentW)
PrevX = CurAX - ScaPrevX + OPrevX
PrevY = CurAY - ScaPrevY + OPrevY
//tv_lightTableMode OoPValuePosition -1 PrevX PrevY
tv_waitbutton
parse result NextButB NextBX NextBY
tv_waitbutton
IF CurButA==3
BDx = (NextBX-NextX)-NextAX
BDy = (NextBY-NextY)-NextAY
NextNegTest = (BDx*BCy)-(BDy*BCx)
IF NextNegtest > 0
NextNeg=-1
ELSE
NextNeg=1
END
NextA=(NextNeg)*ACOS(((BDx)*(BCx)+(BDy)*(BCy))/(SQR((BDx)*(BDx)+(BDy)*(BDy))*SQR((BCx)*(BCx)+(BCy)*(BCy))))
tv_lightTableMode OoPValueAngle 1 NextA
END
IF PrevButA==3
NextSize = SQR(((NextBX-NextX)-NextAX)*((NextBX-NextX)-NextAX)+((NextBY-NextY)-NextAY)*((NextBY-NextY)-NextAY))
NextS = (CurSize*100/NextSize)*(OnextS/100)
tv_lightTableMode OopValueScale 1 NextS
END
//Buggy Rotate+Scale Image Calculation and Compensation for Next Image
tv_lightTableMode
parse result q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q PrevState q q OPrevX OPrevY q q OPrevA q q OPrevS q q NextState q q ONextX ONextY q q ONextA q q ONextS q
RotNextX = (NextAX-CentW)*COS(NextA)-(NextAY-CentH)*SIN(NextA)+CentW
ScaNextX = CurAX-((RotNextX-CentW+ONextY)*NextS/100+CentW)
RotNextY = (NextAY-CentW)*COS(NextA)-(NextAX-CentH)*SIN(NextA)+CentW
ScaNextY = CurAY-((RotNextY-CentW+ONextX)*NextS/100+CentW)
NextX = CurAX - ScaNextX + ONextX
NextY = CurAY - ScaNextY + ONextY
//tv_lightTableMode OoPValuePosition 1 NextX NextY
tv_lightTableMode
parse result q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q PrevState q q OPrevX OPrevY q q OPrevA q q OPrevS q q NextState q q ONextX ONextY q q ONextA q q ONextS q
tv_waitbutton
parse result PrevButA ScaPrevX ScaPrevY
tv_waitbutton
PrevX = CurAX - ScaPrevX + OPrevX
PrevY = CurAY - ScaPrevY + OPrevY
tv_lightTableMode OoPValuePosition -1 PrevX PrevY
tv_waitbutton
parse result NextButA ScaNextX ScaNextY
tv_waitbutton
NextX = CurAX - ScaNextX + ONextX
NextY = CurAY - ScaNextY + ONextY
tv_lightTableMode OoPValuePosition 1 NextX NextY
END
I'm using the mathematic formula to find the image of a point by rotation but I can't find the right result i'm using the center of the image for rotation center and the second/first clic as point reference, plus the rotation I found previously to match the drawings as the angle.
If somebody have an idea
Nathan