Un code épuré pour accompagné mon souci. J’espère que vous allez pouvoir m'aider. Merci.
Code : Tout sélectionner
Enumeration
#Cube
#Text
EndEnumeration
InitEngine3D()
InitKeyboard()
InitSprite()
window = OpenWindow(#PB_Any,0,0,1024,768,"Rotation d'un cube")
OpenWindowedScreen(WindowID(window),0,0,1024,768)
; Mesh
Cube_Mesh = CreateCube(#PB_Any, 2)
Ground_Mesh = CreatePlane(#PB_Any, 20, 20, 3, 6, 6, 6)
; Materiel
Texture = CreateTexture(#PB_Any,512,512)
StartDrawing(TextureOutput(Texture))
Box(0,0,512,512,RGB(0, 0, 0))
Box(1,1,510,510,RGB(255, 216, 0))
StopDrawing()
Material = CreateMaterial(#PB_Any,TextureID(texture))
; Création du sol
Ground = CreateEntity(#PB_Any, MeshID(Ground_Mesh), MaterialID(Material), 0, 0, 0)
EntityPhysicBody(Ground, #PB_Entity_StaticBody, 2, 0, 1)
;
; Un cube
CreateEntity(#Cube, MeshID(Cube_Mesh), MaterialID(Material), 0, 2, 0)
CreateText3D(#Text, "Hello world")
Text3DColor(#text, RGBA(255, 0, 0, 255))
Text3DAlignment(#Text, #PB_Text3D_HorizontallyCentered)
AttachEntityObject(#Cube, "", Text3DID(0))
MoveText3D(#Text, 0, 3, 0)
;
;Lumiere et ombre
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -1.8, 10, 5)
WorldShadows(#PB_Shadow_Additive)
;
; Une camera
Camera = CreateCamera(#PB_Any,0,0,100,100)
While #True
Event = WindowEvent()
If ExamineKeyboard()
If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
Break
EndIf
If KeyboardPushed(#PB_Key_Space)
EndIf
EndIf
MoveCamera(Camera, 4, 4 , 15, #PB_Absolute)
CameraLookAt(camera,0,0,0)
; Affiche le rendu de la scène
ClearScreen(RGB(0, 0, 0))
RenderWorld()
FlipBuffers()
Wend