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 047   as   Test Multi SceneManager.
'   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




    '-----------------------------------------
    ' Create a cube in the base SceneManager
    DIM cubemesh AS Mesh
    cubemesh = CreateCubeMesh(1)
    LOCAL i AS INTEGER

    FOR i = 0 TO 15
        DIM cube AS EntityNode
        cube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
        PositionNode(cube, -6+RND()*12,0,-6+RND()*12)
        LoadTextureNode(cube, "media/body.bmp", 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,0,-5)



    '-----------------------------------------
    ' Create New SceneManager
    DIM smgr2 AS BYTE PTR
    smgr2 = CreateSceneManager()

    '-----------------------------------------
    ' set the N3xtD system with the New SceneManager
    DIM smgr1 AS BYTE PTR
    smgr1 = CurentSceneManager(smgr2)


    '-----------------------------------------
    ' Create a cube in the second SceneManager
    FOR i = 0 TO 15
        DIM pbcube AS EntityNode
        pbcube = CreateEntityNode(cubemesh, 0, 0, 0, %NULL)
        PositionNode(pbcube, -6+RND()*12, -4, -6 + RND()*12)
        LoadTextureNode(pbcube, "media/five.bmp", 0, 0)
    NEXT

    ' Create a camera in the New SceneManager
    ' (each SceneManager must have a camera)
    DIM cam2 AS CameraNode
    cam2 = CreateCamera(%NULL)
    PositionNode(cam2, 0,0,-5)



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


    DIM flag AS INTEGER
    ' ---------------------------------------
    '           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_F1) THEN
            CurentSceneManager(smgr1)
            flag=0
        END IF

        IF GetKeyUp(%KEY_CODE.KEY_F2) THEN
            CurentSceneManager(smgr2)
            flag=1
        END IF

        IF GetKeyUp(%KEY_CODE.KEY_F3) THEN
            flag=2
        END IF





        ' ---------------
        '      Render
        ' ---------------
        BeginScene(0, 0, 0, 255, 1, 1)
        IF(flag=2) THEN DrawSceneManager(smgr1)
        DrawScene()
        DrawText(pbfont, "F1/F2 to switch between SceneManager",  10,10,0,0, &h0ff9999ff)
        DrawText(pbfont, "F3    Draw to SceneManager",  10,30,0,0, &h0ff9999ff)
        EndScene()



    WEND
    ' end
    FreeEngine()

END FUNCTION
  •  

Theo Gottwald

Thanks Peter, when i get it it, I'll give it another try.

Peter Weis


Hi Theo,

Include the hang to it but still.

But here again especially for you the newest

regards Peter









  •  

Peter Weis

Hello,
a new example and include new



' ------------------------------------------------------------
'   n3xt-D exemples
'
'   Sample 048   as   load irr scene
'   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

    ChangeWorkingDirectory("media/irrEdit")


    '------------------------------
    ' Load irrscene
    LoadIrrScene("scenes/example.irr", BYVAL %NULL)

    DIM node_list AS NArray
    node_list = CreateArray()

    SceneNodesFromType(node_list, %ESNT_ANY, BYVAL %NULL)

    FOR i = 0 TO ArraySize(node_list) - 1
        DIM node AS EntityNode
        node =  ArrayElement(node_list,  i)
        'print _Text(_NodeName(*node))
    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,20,-70)



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



regards Peter
  •  

Theo Gottwald

#64
Thanks, Peter.

The problem with all the 3D stuff is the missing usability for GUI.
Actually i do not make games, but i may want to make realistic looking drag'n drop.
I would like to have great looking 3D-Buttons (not the 3D from EZGUI* looking like a Bin, REAL 3D like on on iPhone).

For this, all these libraries are just the base of what is needed.
They are optimized for games and gamers. Not for GUI's.

Thats the problem.
While most people here work on GUI's (including me right now) - not on games - at least here.
So whats missing in my opinion is the next Level.

Make 3D usable for GUI's. Really, easily usable for GUI's.

3D Controls, 3D Items, the user can manipulate and doing so control the program.

Buttons that shine like a LED?
Or Texts that graphically appear and dissapear when i write in a Textbox-Control?

Items that i can REALLY drag from here to there.
Buttons that really go in and out in 3D when the user presses them!

There are usable things thinkable for the GUI of the future.
Yet many people today prodive 3D for gaming, but most people here do not program games!

Think of making a 3D-Controls Library! Not just gaming.

While actually i have not time to take a closer look because i am busy with other things.
This is something that i may take a look at in the future.

Reason:
The average intelligence of the average American (or german) citizen is decreasing, thanks to drugs and MTV.

Means there is a big demand for making GUIs more intuitive to use.
As a result even the most stupid person, can read his mails or drag them into the mail-trashcan.

Look at Windows 8!

