• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

N3xtD - Free 3D engine

Started by Brice Manuel, August 25, 2011, 06:40:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  029   as  Water demo.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN

    ' Dimes
    DIM app AS DWORD
    DIM Quit AS INTEGER


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF

    '----------------------------------------
    ' Load 3D objects
    DIM obj AS Mesh
    obj = LoadMesh("media/room.3ds", %HARDMAPPING.EHM_STATIC)



    '----------------------------------------
    ' Create traditional light And set position
    DIM light AS LightNode
    light = CreateLight(&h0ffaaaaaa, 250, %ELT_POINT , %NULL)
    PositionNode(light, 0,100,0)
    '----------------------------------------


    '----------------------------------------
    ' Create ROOM
    DIM room AS EntityNode
    room =  CreateEntityNode(obj, 0,  0,  0, %NULL)
    ' Load two textures
    DIM colormap AS NTexture
    colormap = LoadTexture( "media/wall0.jpg")
    ' change planar texture mapping on the mesh
    MakePlanarTextureMappingMesh(obj, 0.004)

    ' set texture in the New room (room2)
    MaterialTextureNode(room, colormap , 0)

    ' set material For room parallax mapping
    DIM material AS NMaterial
    material = NodeMaterial(room, 0)
    SpecularColorMaterial(material, 0)
    '----------------------------------------



    '----------------------------------------
    ' Create one hillmesh
    DIM hillMesh AS Mesh
    hillMesh = CreateHillPlaneMesh(20,20, 40,40, %Null, 0,  0, 0,10,10)'

    ' Create WaterNode
    DIM water AS EntityNode
    water = CreateWater(hillMesh,  3.0, 300.0, 30.0, 0)
    PositionNode(water, 0,7,0)
    '
    LoadTextureNode(water, "media/glass.bmp", 0, 0)
    '_LoadTextureNode(water, "media/water1.jpg", 0, 0)
    LoadTextureNode(water, "media/water.jpg", 0, 1)
    '
    '_MaterialTypeNode(water, EMT_REFLECTION_2_LAYER)
    MaterialTypeNode(water, %EMT_TRANSPARENT_REFLECTION_2_LAYER)

    '
    '_ScaleTCoordsMesh(hillMesh, 4.0, 4.0, 2)
    '_MakePlanarTextureMappingMesh(hillMesh, 0.02)
    '----------------------------------------



    '----------------------------------------
    ' Create a camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80.0,  0.1, 1.0, BYVAL %NULL, 0, %False, %False, %NULL)
    PositionNode(cam, -95,155,-263)
    TurnNode(cam, 17,15,0, 0)




    ' simple text inside the scene area
    LoadFont("media/courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM font_ AS IGUIFont
    font_ = GetFont()


    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        DrawText(font_, "water demo",  10,10,0,0, &h0ff9999ff)
        EndScene()


    WEND
    ' end
    FreeEngine()

END FUNCTION



                                             

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  030  :  Fighter demo.
'   Historique  :
'     29/03/09  19:16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS INTEGER


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF


    '-----------------------------------------
    ' Create light And set position
    DIM light AS LightNode
    light = CreateLight(&h0ffffffff, 400, %ELT_POINT, %NULL)
    PositionNode(light, 0,150,10)



    '----------------------------------------
    ' Load 3D objects
    DIM obj1 AS Mesh
    obj1 = LoadMesh("media/land.x", %HARDMAPPING.EHM_STATIC)
    DIM obj2 AS Mesh
    obj2 = LoadMesh("media/su47.x", %HARDMAPPING.EHM_STATIC)

    RotateMesh(obj2, 0,90,0)
    ScaleMesh(obj2, 0.02,0.02,0.02)


    '-----------------------------------------
    ' Create plane
    DIM plane AS EntityNode
    plane = CreateEntityNode(obj1, 0,  0,  0, %NULL)


    '-----------------------------------------
    ' Create fighter
    DIM fighter AS EntityNode
    fighter =  CreateEntityNode(obj2, 0,  0,  0, %NULL)
    PositionNode(fighter, 0,10,0)


    '-----------------------------------------
    ' add a little arm, no ?
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)

    DIM cube AS EntityNode
    cube = CreateEntityNode(cubemesh, 0,-1.3,0, fighter)
    ScaleNode(cube, 0.75, 0.75, 2)



    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCamera(%NULL)
    PositionNode(cam, 0,17,-18)

    '-----------------------------------
    ' Load font png
    LoadFont("media/courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM font_ AS IGUIFont
    font_ = GetFont()



    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF

        Movenode(fighter, 0,0,0.2, %COLLIDE_RESPONSE.RESP_NONE)

        ' control fighter
        IF GetKeyDown(%KEY_CODE.KEY_ARROW_UP) THEN
            TurnNode(fighter, 2,0,0, %RT_QUATERNION )
        END IF
        IF GetKeyDown(%KEY_CODE.KEY_ARROW_DOWN)  THEN
            TurnNode(fighter, -2,0,0, %RT_QUATERNION )
        END IF
        IF GetKeyDown(%KEY_CODE.KEY_Key_B)  THEN
            TurnNode(fighter, 0,2,0, %RT_QUATERNION )
        END IF
        IF GetKeyDown(%KEY_CODE.KEY_Key_V) THEN
            TurnNode(fighter, 0,-2,0, %RT_QUATERNION )
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_ARROW_LEFT ) THEN
            TurnNode(fighter, 0,0, 2, %RT_QUATERNION )
        END IF
        IF GetKeyDown(%KEY_CODE.KEY_ARROW_RIGHT)  THEN
            TurnNode(fighter, 0,0,-2, %RT_QUATERNION )
        END IF


        PointNode( cam, fighter, 0)


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0,  0,  0, 255, 1, 1)
        DrawScene()
        DrawText(font_, "DirKey and V/B for move fighter",  10,10,0,0, &h0ff00ffff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION


                                   

Peter Weis

Hello,
Include many new bug

regards Peter

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  031   as   simple lightmapping test.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS INTEGER


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF


    '---------------------------
    ' define a ManualContruct Mesh
    DIM mesh_ AS Mesh

    ' Create empty mesh
    mesh_ = CreateEmptyMesh(%VERTEX_TYPE.EVT_2TCOORDS)



    ' 3 first vertices
    DIM v1 AS LONG
    v1 = AddVertexMesh(mesh_, 0, 0,0,0, 0, 0, 0, &h0ffffffff, 0, 0, 0,  0)

    DIM v2 AS LONG
    v2 = AddVertexMesh(mesh_, 0, 2,2,0, 0, 0, 0, &h0ffffffff, 0, 0, 0,  0)

    DIM v3 AS LONG
    v3 = AddVertexMesh(mesh_, 0, 2,0,0, 0, 0, 0, &h0ffffffff, 0, 0, 0,  0)

    ' first face
    AddFaceMesh(mesh_, 0, v1,v2,v3)
    ' 3 Next vertices
    DIM v4 AS LONG
    v4 = AddVertexMesh(mesh_, 0, 0,2,0, 0, 0, 0, &h0ffffffff, 0, 0, 0,  0)

    DIM v5 AS LONG
    v5 = AddVertexMesh(mesh_, 0, 2,2,0, 0, 0, 0, &h0ffffffff, 0, 0, 0,  0)

    DIM v6 AS LONG
    v6 = AddVertexMesh(mesh_, 0, 0,0,0, 0, 0, 0, &h0ffffffff, 0, 0, 0,  0)

    ' second face
    AddFaceMesh(mesh_, 0, v4,v5,v6)


    ' texture coordinate layer 0

    VertexTexCoord1Mesh( mesh_, 0,0,  0, 1)
    VertexTexCoord1Mesh( mesh_, 0,1,  1, 0)
    VertexTexCoord1Mesh( mesh_, 0,2,  0, 0)

    VertexTexCoord1Mesh( mesh_, 0,3,  1, 1)
    VertexTexCoord1Mesh( mesh_, 0,4,  1, 0)
    VertexTexCoord1Mesh( mesh_, 0,5,  0, 1)

    ' texture coordinate layer 1  ( the same in this Case)
    VertexTexCoord2Mesh( mesh_, 0,0,  0, 1)
    VertexTexCoord2Mesh( mesh_, 0,1,  1, 0)
    VertexTexCoord2Mesh( mesh_, 0,2,  0, 0)
    VertexTexCoord2Mesh( mesh_, 0,3,  1, 1)
    VertexTexCoord2Mesh( mesh_, 0,4,  1, 0)
    VertexTexCoord2Mesh( mesh_, 0,5,  0, 1)

    '
    DIM entitymesh AS EntityNode
    entitymesh = CreateEntityNode(mesh_, 0,  0, 0, %NULL)

    ' set material of the mesh with EMT_LIGHTMAP mode
    MaterialTypeNode(entitymesh,  %EMT_LIGHTMAP )
    ' Load two textures
    DIM colormap AS NTexture
    colormap = LoadTexture( "media/rockwall.bmp")
    DIM lightmap AS NTexture
    lightmap = LoadTexture( "media/lightmap.bmp")
    ' set two texture layer
    MaterialTextureNode(entitymesh, colormap , 0)
    MaterialTextureNode(entitymesh, lightmap , 1)




    ' Create a camera
    DIM cam AS CameraNode
    cam = CreateCamera(%NULL)
    PositionNode(cam, 0,0,-4)


    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF

        TurnNode(entitymesh,0,0.5,0, 0)


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(30,20,10, 255, 1, 1)
        DrawScene()
        EndScene()

    WEND
    ' end
    FreeEngine()

END FUNCTION
                             

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  033   as   sprite3D code.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS LONG


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF



    '----------------------------------------
    ' Load 3D objects
    DIM obj1 AS Mesh
    obj1 = LoadMesh("media/plane.3ds", %HARDMAPPING.EHM_STATIC)



    '-----------------------------------------
    ' Create plane
    DIM plane AS EntityNode
    plane = CreateEntityNode(obj1, 0, 0, 0, %NULL)
    ScaleNode(plane, 2,2,2)
    '----------------------------------------



    '-----------------------------------------
    ' Create billboard
    DIM spMesh AS Mesh
    spMesh = CreateSpriteMesh( 8.0, &h022ffffff)
    DIM i AS LONG
    FOR i = 0 TO 64
        DIM spG AS SpriteSceneNode
        spG = CreateSprite3D(spMesh, "media/grass.bmp", %NULL)
        PositionNode(spG, -40+RND()*80,11, -40+RND()*80)
        MaterialTypeNode(spG, %EMT_TRANSPARENT_ALPHA_CHANNEL)
        OrientationSprite3D(spG,1)
    NEXT


    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80.0, 0.1, 1.0, BYVAL %NULL, 0, %False, %False, %NULL )
    PositionNode(cam, 0,25,-60)



    '-----------------------------------
    ' Load font png
    LoadFont("media/courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM FONT_ AS IGUIFont
    font_ = GetFont()


    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit = 0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit = 1
        END IF


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(100,100,100, 255, 1, 1)
        DrawScene()
        DrawText(font_, "Sprite3D demo",  10,10,0,0, &h0ff00ffff)
        DrawText(font_, "Primitives as  "+ STR$(PrimitiveCountDrawn() ) ,  10,45,0,0, &h0ffffffff)
        EndScene()

    WEND
    ' end
    FreeEngine()
END FUNCTION
                                                         

Peter Weis

#35
Hello,
Include many new bug

regards Peter

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  034   as   test primitives 3D.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS LONG


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)

    IF app = %NULL THEN
        EXIT FUNCTION
    END IF




    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80.0, 0.1, 1.0, BYVAL %NULL, 0, %False, %False, %NULL)
    PositionNode(cam, 0,0,-60)



    ' ---------------------------------------
    ' define primitives 3D
    DIM tri(9) AS SINGLE
    tri(0)=20 : tri(1)=0   : tri(2)=0
    tri(3)=20 : tri(4)=10  : tri(5)=0
    tri(6)=30 : tri(7)=10  : tri(8)=0


    DIM BOX(6) AS SINGLE
    BOX(0)=-10 : BOX(1)=-10 : BOX(2)=-10
    BOX(3)=10  : BOX(4)=10  : BOX(5)=10

    DIM angle AS SINGLE
    angle = 0
    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF


        angle = angle + 1
        ' ---------------
        '      Render
        ' ---------------
        BeginScene(100,100,100, 255, 1, 1)
        DrawScene()

        SituatePrimitive3D(0, 0, 0, 0, 0, 0)
        DrawTriangle3D(tri(0),  &h0fff0000)
        DrawLine3D(0,0,0,20,10,0, &h0ff0000ff)

        SituatePrimitive3D( 0,0,0, 0,angle,0)
        DrawBox3D(BOX(0), &h0ff00ff00)

        EndScene()

    WEND
    ' end
    FreeEngine()

