1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| ; Include files
IncludePath "includes" : IncludeFile "n3xtD_PB.pbi"
; Globales
Global anglex.f, angley.f, flagXDown.w
Global mox.f, omx.f, moy.l, omy.l
Global i.l
Global *app.l, Quit.l
;- Ouverture ecran
; open n3xt-D screen
*app = iCreateGraphics3D(800,600)
; << OR >>
;iCreateGraphics3D(800,600, 32, #False, #True, #EDT_DIRECT3D9)
If *app= #Null
End
EndIf
;- Mesh manuel
; define a ManualContruct Mesh
Global *mesh.IMMesh
; create the mesh
*mesh=iCreateEmptyMesh()
; add one buffer for vertices and faces
iAddBufferMesh(*mesh)
; define 3 vertices
v1.l= iAddVertexMesh(*mesh, 0,0,0, $ff00, 0,0, 0)
v2.l= iAddVertexMesh(*mesh, 2,2,0, $ff00, 0,0, 0)
v3.l= iAddVertexMesh(*mesh, 2,0,0, $ff00, 0,0, 0)
; add one face
iAddFaceMesh(*mesh, v1,v2,v3, 0)
; add second buffer for vertices and faces
iAddBufferMesh(*mesh)
; define 3 vertices
v1= iAddVertexMesh(*mesh, 0,2,0, $ff, 0,0, 1)
v2= iAddVertexMesh(*mesh, 2,2,0, $ff, 0,0, 1)
v3= iAddVertexMesh(*mesh, 0,0,0, $ff, 0,0, 1)
; add one face
iAddFaceMesh(*mesh, v1,v2,v3, 1)
iPositionNode(*mesh, 0, 0, 0)
;- Camera
; create a camera
Global *cam.ICamera = iCreateCamera()
iPositionNode(*cam, 1, 10, -10)
;iPointTargetNode(*cam)
;iPointNode(*cam, *mesh)
;iTargetCamera(*cam, 0, 0, 0)
;- main loop
Repeat
; move camera with dir key and mouse (left click)
If iGetKeyDown(#KEY_ARROW_UP)
iMoveNode(*cam, 0,0,0.5)
EndIf
If iGetKeyDown(#KEY_ARROW_DOWN)
iMoveNode(*cam, 0,0,-0.5)
EndIf
; if Escape Key, exit
If iGetKeyDown(#KEY_ESCAPE)
Quit=1
EndIf
iBeginScene()
iDrawScene()
iEndScene()
Until Quit=1
iFreeEngine() |
Partager