I wanted to be able to have some text (always facing the camera) at a specific 3d point
I also didn't want to modify minib3d
I couldnt get parenting to work like I wanted so you'll have to reposition the text entity above the entity its labeling but hey its a quick dirty hack!
use like this
and here's the ugliest hack you've seen in ages....
just slap this type in your code where you are not too likely to see it too often
apologies to everyone who's code I've abused
I also didn't want to modify minib3d
I couldnt get parenting to work like I wanted so you'll have to reposition the text entity above the entity its labeling but hey its a quick dirty hack!
use like this
Local label:TTextEnt = TTextEnt.CreateTextEnt() label.text="Entity One" EntityColor label,255,0,0 PositionEntity label,10,4,0
and here's the ugliest hack you've seen in ages....
just slap this type in your code where you are not too likely to see it too often
Type TTextEnt Extends TSprite Field text:String Function CreateTextEnt:TTextEnt() Local tt:TTextEnt=New TTextEnt tt.class$="Text" tt.EntityListAdd(entity_list) tt.UpdateMat(True) tt.view_mode = 4 tt.scale_x#=0.05 tt.scale_y#=0.05 Return tt EndFunction Global fontTex:Int Method update() glcolor3f brush.red , brush.green, brush.blue glPushMatrix() glMultMatrixf(mat_sp.grid) ' STOP THIEF!!!! ripped from brl and bits of minib3d ' abuse and errors all my own..... ' its basically brl's text drawing but not in ortho mode glPushAttrib GL_ENABLE_BIT|GL_TEXTURE_BIT|GL_TRANSFORM_BIT glenable(GL_BLEND) glShadeModel(GL_FLAT) glDisable GL_CULL_FACE glenable GL_ALPHA_TEST glDisable GL_LIGHTING If Not fontTex Local pixmap:TPixmap=TPixmap.Create( 1024,16,PF_RGBA8888 ) Local p:Byte Ptr=IncbinPtr( "gldrawtextfont.bin" ) For Local y:Int=0 Until 16 For Local x:Int=0 Until 96 Local b:Byte=p[x] For Local n:Int=0 Until 8 If b & (1 Shl n) pixmap.WritePixel x*8+n,y,~0 Else pixmap.WritePixel x*8+n,y,0 EndIf Next Next p:+96 Next GLGraphicsDriver().SwapSharedContext fontTex=GLTexFromPixmap( pixmap ) GLGraphicsDriver().SwapSharedContext EndIf glenable GL_TEXTURE_2D glBindTexture GL_TEXTURE_2D,fontTex Local x:Int , y:Int x = - 4 * text.length y=-8 For Local i:Int=0 Until text.length Local c:Byte=text[i]-32 If c>=0 And c<96 Const adv#=8/1024.0 Local t#=c*adv; glBegin GL_QUADS glTexcoord2f t,1 glVertex2f x,y glTexcoord2f t+adv,1 glVertex2f x+8,y glTexcoord2f t+adv,0 glVertex2f x+8,y+16 glTexcoord2f t,0 glVertex2f x,y+16 glEnd EndIf x:+8 Next glPopAttrib glPopMatrix() glenable GL_LIGHTING EndMethod EndType
apologies to everyone who's code I've abused