[PB 5.50] - Créer et texturer un cube

Généralités sur la programmation 3D
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

[PB 5.50] - Créer et texturer un cube

Message par falsam »

Avec PB 5.50, le cube possède six sub-meshes pour le rendre facile à texturer sur chacune des faces.

■ Il est encore possible d'appliquer globalement une texture sur un cube lors de la création de l'entité de cette manière.

Code : Tout sélectionner

LoadTexture(0, "texture.jpg")
CreateMaterial(0, TextureID(0))
CreateEntity(0, MeshID(0), MaterialID(0))
■ Pour texturer chaque face d'une entité (cube) avec PB5.50 il faut
- Loader une texture par face.
- Créer l'entité sans appliquer de material : CreateEntity(0, MeshID(0), #PB_Material_None)
- Texturer chaque face avec l'instruction SetEntityMaterial(0, MaterialID(#Material), Sub-Mesh)

■ Code exemple.

Code : Tout sélectionner

;[PB 5.50] - Create cube
;Avec PB 5.50, le cube possède six sub-meshes pour le rendre facile à texturer sur chacune des faces.
;With PB 5.50,  the cube have six submeshes to make it easy to texture its faces separately.


LoadFont(0, "Arial", 20)

InitEngine3D() : InitKeyboard() : InitSprite()

UseJPEGImageEncoder()

OpenWindow(0,0,0,1024,768,"Cube Texturing")
OpenWindowedScreen(WindowID(0),0,0,1024,768)

Add3DArchive(".", #PB_3DArchive_FileSystem)

CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0, RGB(245, 222, 179))
MoveCamera(0, 5, 5, 5)
CameraLookAt(0, 0, 0, 0)
CreateLight(0, RGB(255, 255, 255), -100, 200, 100)

;Creer un cube mesh - Create a cube mesh
CreateCube(0, 2)

