Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: 3d text label?  (Read 1754 times)
cybertrickle
Community Member
*
Posts: 504


« on: December 06, 2002, 12:52:57 AM »

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...
Code:

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


Logged

Evan Duffield
Dymm Inc.
_______________
Project: Journeys End
Status Code: 80%
Status Modeling: 20%
Working on:  completion of demo
Arli
Administrator
Community Member
*****
Posts: 993


« Reply #1 on: December 06, 2002, 04:25:25 AM »

Try using the 3DText function of TVMesh.
Logged

Happy Coding

Arli
Truevision3D Developer
Arli@Truevision3D.com
cybertrickle
Community Member
*
Posts: 504


« Reply #2 on: December 06, 2002, 10:19:53 AM »

ok thanks =)
Logged

Evan Duffield
Dymm Inc.
_______________
Project: Journeys End
Status Code: 80%
Status Modeling: 20%
Working on:  completion of demo
cybertrickle
Community Member
*
Posts: 504


« Reply #3 on: December 06, 2002, 10:33:41 AM »

hmm..

This comes out as a big blob.
I cant find a function to tell it how big to make the text.

my code so far

Code:

Option Explicit
Dim pos As D3DVECTOR
Dim Caption As String

'Render To Surface objects
Public TextMesh As TVMesh

Sub Init()
    Set TextMesh = Scene.CreateMeshBuilder("TextMesh")
End Sub

Sub SetPosition(X As Single, Y As Single, z As Single)
    pos = Vector(X, Y, z)
    TextMesh.SetPosition pos.X, pos.Y, pos.z
   
End Sub

Sub SetCaption(sText As String)
    Caption = sText
   
    TextMesh.Create3DText sText, "Times New Roman", 18
End Sub

Function Render()
    TextMesh.Render
End Function

Function DestroyMe()
    Set TextMesh = Nothing
End Function
Logged

Evan Duffield
Dymm Inc.
_______________
Project: Journeys End
Status Code: 80%
Status Modeling: 20%
Working on:  completion of demo
cybertrickle
Community Member
*
Posts: 504


« Reply #4 on: December 06, 2002, 11:33:31 AM »

Figured it out..

the problem was that the 2 optional settings were
automaticly turned on.

TextMesh.Create3DText sText, "Times New Roman", 180, 0, 0
Logged

Evan Duffield
Dymm Inc.
_______________
Project: Journeys End
Status Code: 80%
Status Modeling: 20%
Working on:  completion of demo
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks