From 6f5a72229c6c8aa9263b9e4c0a113ac1ac353bc2 Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Thu, 4 Apr 2019 12:00:06 -0500 Subject: [PATCH] Add focusing to the magicleap demo cube --- demo/magicleap/src/landscape.cpp | 67 +++++++++++++++++++++++++------- demo/magicleap/src/landscape.h | 13 ++++++- 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/demo/magicleap/src/landscape.cpp b/demo/magicleap/src/landscape.cpp index 798d81b9..0498fc7f 100644 --- a/demo/magicleap/src/landscape.cpp +++ b/demo/magicleap/src/landscape.cpp @@ -19,8 +19,6 @@ int main(int argc, char **argv) return myApp.run(); } -const int NUM_QUADS = 6; - const char* QUAD_NAMES[NUM_QUADS] = { "quad1", "quad2", @@ -95,6 +93,7 @@ int PathfinderDemo::init() { abort(); return 1; } + quad_nodes_[i] = quad_node->getNodeId(); // Create the EGL surface for it to draw to lumin::ResourceIDType plane_id = prism_->createPlanarEGLResourceId(); @@ -103,19 +102,35 @@ int PathfinderDemo::init() { abort(); return 1; } - lumin::PlanarResource* plane = static_cast(prism_->getResource(plane_id)); + quad_node->setRenderResource(plane_id); + + renderNode(quad_node->getNodeId()); + } + + return 0; +} + +void PathfinderDemo::renderNode(lumin::NodeIDType node_id) { + if (node_id == lumin::INVALID_NODE_ID) { return; } + + lumin::QuadNode* quad_node = static_cast(prism_->getNode(node_id)); + if (!quad_node) { + ML_LOG(Error, "Pathfinder Failed to get quad node"); + return; + } + + lumin::PlanarResource* plane = const_cast(static_cast(quad_node->getRenderResource())); if (!plane) { ML_LOG(Error, "Pathfinder Failed to get plane"); - abort(); - return 1; + return; } - quad_node->setRenderResource(plane_id); - + // Get the EGL context, surface and display. + uint32_t width = plane->getWidth(); + uint32_t height = plane->getHeight(); EGLContext ctx = plane->getEGLContext(); EGLSurface surf = plane->getEGLSurface(); EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - eglMakeCurrent(dpy, surf, surf, ctx); // Initialize pathfinder if (!pathfinder_) { @@ -124,23 +139,39 @@ int PathfinderDemo::init() { ML_LOG(Info, "Pathfinder initialized"); } - uint32_t width = plane->getWidth(); - uint32_t height = plane->getHeight(); + // Get the SVG filename + const char* svg_filename; + for (int i=0; i #include +const uint32_t NUM_QUADS = 6; + /** * PathfinderDemo Landscape Application */ @@ -92,7 +94,12 @@ protected: * Dispatch an SVG file to the immersive app */ void dispatch(const char* svg_filename); - + + /** + * Render a node in the scene + */ + void renderNode(lumin::NodeIDType node_id); + /** * Run application login */ @@ -106,7 +113,9 @@ protected: private: lumin::Prism* prism_ = nullptr; // represents the bounded space where the App renders. PrismSceneManager* prismSceneManager_ = nullptr; - void* pathfinder_ = nullptr; + void* pathfinder_ = nullptr; + lumin::NodeIDType quad_nodes_[NUM_QUADS] = {lumin::INVALID_NODE_ID}; + lumin::NodeIDType highlighted_node_ = lumin::INVALID_NODE_ID; lumin::NodeIDType focus_node_ = lumin::INVALID_NODE_ID; };