displaying text overlays in the viewport (floating on objects)


#1

hi guys,

is there anyway to display floating text above an object using maxscript? (see example image)


#2

Hi Aeron,

Search for gw.text

Cheers,


#3

This is a piece of code that Bobo showed at this year’s Siggraph MaxScript class. I think this is exaclty what you need:

 
unRegisterRedrawViewsCallback showObjectNames
fn showObjectNames=
(
gw.setTransform(Matrix3 1)
for o in objects where not o.isHidden do
(
gw.text o.pos (o.name) color:yellow
gw.text (o.pos+[0,0,-2]) (o.pos as string) color:yellow
) 
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
registerRedrawViewsCallback showObjectNames
showObjectNames()

I’ve already used it to make a script that shows the name and coordinates of some objects in the scene. It saves a lot of time when doing camera tracking.


#4

To make it a single line, you can also replace the code lines

gw.text o.pos (o.name) color:yellow
gw.text (o.pos+[0,0,-2]) (o.pos as string) color:yellow

with

gw.text o.pos (o as string) color:yellow

because the MXS object signature shows both the class, the name and the position of the object…


#5

Cool, these “gw” functions open up a lot of new possibilities…


#6

thanks for the help guys,

there’s a problem though: when i execute the script the text is sometimes displayed, sometimes not at all. when it is displayed at first, it disappears when i pan the viewport or do anything else the causes a redraw

am i missing something?


#7

they didn’t disappear when I moved around the viewport, although they were very flickery…I am not sure why they would have such a poor redraw rate since I have a quadro 3000, unless they are all getting slowly interpreted through max


#8

i have a quadro 3000 as well

i just tested with various drivers… opengl and maxtreme work great, directx: nada


#9

The question is why were you using directx in the first place?


#10

Because DX cached meshes are several dozen times faster? :wink:
Of course, if you have MAXtreme, performance should be similar.


#11

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.