Josh Posted December 31, 2009 Share Posted December 31, 2009 Here, the program creates a skybox just by loading the environment_atmosphere model. Make sure you have the scripts folder copied to your project directory: // ==================================================================== // This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard // Written by Rimfrost Software // http://www.rimfrost.com // ==================================================================== #include "engine.h" int main( int argn, char* argv[] ) { Initialize() ; RegisterAbstractPath("C:/Leadwerks Engine SDK"); SetAppTitle( "luatest" ) ; Graphics( 800, 600 ) ; AFilter() ; TFilter() ; TWorld world; TBuffer gbuffer; TCamera camera; TMesh mesh; TLight light; TMesh ground; TMaterial material; world = CreateWorld() ; if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); return Terminate(); } TFramework framework=CreateFramework(); TLayer layer = GetFrameworkLayer(0); camera=GetLayerCamera(layer); PositionEntity(camera,Vec3(0,0,-2)); //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); LoadModel("abstract::environment_atmosphere.gmf"); material=LoadMaterial("abstract::cobblestones.mat"); mesh=CreateCube(); PaintEntity(mesh,material); ground=CreateCube(); ScaleEntity(ground,Vec3(10,1,10)); PositionEntity(ground,Vec3(0,-2,0)); PaintEntity(ground,material); light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,45)); // Game loop while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { // Rotate cube TurnEntity( mesh, Vec3( 0.5f*AppSpeed() ) ) ; // Update timing and world UpdateFramework(); // Render RenderFramework(); // Send to screen Flip(0) ; } } // Done return Terminate() ; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Pixel Perfect Posted December 31, 2009 Share Posted December 31, 2009 Very nice, this is really coming together now. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
TylerH Posted December 31, 2009 Share Posted December 31, 2009 This is wonderful, but there is a MAJOR issue. I initialize the Jeklynn Heights scripting system currently using lua_open(). It returns a native type of lua_State*. I tried replacing lua_open() with: State = reinterpret_cast<lua_State*>(GetLuaState()); but it causes a major load of run-time errors and exceptions. Basically, your byte pointer to the Lua State used in Blitzmax will not transfer easily to C/C++, and will be incompatible with any direct usage of Lua, LuaBind, tolua++, etc. libraries that require a lua_State* pointer. Maybe there is a way to get this working? Because, honestly, there is much more versatility in using Lua native in C/C++ along with third party libraries instead of the overhead of Lua in C -> BMX -> Re-exposed in engine.h/.cpp. Anyways, this is working great otherwise. Cheers, Tyler 1 1 Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Niosop Posted December 31, 2009 Share Posted December 31, 2009 What are our current options for communicating/passing data between C++ and Lua scripts? Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Josh Posted January 1, 2010 Author Share Posted January 1, 2010 It is questionable whether another instance of Lua opened in C can use the lua state created by the engine. The best bet is probably to use the Lua API declared in the engine DLL. Right now the exposed Lua commands are minimal, but I'll add more with time. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
TylerH Posted January 2, 2010 Share Posted January 2, 2010 We can not make use of LuaBind without a Lua State. By using your Lua State (granted it was indeed usable from C/C++ properly), we wouldn't even be using another instance, we would be using the same instance of Lua, since it is already in memory from when you created yours. The state is just a pointer to the core memory utilized by Lua and some other variables it needed for garbage collection and such. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Josh Posted January 2, 2010 Author Share Posted January 2, 2010 The lua state byte pointer GetLuaState() returns is the real lua state. The commands I have exposed through the DLL work on it, and they are just the raw lua API. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Scott Richmond Posted January 10, 2010 Share Posted January 10, 2010 How come there is no LEO? Is LEO officially supported?I'm beginning to get confused as to how all these different modules fit in. Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
Canardia Posted January 10, 2010 Share Posted January 10, 2010 There is LEO, and it's officially supported also. When programming C++, you can choose whether you want to use the procedural C++ headers (engine.h), or the OOP C++ headers (leo.h). When you use LEO (the OOP C++ headers), you can still access the procedural C++ headers directly, since LEO includes also engine.h. Framework is available in both also, with LEO you just have an OOP style framework interface, but you can also mix procedural and OOP engine (and framework) commands if you like. Lua is used in Editor to make logic and actions to models, you don't have to do anything in C++ for them, they just works automatically like in Editor. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Scott Richmond Posted January 10, 2010 Share Posted January 10, 2010 mmm, I think I just get a bit confused on whats best practice. I think that's where I find LeadWerks lacking at the moment - There are all these different modules and most of the tutorials use a mix of them. Doesn't seem to be a set standard. I mean surely LEO is preferred, so why not make them the only headers? More simple and less maintainance. Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
Canardia Posted January 10, 2010 Share Posted January 10, 2010 The procedural C++ headers are the mostly for easier conversion to other languages. It would be a huge task to convert LEO to all other languages (and many languages don't even have full OOP capability), so the procedural headers are kinda like the minimum you need to convert. There is no additional maintenance for LEO, since LEO uses the procedural headers, so you would need to write the new DLL imports anyway. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Scott Richmond Posted January 11, 2010 Share Posted January 11, 2010 Thanks for taking the time to clear this stuff up Lumooja, but a couple more things: If one uses LEO, does it still use the depreciated 'Framewerk' or the newer integrated 'Framework'?...or both? Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
Canardia Posted January 11, 2010 Share Posted January 11, 2010 LEO uses only the integrated Framework. LEO never used the C++ Framewerk, since that is a standalone class. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Flexman Posted May 9, 2010 Share Posted May 9, 2010 Here, the program creates a skybox just by loading the environment_atmosphere model. Make sure you have the scripts folder copied to your project directory: LoadModel("abstract::environment_atmosphere.gmf"); I have a question about this. In C++ or bmax, how do you access the properties of the "environment_atmosphere" object? If you wanted to change the fogcolor, or skymaterial for example? And sorry for re-spawning a fairly old thread but it seemed a relevant question and searching didn't yield any clues. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
ZioRed Posted May 9, 2010 Share Posted May 9, 2010 I suppose with GetEntityKey and SetEntityKey Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Guest Red Ocktober Posted May 9, 2010 Share Posted May 9, 2010 you guys are starting to confuse me here... i mean, why are you doing all of this work... it just seems as if you're overcomplicating something that really doesn't have to be... or maybe i have it all messed up and wrong... anyway... i learned, from Macklebee, that all i needed to do to take advantage of the lua scripts as they play out when loading a scene in the editor, is to (BMAX code, but should be the same or similar in c++)... 'To generatue glue functions for Lua, comment this line out: Include "lua-gluefunctions.bmx" 'And uncomment these two lines, run the program once, Then undo your changes: 'generateGlueCode("lua-gluefunctions.bmx") 'End then, farther down create a fw (framework) object... 'Create a New Framework Object. Global fw:TFramework = TFramework.Create() If Not fw RuntimeError "Failed To initialize engine." SetScriptObject("fw", fw) 'Setup the Global script objects. then, load the scene... and access the rendering properties like so... 'Load the scene. Global scene:TEntity = LoadScene("Abstract::hydro.sbx") fw.renderer.ReflectionRenderComponents=ENTITY_RENDERABLE fw.renderer.SetWaterAmplitude(64) fw.Main.camera.SetZoom 1.2 so... to answer your question about changing the fog color of the atmosphere... the atmosphere in the editor is a logical grouping for certain properties of the renderer... forget the editor and lua for a second, and open the render.bmx (or corresponding c++) source file, and click on the code button in the upper right... look at the list of functions... there you'll see the methods for the different accessible rendering properties... these are the same things you see in the editor, only in different places (as part of the atmosphere group, or other stuff) ... now click on one and look at the corresponding source code to see how they're changed... fog is represented as the renderer.fog property... you can either change it manually like so... fw.renderer.distancefogenabled=True fw.renderer.fogcolor=Vec4(1,.3,.3,1) fw.renderer.fogrange.x=1 fw.renderer.fogrange.y=44 or, as you'll see by glancing at the functions listing on the right side of the source window there are methods available for setting the fogdistance, color etc... thus making changing it a lil less verbose... fw.renderer.distancefogenabled=True fw.renderer.setDistancefogcolor(Vec4(1,.3,.3,1)) fw.renderer.setDistanceFogRange(.1,44) to sum it all up... when coding in bmax, i only use the lua scripted base classes to load up a scene as it is in the editor... then i use fw.renderer properties to change the properties i wanna modify in code... this works out great as it eliminates the need for the ole processScene function, and allows scenes to be loaded with lil or no hassle... it also makes the rendering properties easily accessible... my thanks to Mack and Marley for their guidance on this stuff... this lua thing had me going for a spin as well... now i know there are those who want to use lua more tan c++ or bmax... i'm just getting into that aspect of coding the engine myself... i'm impressed with how fasst the lua compiler spits out the luac ready 'compiled' code... but for some reason i can't get some scenes that i can load with bmax and c++ to load with straight lua script... --Mike Quote Link to comment Share on other sites More sharing options...
Flexman Posted May 9, 2010 Share Posted May 9, 2010 Well to explain a little I'm building an environmental system to control dynamic weather. And I wanted to keep it simple by taking the lua Atmosphere entity and over time pushing different parameters to it. Accessing it through the framework was causing exception errors as the skybox was not available (=null). This turns out not to be so strange, as I'd removed it in the editor You're code snippets I'm familiar with, I used them to learn and setup scripting at the start of the year for which I am grateful. Sorry if I come across as being a numbnuts at times. User at fault :/ Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.