Je n'arrive pas à centrer horizontalement un texte 3D
Publié : mar. 07/mars/2023 22:49
Tout est dans le titre alors voici le code de test.D'avance merci pour votre aide 
Code : Tout sélectionner
EnableExplicit
; DPI Résolution
Global drx.f, dry.f, t
; Node Cube et texte 3D
Global node, cube, text3d
drx = DesktopResolutionX()
dry = DesktopResolutionY()
InitEngine3D(#PB_Engine3D_DebugLog) : InitSprite() : InitKeyboard()
ExamineDesktops()
OpenWindow(0, 0,0, DesktopWidth(0)*0.5,DesktopHeight(0)*0.5, "CreateShader - [Esc] quit",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0)*drx, WindowHeight(0)*dry, 0, 0, 0)
; Localisation des assets pour le texte 3D
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/fonts", #PB_3DArchive_FileSystem)
Parse3DScripts()
; Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, -6)
CameraLookAt(0, 0, 0, 0)
CameraBackColor(0, RGB(211, 211, 211))
; Lumiere
CreateLight(0, RGB(211, 211, 211), -100, 100, 0)
AmbientColor(RGB(154, 205, 50))
; Une entité
cube = CreateEntity(#PB_Any, MeshID(CreateCube(#PB_Any, 0.1)), #PB_Material_None)
; Le texte couleur rouge
text3d = CreateText3D(#PB_Any, "Hello World", "", 0.5, RGBA(255, 255, 255, 255))
Text3DAlignment(text3d, #PB_Text3D_HorizontallyCentered)
; Un node sur lequel j'attache le cube puis le texte
node = CreateNode(#PB_Any, -4, 0, 0)
AttachNodeObject(node, EntityID(cube))
AttachNodeObject(node, Text3DID(text3d))
t=1
Repeat
While WindowEvent() : Wend
ExamineKeyboard()
MoveNode(node, 0.004 * t, 0, 0, #PB_Relative)
If NodeX(node) > 4
t*-1
EndIf
If NodeX(node) < -4
t*-1
EndIf
RenderWorld()
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