END FUNCTION
                                               

Peter Weis

#37

'
'   Sample  035   as   Picking Test.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#INCLUDE "N3xtD.bi"

DECLARE SUB DrawTriangle()

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS INTEGER



    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF


    '-----------------------------------------
    ' Create single sphere
    DIM mesh_ AS Mesh
    mesh_ =  CreateSphereMesh(5,16)

    DIM sphere AS EntityNode
    sphere = CreateEntityNode(mesh_, 0, 0, 0, %NULL)


    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCamera(%NULL )
    PositionNode(cam, 0,0,-10)


    '-----------------------------------
    ' Load font png
    LoadFont("media/courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM font_ AS IGUIFont
    font_ =  GetFont()



    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit = 0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF


        IF GetMouseEvent(%MOUSE_EVENT.MOUSE_BUTTON_LEFT) THEN
            DIM node AS EntityNode
            node = PickCamera(cam, GetMouseX(), GetMouseY(), %ENT_PICKFACE, 5000.0)
        END IF



        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        DrawTriangle()
        DrawText(font_, "FPS  as  "+ STR$(FPS())  ,  10,10,0,0, &h0ff00ffff)
        DrawText(font_, "use click mouse for pick mesh as "  ,  10,25,0,0, &h0ff00ffff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION

SUB DrawTriangle()
  DIM tri(0 to 8) AS SINGLE
  Pickedtriangle (tri(0))
  DrawTriangle3D(tri(0),  &h0ffffff00)
END SUB



                               

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 036   as   Ray Collide Test And
'                  used Octtree system For large model
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

DECLARE SUB DrawTriangle()

FUNCTION PBMAIN

    ' Dimes
    DIM app AS DWORD
    DIM Quit AS LONG


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %TRUE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF





    '-----------------------------------
    ' add in memory management system a zip file
    AddZipFileArchive( "media/chiropteradm.pk3" )

    '-----------------------------------
    ' Load Quake3 scene Object
    DIM obj AS Mesh
    obj = LoadMesh("chiropteradm.bsp", %HARDMAPPING.EHM_STATIC)


    ' Create a mesh with one of the 3D Object loaded
    '  dim quake as EntityNode = _CreateEntityNode(obj)
    DIM quake AS EntityNode
    quake =  CreatePopNodes(obj, %NULL)




    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80.0,  0.1, 1.0, BYVAL %NULL, 0, %False, %False, %NULL)
    PositionNode(cam, 0,20,-50)


    '-----------------------------------
    ' Load font png
    LoadFont("media/courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM font_ AS IGUIFont
    font_ = GetFont()

    '-----------------------------------
    ' define 3D Line ray test
    DIM Lstart AS iVECTOR3
    DIM Lend AS iVECTOR3
    Lstart.x=0  : Lstart.y=30 : Lstart.z=0
    Lend.x=0  : Lend.y=-70  : Lend.z=0


    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    DIM a AS STRING
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF


        IF GetKeyUp(%KEY_CODE.KEY_SPACE) THEN
            DIM res_ AS INTEGER
            res_ = CollisionPoint(Lstart.x,  Lstart.y,  Lstart.z,  Lend.x,  Lend.y,  Lend.z, quake)
            a = "collision result = " + STR$(res_)
        END IF

        ' move ray
        IF GetKeyDown(%KEY_CODE.KEY_KEY_H) THEN
            Lstart.x = Lstart.x+1
            Lend.x = Lend.x+1
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_G) THEN
            Lstart.x = Lstart.x-1
            Lend.x = Lend.x-1
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_Y) THEN
            Lstart.z = Lstart.z+1
            Lend.z = Lend.z+1
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_B) THEN
            Lstart.z = Lstart.z-1
            Lend.z = Lend.z-1
        END IF





        ' ---------------
        '      Render
        ' ---------------
        BeginScene(250,250,250, 255, 1, 1)
        DrawScene()
        DrawTriangle()
        DrawLine3D(Lstart.x,  Lstart.y,  Lstart.z,  Lend.x,  Lend.y,  Lend.z, &h0ff0000ff)
        DrawText(font_, "FPS  as  "+ TRIM$(STR$(FPS()))  ,  10,10,0,0, &hff00ffff)
        DrawText(font_, "Dir key and mous/Left-click for move camera",  10,25,0,0, &h0ffff00ff)
        DrawText(font_, "H/G/Y/B for move Ray and SpaceKey for test collide",  10,40,0,0, &h0ffff00ff)
        DrawText(font_, "Primitives as  "+ STR$(PrimitiveCountDrawn())  ,  10,55,0,0, &h0ffffffff)
        EndScene()


    WEND
    ' end
    FreeEngine()