;Créer six textures & materiel - Create six textures & materials
For n = 0 To 5
  CreateImage(n, 128, 128, 24, RGB(154, 205, 50))
  StartDrawing(ImageOutput(n))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawingFont(FontID(0))
  DrawText(20, 20, "Face " + n, RGB(255, 255, 255))
  StopDrawing()
   
  SaveImage(n, "texture" + n + ".jpg", #PB_ImagePlugin_JPEG)
  CreateMaterial(n, TextureID(LoadTexture(#PB_Any, "texture" + n + ".jpg")))
Next

;Creation entité (Cube) - Create entitity (Cube)
CreateEntity(0, MeshID(0), #PB_Material_None)

;Texturer chaque cotés du cube  - Texturing each side of the cube 
For n = 0 To 5
  SetEntityMaterial(0, MaterialID(n), n)
Next


While #True  
  Repeat
    Event  = WindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        End
    EndSelect
  Until Event = 0     
  
  RotateEntity(0, 0.1, 0.2, 0.3, #PB_Relative)
  
  If ExamineKeyboard()  
    If KeyboardReleased(#PB_Key_Escape)
      Break
    EndIf    
  EndIf
  
  RenderWorld()
  FlipBuffers()
Wend
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
Cool Dji
Messages : 1126
Inscription : ven. 05/sept./2008 11:42
Localisation : Besançon
Contact :

Re: [PB 5.50] - Créer et texturer un cube

Message par Cool Dji »

Merci de l'info falsam :D

C'est bon ça !
Only PureBasic makes it possible
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: [PB 5.50] - Créer et texturer un cube

Message par falsam »

Retour en arrière avec la version 5.60 : Le cube ne se compose plus que d'un seul mesh. !!!
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
comtois
Messages : 5172
Inscription : mer. 21/janv./2004 17:48
Contact :

Re: [PB 5.50] - Créer et texturer un cube

Message par comtois »

oui c'est suite à cette discussion
http://www.purebasic.fr/english/viewtop ... 36&t=67632

Et ci-dessous un cube avec 6 faces

Code : Tout sélectionner

; ------------------------------------------------------------
;
;   PureBasic - Manual Mesh
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------


#CameraSpeed = 1

IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

Define.f x, y, z, nx, ny, nz, u, v
Define.l Co
Define.w t1, t2, t3

If InitEngine3D()
  
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
     
  If Screen3DRequester()
    LoadFont(0, "Arial", 20)
          
    UseJPEGImageEncoder()
    
    #CUBE_SIZE = 1
    #CUBE_HALF_SIZE = #CUBE_SIZE / 2.0
    CreateMesh(0, #PB_Mesh_TriangleList)
    ;front side
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
    
    
    ;back side
    AddSubMesh()
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
    
    ;left side
    AddSubMesh()
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
    
    ;right side
    AddSubMesh()
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
    
    
    ;up side
    AddSubMesh()
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
    
    ;down side
    AddSubMesh()
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
       
    FinishMesh(#True)

    UpdateMeshBoundingBox(0)
       
    ;Créer six textures & materiel - Create six textures & materials
    For n = 0 To 5
      CreateTexture(n, 128, 128)
      StartDrawing(TextureOutput(n))
      Box(0,0, OutputWidth(), OutputHeight(), RGB(154, 205, 50))
      DrawingMode(#PB_2DDrawing_Transparent)
      DrawingFont(FontID(0))
      DrawText(20, 20, "Face " + n, RGB(255, 255, 255))
      StopDrawing()
      
      ;SaveImage(n, "texture" + n + ".jpg", #PB_ImagePlugin_JPEG)
      CreateMaterial(n, TextureID(n))
    Next
    
    ;Creation entité (Cube) - Create entitity (Cube)
    CreateEntity(0, MeshID(0), #PB_Material_None)
    
    ;Texturer chaque cotés du cube  - Texturing each side of the cube
    For n = 0 To 5
      SetEntityMaterial(0, MaterialID(n), n)
    Next
    
    
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 0, 5, #PB_Absolute)
    
    CreateLight(0, RGB(255,255,255), 300, 600, -100)
    AmbientColor(RGB(80, 80, 80))
    
    Repeat
      Screen3DEvents()
      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      RotateEntity(0, 1, 1, 1, #PB_Relative)
      
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld()
      Screen3DStats()      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

End
http://purebasic.developpez.com/
Je ne réponds à aucune question technique en PV, utilisez le forum, il est fait pour ça, et la réponse peut profiter à tous.
Avatar de l’utilisateur
Zorro
Messages : 2185
Inscription : mar. 31/mai/2016 9:06

Re: [PB 5.50] - Créer et texturer un cube

Message par Zorro »

heu ... j'ai pas testé mais

la methode "Falsam"

Code : Tout sélectionner

CreateCube(0, 2)
, bon ok ça reste simple


la methode "Comtois"

Code : Tout sélectionner

CreateMesh(0, #PB_Mesh_TriangleList)
    ;front side
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, 1)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
   
   
    ;back side
    AddSubMesh()
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 0, -1)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
   
    ;left side
    AddSubMesh()
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(-1, 0, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
   
    ;right side
    AddSubMesh()
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(1, 0, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
   
   
    ;up side
    AddSubMesh()
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, #CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, 1, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
   
    ;down side
    AddSubMesh()
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(0, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(1, 1)
    MeshVertexPosition(#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(1, 0)
    MeshVertexPosition(-#CUBE_HALF_SIZE, -#CUBE_HALF_SIZE, #CUBE_HALF_SIZE)
    MeshVertexNormal(0, -1, 0)
    MeshVertexTextureCoordinate(0, 0)
    MeshFace(0, 1, 2)
    MeshFace(0, 2, 3)
       
    FinishMesh(#True)


c'est une blague ? :lol: :lol:
je me vois pas faire un Minecraft , si on dois faire ça a chaque cube :lol:

nombre de ligne de code : 1265498764655121319846464 , juste pour les cubes ! :lol:

(oui, je sais, c'est juste le mesh... ;) )
Image
Image
Site: http://michel.dobro.free.fr/
Devise :"dis moi ce dont tu as besoin, je t'expliquerai comment t'en passer"
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: [PB 5.50] - Créer et texturer un cube

Message par falsam »

@Comtois: Merci beaucoup pour ce code. Peut etre qu'un flag #False ou #True aurait pu permettre de préciser si on souhaite créer un mesh à un ou six sub-mesh. :wink:
Zorro a écrit :je me vois pas faire un Minecraft , si on dois faire ça a chaque cube
Heureusement que non. Le mesh est une forme invisible servant de model lors de la création de l'entité visible.
Pour créer 3 ou x cubes, un seul mesh suffit.

Petit code de démonstration.

Code : Tout sélectionner

InitEngine3D()
InitKeyboard()
InitSprite()

window = OpenWindow(#PB_Any,0,0,1024,768,"Cubes")
OpenWindowedScreen(WindowID(window),0,0,1024,768)

;Les textures utiliser se trouvent dans les exemples de PureBasic
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)

; Une forme : C'est notre MESH qui ici sera un cube
Mesh = CreateCube(#PB_Any, 1) 

; Chargement texture (Ne pas indiquer le path)
Texture = LoadTexture(#PB_Any, "Caisse.png")

; Un MATERIEL c'est la partie visible de notre cube qui sera constitué de notre texture
Material = CreateMaterial(#PB_Any,TextureID(texture))

; Création de trois entité : ENTITE = MESH + MATERIEL en position x y z
Cube0 = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 0, 0)
Cube1 = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 1, 0)
Cube2 = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 1, 0, 0)

; Une camera 
Camera = CreateCamera(#PB_Any,0, 0, 100,100)
CameraBackColor(Camera, RGB(154, 205, 50))

; La caméra regarde en direction d'un point au coordonnées x=0, y=0, z=0
CameraLookAt(camera, 0, 0, 0)

;Contrairement à la 2D on affiche pas les entités 
While #True
  
  Event = WindowEvent()
  ExamineKeyboard()  
  
  ; Bouton Close ou touche Escape pour fermer l'application
  If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf  
  
  ;Rappel : La camera regarde en direction d'un point au coordonnées x=0, y=0, z=0
  ;Placement de la camera en x = 0, y=2 z=10
  MoveCamera(camera, 2, 2, 8, #PB_Absolute)
  
  ; Affiche le rendu de la scène
  ClearScreen(RGB(0, 0, 0))
  RenderWorld()
  FlipBuffers()
Wend
Avec ce code je n'utilise pas la méthode de Comtois car je ne cherche pas à texturer chacune des faces avec une texture différente.
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Répondre