Code : Tout sélectionner
EnableExplicit
Enumeration
#texture
EndEnumeration
Declare DrawTriangle()
InitEngine3D(#PB_Engine3D_DebugLog)
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0, 0, 0, 800, 600,"Rotation xyz d'un trinagle",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600,1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
KeyboardMode(#PB_Keyboard_AllowSystemKeys)
CreateMaterial(#texture, LoadTexture(#texture, "White.jpg"))
MaterialCullingMode(#texture, #PB_Material_NoCulling)
CreateLight(0,RGB(245,245,205),6,13,0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 10, #PB_Absolute)
CameraLookAt(0, 0, 0, 0)
CameraBackColor(0, RGB(0, 200, 200))
DrawTriangle()
Repeat
WindowEvent()
ExamineKeyboard()
RotateEntity(0, 0.5, 0.5, 0.5, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow
Procedure DrawTriangle()
; Création d'un mesh representant le triangle
CreateMesh(0, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)
; Vecteur 0 - Sommet
MeshVertexPosition(0, 1, 0)
MeshVertexNormal(0, 1, 0)
MeshVertexTextureCoordinate(0, 0)
; Vecteur 1 - Coin droit
MeshVertexPosition(1, -1, 0)
MeshVertexNormal(0, 1, 0)
MeshVertexTextureCoordinate(1, 0)
; Vecteur 2 - Coin gauche
MeshVertexPosition(-1, -1, 0)
MeshVertexNormal(0, 1 ,0)
MeshVertexTextureCoordinate(1, 1)
; Création de la face du triangle
MeshFace(0, 1, 2)
; Le mesh est terminée
FinishMesh(#True)
; Creation de l'entité
CreateEntity(0, MeshID(0), MaterialID(#texture))
ScaleEntity(0, 2, 2, 2)
EndProcedure