A little nonsense example for Text3D.
Code: Select all
If InitEngine3D() = 0
End
EndIf
If InitSprite() = 0
End
EndIf
If InitKeyboard() = 0
End
EndIf
Add3DArchive(#PB_Compiler_Home + "Examples\3D\Data\fonts", #PB_3DArchive_FileSystem)
Parse3DScripts()
Structure _mesh
id.i
ms.i
ma.i
tx.i
EndStructure
Declare DoWin()
Declare DoWheel()
Declare DoTeeth()
Declare DoText()
Global Dim tx.i(5), nod.i, nod2.i, cam.i, light.i
Global base._mesh
Global Dim Teeths._mesh(8)
Procedure DoWin()
OpenWindow(0, 0, 0, 1024, 768, "3D text",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, #False, 0, 0, #PB_Screen_WaitSynchronization)
light = CreateLight(#PB_Any, $FFFFFF,0,10,-100,#PB_Light_Directional)
nod = CreateNode(#PB_Any, 0, 0, 0)
EndProcedure
Procedure DoWheel()
Protected gval.i = 64
base\ms = CreateCylinder(#PB_Any, 1, 0.2, 50, 1, 0)
base\tx = CreateTexture(#PB_Any, 256, 256)
StartDrawing(TextureOutput(base\tx))
For x = 0 To 256
LineXY(x, 0, x, 256, RGB(gval,gval,gval))
If gval + 8 > 255
gval = 64
Else
gval + 8
EndIf
Next x
StopDrawing()
base\ma = CreateMaterial(#PB_Any, TextureID(base\tx))
base\id = CreateEntity(#PB_Any, MeshID(base\ms), MaterialID(base\ma), 0, 0, 0)
RotateEntity(base\id, 90,0,0)
AttachNodeObject(nod, EntityID(base\id))
EndProcedure
Procedure DoTeeth()
Protected count.i
For count = 0 To 7
With Teeths(count)
\ms = CreateCube(#PB_Any, 0.2)
\ma = CopyMaterial(base\ma,#PB_Any)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
ScaleEntity(\id, 11, 0.8, 0.8)
RotateEntity(\id, 0, 0, count * 45,#PB_Absolute)
AttachNodeObject(nod, EntityID(\id))
EndWith
Next count
EndProcedure
Procedure DoText()
Protected count.i
For count = 0 To 4
If Random(100,1) < 50
tx(count) = CreateText3D(#PB_Any, "Text num " + Str(count+1),"StarWars",0.6,RGBA(155,100,0,255))
Else
tx(count) = CreateText3D(#PB_Any, "Text num " + Str(count+1),"BlueHighway-16",0.6,RGBA(100,144,200,255))
EndIf
Next Count
MoveText3D(tx(0), 3,3,1)
MoveText3D(tx(1), 0,3,1)
MoveText3D(tx(2), 3,0,1)
MoveText3D(tx(3), -3,3,1)
MoveText3D(tx(4), 3,-3,1)
AttachNodeObject(nod, Text3DID(tx(0)))
AttachNodeObject(nod, Text3DID(tx(1)))
AttachNodeObject(nod, Text3DID(tx(2)))
AttachNodeObject(nod, Text3DID(tx(3)))
AttachNodeObject(nod, Text3DID(tx(4)))
EndProcedure
DoWin()
DoWheel()
DoTeeth()
DoText()
cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, 0, 16)
Repeat
Repeat
ev = WindowEvent()
Until ev = 0
RotateNode(nod, 0, 0, -0.8, #PB_Relative)
RenderWorld()
ExamineKeyboard()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)