Skip to content

Commit

Permalink
wip append gltfs
Browse files Browse the repository at this point in the history
  • Loading branch information
jxarco committed Dec 9, 2024
1 parent 6d1d18b commit f1cb0b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/engine/sample_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,9 +1099,15 @@ std::vector<std::string> SampleEngine::get_cameras_names()
void SampleEngine::append_glb(const std::string& filename)
{
std::vector<Node*> entities;
parse_scene(filename.c_str(), entities);

main_scene->add_nodes(entities);
parse_scene(filename.c_str(), entities, true, scene_root);

if (!entities.empty()) {
assert(!scene_root);
assert(entities.size() == 1u);
scene_root = static_cast<Node3D*>(entities[0]);
main_scene->add_nodes(entities);
}
}

Camera* SampleEngine::get_current_camera()
Expand Down
3 changes: 3 additions & 0 deletions src/engine/sample_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class EntityCamera;
class MeshInstance3D;
class Node3D;

class SampleEngine : public Engine {

Expand All @@ -26,6 +27,8 @@ class SampleEngine : public Engine {
std::vector<EntityCamera*> cameras;
bool rotate_scene = false;

Node3D* scene_root = nullptr;

float camera_interp_speed = 1.0f;

// Vpet connection
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ EMSCRIPTEN_BINDINGS(_Class_) {

emscripten::class_<SampleEngine>("Engine")
.constructor<>()
.class_function("getInstance", &SampleEngine::get_sample_instance, emscripten::return_value_policy::reference())
.function("setEnvironment", &SampleEngine::set_skybox_texture)
.function("loadGLB", &SampleEngine::load_glb)
.function("appendGLB", &SampleEngine::append_glb)
.function("loadPly", &SampleEngine::load_ply)
.function("setCameraType", &SampleEngine::set_camera_type)
.class_function("getInstance", &SampleEngine::get_sample_instance, emscripten::return_value_policy::reference())
.function("setCameraLookAtIndex", &SampleEngine::set_camera_lookat_index)
.function("setCameraSpeed", &SampleEngine::set_camera_speed)
.function("resetCamera", &SampleEngine::reset_camera)
Expand All @@ -55,6 +54,7 @@ EMSCRIPTEN_BINDINGS(_Class_) {
//.function("getVPETContext", &SampleEngine::get_vpet_context);
.function("loadTracerScene", &SampleEngine::load_tracer_scene)
// UHasselt gltf streaming demo
.function("appendGLB", &SampleEngine::append_glb)
.function("getCamera", &SampleEngine::get_current_camera, emscripten::return_value_policy::reference())
.function("setLightColor", &SampleEngine::set_light_color)
.function("setLightIntensity", &SampleEngine::set_light_intensity);
Expand Down

0 comments on commit f1cb0b8

Please sign in to comment.