END FUNCTION

SUB DrawTriangle()
  DIM tri(8) AS SINGLE

  Pickedtriangle (tri(0))
  DrawTriangle3D( tri(0),  &h0ffff0000)
END SUB
                                 

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 038  : Occlusion Test.
'   Historique  :
'     29/03/09  19:16    TMyke
'
' ------------------------------------------------------------
' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN

    ' Dimes
    DIM app AS DWORD
    DIM Quit AS INTEGER


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, %FALSE, %FALSE, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)

    IF app = %NULL THEN
        EXIT FUNCTION
    END IF


    '---------------------------------------------
    ' Create light And set position
    DIM light AS LightNode
    light = CreateLight( &h0ffffffff, 50, %ELT_POINT , %NULL)
    PositionNode(light, 0,5,-20)



    '---------------------------------------------
    ' Create mesh
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)
    DIM spheremesh AS Mesh
    spheremesh = CreateSphereMesh(1.0, 32)
    DIM cylindermesh AS Mesh
    cylindermesh = CreateCylinderMesh(1.0, 3.0, &h0ffffffff, 8, %True, 0)


    '---------------------------------------------
    ' Create a cube And set position
    DIM cube AS EntityNode
    cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
    ScaleNode(cube, 8,8,1)
    PositionNode(cube, -1,0,-5)




    '---------------------------------------------
    ' Create 12 sphere entities, with occlusion
    ' system test
    DIM i AS LONG, j AS LONG
    FOR i =0 TO 3
        FOR  j  = 0 TO 3
            DIM sphere AS EntityNode
            sphere = CreateEntityNode(spheremesh, 0, 0, 0, %NULL)
            PositionNode(sphere, -1.5+i, -1.5+j,0)
            LoadTextureNode(sphere, "media/five.bmp", 0, 0)
            AddOcclusionQuery(sphere, spheremesh)
        NEXT
    NEXT


    '---------------------------------------------
    ' Create a cylinder entity And set position
    DIM cylinder AS EntityNode
    cylinder = CreateEntityNode(cylindermesh, 0, 0, 0, %NULL)
    PositionNode(cylinder, 2,2,0)




    ' Create a camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80, 0.03, 1.0, BYVAL %NULL, 0, %False, %False, %NULL)
    PositionNode(cam, 0,0,-20)



    '-----------------------------------
    ' Load font png
    LoadFont("media/courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM font_ AS IGUIFont
    font_ = GetFont()


    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF



        ' ---------------
        '      Render
        ' ---------------
        BeginScene(128,128,128, 255, 1, 1)
        DrawScene()
        DrawText(font_, "Move arround the plane, FPS : "+ TRIM$(STR$(FPS()))  ,  10,25,0,0, &h0ffffffff)
        DrawText(font_, "Primitives: "+ TRIM$(STR$(PrimitiveCountDrawn()))  ,  10,45,0,0, &h0ffffffff)
        EndScene()


    WEND
    ' end
    FreeEngine()


END FUNCTION
                 

Peter Weis

#40
Hello,
Include many new bug

regards Peter

Peter Weis

#41

' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  039   as  Animate Texture.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS LONG


    '----------------------------------------------------------
    ' open n3xt-D screen
    app = CreateGraphics3D(800,600, 32, 0, %True, %DEVICE_TYPES.EDT_DIRECT3D9, %TRUE)
    IF app = %NULL THEN
        EXIT FUNCTION
    END IF



    '----------------------------------------
    ' Create a cube And set position
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(2.0)

    DIM cube AS EntityNode
    cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)





    DIM texturelist AS NArray
    texturelist = CreateListTexture("media/ball2.png", 64,64)

    'dim texturelist as NArray = _CreateListTexture("media/canvas.bmp", 32,32)

    DIM anim AS NNodeAnimator
    anim = CreateTextureAnimator( texturelist, 50, %TRUE)
    ' add inside the node  the animator Texture animator)
    AddAnimatorTexture(cube, anim)



    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80.0, 0.1, 1.0, BYVAL %NULL, 0, %False, %False, %NULL)
    PositionNode(cam,0,0,-10)



    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


        ' If Escape Key, Exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF

        TurnNode(cube, 0.3,0.3,0, 0)

        ' ---------------
        '      Render
        ' ---------------
        BeginScene(200,200,200, 255, 1, 1)
        DrawScene()
        EndScene()



    WEND
    ' end
    FreeEngine()

