procedure TForm1.Button1Click(Sender: TObject); var sphere:TGLSphere; begin sphere:=TGLSphere.Create(nil); GLScene1.Objects.AddChild(sphere); sphere.Position.AsVector:=PointMake(random(10)-5, random(10)-5, 0); inc(count); sphere.Tag:=count; end; ※count:Integer;をどこかグローバルな所に設定しておいてください。
GLSceneViewerのonMouseDownイベントに以下のコードを書く procedure TForm1.GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var pick : TGLBaseSceneObject; i : Integer; begin pick:=GLSceneViewer1.Buffer.GetPickedObject(x, y); if Assigned(pick) then begin i:=pick.Tag; ShowMessage(IntToStr(i)); end;