Jump to content

AndyGFX

Members
  • Posts

    124
  • Joined

  • Last visited

Everything 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
  5. I have same problem with this page. I think that problem is with loading steam IMG TAG assigned to account. Opera shows that Maclebee has assigned this image tag from Steam, but isn't loaded (Me too). When I disable "Show Image" from Opera, then never-ending load is stoped
  6. When you want create effect which looks like "LookAt", use align to forward direction [Z axis] - PointEntity(a, b, 3,1,0)
  7. 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
  8. 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?
  9. 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 Screenshots: Download: DEV PACK
  10. execute script inside code: lua_dofile(...) lua_dostring(...) http://www.lua.org/manual/2.4/node14.html
  11. A lot of years only WASD + mouse, last few years only JOYPAD on X360, and i like it too.
  12. 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
  13. 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")
  14. i like it ... actual result 50:50 BMX/C++
  15. AndyGFX

    LuaGui

    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.
  16. @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
  17. http://lua-users.org/wiki/LuaLinks and of course http://www.lua.org/manual/5.1/
  18. Oops. Sorry. When i good remember, for lua exist clibs - luagl and luaglu, but i newer tried it from LE - maybe don't work becuase LE has LUA interpreter included to core of LE.
  19. Very good idea 1) Language: BMX. Why? Because it's and will be primary language (by Josh's last words) * 2) Blog/Tutorial: Hmm it's hard. Blog looks like modern wave of this age, nothing more. * When i started with 3D a lot of years ago, i was every day on NEHE, this page has a lot of basic tutorials and everyone is writed in same language, and at end of tutorial is added download section with links to other language conversions. I think this is way from my point of view. All tutorials in ONE language with download links to others conversion. Note: This idea give me new "fresh air" to my life, because i haven't time now to make any game project (i have new house and I'm surpised how many time need it from my free-time ), but i can help with this idea when you want.
  20. I think that for you is now best way, learn LUA with LE Scene editor. You need know, how lua works, then how it works in LE Scene and after this goals to learning, you are partly ready to use lua in BMX or other language.
  21. When you need change font size, use glScalef. I know, ins't ideal, but works.
×
×
  • Create New...