Here's the working code for now, if anyone was curious. This doesn't take into account for objects that have normal rotation and don't need to be adjusted when converted to vertexdata. But I will fix that later.
function save_world( exclude as integer , swb_file as string )
local swb_message as string
local swb_x as float
local swb_y as float
local swb_z as float
if object count() = 1 then swb_message = "empty level" : exitfunction
objcount = object count()
for x = 1 to objcount
if object exist(x) = 1 and x <> exclude then first = x : x = objcount
NEXT 1
swb_passback = find free object()
clone object swb_passback, first
rotate object first, 0, 0, 0
position object first, 0, 0, 0
limb = 1
for x = first to objcount
if x = first
make mesh from object 1, swb_passback
add limb first, limb, 1
link limb first, 0, limb
rotate limb first, limb, 180, 0, 0, 1
offset limb first, limb, object position x(swb_passback), object position y(swb_passback), object position z(swb_passback), 1
texture limb first, limb, limb texture(swb_passback, 0)
sync
inc limb, 1
ENDIF
if object exist(x) = 1 and x <> exclude and x <> first
make mesh from object 1, x
add limb first, limb, 1
link limb first, 0, limb
rotate limb first, limb, 180, 0, 0, 1
swb_x = object position x(x) : swb_y = object position y(x) : swb_z = object position z(x)
offset limb first, limb, swb_x, swb_y, swb_z , 1
texture limb first, limb, limb texture(x,0)
set limb normals first, limb
sync
inc limb, 1
ENDIF
NEXT 1
exclude limb on first, 0
if file exist(swb_file) = 1 then delete file swb_file
save object swb_file, first
delete object first
clone object first, swb_passback
delete object swb_passback
swb_message = "successful"
ENDFUNCTION swb_message
In fact, I might just convert planes to vertexdata, then back to regular objects on
creation, with the requisite rotation and
normal fixes in-play at that point. Then, the save world function would never have to take these quarrelsome
plane's into account.
-
