0

I created a multi-device firemonkey form which included one viewport3d ,one Cube and one camera.I want to make a calloutpanel exactly on the top of the cube in the form with camera projection.

In Firemonkey, we can use worldtoscreen() to convert absolute position properties to screen position. The resulting point is correct for the Windows platform but unfortunately in Android platform the point is not accurate.

Procedure TForm50.Cube1Render(Sender: TObject; Context: TContext3D);
var p:TPoint3D;
x,y:real;
Begin 
  p:=context.worldtoscreen(TProjection.Camera, Cube1.AbsolutePosition);
  Label1.Text:=(p.x.tostring+'  '+P.Y.ToString);
  x:=p.X-(CalloutPanel1.Width /2);
  y:=p.y-CalloutPanel1.Height;
  CalloutPanel1.Position.X:=x;
  CalloutPanel1.Position.y:=y;
End;

update Base of this post WorldToScreen function C# my Cube1.AbsolutePosition must change base on size of monitor(android screen) to place CalloutPanel1 over cube1. Who can apply this code on Delphi?

A.K
  • 106
  • 1
  • 11
  • 2
    Can you elaborate on "not accurate"? – Brian Jun 13 '19 at 11:52
  • The calloutpanel position isn’t in top of cube. Base on android version or size of screen device the result point is before or after of cube position on the screen. – A.K Jun 13 '19 at 13:54
  • You say that the screen size of your device affects the position of your control. So I'm guessing that your controls might be automatically scaled to fit best in the actual screen size of your device. So instead of using `Width` and `Height` properties you should be using `AbsoluteWidth` and `AbsoluteHeight` properties instead. According to [documentation](http://docwiki.embarcadero.com/Libraries/Tokyo/en/FMX.Controls.TControl.AbsoluteHeight) they are affected by transformation applied over the control. – SilverWarior Jun 14 '19 at 17:06
  • AbsolutePosition is in 3d word coordinate and cannot apply to 2d screen coordinate for calloutpanel. – A.K Jun 15 '19 at 05:56
  • Base of this post [https://stackoverflow.com/questions/30777671/worldtoscreen-function-c-sharp][1] my Cube1.AbsolutePosition must change base on size of monitor(android screen) to place CalloutPanel1 over cube1. Who can apply this code on Delphi? – A.K Jun 15 '19 at 06:24

0 Answers0