While browsing the forums i noticed a dbpro user asking how to put labels in 3d space, all though not complete this is what i have so far.
edit; Now able to delete labels with delete_label(label ID)
edit; Functions below return label position
edit; label_x(label ID), label_y(label ID), label_z(label ID)
set display mode 800, 600, 32
sync on; sync rate 60; autocam off; sync;
set image colorkey 0, 0, 0
global red as dword; red = rgb(255, 0, 0)
global green as dword; green = rgb(0, 255, 0)
global blue as dword; blue = rgb(0, 0, 255)
type labeltype
active as boolean
caption as string
image as integer
object as integer
x as float
y as float
z as float
width as integer
height as integer
color as dword
endtype
global dim labels(0) as labeltype
labela = new_label("3d label", 0, 2.0, 0, red)
labelb = new_label("3d label", 0, 1.0, 0, green)
labelc = new_label("3d label", 0, 0, 0, green)
labeld = new_label("3d label", 0, -1.0, 0, blue)
labele = new_label("3d label", 0, -2.0, 0, rgb(255, 0, 255))
change_label_caption(labeld, "RealUnReal") `labeld now reads RealUnReal
change_label_color(labelb, blue) `labelb is now blue
change_label_position(labela, -2.0, 2.0, 0) `labela now apears to the left of the other labels
change_label_color(labeld, rgb(255,255,255)) `labeld is now white
delete_label(labelc) `labelc has now been deleted and will not apear
position camera 0, 0, -10
point camera 0, 0, 0
repeat
process_labels()
sync
until returnkey()
end;
function process_labels()
arraycount = array count(labels(0)) - 1
if arraycount > -1
for count = 0 to arraycount
if labels(count).active
point object labels(count).object, camera position x(), camera position y(), camera position z()
endif
next count
endif
endfunction
function change_label_position(element as integer, x as float, y as float, z as float)
labels(element).x = x
labels(element).y = y
labels(element).z = z
position object labels(element).object, x, y, z
endfunction
function change_label_caption(element as integer, caption as string)
width = text width(caption)
height = text height(caption)
labels(element).caption = caption
labels(element).width = width
labels(element).height = height
delete image labels(element).image
delete object labels(element).object
currentbitmap = current bitmap()
bitmap = free_bitmap()
create bitmap bitmap, width, height
ink labels(element).color, 0
text 0, 0, caption
get image labels(element).image, 0, 0, width, height, 1
set current bitmap currentbitmap
delete bitmap bitmap
make object plain labels(element).object, 0.025 * width, 0.025 * height
texture object labels(element).object, labels(element).image
set object transparency labels(element).object, 1
position object labels(element).object, labels(element).x, labels(element).y, labels(element).z
endfunction
function change_label_color(element as integer, color as dword)
delete image labels(element).image
currentbitmap = current bitmap()
bitmap = free_bitmap()
create bitmap bitmap, labels(element).width, labels(element).height
ink color, 0
text 0, 0, labels(element).caption
get image labels(element).image, 0, 0, labels(element).width, labels(element).height, 1
set current bitmap curentbitmap
delete bitmap bitmap
texture object labels(element).object, labels(element).image
labels(element).color = color
endfunction
function new_label(caption as string, x as float, y as float, z as float, color as dword)
width = text width(caption)
height = text height(caption)
element = free_label()
labels(element).active = 1
labels(element).image = free_image()
labels(element).object = free_object()
labels(element).caption = caption
labels(element).x = x
labels(element).y = y
labels(element).z = z
labels(element).width = width
labels(element).height = height
labels(element).color = color
bitmap = free_bitmap()
currentbitmap = current bitmap()
create bitmap bitmap, width, height
ink color, 0
text 0, 0, caption
get image labels(element).image, 0, 0, width, height, 1
set current bitmap currentbitmap
delete bitmap bitmap
make object plain labels(element).object, 0.025 * width, 0.025 * height
texture object labels(element).object, labels(element).image
set object transparency labels(element).object, 1
position object labels(element).object, x, y, z
endfunction element
function delete_label(element)
labels(element).active = 0
delete object labels(element).object
delete image labels(element).image
endfunction
function label_x(element as integer)
result = labels(element).x
endfunction result
function label_y(element as integer)
result = labels(element).y
endfunction result
function lebel_z(element as integer)
result = labels(element).z
endfunction result
function free_image()
result = 1
while image exist(result)
inc result, 1
endwhile
endfunction result
function free_object()
result = 1
while object exist(result)
inc result, 1
endwhile
endfunction result
function free_bitmap()
count = 0
result = -1
repeat
inc count, 1
if not bitmap exist(count) then result = count
until count = 32 or result > 0
endfunction result
function free_label()
result = -1
arraycount = array count(labels(0)) - 1
if arraycount > -1
count = -1
repeat
inc count, 1
if not labels(count).active then result = count
until count = arraycount or result > -1
endif
if result = -1
array insert at bottom labels(0)
result = array count(labels(0)) - 1
endif
endfunction result
process_labels() - This function must be called in your game loop.
* * * * * new_label * * * * *
label ID = new_label(caption, x, y, z, color)
caption: string
x, y, z: float
color: dword
label ID: integer
This function will create a new label in 3d space at coords x, y, z and return the label ID for it.
* * * * * change_label_caption * * * * *
change_label_caption(label ID, Caption)
label ID: integer
caption: string
This function will change the text of an already existing label.
* * * * * change_label_color * * * * *
change_label_color(label ID, color)
label ID: integer
color: DWORD
This function will change the colour of an already existing label.
* * * * * change_label_position * * * * *
change_label_position(label ID, x, y, z)
label ID: integer
x, y, z: Float
This function will change the position of the label in 3d space.
* * * * * delete_label * * * * *
delete_label(label ID)
label ID: integer
This function will delete an already existing label.