aboutsummaryrefslogtreecommitdiffstats
path: root/support/magicleap/Servo2D/code
diff options
context:
space:
mode:
Diffstat (limited to 'support/magicleap/Servo2D/code')
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/PrismSceneManager.h74
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/SceneDescriptor.h58
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/Servo2D/Servo2D.h60
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/SpawnedSceneBase.h43
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/SpawnedSceneHandlers.h31
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/SpawnedSceneUserData.h27
-rw-r--r--support/magicleap/Servo2D/code/inc.gen/scenes.h33
-rw-r--r--support/magicleap/Servo2D/code/inc/Servo2D.h148
-rw-r--r--support/magicleap/Servo2D/code/src.gen/PrismSceneManager.cpp124
-rw-r--r--support/magicleap/Servo2D/code/src.gen/SceneDescriptor.cpp66
-rw-r--r--support/magicleap/Servo2D/code/src.gen/Servo2D/Servo2D.cpp108
-rw-r--r--support/magicleap/Servo2D/code/src.gen/SpawnedSceneBase.cpp35
-rw-r--r--support/magicleap/Servo2D/code/src.gen/SpawnedSceneHandlers.cpp29
-rw-r--r--support/magicleap/Servo2D/code/src.gen/SpawnedSceneUserData.cpp26
-rw-r--r--support/magicleap/Servo2D/code/src.gen/scenes.cpp74
-rw-r--r--support/magicleap/Servo2D/code/src/Servo2D.cpp396
-rw-r--r--support/magicleap/Servo2D/code/src/main.cpp36
-rw-r--r--support/magicleap/Servo2D/code/srcs.comp8
18 files changed, 0 insertions, 1376 deletions
diff --git a/support/magicleap/Servo2D/code/inc.gen/PrismSceneManager.h b/support/magicleap/Servo2D/code/inc.gen/PrismSceneManager.h
deleted file mode 100644
index 82d43212325..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/PrismSceneManager.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-#include <lumin/Prism.h>
-#include <lumin/node/Node.h>
-
-#include <SceneDescriptor.h>
-#include <SpawnedSceneBase.h>
-#include <SpawnedSceneUserData.h>
-#include <scenes.h>
-
-class PrismSceneManager {
- public:
-
- typedef std::function<SpawnedSceneUserData*(SpawnedSceneBase&)> (*CreateSpawnedSceneUserData);
- static void setUserDataCreator(const SceneDescriptor & sceneDescriptor, CreateSpawnedSceneUserData createSpawnedSceneUserData);
-
- public:
-
- PrismSceneManager(lumin::Prism* prism);
-
- enum class SceneState {
- Unloaded,
- ResourceModelLoaded,
- ResourceAndObjectModelLoaded,
- };
-
- void setSceneState(const SceneDescriptor & sceneDescriptor, SceneState sceneState);
- SceneState getSceneState(const SceneDescriptor & sceneDescriptor, SceneState sceneState) const;
-
- SpawnedSceneBase* spawnScene(const SceneDescriptor & sceneDescriptor);
- lumin::Node* spawn(const SceneDescriptor & sceneDescriptor);
-
- private:
-
- typedef SpawnedSceneBase* (*CreateSpawnedScene)(const SceneDescriptor& sceneDescriptor, lumin::Node* root);
- static const CreateSpawnedScene createSpawnedScene[scenes::numberOfExternalScenes];
-
- typedef SpawnedSceneHandlers* (*CreateSpawnedSceneHandlers)(SpawnedSceneBase& spawnedScene);
- static const CreateSpawnedSceneHandlers createSpawnedSceneHandlers[scenes::numberOfExternalScenes];
-
- static CreateSpawnedSceneUserData createSpawnedSceneUserData[scenes::numberOfExternalScenes];
-
- private:
-
- lumin::Node* createNodeTree(const SceneDescriptor & sceneDescriptor);
-
- private:
-
- lumin::Prism* prism_;
- SceneState sceneStates_[scenes::numberOfExternalScenes];
- std::string objectModelNames_[scenes::numberOfExternalScenes];
-};
-
diff --git a/support/magicleap/Servo2D/code/inc.gen/SceneDescriptor.h b/support/magicleap/Servo2D/code/inc.gen/SceneDescriptor.h
deleted file mode 100644
index c1b42119bae..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/SceneDescriptor.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-#include <string>
-#include <map>
-
-// data class
-class SceneDescriptor {
- public:
-
- typedef std::map<std::string /* externalNodeName */, const std::string& /* externalNodeId */> ExternalNodeReferences;
-
- SceneDescriptor(int index, const char* externalName, const char* id, const char* sceneGraphFilePath, const char* resourceModelFilePath, const ExternalNodeReferences& externalNodeReferences, bool initiallySpawned);
- const std::string& getExternalName() const;
- const std::string& getId() const;
- const std::string& getSceneGraphPath() const;
- const std::string& getResourceModelPath() const;
- const ExternalNodeReferences & getExternalNodeReferences() const;
- bool getInitiallySpawned() const;
-
- private:
-
- friend class PrismSceneManager;
- int getIndex() const;
-
- private:
-
- int index_;
- std::string externalName_;
- std::string id_;
- std::string sceneGraphPath_;
- std::string resourceModelPath_;
- const ExternalNodeReferences& externalNodeReferences_;
- bool initiallySpawned_;
-};
-
-bool operator<(const SceneDescriptor& a, const SceneDescriptor& b);
-
diff --git a/support/magicleap/Servo2D/code/inc.gen/Servo2D/Servo2D.h b/support/magicleap/Servo2D/code/inc.gen/Servo2D/Servo2D.h
deleted file mode 100644
index aea4afe8ff8..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/Servo2D/Servo2D.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-#include <SpawnedSceneBase.h>
-#include <SpawnedSceneHandlers.h>
-
-#include <lumin/node/QuadNode.h>
-#include <lumin/ui/node/UiButton.h>
-#include <lumin/ui/node/UiPanel.h>
-#include <lumin/ui/node/UiTextEdit.h>
-
-namespace scenes {
-
- namespace Servo2D {
-
- namespace externalNodes {
- extern const std::string contentPanel;
- extern const std::string content;
- extern const std::string backButton;
- extern const std::string fwdButton;
- extern const std::string urlBar;
- }
-
- struct SpawnedScene : public SpawnedSceneBase {
- SpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root);
- ~SpawnedScene();
- lumin::ui::UiPanel* contentPanel;
- lumin::QuadNode* content;
- lumin::ui::UiButton* backButton;
- lumin::ui::UiButton* fwdButton;
- lumin::ui::UiTextEdit* urlBar;
- };
-
- SpawnedSceneBase* createSpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root);
- SpawnedSceneHandlers* createSpawnedSceneHandlers(SpawnedSceneBase& spawnedScene);
-
- extern const SceneDescriptor descriptor;
- }
-}
-
diff --git a/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneBase.h b/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneBase.h
deleted file mode 100644
index 4b597bfdd73..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneBase.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-#include <lumin/node/Node.h>
-
-class SceneDescriptor;
-class SpawnedSceneHandlers;
-struct SpawnedSceneUserData;
-
-struct SpawnedSceneBase {
- SpawnedSceneBase(const SceneDescriptor &sd, lumin::Node* rt);
- virtual ~SpawnedSceneBase();
-
- SpawnedSceneBase() = delete;
- SpawnedSceneBase(const SpawnedSceneBase&) = delete;
- SpawnedSceneBase(const SpawnedSceneBase&&) = delete;
-
- const SceneDescriptor& sceneDescriptor;
- lumin::Node* root = nullptr;
- SpawnedSceneHandlers* handlers = nullptr;
- SpawnedSceneUserData* userData = nullptr;
-};
-
diff --git a/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneHandlers.h b/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneHandlers.h
deleted file mode 100644
index 071a9c9bea6..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneHandlers.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-struct SpawnedSceneBase;
-
-class SpawnedSceneHandlers {
-public:
- SpawnedSceneHandlers(SpawnedSceneBase& ssb);
- virtual ~SpawnedSceneHandlers();
-};
-
diff --git a/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneUserData.h b/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneUserData.h
deleted file mode 100644
index 936efea6880..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/SpawnedSceneUserData.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-struct SpawnedSceneUserData {
- virtual ~SpawnedSceneUserData();
-};
-
diff --git a/support/magicleap/Servo2D/code/inc.gen/scenes.h b/support/magicleap/Servo2D/code/inc.gen/scenes.h
deleted file mode 100644
index 73f00a033a1..00000000000
--- a/support/magicleap/Servo2D/code/inc.gen/scenes.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#pragma once
-
-#include <SceneDescriptor.h>
-#include <map>
-
-namespace scenes {
- const int numberOfExternalScenes = 1;
-
- typedef std::map<std::string /* externalName */, const SceneDescriptor& /* sceneDescription */> SceneDescriptorReferences;
- extern const SceneDescriptorReferences externalScenes;
-}
-
diff --git a/support/magicleap/Servo2D/code/inc/Servo2D.h b/support/magicleap/Servo2D/code/inc/Servo2D.h
deleted file mode 100644
index 46962855dfe..00000000000
--- a/support/magicleap/Servo2D/code/inc/Servo2D.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-
-#include <lumin/LandscapeApp.h>
-#include <lumin/Prism.h>
-#include <lumin/event/ServerEvent.h>
-#include <SceneDescriptor.h>
-#include <PrismSceneManager.h>
-
-#include <GLES/gl.h>
-#include <lumin/event/GestureInputEventData.h>
-#include <lumin/event/KeyInputEventData.h>
-#include <lumin/event/ControlTouchPadInputEventData.h>
-#include <lumin/event/ControlPose6DofInputEventData.h>
-#include <lumin/node/LineNode.h>
-#include <lumin/node/QuadNode.h>
-#include <lumin/resource/PlanarResource.h>
-#include <lumin/ui/KeyboardDefines.h>
-#include <lumin/ui/node/UiButton.h>
-#include <lumin/ui/node/UiPanel.h>
-#include <lumin/ui/node/UiTextEdit.h>
-
-typedef struct Opaque ServoInstance;
-
-/**
- * Servo2D Landscape Application
- */
-class Servo2D : public lumin::LandscapeApp {
-public:
- /**
- * Constructs the Landscape Application.
- */
- Servo2D(const char* uri, const char* args);
-
- /**
- * Destroys the Landscape Application.
- */
- virtual ~Servo2D();
-
- /**
- * Disallows the copy constructor.
- */
- Servo2D(const Servo2D&) = delete;
-
- /**
- * Disallows the move constructor.
- */
- Servo2D(Servo2D&&) = delete;
-
- /**
- * Disallows the copy assignment operator.
- */
- Servo2D& operator=(const Servo2D&) = delete;
-
- /**
- * Disallows the move assignment operator.
- */
- Servo2D& operator=(Servo2D&&) = delete;
-
- /**
- * Update the browser history UI
- */
- void updateHistory(bool canGoBack, bool canGoForward);
-
- /**
- * Update the browser url bar.
- */
- void updateUrl(const char* url);
-
- /**
- * Make the keyboard visible
- */
- void keyboardVisible(bool visible);
-
-protected:
- /**
- * Initializes the Landscape Application.
- * @return - 0 on success, error code on failure.
- */
- int init() override;
-
- /**
- * Deinitializes the Landscape Application.
- * @return - 0 on success, error code on failure.
- */
- int deInit() override;
-
- /**
- * Returns the initial size of the Prism
- * Used in createPrism().
- */
- const glm::vec3 getInitialPrismSize() const;
-
- /**
- * Creates the prism, updates the private variable prism_ with the created prism.
- */
- void createInitialPrism();
-
- /**
- * Initializes and creates the scene of all scenes marked as initially instanced
- */
- void spawnInitialScenes();
-
- /**
- * Run application login
- */
- virtual bool updateLoop(float fDelta) override;
-
- /**
- * Handle events from the server
- */
- virtual bool eventListener(lumin::ServerEvent* event) override;
- bool pose6DofEventListener(lumin::ControlPose6DofInputEventData* event);
- void urlBarEventListener();
- bool gestureEventListener(lumin::GestureInputEventData* event);
- bool keyboardEventListener(const lumin::ui::KeyboardEvent::EventData& event);
-
- /**
- * Convert a point in prism coordinates to viewport coordinates
- * (ignoring the z value).
- */
- glm::vec2 viewportPosition(glm::vec3 prism_pos);
- bool pointInsideViewport(glm::vec2 pt);
-
- /**
- * Returns the intersection of the laser and the viewport, in viewport coordinates.
- * Returns (-1, -1) if the laser does not intersect the viewport.
- */
- glm::vec2 laserPosition();
-
-private:
- lumin::Prism* prism_ = nullptr; // represents the bounded space where the App renders.
- PrismSceneManager* prismSceneManager_ = nullptr;
- lumin::PlanarResource* plane_ = nullptr; // the plane we're rendering into
- lumin::QuadNode* content_node_ = nullptr; // the node containing the plane
- lumin::ui::UiPanel* content_panel_ = nullptr; // the panel containing the node
- lumin::ui::UiButton* back_button_ = nullptr; // the back button
- lumin::ui::UiButton* fwd_button_ = nullptr; // the forward button
- lumin::ui::UiTextEdit* url_bar_ = nullptr; // the URL bar
- lumin::LineNode* laser_ = nullptr; // The laser pointer
- glm::vec3 controller_position_; // The last recorded position of the controller (in world coords)
- glm::quat controller_orientation_; // The last recorded orientation of the controller (in world coords)
- bool controller_trigger_down_ = false; // Is the controller trigger currently down?
- ServoInstance* servo_ = nullptr; // the servo instance we're embedding
- const char* uri_ = nullptr;
- const char* args_ = nullptr;
-};
diff --git a/support/magicleap/Servo2D/code/src.gen/PrismSceneManager.cpp b/support/magicleap/Servo2D/code/src.gen/PrismSceneManager.cpp
deleted file mode 100644
index 7a8aee9f3ff..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/PrismSceneManager.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <PrismSceneManager.h>
-
-#include <ml_logging.h>
-
-PrismSceneManager::CreateSpawnedSceneUserData PrismSceneManager::createSpawnedSceneUserData[scenes::numberOfExternalScenes];
-
-PrismSceneManager::PrismSceneManager(lumin::Prism* prism)
-: prism_(prism) {
-
- if (!prism_) {
- ML_LOG(Error, "PrismSceneManager nullptr prism");
- abort();
- }
-
- for (int i = 0; i < sizeof(sceneStates_)/sizeof(sceneStates_[0]); ++i) {
- sceneStates_[i] = SceneState::Unloaded;
- }
-}
-
-void PrismSceneManager::setSceneState(const SceneDescriptor & sceneDescriptor, SceneState newState) {
-
- const int sceneIndex = sceneDescriptor.getIndex();
- SceneState& sceneState = sceneStates_[sceneIndex];
- std::string& objectModelName = objectModelNames_[sceneIndex];
-
- if (sceneState == SceneState::Unloaded && (newState == SceneState::ResourceModelLoaded || newState == SceneState::ResourceAndObjectModelLoaded)) {
- if (!prism_->loadResourceModel(sceneDescriptor.getResourceModelPath())) {
- ML_LOG(Error, "PrismSceneManager failed to load resource model");
- abort();
- }
- sceneState = SceneState::ResourceModelLoaded;
- }
-
- if (sceneState == SceneState::ResourceModelLoaded && newState == SceneState::ResourceAndObjectModelLoaded) {
- std::string& objectModelName = objectModelNames_[sceneIndex];
- if (!prism_->loadObjectModel(sceneDescriptor.getSceneGraphPath(), objectModelName)) {
- ML_LOG(Error, "PrismSceneManager failed to load object model");
- abort();
- }
- sceneState = SceneState::ResourceAndObjectModelLoaded;
- }
-
- if (sceneState == SceneState::ResourceAndObjectModelLoaded && (newState == SceneState::ResourceModelLoaded || newState == SceneState::Unloaded)) {
- if (!prism_->unloadObjectModel(objectModelName)) {
- ML_LOG(Error, "PrismSceneManager failed to unload object model");
- abort();
- }
- sceneState = SceneState::ResourceModelLoaded;
- objectModelName.clear();
- }
-
- // Currently there is no effective way to unload the resource model
-}
-
-SpawnedSceneBase* PrismSceneManager::spawnScene(const SceneDescriptor & sceneDescriptor) {
-
- lumin::Node* root = createNodeTree(sceneDescriptor);
- if (!root) {
- return nullptr;
- }
-
- const int index = sceneDescriptor.getIndex();
- CreateSpawnedScene css = createSpawnedScene[index];
- SpawnedSceneBase* const spawnedScene = (*css)(sceneDescriptor, root);
-
- CreateSpawnedSceneHandlers ch = createSpawnedSceneHandlers[index];
- SpawnedSceneHandlers* const handlers = (*ch)(*spawnedScene);
- spawnedScene->handlers = handlers;
-
- CreateSpawnedSceneUserData cssud = createSpawnedSceneUserData[sceneDescriptor.getIndex()];
- if (cssud) {
- spawnedScene->userData = (*cssud)(*spawnedScene);
- }
- return spawnedScene;
-}
-
-lumin::Node* PrismSceneManager::spawn(const SceneDescriptor & sceneDescriptor) {
- SpawnedSceneBase* spawnedSceneBase = spawnScene(sceneDescriptor);
- if (!spawnedSceneBase) {
- return nullptr;
- }
- lumin::Node* root = spawnedSceneBase->root;
- return root;
-}
-
-lumin::Node* PrismSceneManager::createNodeTree(const SceneDescriptor & sceneDescriptor) {
- setSceneState(sceneDescriptor, SceneState::ResourceAndObjectModelLoaded);
- const int sceneIndex = sceneDescriptor.getIndex();
- std::string& objectModelName = objectModelNames_[sceneIndex];
-
- lumin::Node* root = prism_->createAll(objectModelName);
- if (!root) {
- ML_LOG(Error, "PrismSceneManager failed to create the scene. Is the scene empty?");
- return nullptr;
- }
-
- return root;
-}
-
-void PrismSceneManager::setUserDataCreator(const SceneDescriptor & sceneDescriptor, CreateSpawnedSceneUserData cssud) {
- createSpawnedSceneUserData[sceneDescriptor.getIndex()] = cssud ;
-}
-
diff --git a/support/magicleap/Servo2D/code/src.gen/SceneDescriptor.cpp b/support/magicleap/Servo2D/code/src.gen/SceneDescriptor.cpp
deleted file mode 100644
index 92673e33d62..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/SceneDescriptor.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <SceneDescriptor.h>
-
-SceneDescriptor::SceneDescriptor(int index, const char * externalName, const char * id, const char * sceneGraphPath, const char * resourceModelPath, const ExternalNodeReferences& externalNodeReferences, bool initiallySpawned)
-:
- index_(index),
- externalName_(externalName),
- id_(id),
- sceneGraphPath_(sceneGraphPath),
- resourceModelPath_(resourceModelPath),
- externalNodeReferences_(externalNodeReferences),
- initiallySpawned_(initiallySpawned) {
-}
-
-int SceneDescriptor::getIndex() const {
- return index_;
-}
-
-const std::string & SceneDescriptor::getExternalName() const {
- return externalName_;
-}
-
-const std::string & SceneDescriptor::getId() const {
- return id_;
-}
-
-const std::string & SceneDescriptor::getSceneGraphPath() const {
- return sceneGraphPath_;
-}
-
-const std::string & SceneDescriptor::getResourceModelPath() const {
- return resourceModelPath_;
-}
-
-const SceneDescriptor::ExternalNodeReferences & SceneDescriptor::getExternalNodeReferences() const {
- return externalNodeReferences_;
-}
-
-bool SceneDescriptor::getInitiallySpawned() const {
- return initiallySpawned_;
-}
-
-bool operator<(const SceneDescriptor& a, const SceneDescriptor& b) {
- return a.getExternalName() < b.getExternalName();
-}
-
diff --git a/support/magicleap/Servo2D/code/src.gen/Servo2D/Servo2D.cpp b/support/magicleap/Servo2D/code/src.gen/Servo2D/Servo2D.cpp
deleted file mode 100644
index 5a57bb947ae..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/Servo2D/Servo2D.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <SceneDescriptor.h>
-#include <SpawnedSceneBase.h>
-#include <Servo2D/Servo2D.h>
-
-namespace scenes {
-
- namespace Servo2D {
-
- SpawnedScene::SpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root)
- : SpawnedSceneBase(sceneDescriptor, root) {
- contentPanel = lumin::ui::UiPanel::CastFrom(root->findChild(externalNodes::contentPanel));
- content = lumin::QuadNode::CastFrom(root->findChild(externalNodes::content));
- backButton = lumin::ui::UiButton::CastFrom(root->findChild(externalNodes::backButton));
- fwdButton = lumin::ui::UiButton::CastFrom(root->findChild(externalNodes::fwdButton));
- urlBar = lumin::ui::UiTextEdit::CastFrom(root->findChild(externalNodes::urlBar));
- }
-
- SpawnedScene::~SpawnedScene() {
- }
-
- SpawnedSceneBase* createSpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root) {
- using namespace externalNodes;
- SpawnedScene* spawnedScene = new SpawnedScene(sceneDescriptor, root);
- return spawnedScene;
- }
-
- class Handlers : public SpawnedSceneHandlers
- {
- public:
- Handlers(SpawnedScene& ss);
-
- private:
-
- struct contentPanelHandlers {
- contentPanelHandlers(SpawnedScene& ss);
- };
- contentPanelHandlers contentPanelHandlers_;
- struct contentHandlers {
- contentHandlers(SpawnedScene& ss);
- };
- contentHandlers contentHandlers_;
- struct backButtonHandlers {
- backButtonHandlers(SpawnedScene& ss);
- };
- backButtonHandlers backButtonHandlers_;
- struct fwdButtonHandlers {
- fwdButtonHandlers(SpawnedScene& ss);
- };
- fwdButtonHandlers fwdButtonHandlers_;
- struct urlBarHandlers {
- urlBarHandlers(SpawnedScene& ss);
- };
- urlBarHandlers urlBarHandlers_;
- };
-
- Handlers::contentPanelHandlers::contentPanelHandlers(SpawnedScene& ss)
- {
- }
- Handlers::contentHandlers::contentHandlers(SpawnedScene& ss)
- {
- }
- Handlers::backButtonHandlers::backButtonHandlers(SpawnedScene& ss)
- {
- }
- Handlers::fwdButtonHandlers::fwdButtonHandlers(SpawnedScene& ss)
- {
- }
- Handlers::urlBarHandlers::urlBarHandlers(SpawnedScene& ss)
- {
- }
-
- Handlers::Handlers(SpawnedScene& ss)
- : SpawnedSceneHandlers(ss),
- contentPanelHandlers_(ss),
- contentHandlers_(ss),
- backButtonHandlers_(ss),
- fwdButtonHandlers_(ss),
- urlBarHandlers_(ss)
- {
- }
-
- SpawnedSceneHandlers* createSpawnedSceneHandlers(SpawnedSceneBase& ssb) {
- return new Handlers(static_cast<SpawnedScene&>(ssb));
- }
- }
-}
-
diff --git a/support/magicleap/Servo2D/code/src.gen/SpawnedSceneBase.cpp b/support/magicleap/Servo2D/code/src.gen/SpawnedSceneBase.cpp
deleted file mode 100644
index 51cc3aa76cf..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/SpawnedSceneBase.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <SpawnedSceneBase.h>
-#include <SpawnedSceneHandlers.h>
-#include <SpawnedSceneUserData.h>
-
-SpawnedSceneBase::SpawnedSceneBase(const SceneDescriptor &sd, lumin::Node* rt)
-: sceneDescriptor(sd),
- root(rt) {
-}
-
-SpawnedSceneBase::~SpawnedSceneBase() {
- delete handlers;
- delete userData;
-}
-
diff --git a/support/magicleap/Servo2D/code/src.gen/SpawnedSceneHandlers.cpp b/support/magicleap/Servo2D/code/src.gen/SpawnedSceneHandlers.cpp
deleted file mode 100644
index 6aa3042234f..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/SpawnedSceneHandlers.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <SpawnedSceneHandlers.h>
-
-SpawnedSceneHandlers::SpawnedSceneHandlers(SpawnedSceneBase& ssb) {
-}
-
-SpawnedSceneHandlers::~SpawnedSceneHandlers() {
-}
-
diff --git a/support/magicleap/Servo2D/code/src.gen/SpawnedSceneUserData.cpp b/support/magicleap/Servo2D/code/src.gen/SpawnedSceneUserData.cpp
deleted file mode 100644
index 777f0ed6846..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/SpawnedSceneUserData.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <SpawnedSceneUserData.h>
-
-SpawnedSceneUserData::~SpawnedSceneUserData() {
-}
-
diff --git a/support/magicleap/Servo2D/code/src.gen/scenes.cpp b/support/magicleap/Servo2D/code/src.gen/scenes.cpp
deleted file mode 100644
index 4281ecfacd0..00000000000
--- a/support/magicleap/Servo2D/code/src.gen/scenes.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-//
-// THE CONTENTS OF THIS FILE IS GENERATED BY CODE AND
-// ANY MODIFICATIONS WILL BE OVERWRITTEN
-//
-// -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING --
-
-// %BANNER_BEGIN%
-// ---------------------------------------------------------------------
-// %COPYRIGHT_BEGIN%
-//
-// Copyright (c) 2018 Magic Leap, Inc. All Rights Reserved.
-// Use of this file is governed by the Creator Agreement, located
-// here: https://id.magicleap.com/creator-terms
-//
-// %COPYRIGHT_END%
-// ---------------------------------------------------------------------
-// %BANNER_END%
-
-// %SRC_VERSION%: 1
-
-#include <PrismSceneManager.h>
-#include <scenes.h>
-#include <Servo2D/Servo2D.h>
-
-namespace scenes {
-
- namespace Servo2D {
-
- namespace externalNodes {
- extern const std::string contentPanel = "contentPanel";
- extern const std::string content = "content";
- extern const std::string backButton = "backButton";
- extern const std::string fwdButton = "fwdButton";
- extern const std::string urlBar = "urlBar";
- }
-
- const SceneDescriptor::ExternalNodeReferences externalNodesMap = {
- {"contentPanel", externalNodes::contentPanel},
- {"content", externalNodes::content},
- {"backButton", externalNodes::backButton},
- {"fwdButton", externalNodes::fwdButton},
- {"urlBar", externalNodes::urlBar}
- };
-
- const SceneDescriptor descriptor(
- 0,
- "Servo2D",
- "root",
- "/assets/scenes/Servo2D.scene.xml",
- "/assets/scenes/Servo2D.scene.res.xml",
- externalNodesMap,
- true);
- }
-
- const SceneDescriptorReferences externalScenes = {
- {Servo2D::descriptor.getExternalName(), Servo2D::descriptor}
- };
-
- struct VerifyNumberOfExternalScenes {
- VerifyNumberOfExternalScenes() { assert(externalScenes.size() == numberOfExternalScenes); }
- };
-
- VerifyNumberOfExternalScenes verifyNumberOfExternalScenes;
-}
-
-const PrismSceneManager::CreateSpawnedScene PrismSceneManager::createSpawnedScene[scenes::numberOfExternalScenes] = {
- ::scenes::Servo2D::createSpawnedScene
-};
-
-const PrismSceneManager::CreateSpawnedSceneHandlers PrismSceneManager::createSpawnedSceneHandlers[scenes::numberOfExternalScenes] = {
- static_cast<CreateSpawnedSceneHandlers>(::scenes::Servo2D::createSpawnedSceneHandlers)
-};
-
diff --git a/support/magicleap/Servo2D/code/src/Servo2D.cpp b/support/magicleap/Servo2D/code/src/Servo2D.cpp
deleted file mode 100644
index 71abf7424b7..00000000000
--- a/support/magicleap/Servo2D/code/src/Servo2D.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-
-#include <Servo2D/Servo2D.h>
-#include <lumin/node/RootNode.h>
-#include <lumin/ui/Cursor.h>
-#include <ml_logging.h>
-#include <scenes.h>
-#include <PrismSceneManager.h>
-
-#include <Servo2D.h>
-#include <lumin/node/QuadNode.h>
-#include <lumin/ui/Keyboard.h>
-#include <EGL/egl.h>
-#include <GLES/gl.h>
-#include <glm/gtc/matrix_transform.hpp>
-#include <string.h>
-
-// The viewport dimensions (in px).
-const int VIEWPORT_W = 852;
-const int VIEWPORT_H = 480;
-
-// The hidpi factor.
-const float HIDPI = 1.0;
-
-// The prism dimensions (in m).
-const float PRISM_W = 1.50;
-const float PRISM_H = 1;
-const float PRISM_D = 0.05;
-
-// The length of the laser pointer (in m).
-const float LASER_LENGTH = 10.0;
-
-// The width of the keyboard
-const float KEYBOARD_W = 1.333;
-
-// The home page
-const char* HOME_PAGE = "https://servo.org/ml-home";
-
-// The locale (currently ML only supports en)
-const lumin::ui::Locale::Code DEFAULT_LOCALE = lumin::ui::Locale::Code::kEn;
-
-// A function which calls the ML logger, suitable for passing into Servo
-typedef void (*MLLogger)(MLLogLevel lvl, char* msg);
-void logger(MLLogLevel lvl, char* msg) {
- if (MLLoggingLogLevelIsEnabled(lvl)) {
- MLLoggingLog(lvl, ML_DEFAULT_LOG_TAG, msg);
- }
-}
-
-// A function which updates the history ui, suitable for passing into Servo
-typedef void (*MLHistoryUpdate)(Servo2D* app, bool canGoBack, bool canGoForward);
-void history(Servo2D* app, bool canGoBack, bool canGoForward) {
- app->updateHistory(canGoBack, canGoForward);
-}
-
-// A function which updates the url ui, suitable for passing into Servo
-typedef void (*MLURLUpdate)(Servo2D* app, char* url);
-void url(Servo2D* app, char* url) {
- app->updateUrl(url);
-}
-
-// A function to show or hide the keyboard
-typedef void (*MLKeyboard)(Servo2D* app, bool visible);
-void keyboard(Servo2D* app, bool visible) {
- app->keyboardVisible(visible);
-}
-
-// The functions Servo provides for hooking up to the ML.
-extern "C" ServoInstance* init_servo(EGLContext, EGLSurface, EGLDisplay, bool landscape,
- Servo2D*, MLLogger, MLHistoryUpdate, MLURLUpdate, MLKeyboard,
- const char* url, const char* args, int width, int height, float hidpi);
-extern "C" void heartbeat_servo(ServoInstance*);
-extern "C" void keyboard_servo(ServoInstance*, char32_t code, lumin::ui::KeyType keyType);
-extern "C" void trigger_servo(ServoInstance*, float x, float y, bool down);
-extern "C" void move_servo(ServoInstance*, float x, float y);
-extern "C" void traverse_servo(ServoInstance*, int delta);
-extern "C" void navigate_servo(ServoInstance*, const char* text);
-extern "C" void discard_servo(ServoInstance*);
-
-// Create a Servo2D instance
-Servo2D::Servo2D(const char* uri, const char* args)
-: uri_(uri ? uri : HOME_PAGE)
-, args_(args)
-{
- ML_LOG(Debug, "Servo2D Constructor.");
-}
-
-// Destroy a Servo 2D instance
-Servo2D::~Servo2D() {
- ML_LOG(Debug, "Servo2D Destructor.");
-}
-
-const glm::vec3 Servo2D::getInitialPrismSize() const {
- return glm::vec3(PRISM_W, PRISM_H, PRISM_D);
-}
-
-void Servo2D::createInitialPrism() {
- prism_ = requestNewPrism(getInitialPrismSize());
- if (!prism_) {
- ML_LOG(Error, "Servo2D Error creating default prism.");
- abort();
- }
- prismSceneManager_ = new PrismSceneManager(prism_);
-}
-
-int Servo2D::init() {
-
- ML_LOG(Debug, "Servo2D Initializing.");
-
- createInitialPrism();
- lumin::ui::Cursor::SetScale(prism_, 0.03f);
- spawnInitialScenes();
-
- // Check privileges
- if (checkPrivilege(lumin::PrivilegeId::kInternet) != lumin::PrivilegeResult::kGranted) {
- ML_LOG(Error, "Servo2D Failed to get internet access");
- abort();
- return 1;
- }
- if (checkPrivilege(lumin::PrivilegeId::kControllerPose) != lumin::PrivilegeResult::kGranted) {
- ML_LOG(Error, "Servo2D Failed to get controller access");
- abort();
- return 1;
- }
-
- // Get the planar resource that holds the EGL context
- lumin::RootNode* root_node = prism_->getRootNode();
- if (!root_node) {
- ML_LOG(Error, "Servo2D Failed to get root node");
- abort();
- return 1;
- }
-
- std::string content_node_id = scenes::Servo2D::externalNodes::content;
- content_node_ = lumin::QuadNode::CastFrom(prism_->findNode(content_node_id, root_node));
- if (!content_node_) {
- ML_LOG(Error, "Servo2D Failed to get content node");
- abort();
- return 1;
- }
- content_node_->setTriggerable(true);
-
- content_panel_ = lumin::ui::UiPanel::CastFrom(
- prism_->findNode(scenes::Servo2D::externalNodes::contentPanel, root_node)
- );
- if (!content_panel_) {
- ML_LOG(Error, "Servo2D Failed to get content panel");
- abort();
- return 1;
- }
- lumin::ui::UiPanel::RequestFocus(content_panel_);
-
- lumin::ResourceIDType plane_id = prism_->createPlanarEGLResourceId(VIEWPORT_W, VIEWPORT_H);
- if (!plane_id) {
- ML_LOG(Error, "Servo2D Failed to create EGL resource");
- abort();
- return 1;
- }
-
- plane_ = static_cast<lumin::PlanarResource*>(prism_->getResource(plane_id));
- if (!plane_) {
- ML_LOG(Error, "Servo2D Failed to create plane");
- abort();
- return 1;
- }
-
- content_node_->setRenderResource(plane_id);
-
- // Get the EGL context, surface and display.
- EGLContext ctx = plane_->getEGLContext();
- EGLSurface surf = plane_->getEGLSurface();
- EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-
- // Set up gstreamer
- auto tmpdir = getTempPath();
- auto bindir = getPackagePath() + "bin";
- auto registry = getWritablePath() + "gstreamer-registry.bin";
- setenv("GIO_MODULE_DIR", bindir.c_str(), 1);
- setenv("GST_PLUGIN_SYSTEM_PATH", bindir.c_str(), 1);
- setenv("GST_REGISTRY", registry.c_str(), 1);
- setenv("XDG_CACHE_HOME", tmpdir.c_str(), 1);
-
- // Hook into servo
- servo_ = init_servo(ctx, surf, dpy, true,
- this, logger, history, url, keyboard, uri_, args_,
- VIEWPORT_W, VIEWPORT_H, HIDPI);
- if (!servo_) {
- ML_LOG(Error, "Servo2D Failed to init servo instance");
- abort();
- return 1;
- }
-
- // Add a callback to the back button
- std::string back_button_id = scenes::Servo2D::externalNodes::backButton;
- back_button_ = lumin::ui::UiButton::CastFrom(prism_->findNode(back_button_id, root_node));
- if (!back_button_) {
- ML_LOG(Error, "Servo2D Failed to get back button");
- abort();
- return 1;
- }
- back_button_->onActivateSub(std::bind(traverse_servo, servo_, -1));
-
- // Add a callback to the forward button
- std::string fwd_button_id = scenes::Servo2D::externalNodes::fwdButton;
- fwd_button_ = lumin::ui::UiButton::CastFrom(prism_->findNode(fwd_button_id, root_node));
- if (!fwd_button_) {
- ML_LOG(Error, "Servo2D Failed to get forward button");
- abort();
- return 1;
- }
- fwd_button_->onActivateSub(std::bind(traverse_servo, servo_, +1));
-
- // Add a callback to the URL bar
- std::string url_bar_id = scenes::Servo2D::externalNodes::urlBar;
- url_bar_ = lumin::ui::UiTextEdit::CastFrom(prism_->findNode(url_bar_id, root_node));
- if (!url_bar_) {
- ML_LOG(Error, "Servo2D Failed to get URL bar");
- abort();
- return 1;
- }
- lumin::ui::KeyboardProperties keyboard_properties;
- keyboard_properties.keyboardZPosition = lumin::ui::KeyboardProperties::KeyboardZPosition::kVolumeCursorPlane;
- keyboard_properties.width = KEYBOARD_W;
- url_bar_->setKeyboardProperties(keyboard_properties);
- url_bar_->onFocusLostSub(std::bind(&Servo2D::urlBarEventListener, this));
-
- return 0;
-}
-
-int Servo2D::deInit() {
- ML_LOG(Debug, "Servo2D Deinitializing.");
- discard_servo(servo_);
- servo_ = nullptr;
- return 0;
-}
-
-void Servo2D::spawnInitialScenes() {
-
- // Iterate over all the exported scenes
- for (auto& exportedSceneEntry : scenes::externalScenes ) {
-
- // If this scene was marked to be instanced at app initialization, do it
- const SceneDescriptor &sd = exportedSceneEntry.second;
- if (sd.getInitiallySpawned()) {
- lumin::Node* const spawnedRoot = prismSceneManager_->spawn(sd);
- if (spawnedRoot) {
- if (!prism_->getRootNode()->addChild(spawnedRoot)) {
- ML_LOG(Error, "Servo2D Failed to add spawnedRoot to the prism root node");
- abort();
- }
- }
- }
- }
-}
-
-bool Servo2D::updateLoop(float fDelta) {
- glm::vec2 pos = laserPosition();
- move_servo(servo_, pos.x, pos.y);
- heartbeat_servo(servo_);
- return true;
-}
-
-bool Servo2D::eventListener(lumin::ServerEvent* event) {
- // Dispatch based on event type
- lumin::ServerEventType typ = event->getServerEventType();
- switch (typ) {
- case lumin::ServerEventType::kGestureInputEvent:
- return gestureEventListener(static_cast<lumin::GestureInputEventData*>(event));
- case lumin::ServerEventType::kControlPose6DofInputEvent:
- return pose6DofEventListener(static_cast<lumin::ControlPose6DofInputEventData*>(event));
- default:
- return false;
- }
-}
-
-glm::vec2 Servo2D::viewportPosition(glm::vec3 prism_pos) {
- // Get the cursor position relative to the origin of the content node (in m)
- glm::vec3 pos = prism_pos - content_node_->getPrismPosition();
-
- // Get the size of the content node (in m)
- glm::vec2 sz = content_node_->getSize();
-
- // Convert to a position in viewport px
- float x = (pos.x / sz.x) * (float)VIEWPORT_W;
- float y = (1 - pos.y / sz.y) * (float)VIEWPORT_H; // Sigh, invert the y coordinate
-
- return glm::vec2(x, y);
-}
-
-bool Servo2D::pointInsideViewport(glm::vec2 pt) {
- return (0 <= pt.x && 0 <= pt.y && pt.x <= VIEWPORT_W && pt.y <= VIEWPORT_H);
-}
-
-bool Servo2D::pose6DofEventListener(lumin::ControlPose6DofInputEventData* event) {
- // Get the controller position in world coordinates
- event->get6DofPosition(controller_position_.x, controller_position_.y, controller_position_.z);
- // Get the controller orientation
- event->getQuaternion(controller_orientation_.w, controller_orientation_.x,
- controller_orientation_.y, controller_orientation_.z);
- // Bubble up to any other 6DOF handlers
- return false;
-}
-
-glm::vec2 Servo2D::laserPosition() {
- // Return (-1, -1) if the laser doesn't intersect z=0
- glm::vec2 result = glm::vec2(-1.0, -1.0);
-
- // Convert to prism coordinates
- glm::vec3 position = glm::inverse(prism_->getTransform()) * glm::vec4(controller_position_, 1.0f);
- glm::quat orientation = glm::inverse(prism_->getRotation()) * controller_orientation_;
-
- // 1m in the direction of the controller
- glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f);
- // The endpoint of the laser, in prism coordinates
- glm::vec3 endpoint = position + direction * LASER_LENGTH;
-
- // The laser color
- glm::vec4 color = glm::vec4(1.0, 0.0, 0.0, 1.0);
-
- // Does the laser intersect z=0?
- if ((position.z > 0) && (endpoint.z < 0)) {
- // How far along the laser did it intersect?
- float ratio = 1.0 / (1.0 - (endpoint.z / position.z));
- // The intersection point
- glm::vec3 intersection = ((1 - ratio) * position) + (ratio * endpoint);
- result = viewportPosition(intersection);
- }
-
- return result;
-}
-
-bool Servo2D::gestureEventListener(lumin::GestureInputEventData* event) {
- // Only respond to trigger up or down
- lumin::input::GestureType typ = event->getGesture();
- if (typ != lumin::input::GestureType::TriggerDown && typ != lumin::input::GestureType::TriggerUp) {
- return false;
- }
-
- // Only respond to trigger down if the laser is currently in the viewport
- glm::vec2 pos = laserPosition();
- if ((typ == lumin::input::GestureType::TriggerDown) && !pointInsideViewport(pos)) {
- return false;
- }
-
- // Only respond to trigger up if the trigger down happened inside the viewport
- if ((typ == lumin::input::GestureType::TriggerUp) && !controller_trigger_down_) {
- return false;
- }
-
- // Inform Servo of the trigger
- controller_trigger_down_ = (typ == lumin::input::GestureType::TriggerDown);
- trigger_servo(servo_, pos.x, pos.y, controller_trigger_down_);
- return true;
-}
-
-void Servo2D::urlBarEventListener() {
- navigate_servo(servo_, url_bar_->getText().c_str());
-}
-
-void Servo2D::keyboardVisible(bool visible) {
- lumin::ui::Keyboard* keys = lumin::ui::Keyboard::Get();
- if (visible) {
- lumin::ui::KeyboardProperties properties;
- properties.keyboardZPosition = lumin::ui::KeyboardProperties::KeyboardZPosition::kVolumeCursorPlane;
- properties.width = KEYBOARD_W;
- keys->show(
- prism_,
- DEFAULT_LOCALE,
- properties,
- std::bind(&Servo2D::keyboardEventListener, this, std::placeholders::_1)
- );
- } else {
- keys->hide();
- }
-}
-
-bool Servo2D::keyboardEventListener(const lumin::ui::KeyboardEvent::EventData& event) {
- if (event.getEventType() != lumin::ui::KeyboardEvent::EventType::KEY_PRESSED) {
- return false;
- }
- const lumin::ui::KeyboardEvent::KeyPressedData* keyPress =
- static_cast<const lumin::ui::KeyboardEvent::KeyPressedData*>(&event);
- keyboard_servo(servo_, keyPress->getCharCode(), keyPress->getKeyType());
- return true;
-}
-
-void Servo2D::updateUrl(const char* url) {
- url_bar_->setText(url);
-}
-
-void Servo2D::updateHistory(bool canGoBack, bool canGoForward) {
- back_button_->setEnabled(canGoBack);
- fwd_button_->setEnabled(canGoForward);
-}
diff --git a/support/magicleap/Servo2D/code/src/main.cpp b/support/magicleap/Servo2D/code/src/main.cpp
deleted file mode 100644
index a93c692e364..00000000000
--- a/support/magicleap/Servo2D/code/src/main.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-
-#include <Servo2D.h>
-#include <ml_lifecycle.h>
-#include <ml_logging.h>
-
-int main(int argc, char **argv)
-{
- ML_LOG(Debug, "Servo2D Starting.");
-
- // Handle optional initialization string passed via 'mldb launch'
- MLLifecycleInitArgList* list = NULL;
- MLLifecycleGetInitArgList(&list);
- const char* uri = NULL;
- if (nullptr != list) {
- int64_t list_length = 0;
- MLLifecycleGetInitArgListLength(list, &list_length);
- if (list_length > 0) {
- const MLLifecycleInitArg* iarg = NULL;
- MLLifecycleGetInitArgByIndex(list, 0, &iarg);
- if (nullptr != iarg) {
- MLLifecycleGetInitArgUri(iarg, &uri);
- }
- }
- }
-
- const char* args = getenv("SERVO_ARGS");
-
- Servo2D myApp(uri, args);
- int rv = myApp.run();
-
- MLLifecycleFreeInitArgList(&list);
- return rv;
-}
diff --git a/support/magicleap/Servo2D/code/srcs.comp b/support/magicleap/Servo2D/code/srcs.comp
deleted file mode 100644
index 7319bc2e28f..00000000000
--- a/support/magicleap/Servo2D/code/srcs.comp
+++ /dev/null
@@ -1,8 +0,0 @@
-SRCS = \
- src.gen/scenes.cpp \
- src.gen/Servo2D/Servo2D.cpp \
- src.gen/PrismSceneManager.cpp \
- src.gen/SceneDescriptor.cpp \
- src.gen/SpawnedSceneBase.cpp \
- src.gen/SpawnedSceneHandlers.cpp \
- src.gen/SpawnedSceneUserData.cpp \