It's not more professional then windows 2000, its just safer (internally) and more easy to use for people with low IQ.
This is the direction to go, 3D will play a role then. Aside from gaming.

*I just remember EZGUI 5 because it also includes (nice!) 3D Features, which would be nice for gaming or making 3D Desginers. But  I have discussed this with CB also. Who really needs it? We make GUI's not games. At all this stuff is missing the final step to make the 3D really usable for GUI's. How about a 3D-Treview? This is advanced programming, we must try to go ahead, not look to just follow old trends.

Theo Gottwald

Peter, I tried one example that was completely in b/w (see attached picture).

Even using the newest includes, the "game" crashed as before.

Wouldn't it be good if there would be a warning "component not available" or like that?
Because it just doesn't say why it crashes,
I can say that the PureBasic Examples worked fine.

Peter Weis

Hi Theo,
can you give me the number or the name of the example to tell me at all to work now that I've rewritten!

The examples are not nice I know. I've taken from the Free Basic because they are easier to write about because FreeBasic and PowerBASIC are similar!

Get me the look of PureBasic whom I'm done

Excuse my English still is not very good



regards Peter
  •  

Peter Weis

Hi Theo,

What I really wanted to say I'm really not a game programmer! I really wanted to show only the one written with PowerBASIC on the tools for other programming languages ​​can access!

In addition, here in this forum provides an interface to N3xtD was required!

Whether it makes sense or not I can not say at this time

What happened to me. noticed Bob's has not done its homework properly must be reworked for PowerBASIC here!

The transfer of optional parameters and constants is bugging me for PowerBASIC! They can not pre-assign a value to how to do it in Visual Basic and FreeeBasic

regards Peter
  •  

Brice Manuel

Theo:  I am not sure why you are insisting on using the PureBasic version when Peter is following my advice and working from the FreeBasic version.  There are four different versions of the engine for a reason.  It would be best to use the version that Peter is working from.  As long as you are doing that and running the example from the correct path and have your resources in the correct directories, you should have no problems (as long as you have the runtimes installed for whatever rendering API you are using).
  •  

Theo Gottwald

Peter, if you have really stuff that you think is not working as expected, please sent me a mail with example code that can be compiled.
I am actually not aware of any Bug in PB 10, but if there are some, i want to know it and look that they get reported.

Peter Weis

 Hi Theo,

I may have misunderstood you, or you misunderstood me. PB 10 has no fault! It is not merely beautiful
That is the bottom written in PowerBASIC do not!

declare Function CloneNode  cdecl alias "_CloneNode"(opt ByVal node As long = 5,  opt ByVal parent As integer =NULL)  As EntityNode     



But anyway I'll send you all the examples I've rewritten it to now work with me

regards Peter


  •  

Jeff Blakeney

Quote from: Peter Weis on October 07, 2011, 03:10:52 PMThat is the bottom written in PowerBASIC do not!

declare Function CloneNode  cdecl alias "_CloneNode"(opt ByVal node As long = 5,  opt ByVal parent As integer =NULL)  As EntityNode     

I have never seen this form of declare before and I mentioned it to my brother and he told me that in some languages, this is used to set the value to send to the routine if the optional parameter is not given.

In my mind, this is pretty silly.  If a routine wants a specific value if a parameter is not passed in, then why doesn't it just set the value in the routine rather than expecting the calling program to supply it?

To get around this in PowerBASIC you could create a wrapper function to call the routines that need this.  Using your example above you could do something like this:

DECLARE FUNCTION CloneNode2 CDECL ALIAS "_CloneNode"(OPT BYVAL node AS LONG, OPT BYVAL parent AS INTEGER) AS EntityNode

FUNCTION CloneNode(OPT BYVAL node AS LONG, OPT BYVAL parent AS INTEGER) AS EntityNode

    IF ISMISSING(node) THEN
        node = 5
    END IF

    IF ISMISSING(parent) THEN
        PARENT = %NULL
    END IF

    FUNCTION = CloneNode2(node, parent)

END FUNCTION

  •  

Peter Weis

Hello,
Respect of the declaration was changed to DrawText NX3_DrawText because they are not compatible with Windows API because it gives the name already had the call must be changed in each example
regards Peter
  •  

José Roca

#73
ISMISSING does not work with optional BYVAL scalar parameters. You have to use optional BYREF scalar parameters or optional BYVAL/BYREF VARIANTs.
  •  

Peter Weis

Jeff Blakeney,
IsMissing comes to me out of the question, because it will be decided until runtime what the program is passed. Furthermore, an additional feature requires what makes the program more slowly! Additionally, as Jose already writes the values ​​must be handed over the charge of byref pointer costs even more time!

I wish that just as in free Basic or Visual Basic where the compiler decides what is passed!
regards Peter
  •