1

I have a Firemonkey form with a 3dgrid component on form set to (0,0,0). I would like to get the coordinates of a spot on the grid when the mouse is clicked. I know how to get the screen position of the cursor, but I need the coordinates on the 3d grid itself relative to the mouse position on the 3dgrid.

jachguate
  • 16,976
  • 3
  • 57
  • 98
user1868232
  • 623
  • 2
  • 10
  • 21
  • Firemonkey in XE2 and XE3 are two separate things, and neither of them has to do with `object-pascal`. They're both specific to Delphi, which is *not* Object Pascal. You'll need to decide whether your question is about FM (XE2) or FM2 (XE3). – Ken White Apr 03 '13 at 02:00
  • @ Kevin I am using the Delphi side of Rad Studio XE3, Isn't that Object-pascal? As opposed to C++ – user1868232 Apr 03 '13 at 02:07
  • 2
    :-) My name is Ken, but the answer is: No, [they are not](http://stackoverflow.com/q/15699788/62576). – Ken White Apr 03 '13 at 02:12
  • 1
    @Ken* It's been a long day :) – user1868232 Apr 03 '13 at 02:19
  • No problem. No offense taken. You did see the smile, right? :-) – Ken White Apr 03 '13 at 02:24

1 Answers1

0

You can try that ...

Emmanuel

procedure TFormMain.EveOnMyLayer3D_MouseUp(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Single; RayPos,
      RayDir: TVector3D);
var
  P3: TVector3D;
  LocalX, LocalY: single;


begin
  if MyLayer3D.RayCastIntersect(rayPos, rayDir, P3) then
  begin
    P3 :=  MyLayer3D.AbsoluteToLocalVector(P3);
    LocalX := P3.X*MyLayer3D.Resolution;
    LocalY := P3.Y*MyLayer3D.Resolution;
    ...
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
ed973
  • 1
  • 1