large refactor

This commit is contained in:
Harvey Fong 2025-04-17 07:56:17 -06:00
parent e5c7906d35
commit c9b9807891
8 changed files with 307 additions and 196 deletions

View File

@ -7,101 +7,78 @@
namespace oom { namespace oom {
namespace bella { namespace bella {
// Function declaration // Function declaration
dl::bella_sdk::Node defaultScene2025(dl::bella_sdk::Scene& belScene);
// @param belScene - the scene to create the essentials in /*
// @return - the world node * MyEngineObserver Class override
dl::bella_sdk::Node defaultScene2025(dl::bella_sdk::Scene& belScene) { * This class receives callbacks from the Bella rendering engine to track rendering progress.
// Create the basic scene elements in Bella * It implements the EngineObserver interface and provides methods to:
// Each line creates a different type of node in the scene auto belBeautyPass = belScene.createNode("beautyPass","oomerBeautyPass","oomerBeautyPass"); * - Handle render start/stop events
auto belWorld = belScene.world(); // Get scene world root * - Track rendering progress
* - Handle error conditions
* - Store and retrieve the current progress state
*/
struct MyEngineObserver : public dl::bella_sdk::EngineObserver
{ {
dl::bella_sdk::Scene::EventScope es(belScene); public:
// Called when a rendering pass starts
auto belCamForm = belScene.createNode("xform","oomerCameraXform","oomerCameraXform"); void onStarted(dl::String pass) override
auto belCam = belScene.createNode("camera","oomerCamera","oomerCamera"); {
auto belSensor = belScene.createNode("sensor","oomerSensor","oomerSensor"); dl::logInfo("Started pass %s", pass.buf());
auto belLens = belScene.createNode("thinLens","oomerThinLens","oomerThinLens");
auto belImageDome = belScene.createNode("imageDome","oomerImageDome","oomerImageDome");
auto belGroundPlane = belScene.createNode("groundPlane","oomerGroundPlane","oomerGroundPlane");
auto belBeautyPass = belScene.createNode("beautyPass","oomerBeautyPass","oomerBeautyPass");
auto belGroundMat = belScene.createNode("quickMaterial","oomerGroundMat","oomerGroundMat");
auto belSun = belScene.createNode("sun","oomerSun","oomerSun");
auto belColorDome = belScene.createNode("colorDome","oomerColorDome","oomerColorDome");
auto belSettings = belScene.settings(); // Get scene settings
// Configure camera
belCam["resolution"] = dl::Vec2 {1920, 1080}; // Set resolution to 1080p
belCam["lens"] = belLens; // Connect camera to lens
belCam["sensor"] = belSensor; // Connect camera to sensor
belCamForm.parentTo(belWorld); // Parent camera transform to world
belCam.parentTo(belCamForm); // Parent camera to camera transform
// Position the camera with a transformation matrix
belCamForm["steps"][0]["xform"] = dl::Mat4 {0.525768608156, -0.850627633385, 0, 0, -0.234464751651, -0.144921468924, -0.961261695938, 0, 0.817675761479, 0.505401223947, -0.275637355817, 0, -88.12259018466, -54.468125200218, 50.706001690932, 1};
// Configure environment (image-based lighting)
belImageDome["ext"] = ".jpg";
belImageDome["dir"] = "./res";
belImageDome["multiplier"] = 6.0f;
belImageDome["file"] = "DayEnvironmentHDRI019_1K-TONEMAPPED";
belImageDome["overrides"]["background"] = belColorDome;
belColorDome["zenith"] = dl::Rgba{1.0f, 1.0f, 1.0f, 1.0f};
belColorDome["horizon"] = dl::Rgba{.85f, 0.76f, 0.294f, 1.0f};
belColorDome["altitude"] = 14.0f;
// Configure ground plane
//belGroundPlane["elevation"] = -.5f;
belGroundPlane["material"] = belGroundMat;
/* Commented out: Sun configuration
belSun["size"] = 20.0f;
belSun["month"] = "july";
belSun["rotation"] = 50.0f;*/
// Configure materials
belGroundMat["type"] = "metal";
belGroundMat["roughness"] = 22.0f;
belGroundMat["color"] = dl::Rgba{0.138431623578, 0.5, 0.3, 1.0};
// Set up scene settings
belSettings["beautyPass"] = belBeautyPass;
belSettings["camera"] = belCam;
belSettings["environment"] = belColorDome;
belSettings["iprScale"] = 100.0f;
belSettings["threads"] = dl::bella_sdk::Input(0); // Auto-detect thread count
belSettings["groundPlane"] = belGroundPlane;
belSettings["iprNavigation"] = "maya"; // Use Maya-like navigation in viewer
//settings["sun"] = sun;
auto belVoxel = belScene.createNode("box","oomerVoxel","oomerVoxel");
auto belLiqVoxel = belScene.createNode("box","oomerLiqVoxel","oomerLiqVoxel");
auto belVoxelForm = belScene.createNode("xform","oomerVoxelXform","oomerVoxelXform");
auto belLiqVoxelForm = belScene.createNode("xform","oomerLiqVoxelXform","oomerLiqVoxelXform");
auto belVoxelMat = belScene.createNode("orenNayar","oomerVoxelMat","oomerVoxelMat");
auto belMeshVoxel = belScene.createNode("mesh", "oomerMeshVoxel");
auto belBevel = belScene.createNode("bevel", "oomerBevel");
belBevel["radius"] = 90.0f;
belBevel["samples"] =dl::UInt(6);
//#include "resources/smoothcube.h"
addMeshCube(belMeshVoxel);
// Configure voxel box dimensions
belVoxel["radius"] = 0.33f;
belVoxel["sizeX"] = 0.99f;
belVoxel["sizeY"] = 0.99f;
belVoxel["sizeZ"] = 0.99f;
// Less gap to make liquid look better, allows more light to pass through
belLiqVoxel["sizeX"] = 0.99945f;
belLiqVoxel["sizeY"] = 0.99945f;
belLiqVoxel["sizeZ"] = 0.99945f;
belVoxel.parentTo(belVoxelForm);
belVoxelForm["steps"][0]["xform"] = dl::Mat4 {0.999,0,0,0,0,0.999,0,0,0,0,0.999,0,0,0,0,1};
belVoxelMat["reflectance"] = dl::Rgba{0.0, 0.0, 0.0, 1.0};
belVoxelForm["material"] = belVoxelMat;
} }
return belWorld;
// Called to update the current status of rendering
void onStatus(dl::String pass, dl::String status) override
{
dl::logInfo("%s [%s]", status.buf(), pass.buf());
} }
// Called to update rendering progress (percentage, time remaining, etc)
void onProgress(dl::String pass, dl::bella_sdk::Progress progress) override
{
dl::logInfo("%s [%s]", progress.toString().buf(), pass.buf());
}
void onImage(dl::String pass, dl::bella_sdk::Image image) override
{
dl::logInfo("We got an image %d x %d.", (int)image.width(), (int)image.height());
}
// Called when an error occurs during rendering
void onError(dl::String pass, dl::String msg) override
{
dl::logError("%s [%s]", msg.buf(), pass.buf());
}
// Called when a rendering pass completes
void onStopped(dl::String pass) override
{
dl::logInfo("Stopped %s", pass.buf());
}
// Returns the current progress as a string
std::string getProgress() const {
std::string* currentProgress = progressPtr.load();
if (currentProgress) {
return *currentProgress;
} else {
return "";
}
}
// Cleanup resources in destructor
~MyEngineObserver() {
setString(nullptr);
}
private:
// Thread-safe pointer to current progress string
std::atomic<std::string*> progressPtr{nullptr};
// Helper function to safely update the progress string
void setString(std::string* newStatus) {
std::string* oldStatus = progressPtr.exchange(newStatus);
delete oldStatus; // Clean up old string if it exists
}
};
} }
} }

