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  104   as   terrain physic 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




    ' set the curent folder
    ChangeWorkingDirectory("media")


    '------------------------------------------------------------------------------------
    ' resize physic world space
    SetWorldSize(-1000,-1000,-1000,1000,1000,1000)


    '------------------------------------------------------------------------------------
    DIM terrain AS TerrainNode
    terrain = CreateTerrain("height113.bmp", %TQ_MEDIUM, 2.0, 0.3, 2.0, 32, %TRUE, %HARDMAPPING.EHM_STATIC)
    TextureTerrain(terrain, 0 , "Sol113.jpg", -1 , -1)
    TextureTerrain(terrain, 1 , "detailmap3.jpg", -1, -1)
    MaterialTypeNode(terrain, %EMT_LIGHTMAP_LIGHTING_M2)
    ' Create terrain body
    ' first Method, less accurate, but lighter And faster.
    CreateTerrainBody(terrain, %HEIGHTFIELD_METHOD)
    ' << Or >>
    ' second Method, accurate, but heavier
    '_CreateTerrainBody(terrain, VERTICES_METHOD)
    '------------------------------------------------------------------------------------


    '-----------------------------------------
    ' Create a static base
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(4.0)
    '-----------------------------------------
    ' Create a cube
    DIM i AS INTEGER
    FOR i = 0 TO 25
        DIM cube AS EntityNode
        cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
        PositionNode(cube, -25+RND()*50+50,100,-25+RND()*50+50)
        LoadTextureNode(cube, "body.bmp", 0, 0)
        ' Create body, dynamique
        CreateBody(cube, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
    NEXT





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

    PositionNode(cam, 0,120,-70)


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

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


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




        ' ---------------
        '      Render
        ' ---------------
        BeginScene(1,128,128, 255, 1, 1)
        DrawScene()
        NX3_DrawText(pbfont, "FPS  as  " + TRIM$(STR$(FPS())),  10,25,0,0, &h0ffffffff)
        NX3_DrawText(pbfont, "Primitives as  "+ TRIM$(STR$(PrimitiveCountDrawn()))  ,  10,45,0,0, &h0ffffffff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 105   as   scene with physic engine
'   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
    DIM i 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


    ' set the curent folder
    ChangeWorkingDirectory("media")



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

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



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

    ' resize world box dimension
    SetWorldSize(-1000,-1000,-1000,1000,1000,1000)
    ' Create static body scene
    CreateBody(quake, %COMPLEX_PRIMITIVE_SURFACE, %False, 1.0, 0, 0, 0)




    '-----------------------------------------
    ' Create a static base
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(2.0)
    '-----------------------------------------
    ' Create a cube
    FOR i = 0 TO 25
        DIM cube AS EntityNode
        cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
        PositionNode(cube, -20+RND()*40,10+RND()*10,-10+RND()*12)
        LoadTextureNode(cube, "wcrate.bmp", 0, 0)
        ' Create body, dynamique
        CreateBody(cube, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
    NEXT






    '-----------------------------------------
    ' Load an 3D Object
    obj = LoadMesh("teapot.b3d", %HARDMAPPING.EHM_STATIC)
    ' Create a mesh with one of the 3D Object loaded
    DIM teapot AS EntityNode
    teapot = CreateEntityNode(obj, 0, 0, 0, %NULL)
    PositionNode(teapot, 5,6,0)
    ' Create And  set collide Type
    CreateBody(teapot, %HULL_PRIMITIVE, %True, 1.0, 0, 0, 0)






    '-----------------------------------------
    ' 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,-40)



    '-----------------------------------
    ' Load font png
    LoadFont("courriernew.png", %FONT_TYPE.EGDF_DEFAULT)
    DIM pbfont AS IGUIFont
    pbfont = GetFont()
    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    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
            FOR i = 0 TO 7
                'DIM cube AS EntityNode
                cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
                PositionNode(cube, -20+RND()*40,10+RND()*10,-10+RND()*20)
                Scalenode(cube, 1.5,1.5,1.5)
                LoadTextureNode(cube, "object.jpg", 0, 0)
                ' Create body, no dynamique
                CreateBody(cube, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
            NEXT
        END IF


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


    WEND
    ' end
    FreeEngine()
END FUNCTION
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 106   as   Raycast Test physic engine
'   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
    DIM i 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 traditional light And set position
    DIM light AS LightNode
    light = CreateLight(&h0ffdddddd, 200, %ELT_POINT , %NULL)
    PositionNode(light, 5,25,3)



    '-----------------------------------------
    ' Create a static base
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)

    DIM cube AS EntityNode
    cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
    PositionNode(cube, 0,-2,0)
    LoadTextureNode(cube, "media/grille1.bmp", 0, 0)
    DIM pbmat AS NMaterial
    pbmat = NodeMaterial(cube, 0)
    ColorMaterial(pbmat,  %ECM_NONE)
    ScaleNode(cube, 20,1,20)


    '-----------------------------------------
    ' Create a cube
    FOR i = 0 TO 15
        cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
        PositionNode(cube, -6+RND()*12,-1,-6+RND()*12)
        LoadTextureNode(cube, "media/body.bmp", 0, 0)
        'dim mat as NMaterial
        pbmat = NodeMaterial(cube, 0)
        ColorMaterial(pbmat,  %ECM_NONE)
        ' Create collide Type
        CreateNodeCollide(cube, %BOX_PRIMITIVE, 1, 0, 0, 0)
    NEXT

    cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
    PositionNode(cube, 0,-1,-5)
    LoadTextureNode(cube, "media/body.bmp", 0, 0)
    pbmat = NodeMaterial(cube, 0)
    ColorMaterial(pbmat,  %ECM_NONE)
    ' Create collide Type
    CreateNodeCollide(cube, %BOX_PRIMITIVE, 1, 0, 0, 0)

    cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
    PositionNode(cube, 0,1,-5)
    LoadTextureNode(cube, "media/body.bmp", 0, 0)
    pbmat = NodeMaterial(cube, 0)
    ColorMaterial(pbmat,  %ECM_NONE)
    ' Create collide Type
    CreateNodeCollide(cube, %BOX_PRIMITIVE, 1, 0, 0, 0)



    '-----------------------------------------
    ' Create first  camera
    DIM cam AS CameraNode
    cam = CreateCamera(%NULL )
    PositionNode(cam, 0,7,-12)
    RotateNode(cam, 38,0,0)


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



    DIM dist AS SINGLE
    dist = -1.0
    DIM start AS iVECTOR3
    DIM eend AS iVECTOR3
    start.x=0 : start.y = 10  : start.z=0
    eend.x=0 : eend.y = -1  : eend.z=0
    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


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



        ' move line raycast with dir key
        IF GetKeyDown(%KEY_CODE.KEY_ARROW_UP) THEN
            start.z = start.z + 0.15
            eend.z = eend.z + 0.15
            DIM pbres AS EntityNode
            pbres = CollideRayCastAll( start.x, start.y, start.z, eend.x, eend.y, eend.z, 1, dist)
            IF pbres THEN
                TurnNode(pbres,0,2,0, 0)
                DiffuseColorNode(pbres, &h0ff111111)
            END IF
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_ARROW_DOWN) THEN
            start.z = start.z - 0.15
            eend.z = eend.z - 0.15
            'dim pbres as EntityNode
            pbres = CollideRayCastAll( start.x, start.y, start.z, eend.x, eend.y, eend.z, 1, dist)
            IF pbres THEN
                TurnNode(pbres,0,2,0, 0)
                DiffuseColorNode(pbres, &h0ff111111)
            END IF
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_ARROW_LEFT) THEN
            start.x = start.x - 0.15
            eend.x = eend.x - 0.15
            'dim pbres as EntityNode
            pbres = CollideRayCastAll( start.x, start.y, start.z, eend.x, eend.y, eend.z, 1, dist)
            IF pbres THEN
                TurnNode(pbres,0,2,0, 0)
                DiffuseColorNode(pbres, &h0ff111111)
            END IF
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_ARROW_RIGHT) THEN
            start.x = start.x + 0.15
            eend.x = eend.x + 0.15
            'dim pbres as EntityNode
            pbres = CollideRayCastAll( start.x, start.y, start.z, eend.x, eend.y, eend.z, 1, dist)
            IF pbres THEN
                TurnNode(pbres,0,2,0, 0)
                DiffuseColorNode(pbres, &h0ff111111)
            END IF
        END IF



        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        DrawLine3D(start.x,  start.y,  start.z,  eend.x,  eend.y,  eend.z, &h0ffff00ff)
        NX3_DrawText(pbfont, "Dist as  "+ TRIM$(STR$(dist)),  10,10,0,0, &h0ff9999ff)
        NX3_DrawText(pbfont, "Use Dir key to move raycast line",  10,25,0,0, &h0ff9999ff)
        EndScene()




    WEND
    ' end
    FreeEngine()
