I did some experimenting with this.
The min/max values remain the same when the object is rotated or scaled (Not scaled permanent)
So the min/max values will be as if you had just loaded the object always
The thing with attaching the boxes is: Not matter where the object is, no matter what the scale and rotation, if you create the boxes, move them to the min/max values and attach them to the object, they will always be at the extremities of the object.
This means that you do not need to have the boxes permanently attached to the object. Only when you want to calculate the bounding box.
I made some code to show the technique of attaching objects to the min/max values and calculating the bounding box.
// Project: test27
// Created: 2019-03-19
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test27" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // 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
SetSunActive(1)
SetSunDirection(0.5, -1, 0.5)
SetSunColor(0x80, 0x80, 0x80)
SetambientColor(0x80, 0x80, 0x80)
id = CreateObjectBox(1, 1, 3)
SetObjectColor(id, 0xff, 0, 0, 0xff)
SetCameraPosition(1, 0, 2, -5)
bounds as integer[]
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMinX(id), GetObjectSizeMinY(id), GetObjectSizeMinZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMinX(id), GetObjectSizeMaxY(id), GetObjectSizeMinZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMaxX(id), GetObjectSizeMaxY(id), GetObjectSizeMinZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMaxX(id), GetObjectSizeMinY(id), GetObjectSizeMinZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMinX(id), GetObjectSizeMinY(id), GetObjectSizemaxZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMinX(id), GetObjectSizeMaxY(id), GetObjectSizemaxZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMaxX(id), GetObjectSizeMaxY(id), GetObjectSizemaxZ(id))
bounds.insert(b)
b = CreateObjectBox(0.1, 0.1, 0.1)
SetObjectPosition(b, GetObjectSizeMaxX(id), GetObjectSizeMinY(id), GetObjectSizemaxZ(id))
bounds.insert(b)
for i=0 to bounds.length
FixObjectToObject(bounds[i], id)
next
do
RotateObjectGlobalY(id, 1)
RotateObjectGlobalZ(id, 1)
checkbounds(bounds)
print("MinMaxX=("+str(GetObjectSizeMinX(id))+","+str(GetObjectSizeMaxX(id))+")")
print("MinMaxY=("+str(GetObjectSizeMinY(id))+","+str(GetObjectSizeMaxY(id))+")")
print("MinMaxZ=("+str(GetObjectSizeMinZ(id))+","+str(GetObjectSizeMaxZ(id))+")")
Sync()
loop
function CheckBounds(bounds as integer[])
x as float
y as float
z as float
fx as float
fy as float
tx as float
ty as float
fx = 99999999
fy = 99999999
tx = -99999999
ty = -99999999
for i=0 to bounds.length
x = GetScreenXFrom3D(GetObjectWorldX(bounds[i]), GetObjectWorldY(bounds[i]), GetObjectWorldZ(bounds[i]))
y = GetScreenYFrom3D(GetObjectWorldX(bounds[i]), GetObjectWorldY(bounds[i]), GetObjectWorldZ(bounds[i]))
if x < fx
fx = x
endif
if x > tx
tx = x
endif
if y < fy
fy = y
endif
if y > ty
ty = y
endif
next
DrawBox(fx, fy, tx, ty, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0)
endfunction