Add magicleap landscape demo
This commit is contained in:
parent
8ba56e5597
commit
37c7457929
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "pathfinder_immersive_demo"
|
||||
name = "pathfinder_magicleap_demo"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
authors = ["Alan Jeffrey <ajeffrey@mozilla.com>"]
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
REFS = PathfinderDemo
|
||||
USES = "lre/scenes"
|
||||
REFS = PathfinderImmersiveDemo PathfinderLandscapeDemo
|
||||
OPTIONS=package/debuggable/on
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
KIND = program
|
||||
SRCS = src/main.cpp
|
||||
|
||||
LIBPATHS.debug = \
|
||||
../../target/aarch64-linux-android/debug
|
||||
|
||||
LIBPATHS.release = \
|
||||
../../target/aarch64-linux-android/release
|
||||
|
||||
USES = ml_sdk OpenGL stdc++
|
||||
|
||||
STLIBS = \
|
||||
pathfinder_magicleap_demo
|
||||
|
||||
SHLIBS = \
|
||||
ml_privileges
|
||||
|
||||
DATAS = \
|
||||
../../resources/** : resources/
|
|
@ -0,0 +1,19 @@
|
|||
KIND = program
|
||||
SRCS = src/landscape.cpp
|
||||
|
||||
LIBPATHS.debug = \
|
||||
../../target/aarch64-linux-android/debug
|
||||
|
||||
LIBPATHS.release = \
|
||||
../../target/aarch64-linux-android/release
|
||||
|
||||
INCS = \
|
||||
src/ \
|
||||
lre/code/inc/gen/
|
||||
|
||||
USES = \
|
||||
lumin_runtime \
|
||||
lre/code/srcs
|
||||
|
||||
STLIBS = \
|
||||
pathfinder_magicleap_demo
|
|
@ -0,0 +1,12 @@
|
|||
.DS_Store
|
||||
*.log
|
||||
*.json.dirty
|
||||
*.json.lock
|
||||
*.pyc
|
||||
*.sln
|
||||
*.vcxproj*
|
||||
|
||||
pipeline/cache/intermediate/
|
||||
.out/
|
||||
.vscode/
|
||||
.vs/
|
|
@ -0,0 +1,183 @@
|
|||
<?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.11.1">
|
||||
<property id="name" value="root"/>
|
||||
<property id="sceneName" value="PathfinderDemo"/>
|
||||
<node name="quad1" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0 0.102 0.502 1"/>
|
||||
<property id="name" value="quad1"/>
|
||||
<property id="position">
|
||||
<property id="x" value="0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="-0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="y" value="180.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad2" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0.4 0.6 1"/>
|
||||
<property id="name" value="quad2"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="0.15"/>
|
||||
</property>
|
||||
<property id="rotation"/>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad3" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0 0 1"/>
|
||||
<property id="name" value="quad3"/>
|
||||
<property id="position">
|
||||
<property id="x" value="0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="y" value="90.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad4" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0.302 0 1"/>
|
||||
<property id="name" value="quad4"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="-0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="y" value="-90.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad5" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0.6 0 1"/>
|
||||
<property id="name" value="quad5"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="-0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="x" value="90.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad6" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0 0.2 0 1"/>
|
||||
<property id="name" value="quad6"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="0.15"/>
|
||||
<property id="z" value="0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="x" value="270.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
</design:rootNode>
|
|
@ -0,0 +1,13 @@
|
|||
KIND = program
|
||||
|
||||
INCS = \
|
||||
code/inc/ \
|
||||
code/inc/gen/
|
||||
|
||||
SRCS = \
|
||||
code/src/main.cpp \
|
||||
code/src/PathfinderDemo.cpp
|
||||
|
||||
USES = \
|
||||
lumin_runtime \
|
||||
code/srcs
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<mlproject:mlproject xmlns:mlproject="http://www.magicleap.com/uidesigner/mlproject" generated="true" srcGenVersion="1">
|
||||
<designFile path="scenes/PathfinderDemo.design"/>
|
||||
<pipelineDirectory path="pipeline"/>
|
||||
<preferences key="srcgen.directories.incgen" value="inc/gen"/>
|
||||
<preferences key="srcgen.directories.src" value="src"/>
|
||||
<preferences key="srcgen.directories.srcgen" value="src/gen"/>
|
||||
<preferences key="srcgen.directories.basedir" value="code"/>
|
||||
<preferences key="srcgen.directories.inc" value="inc"/>
|
||||
</mlproject:mlproject>
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
USES = "scenes" "pipeline/cache/AssetManifest"
|
||||
REFS = PathfinderDemo
|
|
@ -0,0 +1,99 @@
|
|||
// %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 <lumin/LandscapeApp.h>
|
||||
#include <lumin/Prism.h>
|
||||
#include <lumin/event/ServerEvent.h>
|
||||
#include <SceneDescriptor.h>
|
||||
#include <PrismSceneManager.h>
|
||||
|
||||
/**
|
||||
* PathfinderDemo Landscape Application
|
||||
*/
|
||||
class PathfinderDemo : public lumin::LandscapeApp {
|
||||
public:
|
||||
/**
|
||||
* Constructs the Landscape Application.
|
||||
*/
|
||||
PathfinderDemo();
|
||||
|
||||
/**
|
||||
* Destroys the Landscape Application.
|
||||
*/
|
||||
virtual ~PathfinderDemo();
|
||||
|
||||
/**
|
||||
* Disallows the copy constructor.
|
||||
*/
|
||||
PathfinderDemo(const PathfinderDemo&) = delete;
|
||||
|
||||
/**
|
||||
* Disallows the move constructor.
|
||||
*/
|
||||
PathfinderDemo(PathfinderDemo&&) = delete;
|
||||
|
||||
/**
|
||||
* Disallows the copy assignment operator.
|
||||
*/
|
||||
PathfinderDemo& operator=(const PathfinderDemo&) = delete;
|
||||
|
||||
/**
|
||||
* Disallows the move assignment operator.
|
||||
*/
|
||||
PathfinderDemo& operator=(PathfinderDemo&&) = delete;
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
lumin::Prism* prism_ = nullptr; // represents the bounded space where the App renders.
|
||||
PrismSceneManager* prismSceneManager_ = nullptr;
|
||||
};
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// -- 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>
|
||||
|
||||
namespace scenes {
|
||||
|
||||
namespace PathfinderDemo {
|
||||
|
||||
namespace externalNodes {
|
||||
}
|
||||
|
||||
struct SpawnedScene : public SpawnedSceneBase {
|
||||
SpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root);
|
||||
~SpawnedScene();
|
||||
};
|
||||
|
||||
SpawnedSceneBase* createSpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root);
|
||||
SpawnedSceneHandlers* createSpawnedSceneHandlers(SpawnedSceneBase& spawnedScene);
|
||||
|
||||
extern const SceneDescriptor descriptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -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];
|
||||
};
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
// -- 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);
|
||||
|
|
@ -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();
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// -- 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;
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
// %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 <PathfinderDemo.h>
|
||||
#include <lumin/node/RootNode.h>
|
||||
#include <lumin/ui/Cursor.h>
|
||||
#include <ml_logging.h>
|
||||
#include <scenes.h>
|
||||
#include <PrismSceneManager.h>
|
||||
|
||||
PathfinderDemo::PathfinderDemo() {
|
||||
ML_LOG(Debug, "PathfinderDemo Constructor.");
|
||||
|
||||
// Place your constructor implementation here.
|
||||
}
|
||||
|
||||
PathfinderDemo::~PathfinderDemo() {
|
||||
ML_LOG(Debug, "PathfinderDemo Destructor.");
|
||||
|
||||
// Place your destructor implementation here.
|
||||
}
|
||||
|
||||
const glm::vec3 PathfinderDemo::getInitialPrismSize() const {
|
||||
return glm::vec3(2.0f, 2.0f, 2.0f);
|
||||
}
|
||||
|
||||
void PathfinderDemo::createInitialPrism() {
|
||||
prism_ = requestNewPrism(getInitialPrismSize());
|
||||
if (!prism_) {
|
||||
ML_LOG(Error, "PathfinderDemo Error creating default prism.");
|
||||
abort();
|
||||
}
|
||||
prismSceneManager_ = new PrismSceneManager(prism_);
|
||||
}
|
||||
|
||||
int PathfinderDemo::init() {
|
||||
|
||||
ML_LOG(Debug, "PathfinderDemo Initializing.");
|
||||
|
||||
createInitialPrism();
|
||||
lumin::ui::Cursor::SetScale(prism_, 0.03f);
|
||||
spawnInitialScenes();
|
||||
|
||||
// Place your initialization here.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PathfinderDemo::deInit() {
|
||||
ML_LOG(Debug, "PathfinderDemo Deinitializing.");
|
||||
|
||||
// Place your deinitialization here.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PathfinderDemo::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, "PathfinderDemo Failed to add spawnedRoot to the prism root node");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PathfinderDemo::updateLoop(float fDelta) {
|
||||
|
||||
// Place your update here.
|
||||
|
||||
// Return true for your app to continue running, false to terminate the app.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PathfinderDemo::eventListener(lumin::ServerEvent* event) {
|
||||
|
||||
// Place your event handling here.
|
||||
|
||||
// Return true if the event is consumed.
|
||||
return false;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
#include <SceneDescriptor.h>
|
||||
#include <SpawnedSceneBase.h>
|
||||
#include <PathfinderDemo/PathfinderDemo.h>
|
||||
|
||||
namespace scenes {
|
||||
|
||||
namespace PathfinderDemo {
|
||||
|
||||
SpawnedScene::SpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root)
|
||||
: SpawnedSceneBase(sceneDescriptor, root) {
|
||||
}
|
||||
|
||||
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:
|
||||
|
||||
};
|
||||
|
||||
|
||||
Handlers::Handlers(SpawnedScene& ss)
|
||||
: SpawnedSceneHandlers(ss)
|
||||
{
|
||||
}
|
||||
|
||||
SpawnedSceneHandlers* createSpawnedSceneHandlers(SpawnedSceneBase& ssb) {
|
||||
return new Handlers(static_cast<SpawnedScene&>(ssb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 ;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
// -- 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();
|
||||
}
|
||||
|
|
@ -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() {
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// -- 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 <PathfinderDemo/PathfinderDemo.h>
|
||||
|
||||
namespace scenes {
|
||||
|
||||
namespace PathfinderDemo {
|
||||
|
||||
namespace externalNodes {
|
||||
}
|
||||
|
||||
const SceneDescriptor::ExternalNodeReferences externalNodesMap = {
|
||||
};
|
||||
|
||||
const SceneDescriptor descriptor(
|
||||
0,
|
||||
"PathfinderDemo",
|
||||
"root",
|
||||
"/assets/scenes/PathfinderDemo.scene.xml",
|
||||
"/assets/scenes/PathfinderDemo.scene.res.xml",
|
||||
externalNodesMap,
|
||||
true);
|
||||
}
|
||||
|
||||
const SceneDescriptorReferences externalScenes = {
|
||||
{PathfinderDemo::descriptor.getExternalName(), PathfinderDemo::descriptor}
|
||||
};
|
||||
|
||||
struct VerifyNumberOfExternalScenes {
|
||||
VerifyNumberOfExternalScenes() { assert(externalScenes.size() == numberOfExternalScenes); }
|
||||
};
|
||||
|
||||
VerifyNumberOfExternalScenes verifyNumberOfExternalScenes;
|
||||
}
|
||||
|
||||
const PrismSceneManager::CreateSpawnedScene PrismSceneManager::createSpawnedScene[scenes::numberOfExternalScenes] = {
|
||||
::scenes::PathfinderDemo::createSpawnedScene
|
||||
};
|
||||
|
||||
const PrismSceneManager::CreateSpawnedSceneHandlers PrismSceneManager::createSpawnedSceneHandlers[scenes::numberOfExternalScenes] = {
|
||||
static_cast<CreateSpawnedSceneHandlers>(::scenes::PathfinderDemo::createSpawnedSceneHandlers)
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// %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 <PathfinderDemo.h>
|
||||
#include <ml_logging.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ML_LOG(Debug, "PathfinderDemo Starting.");
|
||||
PathfinderDemo myApp;
|
||||
return myApp.run();
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
SRCS = \
|
||||
src/gen/scenes.cpp \
|
||||
src/gen/PathfinderDemo/PathfinderDemo.cpp \
|
||||
src/gen/PrismSceneManager.cpp \
|
||||
src/gen/SceneDescriptor.cpp \
|
||||
src/gen/SpawnedSceneBase.cpp \
|
||||
src/gen/SpawnedSceneHandlers.cpp \
|
||||
src/gen/SpawnedSceneUserData.cpp \
|
|
@ -0,0 +1,19 @@
|
|||
<manifest
|
||||
xmlns:ml="magicleap"
|
||||
ml:package="com.company.pathfinderdemo"
|
||||
ml:version_code="1"
|
||||
ml:version_name="1.0">
|
||||
<application
|
||||
ml:visible_name="PathfinderDemo"
|
||||
ml:sdk_version="1.0">
|
||||
<component
|
||||
ml:name=".pathfinderdemo.universe"
|
||||
ml:visible_name="PathfinderDemo"
|
||||
ml:binary_name="bin/PathfinderDemo"
|
||||
ml:type="Universe">
|
||||
<icon
|
||||
ml:model_folder="assets/icon/model"
|
||||
ml:portal_folder="assets/icon/portal" />
|
||||
</component>
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"intermediate-storage": {
|
||||
"path": "cache",
|
||||
"kind": "in-tree"
|
||||
},
|
||||
"project-schema-version": 4,
|
||||
"types": {
|
||||
"assets": [
|
||||
"lap/types/asset/audio",
|
||||
"lap/types/asset/material",
|
||||
"lap/types/asset/model",
|
||||
"lap/types/asset/outline-font",
|
||||
"lap/types/asset/texture"
|
||||
],
|
||||
"files": [
|
||||
"lap/types/file/bmp",
|
||||
"lap/types/file/dds",
|
||||
"lap/types/file/fbx",
|
||||
"lap/types/file/files",
|
||||
"lap/types/file/gltf",
|
||||
"lap/types/file/jpg",
|
||||
"lap/types/file/kmat",
|
||||
"lap/types/file/ogg",
|
||||
"lap/types/file/otf",
|
||||
"lap/types/file/png",
|
||||
"lap/types/file/tga",
|
||||
"lap/types/file/tiff",
|
||||
"lap/types/file/wav"
|
||||
]
|
||||
},
|
||||
"checkpoint-hash": "0a229200eb36f445371d5eef7cd9afaf76b99c1d2278fbca0497449dfcfd890710c7535ff703844a86fabeb5c268c4f234715814458f635ac70bf3d378499654",
|
||||
"templates": [
|
||||
"lap/template/converted_texture_from_bmp",
|
||||
"lap/template/converted_texture_from_tga",
|
||||
"lap/template/converted_texture_from_tiff",
|
||||
"lap/template/passthru_audio_from_ogg",
|
||||
"lap/template/passthru_audio_from_wav",
|
||||
"lap/template/passthru_material_from_kmat",
|
||||
"lap/template/passthru_model_from_fbx",
|
||||
"lap/template/passthru_model_from_gltf",
|
||||
"lap/template/passthru_outline_font_from_otf",
|
||||
"lap/template/passthru_texture_from_dds",
|
||||
"lap/template/passthru_texture_from_jpg",
|
||||
"lap/template/passthru_texture_from_png"
|
||||
],
|
||||
"nodes": {}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
DATAS = \
|
||||
scenes/PathfinderDemo.scene.res.xml : assets/scenes/PathfinderDemo.scene.res.xml \
|
||||
scenes/PathfinderDemo.scene.xml : assets/scenes/PathfinderDemo.scene.xml
|
|
@ -0,0 +1,183 @@
|
|||
<?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.11.1">
|
||||
<property id="name" value="root"/>
|
||||
<property id="sceneName" value="PathfinderDemo"/>
|
||||
<node name="quad1" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0 0.102 0.502 1"/>
|
||||
<property id="name" value="quad1"/>
|
||||
<property id="position">
|
||||
<property id="x" value="0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="-0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="y" value="180.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad2" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0.4 0.6 1"/>
|
||||
<property id="name" value="quad2"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="0.15"/>
|
||||
</property>
|
||||
<property id="rotation"/>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad3" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0 0 1"/>
|
||||
<property id="name" value="quad3"/>
|
||||
<property id="position">
|
||||
<property id="x" value="0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="y" value="90.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad4" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0.302 0 1"/>
|
||||
<property id="name" value="quad4"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="-0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="y" value="-90.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad5" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0.6 0.6 0 1"/>
|
||||
<property id="name" value="quad5"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="-0.15"/>
|
||||
<property id="z" value="-0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="x" value="90.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
<node name="quad6" nodeTypeId="lumin.quad">
|
||||
<property id="color" value="0 0.2 0 1"/>
|
||||
<property id="name" value="quad6"/>
|
||||
<property id="position">
|
||||
<property id="x" value="-0.15"/>
|
||||
<property id="y" value="0.15"/>
|
||||
<property id="z" value="0.15"/>
|
||||
</property>
|
||||
<property id="rotation">
|
||||
<property id="x" value="270.0"/>
|
||||
</property>
|
||||
<property id="scale"/>
|
||||
<property id="size">
|
||||
<property id="x" value="0.3"/>
|
||||
<property id="y" value="0.3"/>
|
||||
</property>
|
||||
<property id="texCoords">
|
||||
<property id="x">
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="y">
|
||||
<property id="x" value="1.0"/>
|
||||
<property id="y" value="1.0"/>
|
||||
</property>
|
||||
<property id="z">
|
||||
<property id="x" value="1.0"/>
|
||||
</property>
|
||||
<property id="w"/>
|
||||
</property>
|
||||
</node>
|
||||
</design:rootNode>
|
|
@ -0,0 +1 @@
|
|||
<ResourceModel version="1"></ResourceModel>
|
|
@ -0,0 +1,9 @@
|
|||
<ObjectModel name="PathfinderDemo" version="1">
|
||||
<TransformNode/>
|
||||
<QuadNode castShadow="false" color="0,0.01512947,0.2453161,1" name="quad1" pos="0.15,-0.15,-0.15" receiveShadow="false" rot="-0,1,-0,-4.371139e-08" shader="MAX" size="0.300000, 0.300000"/>
|
||||
<QuadNode castShadow="false" color="0.3504092,0.1572062,0.3504092,1" name="quad2" pos="-0.15,-0.15,0.15" receiveShadow="false" shader="MAX" size="0.300000, 0.300000"/>
|
||||
<QuadNode castShadow="false" color="0.3504092,0,0,1" name="quad3" pos="0.15,-0.15,0.15" receiveShadow="false" rot="0,0.7071068,0,0.7071068" shader="MAX" size="0.300000, 0.300000"/>
|
||||
<QuadNode castShadow="false" color="0.3504092,0.09219654,0,1" name="quad4" pos="-0.15,-0.15,-0.15" receiveShadow="false" rot="0,-0.7071068,0,0.7071068" shader="MAX" size="0.300000, 0.300000"/>
|
||||
<QuadNode castShadow="false" color="0.3504092,0.3504092,0,1" name="quad5" pos="-0.15,-0.15,-0.15" receiveShadow="false" rot="0.7071068,0,0,0.7071068" shader="MAX" size="0.300000, 0.300000"/>
|
||||
<QuadNode castShadow="false" color="0,0.04397775,0,1" name="quad6" pos="-0.15,0.15,0.15" receiveShadow="false" rot="0.7071068,0,-0,-0.7071068" shader="MAX" size="0.300000, 0.300000"/>
|
||||
</ObjectModel>
|
|
@ -9,10 +9,20 @@
|
|||
ml:min_api_level="3">
|
||||
<uses-privilege ml:name="WorldReconstruction"/>
|
||||
<uses-privilege ml:name="LowLatencyLightwear"/>
|
||||
<uses-privilege ml:name="ControllerPose"/>
|
||||
<component
|
||||
ml:name=".universe"
|
||||
ml:visible_name="Pathfinder Landscape Demo"
|
||||
ml:binary_name="bin/PathfinderLandscapeDemo"
|
||||
ml:type="Universe">
|
||||
<icon
|
||||
ml:model_folder="assets/icon/model"
|
||||
ml:portal_folder="assets/icon/portal" />
|
||||
</component>
|
||||
<component
|
||||
ml:name=".fullscreen"
|
||||
ml:visible_name="Pathfinder Demo"
|
||||
ml:binary_name="bin/PathfinderDemo"
|
||||
ml:visible_name="Pathfinder Immersive Demo"
|
||||
ml:binary_name="bin/PathfinderImmersiveDemo"
|
||||
ml:type="Fullscreen">
|
||||
</component>
|
||||
</application>
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
#include <landscape.h>
|
||||
#include <lumin/node/RootNode.h>
|
||||
#include <lumin/node/QuadNode.h>
|
||||
#include <lumin/resource/PlanarResource.h>
|
||||
#include <lumin/ui/node/UiPanel.h>
|
||||
#include <lumin/ui/Cursor.h>
|
||||
#include <lumin/input/Raycast.h>
|
||||
#include <lumin/event/RayCastEventData.h>
|
||||
#include <ml_logging.h>
|
||||
#include <scenes.h>
|
||||
#include <PrismSceneManager.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ML_LOG(Debug, "PathfinderDemo Starting.");
|
||||
PathfinderDemo myApp;
|
||||
return myApp.run();
|
||||
}
|
||||
|
||||
const char* QUAD_NAMES[1] = {
|
||||
"quad1"
|
||||
};
|
||||
|
||||
const char* PANEL_NAMES[1] = {
|
||||
"uiPanel1"
|
||||
};
|
||||
|
||||
PathfinderDemo::PathfinderDemo() {
|
||||
ML_LOG(Debug, "PathfinderDemo Constructor.");
|
||||
|
||||
// Place your constructor implementation here.
|
||||
svg_filecount_ = magicleap_pathfinder_svg_filecount();
|
||||
svg_filenames_ = magicleap_pathfinder_svg_filenames();
|
||||
}
|
||||
|
||||
PathfinderDemo::~PathfinderDemo() {
|
||||
ML_LOG(Debug, "PathfinderDemo Destructor.");
|
||||
|
||||
// Place your destructor implementation here.
|
||||
}
|
||||
|
||||
const glm::vec3 PathfinderDemo::getInitialPrismSize() const {
|
||||
return glm::vec3(0.4f, 0.4f, 0.4f);
|
||||
}
|
||||
|
||||
void PathfinderDemo::createInitialPrism() {
|
||||
prism_ = requestNewPrism(getInitialPrismSize());
|
||||
if (!prism_) {
|
||||
ML_LOG(Error, "PathfinderDemo Error creating default prism.");
|
||||
abort();
|
||||
}
|
||||
prismSceneManager_ = new PrismSceneManager(prism_);
|
||||
}
|
||||
|
||||
int PathfinderDemo::init() {
|
||||
|
||||
ML_LOG(Debug, "PathfinderDemo Initializing.");
|
||||
|
||||
createInitialPrism();
|
||||
lumin::ui::Cursor::SetEnabled(prism_, false);
|
||||
spawnInitialScenes();
|
||||
|
||||
// Place your initialization here.
|
||||
if (checkPrivilege(lumin::PrivilegeId::kControllerPose) != lumin::PrivilegeResult::kGranted) {
|
||||
ML_LOG(Error, "Pathfinder Failed to get controller access");
|
||||
abort();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Get the root node of the prism
|
||||
lumin::RootNode* root_node = prism_->getRootNode();
|
||||
if (!root_node) {
|
||||
ML_LOG(Error, "Pathfinder Failed to get root node");
|
||||
abort();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get the quad
|
||||
lumin::QuadNode* quad_node = lumin::QuadNode::CastFrom(prism_->findNode(QUAD_NAMES[0], root_node));
|
||||
if (!quad_node) {
|
||||
ML_LOG(Error, "Pathfinder Failed to get quad node");
|
||||
abort();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create the EGL surface for it to draw to
|
||||
lumin::ResourceIDType plane_id = prism_->createPlanarEGLResourceId();
|
||||
if (!plane_id) {
|
||||
ML_LOG(Error, "Pathfinder Failed to create EGL resource");
|
||||
abort();
|
||||
return 1;
|
||||
}
|
||||
lumin::PlanarResource* plane = static_cast<lumin::PlanarResource*>(prism_->getResource(plane_id));
|
||||
if (!plane) {
|
||||
ML_LOG(Error, "Pathfinder Failed to get plane");
|
||||
abort();
|
||||
return 1;
|
||||
}
|
||||
quad_node->setRenderResource(plane_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PathfinderDemo::deInit() {
|
||||
ML_LOG(Debug, "PathfinderDemo Deinitializing.");
|
||||
|
||||
// Place your deinitialization here.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PathfinderDemo::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, "PathfinderDemo Failed to add spawnedRoot to the prism root node");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PathfinderDemo::updateLoop(float fDelta) {
|
||||
|
||||
// Place your update here.
|
||||
|
||||
// Return true for your app to continue running, false to terminate the app.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PathfinderDemo::eventListener(lumin::ServerEvent* event) {
|
||||
// Place your event handling here.
|
||||
lumin::ServerEventType typ = event->getServerEventType();
|
||||
switch (typ) {
|
||||
case lumin::ServerEventType::kControlPose6DofInputEvent:
|
||||
requestWorldRayCast(getHeadposeWorldPosition(), getHeadposeWorldForwardVector(), 0);
|
||||
return false;
|
||||
case lumin::ServerEventType::kRayCastEvent: {
|
||||
lumin::RayCastEventData* raycast_event = static_cast<lumin::RayCastEventData*>(event);
|
||||
std::shared_ptr<lumin::RaycastResult> raycast_result = raycast_event->getHitData();
|
||||
switch (raycast_result->getType()) {
|
||||
case lumin::RaycastResultType::kQuadNode: {
|
||||
std::shared_ptr<lumin::RaycastQuadNodeResult> quad_result = std::static_pointer_cast<lumin::RaycastQuadNodeResult>(raycast_result);
|
||||
focus_node = quad_result->getNodeId();
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
focus_node = lumin::INVALID_NODE_ID;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
// %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 <lumin/LandscapeApp.h>
|
||||
#include <lumin/Prism.h>
|
||||
#include <lumin/event/ServerEvent.h>
|
||||
#include <SceneDescriptor.h>
|
||||
#include <PrismSceneManager.h>
|
||||
|
||||
/**
|
||||
* PathfinderDemo Landscape Application
|
||||
*/
|
||||
class PathfinderDemo : public lumin::LandscapeApp {
|
||||
public:
|
||||
/**
|
||||
* Constructs the Landscape Application.
|
||||
*/
|
||||
PathfinderDemo();
|
||||
|
||||
/**
|
||||
* Destroys the Landscape Application.
|
||||
*/
|
||||
virtual ~PathfinderDemo();
|
||||
|
||||
/**
|
||||
* Disallows the copy constructor.
|
||||
*/
|
||||
PathfinderDemo(const PathfinderDemo&) = delete;
|
||||
|
||||
/**
|
||||
* Disallows the move constructor.
|
||||
*/
|
||||
PathfinderDemo(PathfinderDemo&&) = delete;
|
||||
|
||||
/**
|
||||
* Disallows the copy assignment operator.
|
||||
*/
|
||||
PathfinderDemo& operator=(const PathfinderDemo&) = delete;
|
||||
|
||||
/**
|
||||
* Disallows the move assignment operator.
|
||||
*/
|
||||
PathfinderDemo& operator=(PathfinderDemo&&) = delete;
|
||||
|
||||
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();
|
||||
|
||||
/**
|
||||
* Respond to a cube face being activated
|
||||
*/
|
||||
void onActivate(int face);
|
||||
|
||||
/**
|
||||
* Run application login
|
||||
*/
|
||||
virtual bool updateLoop(float fDelta) override;
|
||||
|
||||
/**
|
||||
* Handle events from the server
|
||||
*/
|
||||
virtual bool eventListener(lumin::ServerEvent* event) override;
|
||||
|
||||
private:
|
||||
lumin::Prism* prism_ = nullptr; // represents the bounded space where the App renders.
|
||||
PrismSceneManager* prismSceneManager_ = nullptr;
|
||||
uint64_t svg_filecount_ = 0;
|
||||
char** svg_filenames_ = nullptr;
|
||||
lumin::NodeIDType focus_node = lumin::INVALID_NODE_ID;
|
||||
};
|
||||
|
||||
extern "C" uint64_t magicleap_pathfinder_svg_filecount();
|
||||
extern "C" char** magicleap_pathfinder_svg_filenames();
|
|
@ -13,6 +13,7 @@ use pathfinder_demo::Options;
|
|||
use pathfinder_demo::window::Mode;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_char;
|
||||
|
||||
mod c_api;
|
||||
mod magicleap;
|
||||
|
@ -57,3 +58,21 @@ pub extern "C" fn magicleap_pathfinder_demo(egl_display: EGLDisplay, egl_context
|
|||
app.finish_drawing_frame();
|
||||
}
|
||||
}
|
||||
|
||||
const SVG_FILENAMES: &[*const c_char] = &[
|
||||
&b"svg/Ghostscript_Tiger.svg\0"[0],
|
||||
&b"svg/paper.svg\0"[0],
|
||||
&b"svg/julius-caesar-with-bg.svg\0"[0],
|
||||
&b"svg/nba-notext.svg\0"[0],
|
||||
&b"svg/pathfinder_logo.svg\0"[0],
|
||||
];
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn magicleap_pathfinder_svg_filecount() -> usize {
|
||||
SVG_FILENAMES.len()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn magicleap_pathfinder_svg_filenames() -> *const *const c_char {
|
||||
&SVG_FILENAMES[0]
|
||||
}
|
Loading…
Reference in New Issue