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