so apparently its not that hard to do I tired in several ways since I'm building a 3d game
and the best solution I came up with is this:
you get the angles and position of the 3d camera
you insert them into the 3d object
then you move the 3d object on the x,y,z angles
works like a charm.
enjoy:
// This will show how to fix a 3d object to screen
// created by Nadav "haliop" Rosenberg 19.11.2016
// set window properties
SetWindowTitle( "FixObjectToScreen" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
// Objects To Be Fixed
CreateObjectBox(1,10,10,10)
CreateOBjectSphere(2,16,16,16)
CreateObjectCone(3,10,16,16)
// Objects to act as surrondings
CreateObjectBox(4,10,150,10)
SetObjectPosition(4,0,0,150)
SetObjectColor(4,255,0,0,255)
do
FixObjectToScreen(1,0,0,100,1)
FixObjectToScreen(2,25,0,50,0)
FixOBjectToScreen(3,-25,0,75,1)
dx# = GetDirectionX()*100
dy# = GetDirectionY()*50
SetCameraRotation(1,dy#,dx#*-1,GetCameraZ(1))
Print( ScreenFPS() )
Sync()
loop
function FixObjectToScreen(id as integer,MoveX as float,MoveY as float,MoveZ as float,fixedAngle as integer)
cx# = GetCameraX(1) : cy# = GetCameraY(1) : cz# = GetCameraZ(1)
cax# = GetCameraAngleX(1) : cay# = GetCameraAngleY(1) : caz# = GetcameraAngleZ(1)
SetOBjectPosition(id,cx#,cy#,cz#)
SetOBjectRotation(id,cax#,cay#,caz#)
MoveObjectLocalX(id,MoveX)
MoveObjectLocalY(id,MoveY)
MoveOBjectLocalZ(id,MoveZ)
if fixedAngle = 0 then SetObjectLookAt(id,cx#,cy#,cz#,0)
endfunction