END FUNCTION
                   

James Klutho

Thank you for your hard work Peter.  N3xtD seem like a fun package.

Jim

Peter Weis

Hello James,
Thank you :). It gives me a lot of fun to work through that. If you work with it and give me notice an error occurs. I still have the problem with the delivery of optional parameters and variables that do can not be solved in PowerBASIC! :'( This is just only with Visual Basic and FreeBasic >:(

regards Peter

Frank Brübach

#44
good job peter, I like your efforts! :)

It's a special interests library N3xtD, but very interesting stuff to play with. I've tried in springtime to adept Irrlichtwrapper library for pbwin 9 (with a friend he's programming on freebasic), but there's a certain amount of differences between freebasic and powerbasic languages (for example: "enum... end enum", "type... end type" blocks statements and the using of "equates") I've nearly managed to convert (translate) 80 per Cent of Irrlichtwrapper from freebasic to powerbasic, but I will wait until I am updating to pbwin 10. I hope that's the converting problems are decreasing to zero. It's a time problem too for me to work at this bigger job, but I will do that in nearby future. thanks. I've not tested yet your N3xtD.bi but I will check it next time and try to help if there are error messages.

one suggestion:
If you have updates of your library send all to your first post (include file and scene examples).

2) freebasic uses for example enum..end enum like type..end type block statements:

