mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-30 08:34:59 +00:00
feat: Add support for loading meshes from PK3 archives
- Updated CMakeLists.txt to find and link libzip. - Modified conanfile.py to include libzip as a dependency. - Created a new configuration file for Quake 3 runtime settings. - Implemented loading of Quake 3 maps from PK3 archives in mesh_service. - Added new Lua bindings for loading meshes from archives in script_engine_service. - Enhanced material handling in materialx_shader_generator to support vertex data blocks.
This commit is contained in:
@@ -471,6 +471,7 @@ void ScriptEngineService::RegisterBindings(lua_State* L) {
|
||||
};
|
||||
|
||||
bind("load_mesh_from_file", &ScriptEngineService::LoadMeshFromFile);
|
||||
bind("load_mesh_from_pk3", &ScriptEngineService::LoadMeshFromArchive);
|
||||
bind("physics_create_box", &ScriptEngineService::PhysicsCreateBox);
|
||||
bind("physics_step_simulation", &ScriptEngineService::PhysicsStepSimulation);
|
||||
bind("physics_get_transform", &ScriptEngineService::PhysicsGetTransform);
|
||||
@@ -528,6 +529,36 @@ int ScriptEngineService::LoadMeshFromFile(lua_State* L) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int ScriptEngineService::LoadMeshFromArchive(lua_State* L) {
|
||||
auto* context = static_cast<LuaBindingContext*>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
auto logger = context ? context->logger : nullptr;
|
||||
if (!context || !context->meshService) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, "Mesh service not available");
|
||||
return 2;
|
||||
}
|
||||
|
||||
const char* archivePath = luaL_checkstring(L, 1);
|
||||
const char* entryPath = luaL_checkstring(L, 2);
|
||||
if (logger) {
|
||||
logger->Trace("ScriptEngineService", "LoadMeshFromArchive",
|
||||
"archivePath=" + std::string(archivePath) +
|
||||
", entryPath=" + std::string(entryPath));
|
||||
}
|
||||
|
||||
MeshPayload payload;
|
||||
std::string error;
|
||||
if (!context->meshService->LoadFromArchive(archivePath, entryPath, payload, error)) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, error.c_str());
|
||||
return 2;
|
||||
}
|
||||
|
||||
context->meshService->PushMeshToLua(L, payload);
|
||||
lua_pushnil(L);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int ScriptEngineService::PhysicsCreateBox(lua_State* L) {
|
||||
auto* context = static_cast<LuaBindingContext*>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
auto logger = context ? context->logger : nullptr;
|
||||
|
||||
Reference in New Issue
Block a user