Anyone have any decent code to put a 3d text caption
on top on an actor or a mesh.
Would be extreamly usefull.
I cant get my code to work.
Heres my code if you wanna check it out.
In a class...
Option Explicit
Dim Pos As D3DVECTOR
Dim Caption As String
'Render To Surface objects
Public Text1 As TVRenderSurface
Public DynTex As TVRenderSurface
'Mesh where the billboard will be applied
Public TextMesh As TVMesh
Public DynTexMesh As TVMesh
Sub Init()
'Create the w_txt "texture"
Set Text1 = Scene.CreateRenderSurface(128, 32, True)
Text1.StartRender
scr.ACTION_Begin2D
scr.DRAW_FilledBox 0, 0, 12, 6, RGBA(0, 0, 0, 0), RGBA(0, 0, 0, 0), RGBA(0, 0, 0, 0), RGBA(0, 0, 0, 0)
scr.ACTION_End2D
w_txt.ACTION_BeginText
w_txt.NormalFont_DrawText "no caption set", 0, 0, RGBA(1, 1, 1, 1), "CaptionFont"
w_txt.ACTION_EndText
Text1.EndRender
Set TextMesh = Scene.CreateMeshBuilder("TextMesh")
TextMesh.AddWall 0, -50, 0, 5, 0, 50
TextMesh.SetTexture Text1.GetTexture
Set DynTex = Scene.CreateRenderSurface(64, 64, True)
Set DynTexMesh = Scene.CreateMeshBuilder("DynTex")
DynTexMesh.AddWall 0, -5, 0, 5, 0, 1.5, -5
DynTexMesh.SetPosition Pos.x, Pos.Y, Pos.z
DynTexMesh.SetTexture DynTex.GetTexture
End Sub
Sub SetPosition(x As Single, Y As Single, z As Single)
Pos = Vector(x, Y, z)
DynTexMesh.SetPosition Pos.x, Pos.Y, Pos.z
End Sub
Sub SetCaption(sText As String)
Caption = sText
' w_txt.ACTION_BeginText
' w_txt.NormalFont_DrawText Caption, 0, 0, RGBA(1, 1, 0, 1), "CaptionFont"
' w_txt.ACTION_EndText
End Sub
Function Render()
DynTex.StartRender
scr.ACTION_Begin2D
scr.DRAW_Texture GetTex("terrain"), 0, 0, 0, 0
scr.ACTION_End2D
DynTex.EndRender
End Function
Function DestroyMe()
Set Text1 = Nothing
Set DynTex = Nothing
Set TextMesh = Nothing
Set DynTexMesh = Nothing
End Function