Quote
ENUM IRR_EGUI_EVENT_TYPE
    ' A gui element has lost its focus.
    EGET_ELEMENT_FOCUS_LOST = 0',
    ' A gui element has got the focus.
    EGET_ELEMENT_FOCUSED
    ' The mouse cursor hovered over a gui element.
    EGET_ELEMENT_HOVERED
    ' The mouse cursor left the hovered element.
    EGET_ELEMENT_LEFT
    ' An element would like to close.
    EGET_ELEMENT_CLOSED
    ' A button was clicked.
    EGET_BUTTON_CLICKED
    ' A scrollbar has changed its position.
    EGET_SCROLL_BAR_CHANGED
    ' A checkbox has changed its check state.
    EGET_CHECKBOX_CHANGED
    ' A new item in a listbox was seleted.
    EGET_LISTBOX_CHANGED
    ' An item in the listbox was selected, which was already selected.
    EGET_LISTBOX_SELECTED_AGAIN
    ' A file has been selected in the file dialog
    EGET_FILE_SELECTED
    ' A directory has been selected in the file dialog
    EGET_DIRECTORY_SELECTED
    ' A file open dialog has been closed without choosing a file
    EGET_FILE_CHOOSE_DIALOG_CANCELLED
    ' 'Yes' was clicked on a messagebox
    EGET_MESSAGEBOX_YES
    ' 'No' was clicked on a messagebox
    EGET_MESSAGEBOX_NO
    ' 'OK' was clicked on a messagebox
    EGET_MESSAGEBOX_OK
    ' 'Cancel' was clicked on a messagebox
    EGET_MESSAGEBOX_CANCEL
    ' In an editbox 'ENTER' was pressed
    EGET_EDITBOX_ENTER
    ' The text in an editbox was changed. This does not include automatic changes in text-breaking.
    EGET_EDITBOX_CHANGED
    ' The marked area in an editbox was changed.
    EGET_EDITBOX_MARKING_CHANGED
    ' The tab was changed in an tab control
    EGET_TAB_CHANGED
    ' A menu item was selected in a (context) menu
    EGET_MENU_ITEM_SELECTED
    ' The selection in a combo box has been changed
    EGET_COMBO_BOX_CHANGED
    ' The value of a spin box has changed
    EGET_SPINBOX_CHANGED
    ' A table has changed
    EGET_TABLE_CHANGED
    EGET_TABLE_HEADER_CHANGED
    EGET_TABLE_SELECTED_AGAIN
    ' A tree view node lost selection. See IGUITreeView::getLastEventNode().
    EGET_TREEVIEW_NODE_DESELECT
    ' A tree view node was selected. See IGUITreeView::getLastEventNode().
    EGET_TREEVIEW_NODE_SELECT
    ' A tree view node was expanded. See IGUITreeView::getLastEventNode().
    EGET_TREEVIEW_NODE_EXPAND
    ' A tree view node was collapsed. See IGUITreeView::getLastEventNode().
    EGET_TREEVIEW_NODE_COLLAPS
    ' No real event. Just for convenience to get number of events
    EGET_COUNT
END ENUM


TYPE IRR_GUI_EVENT
    id AS INTEGER
'    event as IRR_EGUI_EVENT_TYPE ' that's not possible with Powerbasic !
    x AS INTEGER
    y AS INTEGER
END TYPE

but if you're calling "IRR_GUI_EVENT" Powerbasic doesn't accept "event" as "IRR_EGUI_EVENT" (last part) and there are few more problems but I am looking for a good solution to solve these problems.

best regards, frank