Convert you mouse 2D screen position to 3D and assign it to camera taget positon or move the camera according to the 3D position and in the plane you are (xy, yz, zx)
Last edit: Jerome.D (BeanzMaster) 2018-02-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
// Note that 1 wheel-step induces a WheelDelta of 120,
// this code adjusts the distance to target with a 10% per wheel-step ratio
GLCamera1.AdjustDistanceToTarget(Power(1.1, WheelDelta / 120));
end;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes exactly Silverio. But i'm not sure i' need make some verification because don't remember if by using 'Position.AsAffineVector' position notify the changes
You can also try PixelRayToWorld(x,y):TAffineVector instead of screenToWorld
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
How can we zoom on scene to the mouse position by mousewheel event?
Convert you mouse 2D screen position to 3D and assign it to camera taget positon or move the camera according to the 3D position and in the plane you are (xy, yz, zx)
Last edit: Jerome.D (BeanzMaster) 2018-02-09
Hi Jerome,
Thanks for your answer,
I tried to do this conversion using the following code but not work truly:
procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
GLDummyCube1.Position.AsAffineVector:=GLSceneViewer1.Buffer.ScreenToWorld(MousePos.X , MousePos.Y);
// Note that 1 wheel-step induces a WheelDelta of 120,
// this code adjusts the distance to target with a 10% per wheel-step ratio
GLCamera1.AdjustDistanceToTarget(Power(1.1, WheelDelta / 120));
end;
Perhaps camera e camera target have to be moved in accordance
Last edit: shine world 2018-02-12
Yes exactly Silverio. But i'm not sure i' need make some verification because don't remember if by using 'Position.AsAffineVector' position notify the changes
You can also try PixelRayToWorld(x,y):TAffineVector instead of screenToWorld