Jump to content

AndyGFX

Members
  • Posts

    124
  • Joined

  • Last visited

Posts posted by AndyGFX

  1. WHen you want see how work my code, you can download it here: https://sites.google.com/site/andygfxproject/free-pascal/final3d-sdl-ngine/Final3D_SDL_nGine.rar?attredirects=0&d=1

     

    Run: F3D_DEMO_scene_render.exe and press F1 or F3D_DEMO_gui_with_lua.exe - GUI has used call function from native code.

     

    LUAfile:

     

    ..\Final3D_SDL_nGine\bin\data\scripts\editor\editor_gui.lua

     

    ...
    GUI.SetHSlider_OnChange("WIN_01","HSlider_01","fnc_Hslider_onchange");
    ...
    

     

    and fnc is defined:

     

    function fnc_Hslider_onchange()
    local val = GUI.GetHSliderValue("WIN_01","HSlider_01");
    print(val);
    end;
    

     

    and now GUI.GetHSliderValue in native code: wF3D_GUI.pas

     

    F3D.ScriptEngine.AddListFunction('GetHSliderValue', @lua_GUI_HSlider_GetValue);

     

    function lua_GUI_HSlider_GetValue(L: lua_state): integer; cdecl;
    var w_name: string;
       i_name: string;
    
       w_id, i_id: integer;
    begin
       w_name := lua.luaL_check_string(L, 1);
       i_name := lua.luaL_check_string(L, 2);
    
       w_id := F3D.GUI.FindWindowByName(w_name);
       if w_id >= 0 then
       begin
           i_id := F3D.GUI.Window[w_id].FindHSliderByName(i_name);
           if i_id >= 0 then
           begin
               lua.lua_pushnumber(L, F3D.GUI.Window[w_id].HSlider[i_id].value);
           end;
       end;
       result := 1;
    end;
    

     

    Maybe your function isnt properly defined. I have used this steps

     

    1) F3D.ScriptEngine.StartList('GUI');

     

    procedure TF3D_ScriptEngine.StartList(name: pchar);
    begin
    
       if (self.enabled = false) then exit;
    
       lua_pushstring(VM, name);
       lua_newtable(VM);
    end;
    

     

    2) Add functions to GUI table;

     

    ...
    // HSLIDER
       F3D.ScriptEngine.AddListFunction('SetHSlider_OnChange', @lua_GUI_HSlider_OnChange);
       F3D.ScriptEngine.AddListFunction('GetHSliderValue', @lua_GUI_HSlider_GetValue);
    ...
    

     

     

     

    procedure TF3D_ScriptEngine.AddFunction(name: pchar; fnc: pointer);
    begin
    
       if (self.enabled = false) then exit;
    
       lua_pushstring(VM, name);
       lua_pushcclosure(VM, fnc, 0);
       lua_settable(VM, LUA_GLOBALSINDEX);
    end;
    

     

    3) F3D.ScriptEngine.EndList(); (F3D_ScriptEngine.pas)

     

    procedure TF3D_ScriptEngine.EndList();
    begin
    
       if (self.enabled = false) then exit;
    
       lua_settable(VM, LUA_GLOBALSINDEX);
    end;
    
    

     

    I have used Lua 5.1 and bum dll, for linux was used lua.so

  2. This is very strange because i have used same method to return value from native code to lua script.

     

    Try add check inside C code if it's really function pointer returned from lua stack.

     

    state = lua_type(L,-1); 
    

     

    state constants are:

     

     LUA_TNIL           = 0;
     LUA_TBOOLEAN       = 1;
     LUA_TLIGHTUSERDATA = 2;
     LUA_TNUMBER        = 3;
     LUA_TSTRING        = 4;
     LUA_TTABLE         = 5;
     LUA_TFUNCTION      = 6;
     LUA_TUSERDATA	     = 7;
     LUA_TTHREAD	       = 8;
    

  3. Hi Rick

     

    i never tried put loop inside lua execute function, i think this isn't good.

    In my code i have luaV_execute defined as separated exec for external lua function and in native code when i call OnUpdate loop on any object (i.e. gui element) i call this external lua function in loop. From my point of view, your partly published code, look like recursive call => stack overflow or crash.

     

    When you want look on my implementation (but in Delphi) you look here: http://sites.google.com/site/andygfxproject/free-pascal/final3d-sdl-ngine source are on bottom of page.

     

    Note: Yes I'm always around here, but now i work more for mobiles and Tablets with Monkey.

  4. Hmm ... a haven't experiencies with this phys. things, but i have other idea.

    Make 1st phase as animation (rotate catapult arm) and then apply force to the thing throwed from catapult. Your idea is good, but from my point of view, not all in-game solution you have to make "totaly" real :D

  5. Hmm ... strange ... looks like i have now same problem with NV 258.96 (before i have installed 197.13) and full version of LE (2.40), after installation this one DRV crash ALL programs - Editor, Engine and my programs too. In DEBUG mode from BLIde, program is stopped in buffer.bmx. More infos i can't get, because this is LE core.

     

    Log look like:

    Leadwerks Engine 2.40
    Initializing Renderer...
    OpenGL Version: 3.3.0
    GLSL Version: 3.30 NVIDIA via Cg compiler
    Render device: GeForce 8800 GTX/PCI/SSE2
    Vendor: NVIDIA Corporation
    DrawBuffers2 supported: 1
    32 texture units supported.
    GPU instancing supported: 1
    Max batch size: 64
    Shader model 4.0 supported: 1
    Conditional render supported: 0
    Loading shader "zip::e:/_3d_engines/leadwerks engine sdk 2.40 final/tools/adn/shaders.pak//query.vert", ""...
    Invoking script "E:/_3D_Engines/Leadwerks Engine SDK 2.40 Final/Scripts/start/collisions.lua"...
    Invoking script "E:/_3D_Engines/Leadwerks Engine SDK 2.40 Final/Scripts/start/fliphook.lua"...
    Invoking script "E:/_3D_Engines/Leadwerks Engine SDK 2.40 Final/Scripts/start/globals.lua"...
    Loading shader "", "incbin::../../TerrainColorAndLight.frag"...
    Loading shader "", "incbin::../../TerrainColorAndLight.frag"...
    Loading texture "e:/_3d_engines/leadwerks engine sdk 2.40 final/models/entities/light/directional/light_directional_icon.dds"...
    Loading model "e:/_3d_engines/leadwerks engine sdk 2.40 final/models/entities/light/directional/light_directional.gmf"...
    Loading mesh "e:/_3d_engines/leadwerks engine sdk 2.40 final/models/entities/light/directional/light_directional.gmf"...
    Loading material "e:/_3d_engines/leadwerks engine sdk 2.40 final/materials/effects/invisible.mat"...
    Loading script "e:/_3d_engines/leadwerks engine sdk 2.40 final/models/entities/light/directional/light_directional.lua"...
    Creating class light_directional
    

  6. When i create an ini file with classname="blablabla" for gmf model and this model is added to scene and then saved, all properties from INI file are added to SBX file too.

    But when i create INI file with classname="blablabla" for entity without gmf file (like camera with invisible material + icon only) then this properties from INI file isn't saved to SBX file.

    Is it a bug or Josh's intent?

  7. This pack contain two old class collection HUD and GUI posted from "old" LE forum. They are now writed little bit specialy.

    This dev. pack is designer on two different BMX mods - miniB3DExtNew and Leadwerks.

    This solution is good for me , because i have crapy notebook in office and i want some-time work on my game prototypes and ideas.

     

    What is include:

     

    01 - GUI sample

    02 - HUD sample

    03 - SBX file loader

    04 - Space Invaders Game

     

    All this samples are possible compile with LE or miniLE (modified miniB3DExtNew) very simple.

     

    For miniLE compilation u need use this part of code:

     

    Import agfx.agfx_minile
    Include "classes/AGFX_WRAPPER/miniB3Dext/TAGFX_LE_Wrapper_to_mB3D.bmx"
    Include "classes/TAGFX.bmx"
    

     

    and for LE compilation u need use this part of code:

     

    Framework leadwerks.engine
    Import "classes/Framework/Framework.bmx"
    Include "classes/AGFX_WRAPPER/Leadwerks/TAGFX_LE_Wrapper_to_LE.bmx"
    Include "classes/TAGFX.bmx"
    

     

    Note #1: Wrapper contain basic commands for entity, color, fonts, text, texture, World, ...

    Note #2: you need use absolut path to file for loading content, this path is automaticaly converted to abstract path when is used LE compilation.

    Example:

     

    File "media_si/Models/enemy_a/si_enemy_a.gmf" is with miniLE converted to "media_si/Models/enemy_a/si_enemy_a.b3d" and with LE to "abstract::si_enemy_a.gmf".

    For more infos look inside my code - are free - like before :blink:

     

     

    Screenshots:

     

    01_GUI_sample.png

     

    02_HUD_sample.png

     

    04_SpaceInvaders_Game.png

     

    Download: DEV PACK

  8. Hi,

     

    when anybody like Cube 2: Sauerbraten Justice Edition, from today i have private game-server Cube2Fun up.

     

    How-to connect:

     

    1) Press key T

    2) put this line: /connect 213.160.164.14 28000 tmsk

    3) press ENTER

     

    Note: Daily since 18:00 - 23:00 CET

  9. File Name: TFontManager

    File Submitter: AndyGFX

    File Submitted: 03 Jul 2010

    File Category: BlitzMax Code

     

    TFontManager Class:

     

    Type TFontManager
    
    Field fonts:TMap
    Field CurrentFont:TGLFont
    
    Method New()
    	Self.fonts = New TMap
    	Local def:TGLFont = LoadFont("incbin::Arial9")
    	Self.fonts.Insert("Arial9", def)
    End Method
    
    Method AddFont(fname:String)
    	Local fnt:TGLFont = LoadFont("abstract::" + fname)
    	Self.fonts.Insert(fname, fnt)
    
    	? Debug
    		Print("FONT: " + fname + " loaded.")
    	?
    
    End Method
    
    Method RemoveFont(fname:String)
    	Self.Fonts.Remove(fname)
    End Method
    
    Method SetCurrentFont(fname:String)
    	Self.CurrentFont = TGLFont(Self.fonts.ValueForKey(fname))
    	SetFont(Self.CurrentFont)
    End Method
    
    Method GetCurrentFont:TGLFont()
    	Return Self.CurrentFont
    End Method
    
    
    end type
    

     

    sample:

    ...
    Global Fonts:TFontManager = New TFontManager
    ...
    Fonts.AddFont("courier_new_8_bold")
    Fonts.AddFont("courier_new_8_normal")
    Fonts.AddFont("verdana_10_normal")
    Fonts.AddFont("verdana_10_bold")
    ...
    
    Fonts.SetCurrentFont("courier_new_8_normal")
    DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16 * 2)
    Fonts.SetCurrentFont("courier_new_8_bold")
    DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16)
    ...
    ' get current font
    Local actualfont:TGLFont = Fonts.GetCurrentFont()
    
    ...
    'set default font back
    Fonts.SetCurrentFont("Arial9")
    
    

     

    Click here to download this file

  10. Here is simple example howto write FontManager for LE in BMX.

     

    Class:

    Type TFontManager
    
    Field fonts:TMap
    Field CurrentFont:TGLFont
    
    Method New()
    	Self.fonts = New TMap
    	Local def:TGLFont = LoadFont("incbin::Arial9")
    	Self.fonts.Insert("Arial9", def)
    End Method
    
    Method AddFont(fname:String)
    	Local fnt:TGLFont = LoadFont("abstract::" + fname)
    	Self.fonts.Insert(fname, fnt)
    
    	? Debug
    		Print("FONT: " + fname + " loaded.")
    	?
    
    End Method
    
    Method RemoveFont(fname:String)
    	Self.Fonts.Remove(fname)
    End Method
    
    Method SetCurrentFont(fname:String)
    	Self.CurrentFont = TGLFont(Self.fonts.ValueForKey(fname))
    	SetFont(Self.CurrentFont)
    End Method
    
    Method GetCurrentFont:TGLFont()
    	Return Self.CurrentFont
    End Method
    
    
    end type
    

     

    sample:

    ...
    Global Fonts:TFontManager = New TFontManager
    ...
    Fonts.AddFont("courier_new_8_bold")
    Fonts.AddFont("courier_new_8_normal")
    Fonts.AddFont("verdana_10_normal")
    Fonts.AddFont("verdana_10_bold")
    ...
    
    Fonts.SetCurrentFont("courier_new_8_normal")
    DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16 * 2)
    Fonts.SetCurrentFont("courier_new_8_bold")
    DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16)
    ...
    ' get current font
    Local actualfont:TGLFont = Fonts.GetCurrentFont()
    
    ...
    'set default font back
    Fonts.SetCurrentFont("Arial9")
    
    

  11. Looks good.

     

    I have only small comment to method names. You don't need add "Button" to method again when object is inherited from button class. Developer knows of what was created.

  12. @NA: OK. Today i prepare my GUI/HUD code as Demo and then i send you link to download via PM. Look on it and then we prepare final design doc of GUI/HUD and then we make decision what we/users need to finish or how to extend your or splited code, etc.

     

    Note: Thank for positive opinion on my coding :D

×
×
  • Create New...