END FUNCTION


New Include
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 108   as    test material physic engine
'   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
    DIM i 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 traditional light And set position
    DIM light AS LightNode
    light = CreateLight(&h0ffdddddd, 200, %ELT_POINT, %NULL)
    PositionNode(light, 5,25,3)
    AmbientLight(&h0ff222222)


    ' -----------------------------------------
    '          Create And init some physicmaterial
    ' -----------------------------------------
    DIM pbmat(6) AS LONG
    pbmat(1)= CreatePhysicMaterial()
    pbmat(2)= CreatePhysicMaterial()
    pbmat(3)= CreatePhysicMaterial()
    pbmat(4)= CreatePhysicMaterial()
    pbmat(5)= CreatePhysicMaterial()

    DIM pair1 AS NMaterialPair
    pair1 = CreatePhysicMaterialPair(pbmat(1), pbmat(1), 0.1, 0.3, 0.25, 0)

    DIM pair2 AS NMaterialPair
    pair2 = CreatePhysicMaterialPair(pbmat(1), pbmat(2), 0.3, 1.1, 0.82, 0)

    DIM pair3 AS NMaterialPair
    pair3 = CreatePhysicMaterialPair(pbmat(1), pbmat(3), 0.5, 0.025, 0.01, 0)

    DIM pair4 AS NMaterialPair
    pair4 = CreatePhysicMaterialPair(pbmat(1), pbmat(4), 0.7, 1.0, 1.0, 0)

    DIM pair5 AS NMaterialPair
    pair5 = CreatePhysicMaterialPair(pbmat(1), pbmat(5), 0.9, 0.1, 0.5, 0)



    '-----------------------------------------
    ' Create a static base
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)

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

    PositionNode(cube, 0,-2,0)
    LoadTextureNode(cube, "media/grille1.bmp", 0, 0)
    ScaleNode( cube, 30,1,30)
    RotateNode(cube, 0,0,25)
    ' Create body, no dynamique
    CreateBody(cube, %BOX_PRIMITIVE, %False, 1.0, 0, 0, 0)
    GroupPhysicMaterialBody(cube,  pbmat(1))


    '-----------------------------------------
    ' Create 5 random cubes
    FOR i = 0 TO 4
        DIM pbmesh AS Entitynode
        pbmesh = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
        ScaleNode(pbmesh, 2,2,2)
        PositionNode(pbmesh, 10, 10 ,-4+4*i)
        MaterialColorNode(pbmesh, %ECM_NONE)
        DiffuseColorNode(pbmesh, &h0ff000000+RND()*&h0ffffff)
        LoadTextureNode(pbmesh, "media/body.bmp", 0, 0)
        CreateBody(pbmesh, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
        GroupPhysicMaterialBody(pbmesh, pbmat(i+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, -5,7,-20)



    ' ---------------------------------------
    '           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()
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION

  •  

Peter Weis

Hello
So all FreeBasic demos for PowerBASIC implemented
Include seen so far removed but still some errors in it. Now I'm still missing the examples PureBasic with the controls to work, then that's all in PowerBASIC.
Who else someone finds fault in the include files I ask you to inform me that would like to eliminate these errors
regards Peter
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  109   as   physic engine - Elastic values with callback traitement
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

DECLARE SUB MaterialEventCallBack CDECL(BYVAL node1 AS EntityNode, BYVAL node2 AS EntityNode, BYVAL material AS NPMaterial, BYVAL contact AS BYTE PTR)

FUNCTION PBMAIN
    ' Dimes
    DIM app AS DWORD
    DIM Quit AS INTEGER
    DIM i 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 traditional light And set position
    DIM light AS LightNode
    light = CreateLight(&h0ffdddddd, 200, %ELT_POINT, %NULL)
    PositionNode(light, 5, 25, 3)
    AmbientLight(&h0ff555555)


    '-----------------------------------------
    ' Create a static base
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)

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

    PositionNode(cube, 0,-2,0)

    LoadTextureNode(cube, "media/grille1.bmp", 0, 0)
    ScaleNode( cube, 20,1,20)
  ' Create body, no dynamique
    CreateBody(cube, %BOX_PRIMITIVE, %False, 1.0, 0, 0, 0)




    ' ---------------------------------------
    '          Create a base PhysicMaterial
    ' ---------------------------------------
    DIM mat0 AS LONG
    mat0 = CreatePhysicMaterial()

    DIM mat1 AS LONG
    mat1 = CreatePhysicMaterial()

    DIM mat2 AS LONG
    mat2 = CreatePhysicMaterial()

    DIM pair0 AS NMaterialPair
    pair0 = CreatePhysicMaterialPair( mat0,  mat0, 0.3, 1.1, 0.82, 0)    ' Create a New PhysicMaterial pair interaction

    DIM pair1 AS NMaterialPair
    pair1 = CreatePhysicMaterialPair( mat1,  mat1, 1.0, 1.1, 0.82, 0)    ' Create a New PhysicMaterial pair interaction

    '_CollisionMemPhysicMaterial(pair0)             ' memorize collision body inside a stack
    PhysicMaterialEventCallBack(pair0,  CODEPTR(MaterialEventCallBack)) ' set callback collide PhysicMaterial

    '_CollisionMemPhysicMaterial(pair1)             ' memorize collision body inside a stack
    PhysicMaterialEventCallBack(pair1,  CODEPTR(MaterialEventCallBack)) ' set callback collide PhysicMaterial



    '-----------------------------------------
    ' Create spheres group 0
    DIM spmesh AS Mesh
    spmesh = CreateSphereMesh(0.5, 16)
    FOR i = 0 TO 3

        DIM sp AS EntityNode
        sp = CreateEntityNode(spmesh, 0, 0, 0, %NULL)
        PositionNode(sp, 0,1+i*2.5, 0)
        LoadTextureNode(sp, "media/body.bmp", 0, 0)
        ' Create body, no dynamique
        CreateBody(sp, %SPHERE_PRIMITIVE, %True, 1.0, 0, 0, 0)
        GroupPhysicMaterialBody(sp,  mat0)
    NEXT

    '-----------------------------------------
    ' Create spheres group 1
    ' creates second sphere mesh, because Newton consider that both geometry
    ' is identical, so it is the same body.
    spmesh = CreateSphereMesh(0.51, 16)

    FOR i = 0 TO 3
        'dim sp As EntityNode
        sp = CreateEntityNode(spmesh, 0, 0, 0, %NULL)
        PositionNode(sp, 5,1+i*2.5, 0)
        LoadTextureNode(sp, "media/body.bmp", 0, 0)
        ' Create body, no dynamique
        CreateBody(sp, %SPHERE_PRIMITIVE, %True, 1.0, 0, 0, 0)
        GroupPhysicMaterialBody(sp,  mat1)
    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,7,-10)


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




    DIM restitution AS GLOBAL SINGLE
    restitution=1.0
    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    WHILE Quit=0


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

        IF GetKeyDown(%KEY_CODE.KEY_KEY_T) THEN
            restitution = restitution + 0.01
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_G) THEN
            restitution = restitution - 0.01
        END IF


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        NX3_DrawText(pbfont, "KEY T/G for change restitution as  "+ TRIM$(STR$(restitution)),  10,10,0,0, &h0ff00ffff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION
'-----------------------------------------------------
' callback procedure
' it's a derivation of the treatment of collisions and
' associated PhysicMaterials.
SUB MaterialEventCallBack CDECL(BYVAL node1 AS EntityNode, BYVAL node2 AS EntityNode, BYVAL material AS NPMaterial, BYVAL contact AS BYTE PTR)
  ContactElasticityPhysicMaterial( material, restitution )
END SUB
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  110   as    physic joint test
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

DECLARE SUB ApplyForceAndTorque CDECL(BYVAL bdy AS NBody)

' dimes
FUNCTION PBMAIN
    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 traditional light And set position
    DIM light AS LightNode
    light = CreateLight(&h0ffdddddd, 20, %ELT_POINT, %NULL)
    PositionNode(light, 5,15,3)
    AmbientLight(&h0ff555555)



    '-----------------------------------------
    ' Create And Load mesh
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)
    ' Load
    DIM obj1 AS Mesh
    obj1 = LoadMesh("media/N1.b3d", %HARDMAPPING.EHM_STATIC)

    DIM obj2 AS Mesh
    obj2 = LoadMesh("media/N2.b3d", %HARDMAPPING.EHM_STATIC)

    RotateMesh(obj2, 0,90,0)
    ScaleMesh(obj1 , 0.25,0.25,0.25)


    '-----------------------------------------
    ' Create a static base
    DIM cube AS Entitynode
    cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
    PositionNode(cube, 0,0,0)
    LoadTextureNode(cube, "media/dirt.bmp", 0, 0)
    ScaleNode( cube, 50,1,50)
  ' Create body, no dynamique
    CreateBody(cube, %BOX_PRIMITIVE, %False, 1.0, 0, 0, 0)



    '=============================================================
    ' Create two mesh For Ball Joint
    '=============================================================
    DIM mesh1 AS Entitynode
    mesh1 = CreateEntityNode(obj1, 0, 0, 0, %NULL)
    PositionNode(mesh1, 10, 10 ,0)
    GlobalColorNode(mesh1, &h0ff00ff00)
    CreateBody(mesh1, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)


    DIM mesh2 AS Entitynode
    mesh2 = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    RotateNode(mesh2, 0,180,0)
    PositionNode(mesh2, 10, 10 ,3.5)
    GlobalColorNode(mesh2, &h0ff00ffff)
    CreateBody(mesh2, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
   ' Create Ball Joint
    DIM ball AS NJoint
    ball = CreateBallJoint(mesh2, mesh1 ,  10,10,1.5)
    BallSetConeLimits(ball,  10,10,3.0,  0,  20)


    '=============================================================
    ' Create two mesh For Hinge Joint
    '=============================================================
    DIM mesh3 AS Entitynode
    mesh3 = CreateEntityNode(obj1, 0, 0, 0, %NULL)
    PositionNode(mesh3, -20, 10 ,2.5)
    GlobalColorNode(mesh3, &h0ffffff00)
    CreateBody(mesh3, %BOX_PRIMITIVE, %True, 3,3,3, 0)

    DIM mesh4 AS Entitynode
    mesh4 = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    ' For good orientation cylinder For physical engine
    PositionNode(mesh4, -20, 10 ,5)
    RotateNode(mesh4, 0,0,90)
    GlobalColorNode(mesh4, &h0ffff0000)
    CreateBody(mesh4, %CYLINDER_PRIMITIVE, %False, 1.0, 0, 0, 0)
    ' Create Hinge Joint
    CreateHingeJoint(mesh3, mesh4, -20,10, 5.0, 0, 1, 0)

    '=============================================================
    ' Create two mesh For Slider Joint
    '=============================================================
    DIM mesh5 AS Entitynode
    mesh5 = CreateEntityNode(obj1, 0, 0, 0, %NULL)
    PositionNode(mesh5, -10, 10 ,2.5)
    GlobalColorNode(mesh5, &h0ffff00ff)
    CreateBody(mesh5, %BOX_PRIMITIVE, %True, 3, 3, 3, 0)

    DIM mesh6 AS Entitynode
    mesh6 = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    ' For good orientation cylinder For physical engine

    PositionNode(mesh6, -10, 12 ,7)
    RotateNode(mesh6, 0,0,90)
    GlobalColorNode(mesh6, &h0ff0f00ff)
    CreateBody(mesh6, %CYLINDER_PRIMITIVE, %False, 1.0, 0, 0, 0)
    ' Create Hinge Joint
    CreateSliderJoint(mesh5, mesh6, -10,10, 6.5, 0, 1, 0)


    '=============================================================
    ' Create two mesh For Corks Crew Joint
    '=============================================================
    DIM mesh7 AS Entitynode
    mesh7 = CreateEntityNode(obj1, 0, 0, 0, %NULL)
    PositionNode(mesh7, 0, 10 ,2.5)
    GlobalColorNode(mesh7, &h0ff0f000f)
    CreateBody(mesh7, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)

    DIM mesh8 AS Entitynode
    mesh8 = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    ' For good orientation cylinder For physical engine
    PositionNode(mesh8, 0, 12 ,7)
    RotateNode(mesh8, 0,0,90)
    GlobalColorNode(mesh8, &h0ff0ff00f)
    CreateBody(mesh8, %CYLINDER_PRIMITIVE, %False, 1.0, 0, 0, 0)
    ' Create Hinge Joint
    CreateCorkScrewJoint(mesh7, mesh8, 0,10,  6.5, 0, 1, 0)




    '-----------------------------------------
    ' 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,-27)


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


    ' ---------------------------------------
    '           Main loop
    ' ---------------------------------------
    GLOBAL dirx, diry, dirz AS SINGLE
    WHILE Quit=0


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

        IF GetKeyDown(%KEY_CODE.KEY_KEY_O) THEN
            ApplyForceAndTorqueBody(mesh2, CODEPTR(ApplyForceAndTorque))
            dirz=0
            dirx=0
            diry=8
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_P) THEN
            PulseBody(mesh3,  1,0,0,  1,0,0)
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_I) THEN
            PulseBody(mesh5,  0,5.8,0,  0,5.8,0)
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_U) THEN
            PulseBody(mesh7,  1,0,0,  1,0,0)
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_J) THEN
            PulseBody(mesh7,  0,5,0,  0,2,0)
        END IF



        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        NX3_DrawText(pbfont, "O   Ball Joint", 10, 35,0,0, &h0ff9999ff)
        NX3_DrawText(pbfont, "P   Hinge joint", 10, 50,0,0, &h0ff9999ff)
        NX3_DrawText(pbfont, "I   Slider joint", 10, 65,0,0, &h0ff9999ff)
        NX3_DrawText(pbfont, "U/J CorksCrew joint", 10, 80,0,0, &h0ff9999ff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION

SUB ApplyForceAndTorque CDECL(BYVAL bdy AS NBody)
    DirectForceBody(bdy, dirx, diry, dirz)
END SUB
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  201   as   Test HighLevelShaders.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

DECLARE SUB CallbackShader CDECL(BYVAL services AS NMaterialServices,BYVAL  userData AS LONG)
DECLARE SUB CallbackShaderMaterial CDECL(BYVAL pbmat AS NMaterial)

FUNCTION PBMAIN
    ' Globales
    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

    DIM video AS LONG
    video = %DEVICE_TYPES.EDT_DIRECT3D9


    ' Load an 3D Object
    DIM obj2 AS Mesh
    obj2 = CreateCubeMesh(1.0)



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


    '-----------------------------------------
    ' Load And Create shader
    DIM shad AS LONG
    DIM shad2 AS LONG

    VersionShader(%VERTEXSHADER_VERSION.EVST_VS_1_1, %PIXELSHADER_VERSION.EPST_PS_2_0)

    IF video = %DEVICE_TYPES.EDT_DIRECT3D9 THEN
        shad = CreateShaderHighLevel("media/d3d9.hlsl", _
        "vertexMain", _
        "media/d3d9.hlsl", _
        "pixelMain", _
        %EMT_SOLID, _
        CODEPTR(CallbackShader), _
        CODEPTR(CallbackShaderMaterial))

        shad2 = CreateShaderHighLevel("media/d3d9.hlsl", _
        "vertexMain", _
        "media/d3d9.hlsl", _
        "pixelMain", _
        %EMT_TRANSPARENT_ADD_COLOR, _
        CODEPTR(CallbackShader), CODEPTR(CallbackShaderMaterial))

    ELSE
        shad = CreateShaderHighLevel("media/opengl.vert", _
        "vertexMain", _
        "media/opengl.frag", _
        "pixelMain", _
        %EMT_SOLID, _
        CODEPTR(CallbackShader), _
        CODEPTR(CallbackShaderMaterial))

        shad2 = CreateShaderHighLevel("media/opengl.vert", _
        "vertexMain", _
        "media/opengl.frag", _
        "pixelMain", _
        %EMT_TRANSPARENT_ADD_COLOR, _
        CODEPTR(CallbackShader), _
        CODEPTR(CallbackShaderMaterial))

    END IF


    ' Create Skybox
    DIM sky AS EntityNode
    sky = CreateSkybox(LoadTexture("media/up.jpg"), _
        LoadTexture("media/dn.jpg"), _
        LoadTexture("media/lf.jpg"), _
        LoadTexture("media/rt.jpg"), _
        LoadTexture("media/ft.jpg"), _
        LoadTexture("media/bk.jpg"), %NULL)



    '-----------------------------------------
    ' add cube
    DIM cube0 AS EntityNode
    cube0 = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    PositionNode(cube0, -1,-1,1)
    LoadTextureNode(cube0, "media/wall.jpg", 0, 0)
    MaterialFlagNode(cube0, %EMF_LIGHTING, %False)


    '-----------------------------------------
    ' add second cube
    DIM cube AS EntityNode
    cube = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    PositionNode(cube, 0,-1.3,0)
    LoadTextureNode(cube, "media/wall.jpg", 0, 0)
    MaterialFlagNode(cube, %EMF_LIGHTING, %False)
    MaterialTypeNode(cube, shad)

    '-----------------------------------------
    ' add third cube
    DIM cube2 AS EntityNode
    cube2 = CreateEntityNode(obj2, 0, 0, 0, %NULL)
    PositionNode(cube2, 1,-1.3,1)
    LoadTextureNode(cube2, "media/wall.jpg", 0, 0)
    MaterialFlagNode(cube2, %EMF_LIGHTING, %False)
    MaterialTypeNode(cube2, shad)







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


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

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


        TurnNode(cube0, 0,0.5,0, 0)
        TurnNode(cube, 0,0.5,0, 0)
        TurnNode(cube2, 0,0.5,0, 0)



        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        NX3_DrawText(pbfont, "FPS  as  " + TRIM$(STR$(FPS())), 10, 25, 0, 0, &h0ffffffff)
        NX3_DrawText(pbfont, "Primitives as  "+ TRIM$(STR$(PrimitiveCountDrawn())), 10, 45, 0, 0, &h0ffffffff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION


SUB CallbackShaderMaterial CDECL(BYVAL pbmat AS NMaterial)

END SUB

' ShaderCallback as
' this procedure call at the each render pass.
' it is this area which will provide the data necessary
' For the shader run.
SUB CallbackShader CDECL(BYVAL services AS NMaterialServices,  BYVAL userData AS LONG)

    DIM mvp(17) AS SINGLE
    DIM invWorld(17) AS SINGLE
    DIM worldViewProj(17) AS SINGLE
    DIM ppos(4) AS SINGLE
    DIM pbcol(4) AS SINGLE
    DIM world(17) AS SINGLE


    NX3_GetWorldTransform(invWorld(0))
    Matrix_Inverse(invWorld(0), invWorld(0))
    VertexShaderConstantNMaterialServices(services, "mInvWorld",  invWorld(0),  16)

    'set clip matrix
    GetProjectionTransform(worldViewProj(0))
    GetViewTransform(mvp(0))
    Matrix_Mul(worldViewProj(0), worldViewProj(0), mvp(0))
    NX3_GetWorldTransform(mvp(0))
    Matrix_Mul(worldViewProj(0), worldViewProj(0), mvp(0))
    VertexShaderConstantNMaterialServices(services, "mWorldViewProj",  worldViewProj(0),  16)

    ' set camera position
    NodePosition(cam, ppos(0))
    VertexShaderConstantNMaterialServices(services, "mLightPos", ppos(0),  3)

    ' set light color
    pbcol(0)=0.0
    pbcol(1)=1.0
    pbcol(2)=1.0
    pbcol(3)=0.0
    VertexShaderConstantNMaterialServices(services, "mLightColor", pbcol(0),  4)
    ' set transposed world matrix
    NX3_GetWorldTransform(world(0))

    Matrix_Transposed(world(0), world(0))
    VertexShaderConstantNMaterialServices(services, "mTransWorld",  world(0),  16)

END SUB
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  203 as   FIRST POSTPROCESSING TEST.
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------

' Includes libraries
#INCLUDE "N3xtD.bi"

DECLARE SUB CallbackShader CDECL(BYVAL services AS NMaterialServices,BYVAL  userData AS INTEGER)
DECLARE SUB EffectRender()


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


    DIM shaderparameters(7) AS SINGLE
    DIM video AS INTEGER
    video = %DEVICE_TYPES.EDT_DIRECT3D9


    ChangeWorkingDirectory("media")


    '-----------------------------------
    ' add in memory management system a zip file
    AddZipFileArchive("map-20kdm2.pk3" )


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

    '-----------------------------------
    ' Create a mesh with one of the 3D Object loaded
    DIM scene AS EntityNode
    scene = CreateEntityNode(obj, 0, 0, 0, %NULL)




    '-----------------------------------------
    ' Load And Create shader
    DIM shad AS INTEGER
    VersionShader(%VERTEXSHADER_VERSION.EVST_VS_1_1, %PIXELSHADER_VERSION.EPST_PS_2_0)

    IF video = %DEVICE_TYPES.EDT_DIRECT3D9 THEN
        shad = CreateShaderHighLevel(_
            "Shaders/PP_DX_Vertex.fx",_
            "main", _
            "Shaders/PP_DX_Invert.fx", _
            "main", _
            %EMT_SOLID, CODEPTR(CallbackShader), _
            %Null)

    ELSE
        shad = CreateShaderHighLevel(_
            "Shaders/PP_GL_Vertex.fx", _
            "main", _
            "Shaders/PP_GL_Invert.fx", _
            "main", %EMT_SOLID, _
            CODEPTR(CallbackShader), _
            %Null)

        'shad = _CreateShaderHighLevel("Shaders/PP_GL_Vertex.fx","main", "Shaders/PP_GL_Bloom1.fx", "main", EMT_SOLID, @CallbackShader, Null)
        'shaderparameters(0)=0.10

        'shad = _CreateShaderHighLevel("Shaders/PP_GL_Vertex.fx","main", "Shaders/PP_GL_Bloom2.fx", "main", EMT_SOLID, @CallbackShader, Null)
        'shaderparameters(0)=0.00185

        'shad = _CreateShaderHighLevel("Shaders/PP_GL_Vertex.fx","main", "Shaders/PP_GL_Bloom3.fx", "main", EMT_SOLID, @CallbackShader, Null)
        'shaderparameters(0)=0.00185

        'shad = _CreateShaderHighLevel("Shaders/PP_GL_Vertex.fx","main", "Shaders/PP_GL_Bloom4.fx", "main", EMT_SOLID, @CallbackShader, Null)
        'shaderparameters(0)=0.98
    END IF


    '---------------------------
    ' quad plane definition
    ' define 4 vertices
    DIM pbid(6) AS GLOBAL INTEGER
    DIM vvv(9*4) AS GLOBAL SINGLE

    vvv(0) = -1  : vvv(1) = -1  : vvv(2) = 0 : vvv(3) = 0  : vvv(4) = 0 : vvv(5) = 0 : vvv(6) = &hff00ffff : vvv(7) = 0  : vvv(8) = 1
    vvv(9) = -1  : vvv(10) =  1  : vvv(11) = 0  : vvv(12) = 0  : vvv(13) = 0 : vvv(14) = 0: vvv(15) = &hff00ffff : vvv(16) = 0  : vvv(17) = 0
    vvv(18) =  1  : vvv(19) =  1  : vvv(20) = 0  : vvv(21) = 0  : vvv(22) = 0 : vvv(23) = 0: vvv(24) = &hff00ffff : vvv(25) = 1  : vvv(26) = 0
    vvv(27) =  1  : vvv(28) = -1  : vvv(29) = 0  : vvv(30) = 0  : vvv(31) = 0 : vvv(32) = 0: vvv(33) = &hff00ffff : vvv(34) = 1  : vvv(35) = 1
    ' define 6 indices, For two triangles
    pbid(0) = 0 : pbid(1) = 1 : pbid(2) = 2
    pbid(3) = 0 : pbid(4) = 2 : pbid(5) = 3


    ' texture render definition
    DIM firstmap AS NTexture
    firstmap = CreateRenderTargetTexture( 512, 512, %ECF_UNKNOWN)
    'dim secondmap as NTexture = Null
    ' New material
    DIM material AS GLOBAL NMaterial

    material = CreateMaterial(%NULL)
    FlagMaterial( material, %EMF_WIREFRAME, %False)
    FlagMaterial( material, %EMF_LIGHTING, %False)
    TextureMaterial(material, 0, firstmap)
    '_TextureMaterial(material, 1, secondmap)
    FlagMaterial(material, %EMF_TEXTURE_WRAP, %ETC_CLAMP)
    TypeMaterial(material, shad)



    '-----------------------------------
    ' Create And position  camera
    DIM cam AS CameraNode
    cam = CreateCameraFPS(80.0, 0.1, 1.0, BYVAL %NULL, 0, %False, %False, %NULL)
    PositionNode(cam, 726, 724, 330)
    TargetCamera(cam, 800,730,400)




    ' ---------------------------------------
    '           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)
        ' element of scene render
        RenderTarget( firstmap , %True,  %True,  &h0ff660000)
        DrawScene()

        ' effect render
        RenderTarget( %Null , %True,  %True,  0)
        ' render effect
        EffectRender()

        EndScene()


    WEND
    ' end
    FreeEngine()

END FUNCTION

'--------------------------------
' effect render procedure
SUB EffectRender()
    SetMaterial(material)
    '_DrawIndexedTriangleList(varptr(vvv(0)), 4, Varptr(id(0)),  2)
    DrawIndexedTriangleList(vvv(0), 4, pbid(0),  2)
END SUB


'--------------------------------
' ShaderCallback as
' this procedure call at the each render pass.
' it is this area which will provide the data necessary
' For the shader run.
SUB CallbackShader CDECL(BYVAL services AS NMaterialServices,  BYVAL userData AS INTEGER)
  DIM text1 AS SINGLE, text2 AS SINGLE

  ' with Bloom process as
  '_PixelShaderConstantNMaterialServices(services,  "vecValues" ,  varptr(shaderparameters(0)),   8)

  IF(userData = 1) THEN
    text1 = 0
    PixelShaderConstantNMaterialServices(services, "texture1" ,  text1,   1)
    text2 = 1
    '_PixelShaderConstantNMaterialServices(services,    "texture2" ,  Varptr(text2),   1)
  END IF

END SUB
  •  

Peter Weis

#99

' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 060  :  test GUI: Button and CheckBox
'   Historique  :
'     05/05/09  19:16    TMyke
'
' ------------------------------------------------------------



'; Include files
#INCLUDE "n3xtD.bi"



'; Globales

FUNCTION PBMAIN
    DIM app AS LONG
    DIM i AS LONG
    DIM Quit AS LONG
    DIM angley AS SINGLE
    DIM anglex AS SINGLE



    ';----------------------------------------------------------
    '; 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 an 3D object

    DIM obj1 AS Mesh
    obj1 = LoadMesh("media/earth.x" , %HARDMAPPING.EHM_STATIC)

    ' create several mesh
    '-----------------------------------

    FOR i = 0 TO 3
        ' create a mesh with one of the 3D object loaded
        DIM sphere AS EntityNode
        sphere = CreateEntityNode(obj1, 0, 0, 0, %NULL)
        ' set position
        PositionNode(sphere, 3*i,0,0)
    NEXT



    '-----------------------------------
    ' load font png
    LoadFont("media/font2.bmp", %FONT_TYPE.EGDF_DEFAULT)
    DIM pbfont AS IGUIFont
    pbfont = GetFont()


    '-----------------------
    ' load Image
    DIM logo AS NTexture

    logo = LoadTexture("media/fireball.bmp")


    '-----------------------
    ' add buttons

    DIM button1 AS IGUIElement

    button1 = AddButtonGUI(20, 195, 120, 224, "text1", "", %NULL , -1)

    DIM button2 AS IGUIElement

    button2 = AddButtonGUI(20,295,120,324, "text2", "button2", %NULL , -1)
    Image_GUIButton(button2, logo)



    '-----------------------
    ' add CheckBox

    DIM check1 AS IGUICheckBox
    check1 = AddCheckBoxGUI(%True, 10, 400, 110, 500, "checkbox", %NULL, -1)



    '-----------------------------------------
    ' create first  camera

    DIM cam AS CameraNode
    cam = CreateCamera(%NULL)

    PositionNode(cam, 6,0,-10)

    ' ---------------------------------------
    '           main loop
    ' ---------------------------------------
    WHILE Quit=0

        ' ------------------------------------------------
        ' move camera with dir key and mouse (left click)

        IF GetMouseEvent(%MOUSE_EVENT.MOUSE_BUTTON_LEFT) THEN
            angley =  GetDeltaMouseX(0) / 4.0
            anglex =  GetDeltaMouseY(0) / 4.0
            TurnNode(cam, anglex, angley, 0, 0)
        END IF


        '; if Escape Key, exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF

        ' ---------------
        '      Render
        ' ---------------
        BeginScene(100,100,100, 255, 1, 1)
        DrawScene()
        DrawGUI()
        NX3_DrawText(pbfont, "Button1 state: "+TRIM$(STR$(GUIButton_Pressed(button1))), 10,10,0,0, &H0ff00ffff)
        NX3_DrawText(pbfont, "Button2 state: "+TRIM$(STR$(GUIButton_Pressed(button2))), 10,30,0,0, &H0ff00ffff)
        NX3_DrawText(pbfont, "GUI CheckBox:  "+TRIM$(STR$(GUICheckBox_Check(check1))), 10,50,0,0, &H0ff00ffff)
        EndScene()

    WEND
    ' end
    FreeEngine()
END FUNCTION

  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 061  :  GUI Test: TextStatic, EditBox and Cursor Control
'   Historique  :
'     07/05/09  19:16    TMyke
'
' ------------------------------------------------------------




' Include files
    #INCLUDE ONCE "windows.inc"
    #INCLUDE "n3xtD.bi"


FUNCTION PBMAIN

    DIM app AS DWORD
    DIM Quit AS LONG
    DIM i AS LONG
    DIM pbres AS STRING
    DIM angley AS SINGLE
    DIM anglex AS SINGLE


    '----------------------------------------------------------
    ' 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 an 3D object
    DIM obj1 AS GLOBAL Mesh
    obj1 = LoadMesh("media/earth.x", %HARDMAPPING.EHM_STATIC)

    ' create several mesh
    '-----------------------------------
    FOR i = 0 TO 3
        ' create a mesh with one of the 3D object loaded
        DIM sphere AS EntityNode
        sphere = CreateEntityNode(obj1, 0, 0, 0, %NULL)
        ' set position
        PositionNode(sphere, 3*i,0,0)
    NEXT



    '-----------------------------------
    ' load font png
    LoadFont("media/font2.bmp", %FONT_TYPE.EGDF_DEFAULT)
    DIM pbfont AS GLOBAL IGUIFont
    pbfont = GetFont()

    '-----------------------
    ' zone text
    DIM pbtext AS IGUIStaticText
    pbtext = AddStaticText("text text text",  120, 10, 450, 230, %True, %True, %False, %NULL, -1)
    BackgroundColor_GUIText(pbtext, &H055808099)



    '-----------------------
    ' edit box
    DIM editbox AS IGUIEditBox
    editbox = AddEditBox("essais", 20, 335, 260, 400, %True, %Null, -1)
    Multiline_GUIEditBox(editbox, %True)
    AutoScroll_GUIEditBox(editbox, %true)
    OverrideColor_GUIEditBox(editbox, &H0ffff0000)

    ' set alignment of text inside the EditBox
    TextAlignment_GUIEditBox(editbox, %TEXT_ALIGN.EGUIA_UPPERLEFT, %TEXT_ALIGN.EGUIA_SCALE)





    '-----------------------------------------
    ' create first  camera
    DIM cam AS GLOBAL CameraNode
    cam = CreateCamera(%Null)
    PositionNode(cam, 6,0,-10)


    ' ---------------------------------------
    '           main loop
    ' ---------------------------------------

    GLOBAL posx AS LONG
    GLOBAL posy AS LONG

    WHILE Quit=0

        CursorControlPosition(posx, posy)

        IF GetKeyUp(%KEY_CODE.KEY_SPACE) THEN
            ';_PositionCursorControl( 400, 300)
            TextGUI(pbtext, "other" + CHR$(13) + " text area")
        END IF

        IF GetKeyUp(%KEY_CODE.KEY_KEY_T) THEN
            pbres = CONST2STR(BYVAL GUIText(editbox))
            TextGUI(pbtext, (pbres))
        END IF


        ' move camera with dir key and mouse (left click)
        IF GetKeyDown(%KEY_CODE.KEY_KEY_F) THEN
            MoveGUI(pbtext, 1,0)
        END IF

        IF GetKeyDown(%KEY_CODE.KEY_KEY_G) THEN
            MoveGUI(pbtext, 0,1)
        END IF


        ' ------------------------------------------------
        ' move camera with dir key and mouse (left click)
        IF GetMouseEvent(%MOUSE_EVENT.MOUSE_BUTTON_LEFT) THEN
            angley = GetDeltaMouseX(0) / 4.0
            anglex = GetDeltaMouseY(0) / 4.0
            TurnNode(cam, anglex, angley,0, 0)
        END IF



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


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(100, 100, 100, 255, 1, 1)
        DrawScene()
        DrawGUI()

        NX3_DrawText(pbfont, "Press SPACE key to change Text inside TextZone",  10,600-20,0,0, &H0ff00ffff)
        NX3_DrawText(pbfont, "Press T key to get and draw in TextZone the EditBox Text",  10,600-40,0,0, &H0ff00ffff)
        NX3_DrawText(pbfont, "Cursor Position: "+TRIM$(STR$(posx))+"  " + TRIM$(STR$(posy)),  10,600-60,0,0, &H0ff00ffff)
        NX3_DrawText(pbfont, "Press F/G key for move TextStatic Zone",  10,600-80,0,0, &H0ff00ffff)
        EndScene()

    WEND
    ' end
    FreeEngine()
END FUNCTION


new Include
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 062  :  TestGUI with FileOpenDialog and ContextMenu
'   Historique  :
'     15/05/09  19:16    TMyke
'
' ------------------------------------------------------------


#INCLUDE "windows.inc"
#INCLUDE "n3xtD.bi"

DECLARE SUB ContextMenu CDECL()
DECLARE SUB pbGUIEventCallBack CDECL(BYVAL eventGUI AS LONG, BYVAL idGUI AS LONG,  BYVAL GUIElement AS IGUIElement)

FUNCTION PBMAIN
    ' Globales
    DIM app AS LONG
    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 an 3D object
    DIM obj1 AS GLOBAL Mesh
    obj1 = LoadMesh("media/earth.x", %HARDMAPPING.EHM_STATIC)

    ' create several mesh
    '-----------------------------------
    ' create a mesh with one of the 3D object loaded
    DIM sphere AS EntityNode
    sphere = CreateEntityNode(obj1, 0, 0, 0, %NULL)




    '-----------------------------------
    ' load font png
    LoadFont("media/font2.bmp", %FONT_TYPE.EGDF_DEFAULT)

    DIM pbfont AS IGUIFont
    pbfont = GetFont()





    '-----------------------
    ' add buttons

    DIM button1 AS IGUIElement
    button1 = AddButtonGUI(20,20,120,45, "fileselector","button1",  %Null, 1  )

    DIM button2 AS IGUIElement
    button2 = AddButtonGUI(120,20,220,45, "contextMenu", "button2",  %Null, 2  )




    '-----------------------
    ' ADD COMBOBOX
    DIM combo AS IGUIComboBox
    combo = AddComboBoxGUI( 10,  300,  150,  320, %Null, 10)

    AddItem_GUIComboBox(combo, "one")
    AddItem_GUIComboBox(combo, "two")
    AddItem_GUIComboBox(combo, "tree")
    AddItem_GUIComboBox(combo, "four")




    '------------------------------------------------------------------
    ' SET CALLBACK procedure FOR EVENT interpret
    GUIEventCallBack(CODEPTR (pbGUIEventCallBack))


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

    ' ---------------------------------------
    '           MAIN LOOP
    ' ---------------------------------------
    DIM pbres AS GLOBAL STRING
    pbres ="a"
    DIM tt AS GLOBAL STRING



    DIM dial AS IGUIFileOpenDialog

    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()
        DrawGUI()
        EndScene()

    WEND
    ' END
    FreeEngine()

END FUNCTION

'------------------------------------------------------------------
' CALLBACK procedure FOR EVENT interpret
SUB pbGUIEventCallBack CDECL(BYVAL eventGUI AS LONG, BYVAL pbidGUI AS LONG, BYVAL GUIElement AS IGUIElement)
    LOCAL pbitem AS LONG
    LOCAL idx AS IGUIContextMenu
    '---------------------------------------------
    ' DISPLAY the ComboxBox SELECT
    IF eventGUI = %GUI_EVENT_TYPE.EGET_COMBO_BOX_CHANGED THEN
        pbitem = GUIComboBox_Selected(GUIElement)
        MSGBOX CONST2STR(BYVAL GUIComboBox_Item(GUIElement, pbitem))
    END IF
    '---------------------------------------------
    ' buttons test EVENTS
    IF eventGUI = %GUI_EVENT_TYPE.EGET_BUTTON_CLICKED THEN
        IF pbidGUI = 2 THEN            ' ContextMenu buttom
            ContextMenu()
        ELSE
            AddFileOpenDialogGUI( "title", %True, %Null, 100)
        END IF
    END IF

    '---------------------------------------------
    ' END fileOpenDialog AND DISPLAY the filename
    IF eventGUI = %GUI_EVENT_TYPE.EGET_FILE_SELECTED THEN
        '; GET curent GUIElement detected
        MSGBOX CONST2STR(BYVAL GUIFileOpenDialog_FileName(GUIElement))
    END IF

    '---------------------------------------------
    ' CONTEXT MENU interpret
    IF eventGUI = %GUI_EVENT_TYPE.EGET_MENU_ITEM_SELECTED THEN
        idx = GUIContexMenu_ItemSelected(GUIElement)
        'Debug idx
        MSGBOX CONST2STR(BYVAL GUIContexMenu_ItemText(GUIElement, idx))
    END IF


END SUB


SUB ContextMenu CDECL()
    DIM pbmenu AS IGUIContextMenu
    DIM pbsubmenu AS IGUIContextMenu

    pbmenu = AddContexMenuGUI(210, 150, 350,  250, %Null, 49)
    AddItem_GUIContexMenu(pbmenu, "text1", 50, %True, %False, %False)
    AddItem_GUIContexMenu(pbmenu, "text2", 51, %True, %False, %False)
    AddSeparator_GUIContexMenu(pbmenu)
    AddItem_GUIContexMenu(pbmenu, "text3", 52, %True, %True, %False)
    AddItem_GUIContexMenu(pbmenu, "text4", 55, %True, %False, %False)

    ' SUB MENU
    pbsubmenu = GUIContexMenu_SubMenu(pbmenu, 3)
    AddItem_GUIContexMenu(pbsubmenu, "subText31", 53, %True, %False, %True)
    AddItem_GUIContexMenu(pbsubmenu, "subText32", 54, %True, %False, %True)

END SUB


New Include
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 063  :  test GUI InOutFader
'   Historique  :
'     15/05/09  19:16    TMyke
'
' ------------------------------------------------------------



'; Include files
#INCLUDE "n3xtD.bi"


FUNCTION PBMAIN
    ' Globales
    DIM app     AS LONG
    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 an 3D object
    DIM obj1 AS Mesh
    OBJ1 = LoadMesh("media/earth.x", %HARDMAPPING.EHM_STATIC)

    ' create several mesh
    '-----------------------------------
    ' create a mesh with one of the 3D object loaded
    DIM sphere AS EntityNode
    sphere = CreateEntityNode(obj1, 0, 0, 0, %NULL)



    '-----------------------------------
    ' load font png
    LoadFont("media/font2.bmp", %FONT_TYPE.EGDF_DEFAULT)
    DIM pbfont AS IGUIFont
    pbfont = GetFont()


    '-----------------------
    ' create GUI Image


    DIM logo AS NTexture
    logo = LoadTexture("media/logo_320.png")

    DIM img AS IGUIImage
    img = AddImageGUI(logo, 0,15, %True, "text", %Null, -1)


    '-----------------------
    ' create InOutFader
    DIM pbrect(3) AS GLOBAL LONG
    pbrect(0) = 0
    pbrect(1) = 0
    pbrect(2) = 320
    pbrect(3) = 200

    DIM pbinout AS LONG
    pbinout = AddInOutFaderGUI(pbrect(0),  BYVAL %Null, -1)
    Color_GUIInOutFader(pbinout, &H00646464)





    '-----------------------------------------
    ' create first  camera
    DIM cam AS CameraNode
    cam = CreateCamera(%NULL)

    PositionNode(cam, 6,0,-10)

    ' ---------------------------------------
    '           main loop
    ' ---------------------------------------
    WHILE Quit = %Null

        IF GetKeyUp(%KEY_CODE.KEY_KEY_I) THEN
            FadeIn_GUIInOutFader(pbinout, 1500)
        END IF

        IF GetKeyUp(%KEY_CODE.KEY_KEY_O) THEN
            FadeOut_GUIInOutFader(pbinout, 1500)
        END IF


        '; if Escape Key, exit
        IF GetKeyDown(%KEY_CODE.KEY_ESCAPE) THEN
            Quit=1
        END IF


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(100, 100, 100, 255, 1, 1)
        DrawScene()
        DrawGUI()
        NX3_DrawText(pbfont, "Press O, and after I Keys",  10,510,0,0, &H0ff00ffff)
        EndScene()

    WEND
    ' end
    FreeEngine()
END FUNCTION


New Include
  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 065  :  TestGUI with Menu
'   Historique  :
'     15/05/09  19:16    TMyke
'
' ------------------------------------------------------------




#INCLUDE "n3xtD.bi"

DECLARE SUB pbGUIEventCallBack CDECL(BYVAL eventGUI AS LONG, BYVAL idGUI AS LONG,  BYVAL GUIElement AS IGUIElement)

FUNCTION PBMAIN

    ' Globales
    DIM app AS LONG
    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 an 3D object

    DIM obj1 AS GLOBAL Mesh
    obj1 = LoadMesh("media/earth.x", %HARDMAPPING.EHM_STATIC)

    ' create several mesh
    '-----------------------------------
    ' create a mesh with one of the 3D object loaded
    DIM sphere AS EntityNode
    sphere = CreateEntityNode(obj1, 0, 0, 0, %NULL)



    '-----------------------------------
    ' load font png
    LoadFont("media/font2.bmp", %FONT_TYPE.EGDF_DEFAULT)

    DIM pbfont AS IGUIFont
    pbfont = GetFont()


    '--------------------------------------------------------
    ' create menu

    DIM pbmenu  AS GLOBAL IGUIContextMenu
    DIM submenu AS GLOBAL IGUIContextMenu
    pbmenu = AddMenuGUI(%NULL, -1)

    ' main menu item
    AddItem_GUIContexMenu(pbmenu, "menu1", -1, %True, %True, %False)
    AddItem_GUIContexMenu(pbmenu, "menu2", -1, %True, %True, %False)
    AddItem_GUIContexMenu(pbmenu, "menu3", -1, %True, %True, %False)
    AddItem_GUIContexMenu(pbmenu, "menu4", -1, %True, %True, %False)

    ' sub menu 0

    submenu = GUIContexMenu_SubMenu(pbmenu, 0)
    AddItem_GUIContexMenu(submenu, "submenu01", 501, %True, %False, %False)
    AddItem_GUIContexMenu(submenu, "submenu02", 502, %True, %False, %False)
    '; sub menu 1
    submenu = GUIContexMenu_SubMenu(pbmenu, 1)
    AddItem_GUIContexMenu(submenu, "submenu11", 511, %True, %False, %False)
    AddItem_GUIContexMenu(submenu, "submenu12", 512, %True, %False, %False)
    '; sub menu 2
    submenu = GUIContexMenu_SubMenu(pbmenu, 2)
    AddItem_GUIContexMenu(submenu, "submenu21", 521, %True, %False, %False)
    AddItem_GUIContexMenu(submenu, "submenu22", 522, %True, %False, %False)
    AddItem_GUIContexMenu(submenu, "submenu23", 523, %True, %False, %False)
    AddItem_GUIContexMenu(submenu, "submenu23", 524, %True, %False, %False)
    '; sub menu 3
    submenu = GUIContexMenu_SubMenu(pbmenu, 3)
    AddItem_GUIContexMenu(submenu, "subText31", 531, %True, %False, %True )
    AddSeparator_GUIContexMenu(submenu)
    AddItem_GUIContexMenu(submenu, "subText32", 532, %True, %False, %False)


    '------------------------------------------------------------------
    ' set callback procedure for event interpret
    GUIEventCallBack(CODEPTR (pbGUIEventCallBack))


    '-----------------------------------------
    ' create first  camera
    DIM cam AS GLOBAL CameraNode
    cam = CreateCamera(%NULL)
    PositionNode(cam, 0,0,-7)


    ' ---------------------------------------
    '           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()
        DrawGUI()
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION

';------------------------------------------------------------------
'; callback procedure for event interpret

SUB pbGUIEventCallBack(BYVAL eventGUI AS LONG, BYVAL pbidGUI AS LONG,  BYVAL GUIElement AS IGUIElement)
    LOCAL idx AS LONG
    IF  eventGUI = %GUI_EVENT_TYPE.EGET_MENU_ITEM_SELECTED THEN
        idx = GUIContexMenu_ItemSelected(GUIElement)
        ztrace TRIM$(STR$(idx))
        ztrace BYVAL GUIContexMenu_ItemText(GUIElement, idx)
    END IF

END SUB



  •  

Peter Weis


' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 066  :  TestGUI with ScrollBar, tabControl ,spinbox, etc...
'   Historique  :
'     20/05/09  19:16    TMyke
'
' ------------------------------------------------------------



'
#INCLUDE "n3xtD.bi"

DECLARE SUB pbGUIEventCallBack CDECL (BYVAL eventGUI AS LONG, BYVAL idGUI AS LONG,  BYVAL GUIElement AS IGUIElement)

FUNCTION PBMAIN

    ' Globales
    DIM app AS LONG
    DIM Quit AS LONG
    DIM i 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 an 3D object

    DIM obj1 AS Mesh
    obj1 = LoadMesh("media/earth.x", %HARDMAPPING.EHM_STATIC)

    ' create several mesh
    '-----------------------------------
    ' create a mesh with one of the 3D object loaded
    DIM sphere AS EntityNode
    sphere = CreateEntityNode(obj1, 0, 0, 0, %NULL)



    '-----------------------------------
    ' load font png
    LoadFont("media/font2.bmp", %FONT_TYPE.EGDF_DEFAULT)
    DIM pbfont AS GLOBAL IGUIFont
    pbfont = GetFont()




    '--------------------------------------------------------
    ' create scrollbar
    AddScrollBarGUI(%True, 10,80,150,95, %NULL, -1)
    AddScrollBarGUI(%False, 165 ,80, 180, 200, %NULL, -1)


    '--------------------------------------------------------
    ' create spinbox

    DIM spinbox AS IGUISpinBox
    spinbox = AddSpinBoxGUI("text", 20, 300, 250, 325, %True, BYVAL %NULL, -1)
    DecimalPlaces_GUISpinBox(spinbox, 3)


    '--------------------------------------------------------
    ' create tabcontrol
    DIM tabcontrol AS IGUITabControl
    tabcontrol = AddTabControlGUI(380,15,750,350, %False, %True, BYVAL %NULL, -1)
    ' add tab 1

    DIM tab1 AS IGUITab
    tab1 = AddTab_GUITabControl(tabcontrol, "caption1", -1)

    ' add tab 2
    DIM tab2 AS IGUITab
    tab2 = AddTab_GUITabControl(tabcontrol, "caption2", -1)

    DrawBackground_GUITab(tab2, %True)
    BackgroundColor_GUITab(tab2, &H0ffFF5500)
    TextColor_GUITab(tab2, &H0ffFF5500)


    ' zone text in tab1
    AddStaticText("n3xtDn3xtDn3xtDn3xtDn3xtD",  10,20,190,45, %False, %False, %False, tab1, -1)
    ' add buttons in tab1

    AddButtonGUI(20,150,120,170, "button1","button1",  tab1, -1)


    ' zone text in Tab2
    AddStaticText("PowerBASICPowerBASICPowerBASIC",  10,20,190,45, %False, %False, %False, tab2, -1)
    AddScrollBarGUI( %True, 10,80,150,95, tab2, -1)


    '--------------------------------------------------------
    ' create table

    DIM table AS IGUITable
    table = AddTableGUI(20, 350, 214, 580, %True, BYVAL %NULL, -1)
    AddColumn_GUITable(table, "column1", -1)
    AddColumn_GUITable(table, "column2", -1)
    AddColumn_GUITable(table, "column3", -1)

    FOR i = 0 TO 7
        AddRow_GUITable(table,  i )
    NEXT
    CellText_GUITable(table,1,1, "text1", &h0ffffffff)
    CellText_GUITable(table,1,2, "text2", &h0ffffffff)
    CellText_GUITable(table,0,2, "text3", &h0ffffffff)
    CellText_GUITable(table,4,0, "text4", &H0ffff00ff)


    ' change window caption color
    DIM skin AS IGUISkin
    skin = SkinGUI_Curent()
    Color_GUISkin(skin, %APP_FLAG.EGDC_ACTIVE_CAPTION , &H0ffffff00)

    ' create window

    DIM win AS IGUIWindow
    win = AddWindowGUI(300, 400,  550, 590, "PressSPACE bar", %FALSE, BYVAL %NULL, -1)
    ' add buttons in windows
    AddButtonGUI(20,100,80,120, "button1","button1",  win, -1)



    '------------------------------------------------------------------
    ' set callback procedure for event interpret
    GUIEventCallBack(CODEPTR (pbGUIEventCallBack))


    '-----------------------------------------
    ' create first  camera
    DIM cam AS CameraNode
    cam = CreateCamera(BYVAL %NULL)
    PositionNode(cam, 0,0,-7)

    ' ---------------------------------------
    '           main loop
    ' ---------------------------------------

    WHILE Quit = 0

        ' if Escape Key, exit
        IF GetKeyUp(%KEY_CODE.KEY_SPACE) THEN
            AddMessageBoxGUI("Messagebox", "test message", %True, %EMBF_OK, BYVAL %NULL, -1)
        END IF


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

        ' ---------------
        '      Render
        ' ---------------
        BeginScene(100, 100, 100, 255, 1, 1)
        DrawScene()
        DrawGUI()
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION

'------------------------------------------------------------------
' callback procedure for event interpret
SUB pbGUIEventCallBack CDECL(BYVAL eventGUI AS LONG, BYVAL pbidGUI AS LONG,  BYVAL GUIElement AS IGUIElement)
    DIM idx AS LONG
    DIM ids AS SINGLE
    DIM pbrow AS LONG
    DIM pbcolumn AS LONG

    IF eventGUI = %GUI_EVENT_TYPE.EGET_SCROLL_BAR_CHANGED THEN
        idx = GUIScrollBar_Pos(GUIElement)
        ztrace STR$(idx)
    END IF

    IF eventGUI = %GUI_EVENT_TYPE.EGET_SPINBOX_CHANGED THEN
        ids =  GUISpinBox_Value(GUIElement)
        ztrace STR$(ids)
    END IF

    IF eventGUI = %GUI_EVENT_TYPE.EGET_TABLE_CHANGED THEN
        pbrow = GUITable_Selected(GUIElement)
        pbcolumn = GUITable_ActiveColumn(GUIElement)
        ztrace  BYVAL GUITable_CellText(GUIElement, pbrow, pbcolumn )
    END IF


END SUB





New Include
  •