Profile cover photo
Profile photo
Leadwerks Game Engine
452 followers -
Leadwerks Game Engine is the easiest way to build your own 3D games.
Leadwerks Game Engine is the easiest way to build your own 3D games.

452 followers
About
Posts

Post has attachment
How to Expose C++ Classes to Lua in Turbo Game Engine: I'm using the excellent sol2 library to interface C++ and Lua in the upcoming Turbo Game Engine. I've decided not to create an automatic header parser like I did for tolua++ in Leadwerks 4, for the following reasons: * There are a lot of different options and special cases that would probably make a header parser a very involved task with me continually discovering new cases I have to account for. * sol2 is really easy to use. Each class I want available to Lua will have a static function the Lua virtual machine code can call when a new Lua state is created. The new_usertype method is able to expose a C++ class to Lua in a single command. At a minimum, the name of the class and the base class should be defined. This method can accept a lot of arguments, so I am going to break it up over several lines. void Vec3::InitializeClass(sol::state* luastate) { //Class luastate->new_usertype ( //Name "Vec3", //Hierarchy sol::base_classes, sol::bases() ); } We can export members to Lua very easily just by adding more arguments in the call to new_usertype: //Members "x", &Vec3::x, "y", &Vec3::y, "z", &Vec3::z, Metamethods are special operations like math operands. For example, adding these arguments into the method call will set all the metamethods we want to use. //Metamethods sol::meta_function::to_string, &Vec3::ToString, sol::meta_function::index, [](Vec3& v, const int index) { if (index 2) return 0.0f; return v[index]; }, sol::meta_function::new_index, [](Vec3& v, const int index, double x) { if (index 2) return; v[index] = x; }, sol::meta_function::equal_to, &Vec3::operator==, sol::meta_function::less_than, &Vec3::operatorset_function("Vec3", [](float x, float y, float z) {return Vec3(x, y, z); } ); This allows us to create a Vec3 object in Lua the same way we would with a constructor in C++. Here is the complete Vec3 class initialization code, which makes Lua recognize the class, exposes the members, adds math operations, and exposes class methods: void Vec3::InitializeClass(sol::state* luastate) { //Class luastate->new_usertype ( //Name "Vec3", //Hierarchy sol::base_classes, sol::bases(), //Members "x", &Vec3::x, "y", &Vec3::y, "z", &Vec3::z, "r", &Vec3::x, "g", &Vec3::y, "b", &Vec3::z, //Metamethods sol::meta_function::to_string, &Vec3::ToString, sol::meta_function::index, [](Vec3& v, const int index) { if (index 2) return 0.0f; return v[index]; }, sol::meta_function::new_index, [](Vec3& v, const int index, double x) { if (index 2) return; v[index] = x; }, sol::meta_function::equal_to, &Vec3::operator==, sol::meta_function::less_than, &Vec3::operatorset_function("Vec3", [](float x, float y, float z) {return Vec3(x, y, z); } ); } To add your own C++ classes to Lua in Turbo, you will create a similar function as above and call it at the start of the program.
Add a comment...

Post has attachment
FBX Converter Updated: A small update has been published to the default branch of Leadwerks Game Engine on Steam. This updates the FBX converter so that the scene units (meters, feet, etc.) are read from the file and used to convert the model at the proper size. Previously, the raw numbers for position, scale, and vertex positions were read in as meters. The new importer also supports both smooth groups and per-vertex normals, so models can be imported more reliably without having to recalculate normals. An error in the probe shader that only occurred when the shader was compiled for VR mode has also been fixed.
Add a comment...

Post has attachment
Turbo Game Engine Beta Updated: An update is available for the new Turbo Game Engine beta. * Fixed compiling errors with latest Visual Studio version * Fixed compatibility problems with AMD hardware * Process is now DPI-aware * Added high-resolution depth buffer (additional parameter on CreateContext()). Subscribers can download the new version here.
Add a comment...

Post has attachment
Add a comment...

Post has attachment
Leadwerks in use at Goddard Space Flight Center. #gamedev #indiedev #vr
Photo
Add a comment...

Post has attachment
Add a comment...

I've got a position open for a 3D artist who is good at mechanical objects (fairly high-poly but still realtime modeling). Send your portfolio if interested. #gamedev #indiedev #vr
Add a comment...

Post has attachment
Add a comment...

Post has attachment
Also interesting. #gamedev #indiedev #vr
Photo
Add a comment...

Post has attachment
Interesting. #gamedev #indiedev #vr
Photo
Add a comment...
Wait while more posts are being loaded