mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Updated Servo2D to LRE v0.22.0
This commit is contained in:
parent
6775c69da1
commit
deb06ffcec
29 changed files with 791 additions and 174 deletions
14
support/magicleap/Servo2D/.gitignore
vendored
Normal file
14
support/magicleap/Servo2D/.gitignore
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
.DS_Store
|
||||
*.log
|
||||
*.json.dirty
|
||||
*.json.lock
|
||||
*.pyc
|
||||
*.sln
|
||||
*.vcxproj*
|
||||
*.previous
|
||||
*.draft
|
||||
|
||||
pipeline/cache/intermediate/
|
||||
.out/
|
||||
.vscode/
|
||||
.vs/
|
|
@ -51,4 +51,4 @@ CXXFLAGS = \
|
|||
|
||||
USES = \
|
||||
lumin_runtime \
|
||||
code/srcsGen
|
||||
code/srcs
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<mlproject:mlproject xmlns:mlproject="http://www.magicleap.com/uidesigner/mlproject" generated="true">
|
||||
<mlproject:mlproject xmlns:mlproject="http://www.magicleap.com/uidesigner/mlproject" generated="true" srcGenVersion="1">
|
||||
<designFile path="scenes/Servo2D.design"/>
|
||||
<pipelineDirectory path="pipeline"/>
|
||||
<preferences key="srcgen.directories.src" value="src"/>
|
||||
<preferences key="srcgen.directories.basedir" value="code"/>
|
||||
<preferences key="srcgen.directories.inc" value="inc"/>
|
||||
<preferences key="srcgen.directories.incgen" value="inc.gen"/>
|
||||
<preferences key="srcgen.directories.srcgen" value="src.gen"/>
|
||||
</mlproject:mlproject>
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
USES = "scenes" "pipeline/cache/AssetManifest"
|
||||
USES = \
|
||||
scenes \
|
||||
pipeline/cache/AssetManifest
|
||||
|
||||
DATAS = \
|
||||
fonts.xml : etc/fonts.xml
|
||||
|
|
74
support/magicleap/Servo2D/code/inc.gen/PrismSceneManager.h
Normal file
74
support/magicleap/Servo2D/code/inc.gen/PrismSceneManager.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
// -- 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];
|
||||
};
|
||||
|
|
@ -17,6 +17,8 @@
|
|||
// ---------------------------------------------------------------------
|
||||
// %BANNER_END%
|
||||
|
||||
// %SRC_VERSION%: 1
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
@ -26,23 +28,31 @@
|
|||
class SceneDescriptor {
|
||||
public:
|
||||
|
||||
typedef std::map<std::string /* exportedNodeName */, const std::string& /* exportedNodeId */> ExportedNodeReferences;
|
||||
typedef std::map<std::string /* externalNodeName */, const std::string& /* externalNodeId */> ExternalNodeReferences;
|
||||
|
||||
SceneDescriptor(const char* exportedName, const char* id, const char* sceneGraphFilePath, const char* resourceModelFilePath, const ExportedNodeReferences& exportedNodeReferences, bool initiallyInstanced);
|
||||
const std::string& getExportedName() const;
|
||||
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 ExportedNodeReferences & getExportedNodeReferences() const;
|
||||
bool getInitiallyInstanced() const;
|
||||
const ExternalNodeReferences & getExternalNodeReferences() const;
|
||||
bool getInitiallySpawned() const;
|
||||
|
||||
private:
|
||||
std::string exportedName_;
|
||||
|
||||
friend class PrismSceneManager;
|
||||
int getIndex() const;
|
||||
|
||||
private:
|
||||
|
||||
int index_;
|
||||
std::string externalName_;
|
||||
std::string id_;
|
||||
std::string sceneGraphPath_;
|
||||
std::string resourceModelPath_;
|
||||
const ExportedNodeReferences& exportedNodeReferences_;
|
||||
bool initiallyInstanced_;
|
||||
const ExternalNodeReferences& externalNodeReferences_;
|
||||
bool initiallySpawned_;
|
||||
};
|
||||
|
||||
typedef std::map<std::string /* exportedName */, const SceneDescriptor&> SceneDescriptorReferences;
|
||||
bool operator<(const SceneDescriptor& a, const SceneDescriptor& b);
|
||||
|
||||
|
|
63
support/magicleap/Servo2D/code/inc.gen/Servo2D/Servo2D.h
Normal file
63
support/magicleap/Servo2D/code/inc.gen/Servo2D/Servo2D.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
// -- 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/LineNode.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;
|
||||
extern const std::string laser;
|
||||
}
|
||||
|
||||
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;
|
||||
lumin::LineNode* laser;
|
||||
};
|
||||
|
||||
SpawnedSceneBase* createSpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root);
|
||||
SpawnedSceneHandlers* createSpawnedSceneHandlers(SpawnedSceneBase& spawnedScene);
|
||||
|
||||
extern const SceneDescriptor descriptor;
|
||||
}
|
||||
}
|
||||
|
43
support/magicleap/Servo2D/code/inc.gen/SpawnedSceneBase.h
Normal file
43
support/magicleap/Servo2D/code/inc.gen/SpawnedSceneBase.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
// -- 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;
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// -- 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();
|
||||
};
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// -- 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();
|
||||
};
|
||||
|
|
@ -17,20 +17,17 @@
|
|||
// ---------------------------------------------------------------------
|
||||
// %BANNER_END%
|
||||
|
||||
// %SRC_VERSION%: 1
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SceneDescriptor.h>
|
||||
|
||||
namespace Servo2D_exportedNodes {
|
||||
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;
|
||||
extern const std::string laser;
|
||||
}
|
||||
#include <map>
|
||||
|
||||
namespace scenes {
|
||||
extern const SceneDescriptor Servo2D;
|
||||
extern const SceneDescriptorReferences exportedScenes;
|
||||
const int numberOfExternalScenes = 1;
|
||||
|
||||
typedef std::map<std::string /* externalName */, const SceneDescriptor& /* sceneDescription */> SceneDescriptorReferences;
|
||||
extern const SceneDescriptorReferences externalScenes;
|
||||
}
|
||||
|
|
@ -2,10 +2,13 @@
|
|||
* 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 <GLES/gl.h>
|
||||
#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>
|
||||
|
@ -17,7 +20,6 @@
|
|||
#include <lumin/ui/node/UiButton.h>
|
||||
#include <lumin/ui/node/UiPanel.h>
|
||||
#include <lumin/ui/node/UiTextEdit.h>
|
||||
#include <SceneDescriptor.h>
|
||||
|
||||
typedef struct Opaque ServoInstance;
|
||||
|
||||
|
@ -85,25 +87,20 @@ protected:
|
|||
int deInit() override;
|
||||
|
||||
/**
|
||||
* Returns the size of the Prism, default = +/- (1.0f, 1.0f, 1.0f) meters.
|
||||
* Returns the initial size of the Prism
|
||||
* Used in createPrism().
|
||||
*/
|
||||
const glm::vec3 getInitialPrismExtents() const;
|
||||
const glm::vec3 getInitialPrismSize() const;
|
||||
|
||||
/**
|
||||
* Creates the prism, updates the private variable prism_ with the created prism.
|
||||
*/
|
||||
int createInitialPrism();
|
||||
void createInitialPrism();
|
||||
|
||||
/**
|
||||
* Initializes and creates the scene of all scenes marked as initially instanced
|
||||
*/
|
||||
void instanceInitialScenes();
|
||||
|
||||
/**
|
||||
* Initializes and creates the scene of the scene and instances it into the prism
|
||||
*/
|
||||
lumin::Node* instanceScene(const SceneDescriptor & sceneToInit);
|
||||
void spawnInitialScenes();
|
||||
|
||||
/**
|
||||
* Run application login
|
||||
|
@ -133,6 +130,7 @@ protected:
|
|||
|
||||
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
|
||||
|
|
124
support/magicleap/Servo2D/code/src.gen/PrismSceneManager.cpp
Normal file
124
support/magicleap/Servo2D/code/src.gen/PrismSceneManager.cpp
Normal file
|
@ -0,0 +1,124 @@
|
|||
// -- 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 ;
|
||||
}
|
||||
|
|
@ -17,20 +17,27 @@
|
|||
// ---------------------------------------------------------------------
|
||||
// %BANNER_END%
|
||||
|
||||
// %SRC_VERSION%: 1
|
||||
|
||||
#include <SceneDescriptor.h>
|
||||
|
||||
SceneDescriptor::SceneDescriptor(const char * exportedName, const char * id, const char * sceneGraphPath, const char * resourceModelPath, const ExportedNodeReferences& exportedNodeReferences, bool initiallyInstanced)
|
||||
SceneDescriptor::SceneDescriptor(int index, const char * externalName, const char * id, const char * sceneGraphPath, const char * resourceModelPath, const ExternalNodeReferences& externalNodeReferences, bool initiallySpawned)
|
||||
:
|
||||
exportedName_(exportedName),
|
||||
index_(index),
|
||||
externalName_(externalName),
|
||||
id_(id),
|
||||
sceneGraphPath_(sceneGraphPath),
|
||||
resourceModelPath_(resourceModelPath),
|
||||
exportedNodeReferences_(exportedNodeReferences),
|
||||
initiallyInstanced_(initiallyInstanced) {
|
||||
externalNodeReferences_(externalNodeReferences),
|
||||
initiallySpawned_(initiallySpawned) {
|
||||
}
|
||||
|
||||
const std::string & SceneDescriptor::getExportedName() const {
|
||||
return exportedName_;
|
||||
int SceneDescriptor::getIndex() const {
|
||||
return index_;
|
||||
}
|
||||
|
||||
const std::string & SceneDescriptor::getExternalName() const {
|
||||
return externalName_;
|
||||
}
|
||||
|
||||
const std::string & SceneDescriptor::getId() const {
|
||||
|
@ -45,10 +52,15 @@ const std::string & SceneDescriptor::getResourceModelPath() const {
|
|||
return resourceModelPath_;
|
||||
}
|
||||
|
||||
const SceneDescriptor::ExportedNodeReferences & SceneDescriptor::getExportedNodeReferences() const {
|
||||
return exportedNodeReferences_;
|
||||
const SceneDescriptor::ExternalNodeReferences & SceneDescriptor::getExternalNodeReferences() const {
|
||||
return externalNodeReferences_;
|
||||
}
|
||||
|
||||
bool SceneDescriptor::getInitiallyInstanced() const {
|
||||
return initiallyInstanced_;
|
||||
bool SceneDescriptor::getInitiallySpawned() const {
|
||||
return initiallySpawned_;
|
||||
}
|
||||
|
||||
bool operator<(const SceneDescriptor& a, const SceneDescriptor& b) {
|
||||
return a.getExternalName() < b.getExternalName();
|
||||
}
|
||||
|
||||
|
|
117
support/magicleap/Servo2D/code/src.gen/Servo2D/Servo2D.cpp
Normal file
117
support/magicleap/Servo2D/code/src.gen/Servo2D/Servo2D.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
// -- 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));
|
||||
laser = lumin::LineNode::CastFrom(root->findChild(externalNodes::laser));
|
||||
}
|
||||
|
||||
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_;
|
||||
struct laserHandlers {
|
||||
laserHandlers(SpawnedScene& ss);
|
||||
};
|
||||
laserHandlers laserHandlers_;
|
||||
};
|
||||
|
||||
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::laserHandlers::laserHandlers(SpawnedScene& ss)
|
||||
{
|
||||
}
|
||||
|
||||
Handlers::Handlers(SpawnedScene& ss)
|
||||
: SpawnedSceneHandlers(ss),
|
||||
contentPanelHandlers_(ss),
|
||||
contentHandlers_(ss),
|
||||
backButtonHandlers_(ss),
|
||||
fwdButtonHandlers_(ss),
|
||||
urlBarHandlers_(ss),
|
||||
laserHandlers_(ss)
|
||||
{
|
||||
}
|
||||
|
||||
SpawnedSceneHandlers* createSpawnedSceneHandlers(SpawnedSceneBase& ssb) {
|
||||
return new Handlers(static_cast<SpawnedScene&>(ssb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
support/magicleap/Servo2D/code/src.gen/SpawnedSceneBase.cpp
Normal file
35
support/magicleap/Servo2D/code/src.gen/SpawnedSceneBase.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
// -- 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;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// -- 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() {
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// -- 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() {
|
||||
}
|
||||
|
76
support/magicleap/Servo2D/code/src.gen/scenes.cpp
Normal file
76
support/magicleap/Servo2D/code/src.gen/scenes.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
// -- 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";
|
||||
extern const std::string laser = "laser";
|
||||
}
|
||||
|
||||
const SceneDescriptor::ExternalNodeReferences externalNodesMap = {
|
||||
{"contentPanel", externalNodes::contentPanel},
|
||||
{"content", externalNodes::content},
|
||||
{"backButton", externalNodes::backButton},
|
||||
{"fwdButton", externalNodes::fwdButton},
|
||||
{"urlBar", externalNodes::urlBar},
|
||||
{"laser", externalNodes::laser}
|
||||
};
|
||||
|
||||
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)
|
||||
};
|
||||
|
|
@ -1,53 +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%
|
||||
|
||||
#include <scenesGen.h>
|
||||
|
||||
namespace Servo2D_exportedNodes {
|
||||
const std::string contentPanel = "contentPanel";
|
||||
const std::string content = "content";
|
||||
const std::string backButton = "backButton";
|
||||
const std::string fwdButton = "fwdButton";
|
||||
const std::string urlBar = "urlBar";
|
||||
const std::string laser = "laser";
|
||||
}
|
||||
|
||||
namespace scenes {
|
||||
|
||||
const SceneDescriptor::ExportedNodeReferences Servo2D_exportedNodesMap = {
|
||||
{"contentPanel", Servo2D_exportedNodes::contentPanel},
|
||||
{"content", Servo2D_exportedNodes::content},
|
||||
{"backButton", Servo2D_exportedNodes::backButton},
|
||||
{"fwdButton", Servo2D_exportedNodes::fwdButton},
|
||||
{"urlBar", Servo2D_exportedNodes::urlBar},
|
||||
{"laser", Servo2D_exportedNodes::laser}
|
||||
};
|
||||
|
||||
const SceneDescriptor Servo2D(
|
||||
"Servo2D",
|
||||
"root",
|
||||
"/assets/scenes/scenes/Servo2D.scene.xml",
|
||||
"/assets/scenes/scenes/Servo2D.scene.res.xml",
|
||||
Servo2D_exportedNodesMap,
|
||||
true);
|
||||
|
||||
const SceneDescriptorReferences exportedScenes = {
|
||||
{Servo2D.getExportedName(), Servo2D}
|
||||
};
|
||||
}
|
|
@ -2,13 +2,15 @@
|
|||
* 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 <Servo2D/Servo2D.h>
|
||||
#include <lumin/node/RootNode.h>
|
||||
#include <lumin/node/QuadNode.h>
|
||||
#include <lumin/ui/Cursor.h>
|
||||
#include <ml_logging.h>
|
||||
#include <scenesGen.h>
|
||||
#include <SceneDescriptor.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>
|
||||
|
@ -90,30 +92,26 @@ Servo2D::~Servo2D() {
|
|||
ML_LOG(Debug, "Servo2D Destructor.");
|
||||
}
|
||||
|
||||
// The prism dimensions
|
||||
const glm::vec3 Servo2D::getInitialPrismExtents() const {
|
||||
const glm::vec3 Servo2D::getInitialPrismSize() const {
|
||||
return glm::vec3(PRISM_W, PRISM_H, PRISM_D);
|
||||
}
|
||||
|
||||
// Create the prism for Servo
|
||||
int Servo2D::createInitialPrism() {
|
||||
prism_ = requestNewPrism(getInitialPrismExtents());
|
||||
void Servo2D::createInitialPrism() {
|
||||
prism_ = requestNewPrism(getInitialPrismSize());
|
||||
if (!prism_) {
|
||||
ML_LOG(Error, "Servo2D Error creating default prism.");
|
||||
return 1;
|
||||
abort();
|
||||
}
|
||||
return 0;
|
||||
prismSceneManager_ = new PrismSceneManager(prism_);
|
||||
}
|
||||
|
||||
// Initialize a Servo instance
|
||||
int Servo2D::init() {
|
||||
|
||||
ML_LOG(Debug, "Servo2D Initializing.");
|
||||
|
||||
// Set up the prism
|
||||
createInitialPrism();
|
||||
lumin::ui::Cursor::SetScale(prism_, 0.03f);
|
||||
instanceInitialScenes();
|
||||
spawnInitialScenes();
|
||||
|
||||
// Check privileges
|
||||
if (checkPrivilege(lumin::PrivilegeId::kInternet) != lumin::PrivilegeResult::kGranted) {
|
||||
|
@ -135,7 +133,7 @@ int Servo2D::init() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
std::string content_node_id = Servo2D_exportedNodes::content;
|
||||
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");
|
||||
|
@ -144,7 +142,9 @@ int Servo2D::init() {
|
|||
}
|
||||
content_node_->setTriggerable(true);
|
||||
|
||||
content_panel_ = lumin::ui::UiPanel::CastFrom(prism_->findNode(Servo2D_exportedNodes::contentPanel, root_node));
|
||||
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();
|
||||
|
@ -193,7 +193,7 @@ int Servo2D::init() {
|
|||
}
|
||||
|
||||
// Add a callback to the back button
|
||||
std::string back_button_id = Servo2D_exportedNodes::backButton;
|
||||
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");
|
||||
|
@ -203,7 +203,7 @@ int Servo2D::init() {
|
|||
back_button_->onActivateSub(std::bind(traverse_servo, servo_, -1));
|
||||
|
||||
// Add a callback to the forward button
|
||||
std::string fwd_button_id = Servo2D_exportedNodes::fwdButton;
|
||||
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");
|
||||
|
@ -213,7 +213,7 @@ int Servo2D::init() {
|
|||
fwd_button_->onActivateSub(std::bind(traverse_servo, servo_, +1));
|
||||
|
||||
// Add a callback to the URL bar
|
||||
std::string url_bar_id = Servo2D_exportedNodes::urlBar;
|
||||
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");
|
||||
|
@ -227,7 +227,7 @@ int Servo2D::init() {
|
|||
url_bar_->onFocusLostSub(std::bind(&Servo2D::urlBarEventListener, this));
|
||||
|
||||
// Add the laser pointer
|
||||
laser_ = lumin::LineNode::CastFrom(prism_->findNode(Servo2D_exportedNodes::laser, root_node));
|
||||
laser_ = lumin::LineNode::CastFrom(prism_->findNode(scenes::Servo2D::externalNodes::laser, root_node));
|
||||
if (!laser_) {
|
||||
ML_LOG(Error, "Servo2D Failed to get laser");
|
||||
abort();
|
||||
|
@ -244,39 +244,21 @@ int Servo2D::deInit() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
lumin::Node* Servo2D::instanceScene(const SceneDescriptor& scene) {
|
||||
// Load resources.
|
||||
if (!prism_->loadResourceModel(scene.getResourceModelPath())) {
|
||||
ML_LOG(Info, "No resource model loaded");
|
||||
}
|
||||
void Servo2D::spawnInitialScenes() {
|
||||
|
||||
// Load a scene file.
|
||||
std::string editorObjectModelName;
|
||||
if (!prism_->loadObjectModel(scene.getSceneGraphPath(), editorObjectModelName)) {
|
||||
ML_LOG(Error, "Servo2D Failed to load object model");
|
||||
abort();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Add scene to this prism.
|
||||
lumin::Node* newTree = prism_->createAll(editorObjectModelName);
|
||||
if (!prism_->getRootNode()->addChild(newTree)) {
|
||||
ML_LOG(Error, "Servo2D Failed to add newTree to the prism root node");
|
||||
abort();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return newTree;
|
||||
}
|
||||
|
||||
void Servo2D::instanceInitialScenes() {
|
||||
// Iterate over all the exported scenes
|
||||
for (auto& exportedSceneEntry : scenes::exportedScenes ) {
|
||||
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.getInitiallyInstanced()) {
|
||||
instanceScene(sd);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
8
support/magicleap/Servo2D/code/srcs.comp
Normal file
8
support/magicleap/Servo2D/code/srcs.comp
Normal file
|
@ -0,0 +1,8 @@
|
|||
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 \
|
|
@ -1,3 +0,0 @@
|
|||
SRCS = \
|
||||
src.gen/scenesGen.cpp \
|
||||
src.gen/SceneDescriptor.cpp \
|
|
@ -1 +0,0 @@
|
|||
DATAS=
|
|
@ -22,7 +22,7 @@
|
|||
"lap/types/file/png"
|
||||
]
|
||||
},
|
||||
"checkpoint-hash": "74689acde6571e19f86366dd94d8890be66acfceb26d14ac3ca14228fa31959087b8771fbb5a86764b4e7dc121bd78c3b0ee4c9c0716f0d91c90a59315f8acd8",
|
||||
"checkpoint-hash": "b1a5b4c3dfe7a6c0a3068dd837adfa07364f5016ddef9e6698090ba3544ccf921abba715182f372e25d65a9b6b13fdf11f12e436482cc3bace76f56876bd2251",
|
||||
"templates": [
|
||||
"lap/template/passthru_material_from_kmat",
|
||||
"lap/template/passthru_model_from_fbx",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
DATAS = \
|
||||
scenes/Servo2D.scene.res.xml : assets/scenes/scenes/Servo2D.scene.res.xml \
|
||||
scenes/Servo2D.scene.xml : assets/scenes/scenes/Servo2D.scene.xml
|
||||
scenes/Servo2D.scene.res.xml : assets/scenes/Servo2D.scene.res.xml \
|
||||
scenes/Servo2D.scene.xml : assets/scenes/Servo2D.scene.xml
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<design:rootNode xmlns:design="http://www.magicleap.com/uidesigner/rcp/document/design" name="root" nodeTypeId="lumin.root" modelId="lumin" version="1.8.0">
|
||||
<design:rootNode xmlns:design="http://www.magicleap.com/uidesigner/rcp/document/design" name="root" nodeTypeId="lumin.root" modelId="lumin" version="1.11.1">
|
||||
<property id="name" value="root"/>
|
||||
<property id="sceneName" value="Servo2D"/>
|
||||
<node name="contentPanel" nodeTypeId="lumin.ui.panel">
|
||||
<property id="cursorInitialPosition"/>
|
||||
<property id="edgeConstraint"/>
|
||||
<property id="externalName" value="contentPanel"/>
|
||||
<property id="external" value="true"/>
|
||||
<property id="gravityWellProperties">
|
||||
<property id="boundaryShape">
|
||||
<property id="size"/>
|
||||
|
@ -25,7 +26,7 @@
|
|||
<property id="rotation"/>
|
||||
<property id="scale"/>
|
||||
<node name="content" nodeTypeId="lumin.quad">
|
||||
<property id="externalName" value="content"/>
|
||||
<property id="external" value="true"/>
|
||||
<property id="name" value="content"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.25"/>
|
||||
|
@ -84,7 +85,7 @@
|
|||
<property id="y" value="0.05"/>
|
||||
</property>
|
||||
<node name="backButton" nodeTypeId="lumin.ui.button">
|
||||
<property id="externalName" value="backButton"/>
|
||||
<property id="external" value="true"/>
|
||||
<property id="gravityWellProperties">
|
||||
<property id="boundaryShape">
|
||||
<property id="size"/>
|
||||
|
@ -105,7 +106,7 @@
|
|||
<property id="width" value="0.1"/>
|
||||
</node>
|
||||
<node name="fwdButton" nodeTypeId="lumin.ui.button">
|
||||
<property id="externalName" value="fwdButton"/>
|
||||
<property id="external" value="true"/>
|
||||
<property id="gravityWellProperties">
|
||||
<property id="boundaryShape">
|
||||
<property id="size"/>
|
||||
|
@ -127,7 +128,7 @@
|
|||
<property id="alignment">
|
||||
<property id="verticalAlignment" value="Center"/>
|
||||
</property>
|
||||
<property id="externalName" value="urlBar"/>
|
||||
<property id="external" value="true"/>
|
||||
<property id="gravityWellProperties">
|
||||
<property id="boundaryShape">
|
||||
<property id="size"/>
|
||||
|
@ -153,7 +154,7 @@
|
|||
</node>
|
||||
<node name="laser" nodeTypeId="lumin.line">
|
||||
<property id="color" value="0 0 0 0"/>
|
||||
<property id="externalName" value="laser"/>
|
||||
<property id="external" value="true"/>
|
||||
<property id="name" value="laser"/>
|
||||
<property id="opaque" value="false"/>
|
||||
<property id="points">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<ResourceModel version="1"></ResourceModel>
|
|
@ -1,19 +1,19 @@
|
|||
<ObjectModel name="Servo2D" version="1">
|
||||
<TransformNode/>
|
||||
<UiPanel gravityWellEnabled="false" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="contentPanel" pos="0.000000, 0.060000, 0.000000" shape="[size:[0.5,0.44], roundness: 0, offset[0,0,0]]">
|
||||
<QuadNode castShadow="false" name="content" pos="-0.250000, -0.220000, -0.000000" receiveShadow="false" shader="UnlitColorTex2d" size="0.500000, 0.500000"/>
|
||||
<UiPanel bottomEdgeConstraint="0.000000" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" leftEdgeConstraint="0.000000" name="contentPanel" pos="0,0.06,0" rightEdgeConstraint="0.000000" shape="[size:[0.5,0.44], roundness: 0, offset:[0,0,0]]" topEdgeConstraint="0.000000">
|
||||
<QuadNode castShadow="false" name="content" pos="-0.25,-0.22,-0" receiveShadow="false" shader="MAX" size="0.500000, 0.500000"/>
|
||||
</UiPanel>
|
||||
<UiLinearLayout alignment="Top, Center" gravityWellEnabled="false" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" itemAlignment="Center, Left" itemPadding="0.000000, 0.010000, 0.000000, 0.010000" name="uiLinearLayout1" orientation="Horizontal" pos="0.000000, -0.200000, 0.000000" size="0.500000, 0.050000">
|
||||
<UiLinearLayout alignment="Top, Center" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" itemAlignment="Center, Left" itemPadding="0.000000, 0.010000, 0.000000, 0.010000" name="uiLinearLayout1" orientation="Horizontal" pos="0,-0.2,0" size="0.500000, 0.050000">
|
||||
<Content>
|
||||
<UiButton gravityWellEnabled="false" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="backButton" pos="0.000000, -0.600000, 0.000000" size="0.100000, 0.100000" text="Back" textSize="0.050000"/>
|
||||
<UiButton gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="backButton" pos="0,-0.6,0" size="0.100000, 0.100000" text="Back" textSize="0.050000"/>
|
||||
</Content>
|
||||
<Content>
|
||||
<UiButton gravityWellEnabled="false" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="fwdButton" size="0.100000, 0.100000" text="Fwd" textSize="0.050000"/>
|
||||
<UiButton gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="fwdButton" size="0.100000, 0.100000" text="Fwd" textSize="0.050000"/>
|
||||
</Content>
|
||||
<Content>
|
||||
<UiTextEdit alignment="Center, Left" gravityWellEnabled="false" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="urlBar" scrollSpeed="0.500000" size="0.600000, 0.050000" textSize="0.050000"/>
|
||||
<UiTextEdit alignment="Center, Left" font="DefaultRes_Font_LominoUI_Rg" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="urlBar" scrollSpeed="0.500000" size="0.600000, 0.050000" textSize="0.050000"/>
|
||||
</Content>
|
||||
</UiLinearLayout>
|
||||
<LineNode castShadow="false" color="0.000000, 0.000000, 0.000000, 0.000000" name="laser" opaque="false" points="0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000" receiveShadow="false" shader="Line"/>
|
||||
<QuadNode castShadow="false" color="0.157206, 0.092197, 0.481788, 1.000000" name="bevel" pos="-0.260000, -0.170000, -0.010000" receiveShadow="false" shader="UnlitColorTex2d" size="0.520000, 0.520000"/>
|
||||
<LineNode castShadow="false" color="0,0,0,0" name="laser" opaque="false" points="0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000" receiveShadow="false" shader="Line"/>
|
||||
<QuadNode castShadow="false" color="0.1572062,0.09219654,0.4817875,1" name="bevel" pos="-0.26,-0.17,-0.01" receiveShadow="false" shader="MAX" size="0.520000, 0.520000"/>
|
||||
</ObjectModel>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue