Author Topic: N3xtD - Free 3D engine  (Read 69303 times)

0 Members and 1 Guest are viewing this topic.

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine TestGUI load GUI Elements..
« Reply #105 on: October 15, 2011, 08:00:50 PM »
Code: [Select]
' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 067  :  TestGUI load GUI Elements..
'   Historique  :
'     22/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 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 first  camera
    DIM cam AS CameraNode
    cam = CreateCamera(BYVAL %NULL)
    PositionNode(cam, 0,0,-7)


    DIM flag AS LONG
    Flag = %True
    ' ---------------------------------------
    '           main loop
    ' ---------------------------------------
    WHILE Quit = 0


        ' if Escape Key, exit
        IF GetKeyUp(%KEY_CODE.KEY_SPACE) AND flag THEN
            Load_GUI( "media/guiTest.gui", BYVAL %Null)
            flag = %False
            ' set callback procedure for event interpret
            GUIEventCallBack(CODEPTR (pbGUIEventCallBack))
        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 Bar to load GUI elements",  550,10,0,0, &Hff00ffff)
        EndScene()


    WEND
    ' end
    FreeEngine()
END FUNCTION

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

'------------------------------------------------------------------
' 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)
        IF pbcolumn >= 0 THEN
            ztrace  BYVAL GUITable_CellText(GUIElement, pbrow, pbcolumn )
        END IF
    END IF


END SUB

New Include
« Last Edit: October 15, 2011, 11:32:22 PM by Peter Weis »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine TestGUI with Menu and toolbar
« Reply #106 on: October 16, 2011, 09:45:45 PM »
Code: [Select]
' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 068  :  TestGUI with Menu and toolbar
'   Historique  :
'     10/06/09  19:16    TMyke
'
' ------------------------------------------------------------



#INCLUDE "n3xtD.bi"

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

GLOBAL nullstring AS ASCIZ * 10

FUNCTION PBMAIN

    ' Globales
    DIM app AS LONG PTR
    DIM Quit AS LONG
    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



    '-----------------------------------
    ' 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 menu

    DIM pbmenu AS IGUIContextMenu
    DIM submenu AS IGUIContextMenu
    pbmenu = AddMenuGUI(BYVAL %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)


    '------------------------------------------------
    ' create tool bar
    DIM tb AS IGUIToolBar
    tb = AddToolBarGUI(BYVAL %NULL, -1)
    DIM pbimage AS NTexture
    pbimage = LoadTexture("media/open.png")

    AddButton_GUIToolBar(tb, nullstring, "Open a model", pbimage,  BYVAL %Null, %False, %True, 1000)

    pbimage = LoadTexture("media/tools.png")
    AddButton_GUIToolBar(tb, nullstring, "Open Toolset", pbimage,  BYVAL %Null, %False, %True, 1001)

    pbimage = LoadTexture("media/zip.png")
    AddButton_GUIToolBar(tb, nullstring, "Zip Archive", pbimage,  BYVAL %Null, %False, %True, 1002)

    pbimage = LoadTexture("media/help.png")
    AddButton_GUIToolBar(tb, nullstring, "Help menu", pbimage,  BYVAL %Null, %False, %True, 1003)

    DIM pbcolor AS DWORD

    '; disable alpha of the menu items
    FOR i = 0 TO 2

        pbcolor = GUIColor( i)
        pbcolor = (pbcolor OR  &H0ff000000)
        ColorGUI(i, pbcolor)
    NEXT



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


    '-----------------------------------------
    ' create first  camera
    DIM cam AS GLOBAL CameraNode
    cam = CreateCamera(BYVAL %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 CDECL(BYVAL eventGUI AS LONG, BYVAL pbidGUI AS LONG,  BYVAL GUIElement AS IGUIElement)

    DIM idx AS LONG

    IF eventGUI= %GUI_EVENT_TYPE.EGET_MENU_ITEM_SELECTED THEN
        idx = GUIContexMenu_ItemSelected(GUIElement)
        ztrace(STR$(idx))
        ztrace(BYVAL GUIContexMenu_ItemText(GUIElement, idx))
    END IF

    IF eventGUI = %GUI_EVENT_TYPE.EGET_BUTTON_CLICKED THEN
        ztrace STR$(pbidGUI)
    END IF

END SUB





New Include
« Last Edit: October 16, 2011, 09:47:16 PM by Peter Weis »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine Skin GUI test 1
« Reply #107 on: October 17, 2011, 07:14:25 PM »
Code: [Select]
' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 069  :  Skin GUI test 1
'   Historique  :
'     07/08/09  19:16    TMyke
'
' ------------------------------------------------------------



' Include files
#INCLUDE "n3xtD.bi"

GLOBAL nullstr AS ASCIZ * 10



' Globales
FUNCTION PBMAIN
    DIM app AS DWORD PTR
    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




    ' SET the curent folder
    SetCurrentDirectory("media/")

    '-----------------------------------
    ' LOAD an 3D OBJECT
    DIM obj1 AS GLOBAL Mesh
    obj1 = LoadMesh("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)

    ' CREATE Skybox

    DIM sky AS GLOBAL EntityNode
    sky = CreateSkybox(LoadTexture("up.jpg"), _
        LoadTexture("dn.jpg"), _
        LoadTexture("lf.jpg"), _
        LoadTexture("rt.jpg"), _
        LoadTexture("ft.jpg"), _
        LoadTexture("bk.jpg"), _
        BYVAL %NULL)




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


    '-----------------------------------------------
    '-----------------------------------------------
    '  GUI AREA

    '-----------------------------------
    ' LOAD FONT png
    LoadFont("ui1/fontlucida.png", %FONT_TYPE.EGDF_DEFAULT)
    ' LOAD AND CREATE Skin GUI

    DIM skin AS CCustomGUISkin
    skin = CustomSkinGUI("ui1/guiskin.cfg")

    ' SET differents Skin COLOR
    Color_GUISkin(skin, %APP_FLAG.EGDC_3D_FACE  , &H0eecccccc)
    Color_GUISkin(skin, %APP_FLAG.EGDC_ACTIVE_CAPTION ,  &H0ff000000)
    Color_GUISkin(skin, %APP_FLAG.EGDC_BUTTON_TEXT    ,  &H0ff000000)




    '-----------------------------------------------
    ' some gadget FOR test

    DIM win AS IGUIWindow
    win = AddWindowGUI(60,60,260,260, "SkinGUI", %False, BYVAL %NULL, 1)
    AddButtonGUI(10,40,80,65, "Button", nullstr, win, -1)

    AddStaticText("Checkbox",  30, 130, 120, 150, %False, %True, %False, win, -1)


    AddButtonGUI(700,40,760,75, "Quit", "quit!", BYVAL %NULL, -1)


    DIM editbox AS IGUIEditBox
    editbox = AddEditBox("Edit Box", 310,120,460,250, %True, BYVAL %Null , -1)
    Multiline_GUIEditBox(editbox, %True)
    AutoScroll_GUIEditBox(editbox, %True)
    OverrideColor_GUIEditBox(editbox, &Hffff0000)
    ' SET alignment OF TEXT inside the EditBox
    TextAlignment_GUIEditBox(editbox, %TEXT_ALIGN.EGUIA_UPPERLEFT, %TEXT_ALIGN.EGUIA_SCALE)


    '--------------------------------------------------------
    ' progress BAR
    DIM pbbar AS IGUIProgressBar
    pbbar = AddProgressBarGUI(60,300,260,330, BYVAL %NULL)
    Value_ProgressBarGUI(pbbar, 0.5)
    Color_GUIProgressBar(pbbar,  &Hffaaaa00)
    AutomaticText_GUIProgressBar(pbbar, "progress")

    '--------------------------------------------------------
    ' CREATE SCROLLBAR
    AddScrollBarGUI( %True, 310,80,450, 95, BYVAL %NULL, -1)

    '-----------------------
    ' ADD COMBOBOX
    DIM combo AS IGUIComboBox
    combo = AddComboBoxGUI( 480,  120,  620,  140, %Null, 10)
    AddItem_GUIComboBox(combo, "one")
    AddItem_GUIComboBox(combo, "two")
    AddItem_GUIComboBox(combo, "tree")
    AddItem_GUIComboBox(combo, "four")



    ' ---------------------------------------
    '           MAIN LOOP
    ' ---------------------------------------

    WHILE quit = 0


        ' just turn our sphere
        TurnNode(sphere, 0,0.5,0, 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()
        DrawGUI()
        EndScene()
    WEND

    ' END
    FreeEngine()
END FUNCTION

New Include
« Last Edit: October 17, 2011, 07:18:17 PM by Peter Weis »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine Test body with bridge
« Reply #108 on: October 18, 2011, 07:05:39 PM »
Code: [Select]
' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 112  :  Test body with bridge
'     23/08/09  19:16    TMyke
'
' ------------------------------------------------------------



' Include files
#INCLUDE "n3xtD.bi"


DECLARE FUNCTION CreateRope(BYVAL posx AS SINGLE, BYVAL posy AS SINGLE, BYVAL posz AS SINGLE) AS LONG
DECLARE SUB JointCallBack CDECL(BYVAL joint AS NJoint, BYVAL desc AS NewtonHingeSliderUpdateDesc)


FUNCTION PBMAIN

    '; Globales
    DIM app AS GLOBAL LONG PTR
    DIM Quit AS GLOBAL LONG
    DIM cylT AS GLOBAL EntityNode



    '----------------------------------------------------------
    ' 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 and load mesh
    DIM cubemesh AS GLOBAL Mesh
    cubemesh = CreateCubeMesh(1.0)

    '-----------------------------------------
    ' create a static base
    DIM floor AS EntityNode
    floor = CreateEntitynode(cubemesh, 0, 0, 0, %NULL)

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



    ' link all joint with the plateform base static
    DIM downNode1 AS EntityNode
    downNode1 = CreateRope( -7,-2.0,-7)
    CreateBallJoint( cylT, floor, -7, -0.5 , -7)

    DIM downNode2 AS DWORD
    downNode2 = CreateRope( -7,-2.0,7)
    CreateBallJoint(cylT, floor, -7, -0.5 , 7)

    DIM downNode3 AS DWORD
    downNode3 = CreateRope( 7,-2.0,0)
    CreateBallJoint(cylT, floor, 7, -0.5 , 0)




    '-----------------------------------------
    ' create plateforme
    DIM cube AS EntityNode
    cube = CreateEntitynode(cubemesh, 0, 0, 0, BYVAL  %NULL)
    PositionNode(cube, 0,-14,0)
    LoadTextureNode(cube, "media/metal13.jpg", 0, 0)
    ScaleNode(cube, 20,1,20)
    ' create body
    CreateBody(cube, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)

    ' create 3 link for the plateform
    CreateBallJoint(cube, downNode1, -7, -13.5 , -7)
    CreateBallJoint(cube, downNode2, -7, -13.5 , 7)
    DIM joint AS NJoint
    joint = CreateBallJoint(cube, downNode3, 7, -13.5 , 0)
    ' juste  for one link.
    UserCallbackBallJoint(joint,  BYVAL CODEPTR(JointCallBack()))


    '-----------------------------------------
    ' create first  camera
    DIM cam AS GLOBAL CameraNode
    cam = CreateCameraFPS(70,0.1, 1.0, BYVAL %NULL, 0, %False, %False, BYVAL %NULL)
    PositionNode(cam, 0,-5,-30)
    RotateNode(cam, -10,0,0)

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


    DIM camPos AS GLOBAL iVECTOR3
    DIM camDir AS GLOBAL iVECTOR3
    ' ---------------------------------------
    '           main loop
    ' ---------------------------------------

    WHILE Quit = 0

        'set a timer, a bit slower for the physics engine.
        '_TimerUpdatePhysic(100.0)

        ' shoot with cube
        IF GetKeyUp(%KEY_CODE.KEY_KEY_O) THEN
            NodePosition(cam, camPos.x)
            NodeDirection(cam, camDir.x)
            ' create mesh to shoot
            'dim cube as EntityNode
            cube = CreateEntitynode(cubemesh, 0, 0, 0, BYVAL %NULL)
            ScaleNode(cube, 2,2,2)
            LoadTextureNode(cube, "media/wcrate.bmp", 0, 0)
            PositionNode(cube, camPos.x, camPos.y, camPos.z)
            RotateNode(cube, RND(0, 180), RND(0, 180), RND(0, 180))
            CreateBody(cube, %BOX_PRIMITIVE, %True, 10.0, 0, 0, 0)
            VelocityBody(cube, camDir.x * 20, camDir.y *20, camDir.z * 20)
        END IF

        ' shoot with cube
        IF GetKeyUp(%KEY_CODE.KEY_KEY_P) THEN
            NodePosition(cam, camPos.x)
            NodeDirection(cam, camDir.x)
            ' create mesh to shoot
            'dim cube as EntityNode
            cube = CreateEntitynode(cubemesh, 0, 0, 0, BYVAL %NULL)
            ScaleNode(cube, 2,2,2)
            LoadTextureNode(cube, "media/wcrate.bmp", 0, 0)
            PositionNode(cube, camPos.x,camPos.y,camPos.z)
            RotateNode(cube, RND(0, 180), RND(0, 180), RND(0, 180))
            ' create body
            CreateBody(cube, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
            VelocityBody(cube, camDir.x*20, camDir.y*20, camDir.z*20)
        END IF






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


        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        DrawScene()
        NX3_DrawText(pbfont, "Use P Key for shoot light Cube",  10,10,0,0, &h0ff9999ff)
        NX3_DrawText(pbfont, "Use O Key for shoot heavy Cube",  10,25,0,0, &h0ff9999ff)
        EndScene()



    WEND
    ' end
    FreeEngine()

END FUNCTION

'--------------------------------------------------------------------
' create a rope with 4 Ball Joint

FUNCTION CreateRope (BYVAL posx AS SINGLE, BYVAL posy AS SINGLE, BYVAL posz AS SINGLE) AS LONG
    LOCAL i AS LONG
    DIM cylindermesh AS Mesh
    cylindermesh = CreateCylinderMesh(0.3, 3.0, &h0ffffffff, 8, %True, 0)
    ' create first joint
    DIM cyl1 AS EntityNode
    cyl1 = CreateEntityNode(cylindermesh, 0, 0, 0, BYVAL %NULL)
    PositionNode(cyl1, posx, posy, posz)
    LoadTextureNode(cyl1, "media/water.jpg", 0, 0)
    ' create body
    CreateBody(cyl1, %CAPSULE_PRIMITIVE, %True, 1.0, 0, 0, 0)
    cylT= cyl1

    ' link 3 other joint
    FOR i = 0 TO 2
        DIM cyl2 AS EntityNode
        cyl2 = CreateEntityNode(cylindermesh, 0, 0, 0, BYVAL %NULL)
        PositionNode(cyl2, posx, posy - (i+1)*3.2, posz)
        LoadTextureNode(cyl2, "media/water.jpg", 0, 0)
        ' create body
        CreateBody(cyl2, %CAPSULE_PRIMITIVE, %True, 1.0, 0, 0, 0)
        CreateBallJoint(cyl2, cylT, posx,  posy - (i+1)*2.6, posz)
        cylT = cyl2
    NEXT
    cylT = cyl1
    FUNCTION = cyl2
END FUNCTION



';------------------------------------------------------------------------------------------------
'; CallBack Joint. This function call when either of the two bodies linked by the joint is active.
SUB JointCallBack CDECL(BYVAL joint AS NJoint, BYVAL desc AS NewtonHingeSliderUpdateDesc)
    DIM force(2) AS LOCAL SINGLE

    BallJointForce(joint, force(0))

    IF force(1) > 650 THEN
        ' debug vertical joint force
        'Debug force(1)
        FreeJoint(joint)
    END IF
END SUB


New Include
« Last Edit: October 18, 2011, 08:33:59 PM by Peter Weis »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine first test with physic engine
« Reply #109 on: October 18, 2011, 08:32:04 PM »
Code: [Select]
' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 080  :  first test with physic engine
'     23/05/09  19:16    TMyke
'
' ------------------------------------------------------------



#INCLUDE "n3xtD.bi"



FUNCTION PBMAIN
    ' Globales

    DIM app AS DWORD PTR
    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

    '----------------------------------------
    ' create light and set position
    AmbientLight(&Hffffff)

    ' -----------------------------------------
    '          create and init some physicmaterial
    ' -----------------------------------------
    DIM pbmat(1 TO 3) AS LONG
    pbmat(1) = CreatePhysicMaterial()
    pbmat(2) = CreatePhysicMaterial()


    DIM pair1 AS DWORD PTR
    pair1 = CreatePhysicMaterialPair( pbmat(1),  pbmat(1), 0.1, 0.3, 0.25, 0)
    DIM pair2 AS DWORD PTR
    pair2 = CreatePhysicMaterialPair( pbmat(1),  pbmat(2), 0.3, 1.1, 0.82, 0)
    DIM pair3 AS DWORD PTR
    pair3 = CreatePhysicMaterialPair( pbmat(2),  pbmat(2), 0.6, 1.0, 0.82, 0)


    '===========================================================
    ' set specific parameters for Bouyancy setting
    BouyancyParameter(5.0, 0, -9.8, 5)


    '-----------------------------------------
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1.0)

    DIM cylindermesh AS Mesh
    cylindermesh = CreateCylinderMesh(0.5, 2, &h0ffffffff, 8, %True, 0)

    '-----------------------------------------
    ' create water floor
    '----------------------------------------

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

    PositionNode(floor1, 0,-10,0)
    LoadTextureNode(floor1, "media/water1.jpg", 0, 0)
    ScaleNode(floor1, 20, 1, 20)

    ' create body, no dynamique
    CreateBody(floor1, %BOX_PRIMITIVE, %False, 0, 0, 0, 0)
    GroupPhysicMaterialBody(floor1,  pbmat(1))
    BouyancyMaterial(floor1, pair1)

    ' set translucide material
    DIM material AS NMaterial
    material = NodeMaterial(floor1, 0)

    ColorMaterial(material, 0)
    TypeMaterial(material,  %EMT_ONETEXTURE_BLEND )

    TypeBlendMaterial(material, 6, 7, %EMFN_MODULATE_1X,  %EAS_TEXTURE OR %EAS_VERTEX_COLOR)
    DiffuseColorNode(floor1,  &H088ffffff)


    '-----------------------------------------
    ' create solid floor

    DIM floor2 AS EntityNode
    floor2 = CreateEntityNode(cubemesh, 0, 0, 0, BYVAL %NULL)
    PositionNode(floor2, 0, -20, -20)

    LoadTextureNode(floor2, "media/grille1.bmp", 0, 0)
    ' Attention. Even if we wish to define a shape identical to the second base,
    ' it is necessary to provide data sizes slightly different, because otherwise
    ' the physics engine treats the two as the same platform, which creates a bug
    ' in the handling of material in our case.  _ScaleNode( *floor2, 20.1,1,20.1)
    ScaleNode( floor2, 21,1,21)

    ' create body, no dynamique
    CreateBody(floor2, %BOX_PRIMITIVE, %False, 0, 0, 0, 0)
    GroupPhysicMaterialBody(floor2,  pbmat(2))




    '-----------------------------------------
    ' create a cube
    DIM cube AS EntityNode
    cube = CreateEntityNode(cubemesh, 0, 0, 0, BYVAL %NULL)
    PositionNode(cube, 0,-5,-25)
    LoadTextureNode(cube, "media/body.bmp", 0, 0)
    ' create body, dynamique
    CreateBody(cube, %BOX_PRIMITIVE, %True, 1.0, 0, 0, 0)
    GroupPhysicMaterialBody(cube,  pbmat(3))



    '-----------------------------------------
    ' create cubes
    FOR i = 0 TO 10

        cube = CreateEntityNode(cubemesh, 0, 0, 0, BYVAL %NULL)
        PositionNode(cube, -9+RND(0, 18),-RND(0, 8),-9+RND(0, 18))
        LoadTextureNode(cube, "media/wcrate.bmp", 0, 0)
        ' create body, dynamique
        CreateBody(cube, %BOX_PRIMITIVE, %True, 2.0, 0, 0, 0)
        GroupPhysicMaterialBody(cube,  pbmat(1))
    NEXT

    '-----------------------------------------
    ' create barrel
    FOR i = 0 TO 10
        DIM barrel AS EntityNode
        barrel = CreateEntityNode(cylindermesh, 0, 0, 0, BYVAL %NULL)
        PositionNode(barrel, -9+RND(0, 18),-RND(0, 8),-9+RND(0, 18))
        LoadTextureNode(barrel, "media/wall0.jpg", 0, 0)
        ' create body, dynamique
        CreateBody(barrel,  %CYLINDER_PRIMITIVE, %True, 4.0, 0, 0, 0)
        GroupPhysicMaterialBody(barrel,  pbmat(1))
    NEXT





    '-----------------------------------------
    ' create first  camera
    DIM cam AS GLOBAL CameraNode
    cam = CreateCameraFPS(70, 0.1, 1.0, BYVAL %NULL, 0, %False, %False, BYVAL %NULL)

    PositionNode(cam, 20,-0,-20)
    RotateNode(cam, 25,-60,0)



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



    WEND
    ' end
    FreeEngine()

END FUNCTION


Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine Now stop here as with Alt-F4
« Reply #110 on: October 24, 2011, 01:03:46 PM »
Code: [Select]
' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample  006   as   Load a simple 3D Object And set multiple mesh
'   Historique   as
'     29/03/09  19 as 16    TMyke
'
' ------------------------------------------------------------
#IF %DEF(%PB_CC32)
   #CONSOLE OFF

#ENDIF
' Includes libraries
#INCLUDE "windows.inc"
#INCLUDE "N3xtD.bi"

GLOBAL Close_n3xtd AS DWORD
GLOBAL Callback AS DWORD


' Dimes
FUNCTION WINMAIN (BYVAL  hInstance   AS DWORD, BYVAL  hPrevInst AS DWORD, BYVAL  lpszCmdLine AS WSTRINGZ PTR, BYVAL  nCmdShow  AS LONG) AS LONG

    DIM app AS DWORD
    DIM Quit AS LONG
    DIM hWnd AS DWORD

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



    ' Load an 3D Object
    DIM obj AS Mesh
    obj = LoadMesh("media/earth.x", %HARDMAPPING.EHM_STATIC)



    ' Create several mesh
    DIM i AS INTEGER
    DIM sphere AS EntityNode
    FOR  i = 0 TO 3
        '; Create a mesh with one of the 3D Object loaded
        sphere = CreateEntityNode(obj, 0,  0,  0, %NULL)
        ' set position
        PositionNode(sphere, 3*i,0,0)
    NEXT




    ' create a camera
    DIM cam AS CameraNode
    cam = CreateCamera(%NULL)
    PositionNode(cam, 6,0,-10)


    hwnd = GetCallingHwnd()

    Callback = SetWindowLong(hWnd, %GWL_WNDPROC, CODEPTR(PBCallback()))

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


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

        IF GetMouseEvent(%MOUSE_EVENT.MOUSE_BUTTON_LEFT) THEN

        END IF
        IF getKeyDown(%KEY_CODE.KEY_MENU) THEN

        END IF


        ' just turn our sphere
        TurnNode(sphere, 0,0.5,0, 0)



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

    WEND
    ' end
    FreeEngine()
END FUNCTION

FUNCTION EnumProc(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG

    LOCAL ptrlParam AS LONG PTR

    ptrlParam = lParam

    POKE LONG, ptrlParam, hWnd

    FUNCTION = 0

END FUNCTION



FUNCTION GetCallingHwnd() AS LONG

    LOCAL hWnd AS LONG

    LOCAL ptrhWnd AS LONG PTR

    ptrhWnd = VARPTR(hWnd)

    EnumThreadWindows(GetCurrentThreadId(), CODEPTR(EnumProc), ptrhWnd)

    FUNCTION = hWnd

END FUNCTION




FUNCTION pbCallback(BYVAL pbWindow AS DWORD , BYVAL Message AS DWORD , BYVAL wParam AS DWORD, BYVAL lParam AS DWORD) AS DWORD
  LOCAL Result AS DWORD
  Result = CallWindowProc(CallBack, pbWindow, Message, wParam, lParam)
  SELECT CASE Message
  CASE %WM_CLOSE
      Close_n3xtd = %True
  END SELECT
  FUNCTION = Result
END FUNCTION

New Include

Offline Gerald Clark

  • Newbie
  • *
  • Posts: 7
  • User-Rate: +0/-1
Re: N3xtD - Free 3D engine
« Reply #111 on: March 22, 2012, 08:28:14 PM »
Hi,

Link to N3xtD doesn't go to N3xTD. Nice header files no engine  :o

Later...
G.C.
Contempt prior to investigation = Everlasting Ignorance

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine
« Reply #112 on: March 23, 2012, 01:39:09 PM »
Hello,
I found what!
Here can you download the DLL!

http://users.freebasic-portal.de/vanya/N3xtD/

greetings Peter


« Last Edit: March 23, 2012, 01:53:40 PM by Peter Weis »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine
« Reply #113 on: March 23, 2012, 04:19:04 PM »
Hello,

 Hello,
 Here the project with all the examples.

 regards Peter


« Last Edit: March 23, 2012, 04:21:17 PM by Peter Weis »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine
« Reply #114 on: March 23, 2012, 04:44:37 PM »
And here are all the media files to

regards Peter
« Last Edit: March 23, 2012, 04:49:57 PM by Peter Weis »

Offline Gerald Clark

  • Newbie
  • *
  • Posts: 7
  • User-Rate: +0/-1
Re: N3xtD - Free 3D engine
« Reply #115 on: March 24, 2012, 12:12:44 AM »
Hi Peter,

Thanks for the links. Downloading now.

G.C.
Contempt prior to investigation = Everlasting Ignorance

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2525
  • User-Rate: +209/-0
  • Gender: Male
Re: N3xtD - Free 3D engine
« Reply #116 on: May 23, 2012, 06:54:35 PM »
What has happened with N3xtD? Yet another abandoned project? All the official links are dead.

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: N3xtD - Free 3D engine
« Reply #117 on: May 23, 2012, 11:43:51 PM »
[Translation/Theo]
Hallo Jose, it looks like N3xTD is not continued. I have therefore published all Sources i have here in the forum.
As i see it, "Irrlicht 3D" is similiar to N3xTD. When i am ready with my actual project and i get time I'll take a closer look.

------------------
Hallo Jose,

N3xTd scheint Tod zu sein deswegen habe ich auch alles veröffentlicht was ich von N3xTd habe. Wen ich mit Unicode Wide Files fertig bin werde ich mir mal irrlicht-1.7.3 anschauen und dafür vielleicht  Inlude schreiben! Irrlicht ist fast wie N3xTd

Grüße Peter
« Last Edit: May 24, 2012, 09:48:13 AM by Theo Gottwald »