View File

@ -3,9 +3,11 @@
namespace oom { namespace oom {
namespace bella { namespace bella {
// Unit mesh cube created in Blender, with rounded edges // Unit mesh cube created in Blender, with rounded edges
// Used for emitter voxels because procedural Bella box does not currently support emission // Used for emitter voxels because procedural Bella box does not currently support emission
void addMeshCube(dl::bella_sdk::Node& belMeshVoxel) { dl::bella_sdk::Node addMeshCube(dl::bella_sdk::Scene& belScene, dl::String guiName) {
auto belMeshVoxel = belScene.createNode("mesh", guiName);
belMeshVoxel["name"] = "oomerMeshVoxel"; belMeshVoxel["name"] = "oomerMeshVoxel";
belMeshVoxel["channels"][0] = "st"; belMeshVoxel["channels"][0] = "st";
belMeshVoxel["optimized"] = false; belMeshVoxel["optimized"] = false;
@ -1971,6 +1973,7 @@ namespace oom {
points.push_back(dl::Pos3f{0.353579, -0.353579, -0.495}); points.push_back(dl::Pos3f{0.353579, -0.353579, -0.495});
points.push_back(dl::Pos3f{-0.353579, -0.353579, -0.495}); points.push_back(dl::Pos3f{-0.353579, -0.353579, -0.495});
belMeshVoxel["steps"][0]["points"] = points; belMeshVoxel["steps"][0]["points"] = points;
return belMeshVoxel;
} }
} }
} }

41
oom_bella_misc.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
extern int s_oomBellaLogContext; // Declare the s_dlLogContext variable
namespace oom {
namespace bella {
// Define color codes
#define OOMRESET "\033[0m"
#define OOMRED "\033[31m"
#define OOMGREEN "\033[32m"
#define OOMYELLOW "\033[33m"
#define OOMBLUE "\033[34m"
// In your log function:
static void log(void* /*ctx*/, dl::LogType type, const char* msg)
{
switch (type)
{
case dl::LogType_Info:
DL_PRINT(OOMGREEN "[INFO] %s" OOMRESET "\n", msg);
break;
case dl::LogType_Warning:
if (strcmp(msg, "Redefining arg with long form: 'input'") == 0) {
break;
} else if (strcmp(msg, "Core node implementations are not linked.") == 0) {
break;
}
DL_PRINT(OOMYELLOW "[WARN] %s" OOMRESET "\n", msg);
break;
case dl::LogType_Error:
DL_PRINT(OOMRED "[ERROR] %s" OOMRESET "\n", msg);
break;
case dl::LogType_Custom:
DL_PRINT(OOMBLUE "%s\n" OOMRESET, msg);
break;
}
}
}
}

151
oom_bella_premade.h Normal file
View File

@ -0,0 +1,151 @@
#pragma once
// Bella SDK includes - external libraries for 3D rendering
#include "../bella_engine_sdk/src/bella_sdk/bella_engine.h" // For creating and manipulating 3D scenes in Bella
#include "../oom/oom_bella_long.h" // This file is very large
extern int s_oomBellaLogContext; // Declare the s_dlLogContext variable
// Define the oom namespace
namespace oom {
namespace bella {
// Function declaration
dl::bella_sdk::Node defaultScene2025(dl::bella_sdk::Scene& belScene);
dl::bella_sdk::Node defaultSceneVoxel(dl::bella_sdk::Scene& belScene);
// @param belScene - the scene to create the essentials in
// @return - the world node
dl::bella_sdk::Node defaultScene2025(dl::bella_sdk::Scene& belScene) {
// Create the basic scene elements in Bella
// Each line creates a different type of node in the scene auto belBeautyPass = belScene.createNode("beautyPass","oomerBeautyPass","oomerBeautyPass");
auto belWorld = belScene.world(); // Get scene world root
{
dl::bella_sdk::Scene::EventScope es(belScene);
// Configure camera
auto belCamForm = belScene.createNode("xform","oomCameraXform","oomCameraXform");
auto belCam = belScene.createNode("camera","oomCamera","oomCamera");
auto belSensor = belScene.createNode("sensor","oomSensor","oomSensor");
auto belLens = belScene.createNode("thinLens","oomThinLens","oomThinLens");
belCam["resolution"] = dl::Vec2 {800, 800}; // Set resolution to 1080p
belCam["lens"] = belLens; // Connect camera to lens
belCam["sensor"] = belSensor; // Connect camera to sensor
belCamForm.parentTo(belWorld); // Parent camera transform to world
belCam.parentTo(belCamForm); // Parent camera to camera transform
// Position the camera with a transformation matrix
belCamForm["steps"][0]["xform"] = dl::Mat4 {0.525768608156, -0.850627633385, 0, 0, -0.234464751651, -0.144921468924, -0.961261695938, 0, 0.817675761479, 0.505401223947, -0.275637355817, 0, -88.12259018466, -54.468125200218, 50.706001690932, 1};
// Configure environment (image-based lighting)
auto belImageDome = belScene.createNode("imageDome","oomImageDome","oomImageDome");
auto belColorDome = belScene.createNode("colorDome","oomColorDome","oomColorDome");
belImageDome["ext"] = ".jpg";
belImageDome["dir"] = "./res";
belImageDome["multiplier"] = 6.0f;
belImageDome["file"] = "DayEnvironmentHDRI019_1K-TONEMAPPED";
belImageDome["overrides"]["background"] = belColorDome;
belColorDome["zenith"] = dl::Rgba{1.0f, 1.0f, 1.0f, 1.0f};
belColorDome["horizon"] = dl::Rgba{.85f, 0.76f, 0.294f, 1.0f};
belColorDome["altitude"] = 14.0f;
// Configure a metallic ground plane
auto belGroundPlane = belScene.createNode("groundPlane","oomGroundPlane","oomGroundPlane");
auto belGroundMat = belScene.createNode("quickMaterial","oomGroundMat","oomGroundMat");
belGroundPlane["material"] = belGroundMat;
belGroundMat["type"] = "metal";
belGroundMat["roughness"] = 22.0f;
belGroundMat["color"] = dl::Rgba{0.138431623578, 0.5, 0.3, 1.0};
// Set up scene settings
auto belSettings = belScene.settings(); // Get scene settings
auto belBeautyPass = belScene.createNode("beautyPass","oomBeautyPass","oomBeautyPass");
belSettings["beautyPass"] = belBeautyPass;
belSettings["camera"] = belCam;
belSettings["environment"] = belColorDome;
belSettings["iprScale"] = 100.0f;
belSettings["threads"] = dl::bella_sdk::Input(0); // Auto-detect thread count
belSettings["groundPlane"] = belGroundPlane;
belSettings["iprNavigation"] = "maya"; // Use Maya-like navigation in viewer
}
return belWorld;
}
// @param belScene - the scene to create the essentials in
// @return - the world node
dl::bella_sdk::Node defaultSceneVoxel(dl::bella_sdk::Scene& belScene) {
// Create basic scene elements in Bella for voxel rendering
auto belWorld = belScene.world(); // Get scene world root
{
dl::bella_sdk::Scene::EventScope es(belScene);
// Configure camera
auto belCamForm = belScene.createNode("xform","oomCameraXform","oomCameraXform");
auto belCam = belScene.createNode("camera","oomCamera","oomCamera");
auto belSensor = belScene.createNode("sensor","oomSensor","oomSensor");
auto belLens = belScene.createNode("thinLens","oomThinLens","oomThinLens");
belCam["resolution"] = dl::Vec2 {1920, 1080}; // Set resolution to 1080p
belCam["lens"] = belLens; // Connect camera to lens
belCam["sensor"] = belSensor; // Connect camera to sensor
belCamForm.parentTo(belWorld); // Parent camera transform to world
belCam.parentTo(belCamForm); // Parent camera to camera transform
// Position the camera with a transformation matrix
belCamForm["steps"][0]["xform"] = dl::Mat4 {0.525768608156, -0.850627633385, 0, 0, -0.234464751651, -0.144921468924, -0.961261695938, 0, 0.817675761479, 0.505401223947, -0.275637355817, 0, -88.12259018466, -54.468125200218, 50.706001690932, 1};
// Configure environment (image-based lighting)
auto belImageDome = belScene.createNode("imageDome","oomImageDome","oomImageDome");
auto belColorDome = belScene.createNode("colorDome","oomColorDome","oomColorDome");
belImageDome["ext"] = ".jpg";
belImageDome["dir"] = "./res";
belImageDome["multiplier"] = 6.0f;
belImageDome["file"] = "DayEnvironmentHDRI019_1K-TONEMAPPED";
belImageDome["overrides"]["background"] = belColorDome;
belColorDome["zenith"] = dl::Rgba{1.0f, 1.0f, 1.0f, 1.0f};
belColorDome["horizon"] = dl::Rgba{.85f, 0.76f, 0.294f, 1.0f};
belColorDome["altitude"] = 14.0f;
// Configure ground plane
auto belGroundPlane = belScene.createNode("groundPlane","oomGroundPlane","oomGroundPlane");
auto belGroundMat = belScene.createNode("quickMaterial","oomGroundMat","oomGroundMat");
belGroundPlane["material"] = belGroundMat;
belGroundMat["type"] = "metal";
belGroundMat["roughness"] = 22.0f;
belGroundMat["color"] = dl::Rgba{0.138431623578, 0.5, 0.3, 1.0};
// Set up scene settings
auto belSettings = belScene.settings(); // Get scene settings
auto belBeautyPass = belScene.createNode("beautyPass","oomBeautyPass","oomBeautyPass");
belSettings["beautyPass"] = belBeautyPass;
belSettings["camera"] = belCam;
belSettings["environment"] = belColorDome;
belSettings["iprScale"] = 100.0f;
belSettings["threads"] = dl::bella_sdk::Input(0); // Auto-detect thread count
belSettings["groundPlane"] = belGroundPlane;
belSettings["iprNavigation"]= "maya"; // Use Maya-like navigation in viewer
// Create voxel nodes
auto belVoxel = belScene.createNode("box","oomVoxel","oomVoxel");
auto belLiqVoxel = belScene.createNode("box","oomLiqVoxel","oomLiqVoxel");
auto belVoxelForm = belScene.createNode("xform","oomVoxelXform","oomVoxelXform");
auto belLiqVoxelForm = belScene.createNode("xform","oomLiqVoxelXform","oomLiqVoxelXform");
auto belVoxelMat = belScene.createNode("orenNayar","oomVoxelMat","oomVoxelMat");
auto belBevel = belScene.createNode("bevel", "oomBevel", "oomBevel");
belBevel["radius"] = 90.0f;
belBevel["samples"] =dl::UInt(6);
auto belMeshVoxel = addMeshCube(belScene, "oomMeshVoxel");
belVoxel["radius"] = 0.33f;
belVoxel["sizeX"] = 0.99f;
belVoxel["sizeY"] = 0.99f;
belVoxel["sizeZ"] = 0.99f;
// Less gap to make liquid look better, allows more light to pass through
belLiqVoxel["sizeX"] = 0.99945f;
belLiqVoxel["sizeY"] = 0.99945f;
belLiqVoxel["sizeZ"] = 0.99945f;
belVoxel.parentTo(belVoxelForm);
belVoxelForm["steps"][0]["xform"] = dl::Mat4 {0.999,0,0,0,0,0.999,0,0,0,0,0.999,0,0,0,0,1};
belVoxelMat["reflectance"] = dl::Rgba{0.0, 0.0, 0.0, 1.0};
belVoxelForm["material"] = belVoxelMat;
}
return belWorld;
}
}
}

View File

@ -3,95 +3,5 @@
namespace oom { namespace oom {
namespace bella { namespace bella {
// Function declaration
dl::bella_sdk::Node defaultScene2025(dl::bella_sdk::Scene& belScene);
// @param belScene - the scene to create the essentials in
// @return - the world node
dl::bella_sdk::Node defaultScene2025(dl::bella_sdk::Scene& belScene) {
// Create the basic scene elements in Bella
// Each line creates a different type of node in the scene auto belBeautyPass = belScene.createNode("beautyPass","oomerBeautyPass","oomerBeautyPass");
auto belWorld = belScene.world(); // Get scene world root
{
dl::bella_sdk::Scene::EventScope es(belScene);
auto belCamForm = belScene.createNode("xform","oomerCameraXform","oomerCameraXform");
auto belCam = belScene.createNode("camera","oomerCamera","oomerCamera");
auto belSensor = belScene.createNode("sensor","oomerSensor","oomerSensor");
auto belLens = belScene.createNode("thinLens","oomerThinLens","oomerThinLens");
auto belImageDome = belScene.createNode("imageDome","oomerImageDome","oomerImageDome");
auto belGroundPlane= belScene.createNode("groundPlane","oomerGroundPlane","oomerGroundPlane");
auto belBeautyPass = belScene.createNode("beautyPass","oomerBeautyPass","oomerBeautyPass");
auto belGroundMat = belScene.createNode("quickMaterial","oomerGroundMat","oomerGroundMat");
auto belSun = belScene.createNode("sun","oomerSun","oomerSun");
auto belColorDome = belScene.createNode("colorDome","oomerColorDome","oomerColorDome");
auto belSettings = belScene.settings(); // Get scene settings
// Configure camera
belCam["resolution"] = dl::Vec2 {1920, 1080}; // Set resolution to 1080p
belCam["lens"] = belLens; // Connect camera to lens
belCam["sensor"] = belSensor; // Connect camera to sensor
belCamForm.parentTo(belWorld); // Parent camera transform to world
belCam.parentTo(belCamForm); // Parent camera to camera transform
belCamForm["steps"][0]["xform"] = dl::Mat4 {0.525768608156, -0.850627633385, 0, 0, -0.234464751651, -0.144921468924, -0.961261695938, 0, 0.817675761479, 0.505401223947, -0.275637355817, 0, -88.12259018466, -54.468125200218, 50.706001690932, 1};
// Configure environment (image-based lighting)
belImageDome["ext"] = ".jpg";
belImageDome["dir"] = "./res";
belImageDome["multiplier"] = 6.0f;
belImageDome["file"] = "DayEnvironmentHDRI019_1K-TONEMAPPED";
belImageDome["overrides"]["background"] = belColorDome;
belColorDome["zenith"] = dl::Rgba{1.0f, 1.0f, 1.0f, 1.0f};
belColorDome["horizon"] = dl::Rgba{.85f, 0.76f, 0.294f, 1.0f};
belColorDome["altitude"] = 14.0f;
// Configure ground plane
belGroundPlane["material"] = belGroundMat;
// Configure materials
belGroundMat["type"] = "metal";
belGroundMat["roughness"] = 22.0f;
belGroundMat["color"] = dl::Rgba{0.138431623578, 0.5, 0.3, 1.0};
// Set up scene settings
belSettings["beautyPass"] = belBeautyPass;
belSettings["camera"] = belCam;
belSettings["environment"] = belColorDome;
belSettings["iprScale"] = 100.0f;
belSettings["threads"] = dl::bella_sdk::Input(0); // Auto-detect thread count
belSettings["groundPlane"] = belGroundPlane;
belSettings["iprNavigation"]= "maya"; // Use Maya-like navigation in viewer
auto belVoxel = belScene.createNode("box","oomerVoxel","oomerVoxel");
auto belLiqVoxel = belScene.createNode("box","oomerLiqVoxel","oomerLiqVoxel");
auto belVoxelForm = belScene.createNode("xform","oomerVoxelXform","oomerVoxelXform");
auto belLiqVoxelForm = belScene.createNode("xform","oomerLiqVoxelXform","oomerLiqVoxelXform");
auto belVoxelMat = belScene.createNode("orenNayar","oomerVoxelMat","oomerVoxelMat");
auto belMeshVoxel = belScene.createNode("mesh", "oomerMeshVoxel");
auto belBevel = belScene.createNode("bevel", "oomerBevel");
belBevel["radius"] = 90.0f;
belBevel["samples"] =dl::UInt(6);
oom::bella::addMeshCube(belMeshVoxel); // bring in a blender mesh cube for emitters
// Configure voxel box dimensions
belVoxel["radius"] = 0.33f;
belVoxel["sizeX"] = 0.99f;
belVoxel["sizeY"] = 0.99f;
belVoxel["sizeZ"] = 0.99f;
// Less gap to make liquid look better, allows more light to pass through
belLiqVoxel["sizeX"] = 0.99945f;
belLiqVoxel["sizeY"] = 0.99945f;
belLiqVoxel["sizeZ"] = 0.99945f;
belVoxel.parentTo(belVoxelForm);
belVoxelForm["steps"][0]["xform"] = dl::Mat4 {0.999,0,0,0,0,0.999,0,0,0,0,0.999,0,0,0,0,1};
belVoxelMat["reflectance"] = dl::Rgba{0.0, 0.0, 0.0, 1.0};
belVoxelForm["material"] = belVoxelMat;
}
return belWorld;
}
} }
} }

View File

@ -10,6 +10,7 @@ namespace oom {
//Forward declarations //Forward declarations
extern const unsigned char DayEnvironmentHDRI019_1K_TONEMAPPED_jpg[]; extern const unsigned char DayEnvironmentHDRI019_1K_TONEMAPPED_jpg[];
extern const unsigned int DayEnvironmentHDRI019_1K_TONEMAPPED_jpg_len; extern const unsigned int DayEnvironmentHDRI019_1K_TONEMAPPED_jpg_len;
// Convert sRGB color value to linear color space // Convert sRGB color value to linear color space
inline float srgbToLinear(float value) { inline float srgbToLinear(float value) {
return (value <= 0.04045f) ? return (value <= 0.04045f) ?

23
oom_queue.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <string> // For std::string
#include <filesystem> // For std::filesystem
// This is a set of common oomer utilities for file queue operations
#include "../efsw/src/efsw/FileSystem.hpp" // For file watching
#include "../efsw/src/efsw/System.hpp" // For file watching
#include "../efsw/include/efsw/efsw.hpp" // For file watching
#include "../bella_engine_sdk/src/dl_core/dl_string.h"
#include "../bella_engine_sdk/src/dl_core/dl_fs.h"
namespace oom {
namespace filesystem {
/// A class that manages a queue of files to render with both FIFO order and fast lookups
}
}

View File

@ -22,7 +22,7 @@ using json = nlohmann::json;
// Define STB_IMAGE_IMPLEMENTATION before including to create the implementation // Define STB_IMAGE_IMPLEMENTATION before including to create the implementation
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "thirdparty/stb_image.h" // STB Image library #include "thirdparty/stb_image.h" // STB Image library used to read 256x1 vmax palette stored in .png
namespace oom { namespace oom {
namespace vmax { namespace vmax {
@ -36,16 +36,23 @@ namespace oom {
inline uint32_t compactBits(uint32_t n); inline uint32_t compactBits(uint32_t n);
inline void decodeMorton3DOptimized(uint32_t morton, uint32_t& x, uint32_t& y, uint32_t& z); inline void decodeMorton3DOptimized(uint32_t morton, uint32_t& x, uint32_t& y, uint32_t& z);
struct Material; struct Material;
struct VoxelGrid; //struct VoxelGrid;
struct Model; struct Model;
inline std::array<Material, 8> getMaterials(plist_t pnodPalettePlist);
inline std::vector<Voxel> decodeVoxels(const std::vector<uint8_t>& dsData, int mortonOffset, uint16_t chunkID);
struct ChunkInfo; struct ChunkInfo;
inline std::vector<Voxel> decodeVoxels(const std::vector<uint8_t>& dsData, int mortonOffset, uint16_t chunkID);
// Useful plist functions
// Read plist file
inline plist_t readPlist(const std::string& inStrPlist, std::string outStrPlist, bool decompress);
inline plist_t readPlist(const std::string& inStrPlist, bool decompress);
inline std::array<Material, 8> getMaterials(plist_t pnodPalettePlist);
plist_t getNestedPlistNode(plist_t plist_root, const std::vector<std::string>& path); plist_t getNestedPlistNode(plist_t plist_root, const std::vector<std::string>& path);
ChunkInfo chunkInfo(const plist_t& plist_snapshot_dict_item); ChunkInfo chunkInfo(const plist_t& plist_snapshot_dict_item);
std::vector<Voxel> vmaxVoxelInfo(plist_t& plist_datastream, uint64_t chunkID, uint64_t minMorton); std::vector<Voxel> vmaxVoxelInfo(plist_t& plist_datastream, uint64_t chunkID, uint64_t minMorton);
inline plist_t readPlist(const std::string& inStrPlist, std::string outStrPlist, bool decompress);
inline plist_t readPlist(const std::string& inStrPlist, bool decompress); // Use these to parse scene.json
struct JsonModelInfo; struct JsonModelInfo;
struct JsonGroupInfo; struct JsonGroupInfo;
class JsonSceneParser; class JsonSceneParser;
@ -255,17 +262,16 @@ namespace oom {
bool volumetric; // future use bool volumetric; // future use
}; };
struct VoxelGrid { /*struct VoxelGrid {
// dimensions of the voxel grid // dimensions of the voxel grid
uint32_t size_x, size_y, size_z; uint32_t size_x, size_y, size_z;
// voxel data // voxel data
uint8_t* voxel_data; uint8_t* voxel_data;
}; };*/
// Create a structure to represent a model with its voxels with helper functions // Create a structure to represent a model with its voxels with helper functions
// since the xyz coords are at the voxel level, we need an accessor to walk it sequentially // since the xyz coords are at the voxel level, we need an accessor to walk it sequentially
// maybe I create a new structure called VoxelGrid
struct Model { struct Model {
// Model identifier or name // Model identifier or name
std::string vmaxbFileName; // file name is used like a key std::string vmaxbFileName; // file name is used like a key
@ -474,7 +480,7 @@ namespace oom {
} else { } else {
std::cout << "No materials array found or invalid type" << std::endl; std::cout << "No materials array found or invalid type" << std::endl;
} }
#ifdef _DEBUG23 #ifdef _DEBUG
for (const auto& material : vmaxMaterials) { for (const auto& material : vmaxMaterials) {
std::cout << "Material: " << material.materialName << std::endl; std::cout << "Material: " << material.materialName << std::endl;
std::cout << " Transmission: " << material.transmission << std::endl; std::cout << " Transmission: " << material.transmission << std::endl;
@ -594,7 +600,6 @@ namespace oom {
return ChunkInfo{-1, 0, 0, 0, 0, 0}; return ChunkInfo{-1, 0, 0, 0, 0, 0};
} }
// Right after we get ChunkInfo, we can get the voxels because we need morton chunk offset // Right after we get ChunkInfo, we can get the voxels because we need morton chunk offset
// @param pnodSnaphot: plist_t of a snapshot // @param pnodSnaphot: plist_t of a snapshot
// @return vector of Voxel // @return vector of Voxel
@ -821,7 +826,7 @@ namespace oom {
} }
// Parse the JSON // Parse the JSON
json sceneData; json sceneData; // uses nlohmann/json
file >> sceneData; file >> sceneData;
file.close(); file.close();