switched to ../oom

This commit is contained in:
Harvey Fong 2025-04-13 20:02:52 -06:00
parent 9041081b15
commit c77364041d
2 changed files with 68 additions and 22 deletions

View File

@ -87,7 +87,6 @@ all: $(OUTPUT_FILE)
clean: clean:
rm -f $(OBJ_DIR)/$(EXECUTABLE_NAME).o rm -f $(OBJ_DIR)/$(EXECUTABLE_NAME).o
rm -f $(OUTPUT_FILE) rm -f $(OUTPUT_FILE)
rm -f $(BIN_DIR)/$(SDK_LIB_FILE)
rm -f $(BIN_DIR)/*.dylib rm -f $(BIN_DIR)/*.dylib
rmdir $(OBJ_DIR) 2>/dev/null || true rmdir $(OBJ_DIR) 2>/dev/null || true
rmdir $(BIN_DIR) 2>/dev/null || true rmdir $(BIN_DIR) 2>/dev/null || true
@ -97,7 +96,6 @@ cleanall:
rm -f obj/*/debug/*.o rm -f obj/*/debug/*.o
rm -f bin/*/release/$(EXECUTABLE_NAME) rm -f bin/*/release/$(EXECUTABLE_NAME)
rm -f bin/*/debug/$(EXECUTABLE_NAME) rm -f bin/*/debug/$(EXECUTABLE_NAME)
rm -f bin/*/release/$(SDK_LIB_FILE)
rm -f bin/*/debug/$(SDK_LIB_FILE) rm -f bin/*/debug/$(SDK_LIB_FILE)
rm -f bin/*/release/*.dylib rm -f bin/*/release/*.dylib
rm -f bin/*/debug/*.dylib rm -f bin/*/debug/*.dylib

View File

@ -3,7 +3,7 @@
// Bella SDK includes - external libraries for 3D rendering // Bella SDK includes - external libraries for 3D rendering
#include "../bella_scene_sdk/src/bella_sdk/bella_scene.h" // For creating and manipulating 3D scenes in Bella #include "../bella_scene_sdk/src/bella_sdk/bella_scene.h" // For creating and manipulating 3D scenes in Bella
//#include "../bella_scene_sdk/src/dl_core/dl_main.inl" // Core functionality from the Diffuse Logic engine #include "../bella_scene_sdk/src/dl_core/dl_main.inl" // Core functionality from the Diffuse Logic engine
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> // For ShellExecuteW #include <windows.h> // For ShellExecuteW
@ -11,14 +11,15 @@
#include <codecvt> // For wstring_convert #include <codecvt> // For wstring_convert
#endif #endif
#include "oomer_bella_scene.h" // common bella scene code #include "../oom/oom_bella_long.h"
#include "oomer_misc.h" // common misc code #include "../oom/oom_bella_scene.h"
#include "../oom/oom_license.h"
#define OGT_VOX_IMPLEMENTATION #define OGT_VOX_IMPLEMENTATION
#include "../opengametools/src/ogt_vox.h" #include "../opengametools/src/ogt_vox.h"
dl::bella_sdk::Node essentialsToScene(dl::bella_sdk::Scene& belScene); dl::bella_sdk::Node oom::bella::essentialsToScene(dl::bella_sdk::Scene& belScene);
const ogt_vox_scene* load_vox_scene(const char* filename, uint32_t scene_read_flags);
int DL_main(dl::Args& args) { int DL_main(dl::Args& args) {
args.add("i", "input", "", "vmax directory or vmax.zip file"); args.add("i", "input", "", "vmax directory or vmax.zip file");
@ -38,40 +39,87 @@ int DL_main(dl::Args& args) {
if (args.have("--licenseinfo")) if (args.have("--licenseinfo"))
{ {
std::cout << "poomer-ogt-bella\n\nCopyright 2025 Harvey Fong" << std::endl; std::cout << "poomer-ogt-bella\n\nCopyright 2025 Harvey Fong" << std::endl;
std::cout << printLicense() << std::endl; std::cout << oom::license::printLicense() << std::endl;
return 0; return 0;
} }
// If --thirdparty was requested, print third-party licenses and exit // If --thirdparty was requested, print third-party licenses and exit
if (args.have("--thirdparty")) if (args.have("--thirdparty"))
{ {
std::cout << printBellaSDKThirdPartyLicence() << "\n===\n" << std::endl; std::cout << oom::license::printBellaSDK() << "\n===\n" << std::endl;
std::cout << printOpenGameToolsThirdPartyLicence() << "\n===\n" << std::endl; std::cout << oom::license::printOpenGameTools() << "\n===\n" << std::endl;
return 0; return 0;
} }
if (args.have("--input")) if (args.have("--input"))
{ {
dl::String bszName; dl::String bszName;
dl::String objName; dl::String voxName;
dl::String vmaxDirName; voxName = args.value("--input");
vmaxDirName = args.value("--input"); bszName = voxName.replace("vox", "bsz");
bszName = vmaxDirName.replace("vmax", "bsz");
objName = vmaxDirName.replace("vmax", "obj");
// Create a new scene // Create a new scene
dl::bella_sdk::Scene belScene; dl::bella_sdk::Scene belScene;
belScene.loadDefs(); belScene.loadDefs();
auto belWorld = essentialsToScene(belScene); auto belWorld = oom::bella::essentialsToScene(belScene);
auto belMeshXform = belScene.createNode("xform", "oomerMeshXform");
auto belMeshVoxel = belScene.createNode("mesh", "oomerMeshVoxel"); auto voxScene = load_vox_scene(voxName.buf(), 0);
belMeshVoxel.parentTo(belMeshXform);
belMeshXform.parentTo(belWorld); if (!voxScene)
addMeshCube(belMeshVoxel); {
std::cerr << "Failed to load voxel scene" << std::endl;
return 1;
}
for (uint32_t model_index = 0; model_index < voxScene->num_models; model_index++) {
std::cout << "Model " << model_index << std::endl;
const ogt_vox_model* model = voxScene->models[model_index];
// find the model name by finding a named instance that references it.
const char* model_name = NULL;
for (uint32_t instance_index = 0; instance_index < voxScene->num_instances; instance_index++) {
if (voxScene->instances[instance_index].name && voxScene->instances[instance_index].model_index == model_index) {
if (!model_name) {
model_name = voxScene->instances[instance_index].name;
}
}
}
if (model_name) {
std::cout << "Model name: " << model_name << std::endl;
}
}
// Save the scene to a Bella scene file
belScene.write("foo.bsz"); belScene.write("foo.bsz");
} }
return 0; return 0;
} }
// a helper function to load a magica voxel scene given a filename.
const ogt_vox_scene* load_vox_scene(const char* filename, uint32_t scene_read_flags)
{
// open the file
FILE * fp = fopen(filename, "rb");
if (!fp)
return NULL;
// get the buffer size which matches the size of the file
fseek(fp, 0, SEEK_END);
uint32_t buffer_size = ftell(fp);
fseek(fp, 0, SEEK_SET);
// load the file into a memory buffer
uint8_t * buffer = new uint8_t[buffer_size];
fread(buffer, buffer_size, 1, fp);
fclose(fp);
// construct the scene from the buffer
const ogt_vox_scene * scene = ogt_vox_read_scene_with_flags(buffer, buffer_size, scene_read_flags);
// the buffer can be safely deleted once the scene is instantiated.
delete[] buffer;
return scene;
}