How to get mouse click coordinates on TModel3D

  

I have a TModel3D inside a TDummy inside a TViewport3D (I needed an HD form) and I need to create a sphere when I click on it.

The OnClick event does not have coordinates as parameters, so I tried with the OnMouseDown event

procedure TfrModelloMuscoli.Model3D1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Single; RayPos,
RayDir: TVector3D);
var
MySphere: TSphere;
begin

MySphere := TSphere.Create( Model3D1 );
MySphere.Parent := Model3D1;

MySphere.Width := 0.5;
MySphere.Height := 0.5;
MySphere.Depth := 0.5;

MySphere.Position.X := ??;
MySphere.Position.Y := ??;
MySphere.Position.Z := ??;

end;

I tried using X,Y,Z of RayPos and RayDir, but without success, as MySphere is created where the MainCamera is (RayPos) or always in front of the TModel3D (RayDir).

Is there some way to know the coordinates of the click on the OnClick event on a TModel3D?

I searched but couldn’t find anything like this.

Any tips is appreciated. Thanks in advance.

I’m using Delphi XE8 and Firemonkey.

Comments are closed.