Page 1 sur 1

[3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 17:45
par falsam
PB 5.22

Un carré composé de 4 vertex.
- Compilation classique : Le résultat est bien un carré.
- Par contre si je compile avec l'option OpenGl (j'ai besoin de cette option dans le cadre d'une configuration double moniteurs) je n'ai plus de carré.

Le code exemple :

Code : Tout sélectionner

; vertex , point de coordonnée x,y,z dans l'espace
; triangle, composé de 3 vertex
; face , composé de 2 triangles
; mesh , composé de faces

InitEngine3D()
InitKeyboard()
InitSprite()

Add3DArchive(#PB_Compiler_Home +"Examples\3D\Data\Textures", #PB_3DArchive_FileSystem)

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

AmbientColor(RGB(255, 255, 255))
CreateLight(#PB_Any,RGB(255, 255, 255), 3,50,50)

;
; Axes X,Y,Z 
Red = RGB(255, 0, 0)
Green = RGB(0, 255, 0)
Blue = RGB(0, 255, 255)

CreateLine3D(#PB_Any, -20, 0, 0, Red, 20, 0, 0, Red) 
CreateLine3D(#PB_Any, 0,-20,0, Green, 0, 20, 0, Green) 
CreateLine3D(#PB_Any, 0,0,-20, Blue, 0, 0, 20, Blue) 

Mesh = CreateMesh(#PB_Any)

;Vertex 0
MeshVertexPosition(0, 5, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(0, 0) 

;Vertex 1
MeshVertexPosition(0, -5, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(0, 1) 

;Vertex 2
MeshVertexPosition(10, -5, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(1, 1) 

;Vertex 3
MeshVertexPosition(10, 5, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(1, 0) 

;Création des triangles 
MeshFace(0, 1, 2)
MeshFace(0, 2, 3)


FinishMesh(#True)
NormalizeMesh(Mesh)

;SaveMesh(Mesh, "test.mesh")

Texture = LoadTexture(#PB_Any, "Dirt.jpg")
Material = CreateMaterial(#PB_Any, TextureID(Texture))

Entity = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(material))

;
;Camera 
Camera = CreateCamera(#PB_Any,0,0,100,100)
CameraBackColor(Camera, RGB(105, 105, 105))

MoveCamera(Camera, 5, 1, 20, #PB_Absolute)
CameraLookAt(camera,0,0,0)


While #True
  
  Event = WindowEvent()
    
  ExamineKeyboard()  
  
  ; Touche Escape pour fermer l'application
  If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf  
      
  
  ; Affiche le rendu de la scène
  ClearScreen(RGB(0, 0, 0))
  RenderWorld()
  FlipBuffers()
Wend 

Re: [3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 19:48
par G-Rom
essaye :

Code : Tout sélectionner

MaterialCullingMode(Material,#PB_Material_ClockWiseCull)

Re: [3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 20:02
par falsam
Merci G-Rom mais ça ne change rien. Je te montre une image de ce que j'ai quand je compile sans ou avec le mode OpenGL.

Image

Re: [3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 20:34
par G-Rom
Bizarre , j'ai l'impression que le 1 vertex n'est pas pris en compte :(

Re: [3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 20:41
par G-Rom
Ca à l'air d'être un bug... :/

Re: [3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 21:00
par falsam
La constitution des triangles se fait bien de cette maniére ?

Code : Tout sélectionner

;Création des triangles 
MeshFace(0, 1, 2)
MeshFace(0, 2, 3)

Re: [3D] Comportement étrange d'un mesh avec l'option OpenGl

Publié : mar. 25/mars/2014 21:14
par falsam
J'ai ajouté 2 vertices de plus pour formé un deuxième carré à droite du premier et effectivement avec l'option OpenGl le vertice 0 n'ai pas pris en compte.

Code : Tout sélectionner

; vertex , point de coordonnée x,y,z dans l'espace
; triangle, composé de 3 vertex
; face , composé de 2 triangles
; mesh , composé de faces

InitEngine3D()
InitKeyboard()
InitSprite()

Add3DArchive(#PB_Compiler_Home +"Examples\3D\Data\Textures", #PB_3DArchive_FileSystem)

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

AmbientColor(RGB(255, 255, 255))
CreateLight(#PB_Any,RGB(255, 255, 255), 3,50,50)

;
; Axes X,Y,Z 
Red = RGB(255, 0, 0)
Green = RGB(0, 255, 0)
Blue = RGB(0, 255, 255)

CreateLine3D(#PB_Any, -20, 0, 0, Red, 20, 0, 0, Red) 
CreateLine3D(#PB_Any, 0,-20,0, Green, 0, 20, 0, Green) 
CreateLine3D(#PB_Any, 0,0,-20, Blue, 0, 0, 20, Blue) 

Mesh = CreateMesh(#PB_Any)

;Vertex 0
MeshVertexPosition(0, 1, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(0, 0) 

;Vertex 1
MeshVertexPosition(0, 0, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(0, 1) 

;Vertex 2
MeshVertexPosition(1, 0, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(1, 1) 

;Vertex 3
MeshVertexPosition(1, 1, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(1, 0) 

;Vertex 4
MeshVertexPosition(2, 0, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(0, 1) 

;Vertex 5
MeshVertexPosition(2, 1, 0)
MeshVertexNormal(0, 0, 0)
MeshVertexTextureCoordinate(1, 1) 

;Création des triangles 
MeshFace(0, 1, 2)
MeshFace(0, 2, 3)
MeshFace(3, 2, 4)
MeshFace(3, 4, 5)

FinishMesh(#True)
NormalizeMesh(Mesh)

;SaveMesh(Mesh, "test.mesh")

Texture = LoadTexture(#PB_Any, "Dirt.jpg")
Material = CreateMaterial(#PB_Any, TextureID(Texture))


Entity = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(material))

;
;Camera 
Camera = CreateCamera(#PB_Any,0,0,100,100)
CameraBackColor(Camera, RGB(105, 105, 105))

MoveCamera(Camera, 0, 1, 5, #PB_Absolute)
CameraLookAt(camera,0,0,0)


While #True
  
  Event = WindowEvent()
    
  ExamineKeyboard()  
  
  ; Touche Escape pour fermer l'application
  If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf  
   
  ; Affiche le rendu de la scène
  ClearScreen(RGB(0, 0, 0))
  RenderWorld()
  FlipBuffers()
Wend