[Closed] How to make gw.text draw on top?
Hey guys,
I was developing a script that i can create a “tag” on any object in a 3dsmax scene. And i made this external script independent, by embedding the drawing engine script by callbacks.addScript method. so the one who is tagging the objects can simply press “implant tags to the scene” and objects will have the tags even if we don’t have the script. all the object tags on the scene are controlled by a dummy, so anytime we can use the dummy to control the tags (ex: remove the embedded script by simply deleting the dummy… etc…)
all the stuff is going fine except i asked one of my friend to open a test scene i created and see if text is there. he told the tags are there, but they are drawn “behind” the objects. here is the code I used to draw text on each object:
fn GW_displayObjectTags =
(
if isvalidnode $obj_tags then (
--loads the keys
key_loader()
--loops number of times equal to object count in the objects array
for i=1 to tagged_objs_array.count do(
--gets an objec by name
objName = tagged_objs_array[i]
objCatch = execute ("$"+objName as string)
--see if ObjCatch Execute is successful
if isvalidnode objCatch then (
--set transform properties for the drawn text
gw.setTransform (matrix3 1)
--for o in tagged_objs where not o.isHiddenInVpt do
text_color=execute color_array[i]
gw.text objCatch.pos taggs_array[i] color:text_color
gw.enlargeUpdateRect #whole
)
can anyone point out the changes I need to make, to make sure that every PC is drawing the text on top of the objects, not behind them.
and thanks a lot for everyone who is helping me with coding! :bowdown:
DenisT has showed the solution a while ago.
Use
posInScreen = objCatch.pos
posInScreen.z = 0
ge.text posInScreen taggs_array[1] color:text_color
sorry didnt work bro. instead of staying on top, text stopped following the object’s Z axis. i think we restricted its z movement with posInScreen.z = 0…
posInScreen = gw.wTransPoint objCatch.pos
posInScreen.z = 0
gw.text posInScreen taggs_array[1] color:text_color
My bad.
posInScreen = gw.wTransPoint objCatch.pos
posInScreen.z = 0
gw.wText posInScreen taggs_array[1] color:text_color