if you really want FixObjectToScreen() functionality, i think you'll have to create an object, fix the camera to that cam object, then FixObjectToObject() whatever objects you want to fix to the "screen" or Camera:
IE, as scraggle suggests, something like:
// Project: FixObjectToCam
// Created: 2020-09-14
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "FixObjectToCam" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 0 ) // allow the user to resize the window
MaximizeWindow()
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetPrintColor(0,0,0)
for x = 1 to 20 `scatter some boxes to look at
ThisObj = CreateObjectBox(Random(10,20), Random(10,20), Random(10,20))
SetObjectPosition(ThisObj, Random(-500,500),Random(-500,500), Random(-500,500) )
SetObjectColor(ThisObj, Random(128,255), Random(128,255), Random(128,255), Random(128,255))
next x
GLOBAL Cam as Integer : Cam = CreateObjectBox(1,1,1) : SetObjectVisible(Cam,0)
SetCameraPosition(1,0,0,0) : SetCameraRotation(1,0,0,0)
FixCameraToObject(1,Cam)
Blob = CreateObjectSphere(3,3,3) `to attach to cam
SetObjectPosition(Blob, 0,0,10)
FixObjectToObject(Blob, Cam)
GLOBAL RotRate# = 2.0
GLOBAL MoveRate# = 1.5
SetSkyBoxVisible(1)
do
If GetRawKeyPressed(27) then Exit `[ESC]
DoCam()
Print ("[CursorKeys]=Rotate, [A]/[Z]=Move, [Space] to Reset")
Sync()
loop
Function DoCam()
RotX# = (GetRawKeyState(38) - GetRawKeyState(40)) * RotRate#
RotY# = (GetRawKeyState(39) - GetRawKeyState(37)) * RotRate#
Move# = (GetRawKeyState(65) - GetRawKeyState(90)) * MoveRate#
SetObjectRotation(Cam, WrapAngle(GetObjectAngleX(Cam) + RotX#), WrapAngle(GetObjectAngleY(Cam) + RotY#), GetObjectAngleZ(Cam))
MoveObjectLocalZ(Cam, Move#)
If GetRawKeyState(32) `[SPACE] to Reset Cam
SetObjectPosition(Cam,0,0,0)
SetObjectRotation(Cam, 0,0,0)
Endif
EndFunction
Function WrapAngle(angle#)
angle# = angle# - floor(angle#/360) * 360.0
Endfunction angle#
you'll probably find it difficult to decide where to Fix the Object in 3d space in relation to the camera, tho. but, it can be done.
and, as scraggle suggests, it's probably more accurate to describe it as Fix3DObjectToCam() functionality.
i hope that helps