Update tutorial to work with HMD + Hand Controllers only

This commit is contained in:
Ryan Huffman 2016-09-22 14:18:25 -07:00
parent 66a33d020d
commit 216cf2b4bc
15 changed files with 116 additions and 33 deletions

View file

@ -87,6 +87,7 @@
#include <PhysicsEngine.h> #include <PhysicsEngine.h>
#include <PhysicsHelpers.h> #include <PhysicsHelpers.h>
#include <plugins/PluginManager.h> #include <plugins/PluginManager.h>
#include <plugins/PluginUtils.h>
#include <plugins/CodecPlugin.h> #include <plugins/CodecPlugin.h>
#include <RecordingScriptingInterface.h> #include <RecordingScriptingInterface.h>
#include <RenderableWebEntityItem.h> #include <RenderableWebEntityItem.h>
@ -1276,17 +1277,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
bool hasTutorialContent = contentVersion >= 1; bool hasTutorialContent = contentVersion >= 1;
Setting::Handle<bool> firstRun { Settings::firstRun, true }; Setting::Handle<bool> firstRun { Settings::firstRun, true };
bool hasVive = false; bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable() && PluginUtils::isHandControllerAvailable();
for (auto& displayPlugin : PluginManager::getInstance()->getDisplayPlugins()) {
if (displayPlugin->getName() == "OpenVR (Vive)") {
hasVive = true;
break;
}
}
Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
bool shouldGoToTutorial = hasVive && hasTutorialContent && !tutorialComplete.get(); bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get();
qDebug() << "has vive: " << hasVive << ", current plugin: " << _displayPlugin->getName();
qDebug() << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName();
qDebug() << "has tutorial content" << hasTutorialContent; qDebug() << "has tutorial content" << hasTutorialContent;
qDebug() << "tutorial complete" << tutorialComplete.get(); qDebug() << "tutorial complete" << tutorialComplete.get();
qDebug() << "should go to tutorial " << shouldGoToTutorial; qDebug() << "should go to tutorial " << shouldGoToTutorial;
@ -1300,10 +1296,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
addressLookupString = arguments().value(urlIndex + 1); addressLookupString = arguments().value(urlIndex + 1);
} }
const QString TUTORIAL_PATH = "/tutorial_begin";
if (shouldGoToTutorial) { if (shouldGoToTutorial) {
DependencyManager::get<AddressManager>()->ifLocalSandboxRunningElse([=]() { DependencyManager::get<AddressManager>()->ifLocalSandboxRunningElse([=]() {
qDebug() << "Home sandbox appears to be running, going to Home."; qDebug() << "Home sandbox appears to be running, going to Home.";
DependencyManager::get<AddressManager>()->goToLocalSandbox("/tutorial_begin"); DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH);
}, [=]() { }, [=]() {
qDebug() << "Home sandbox does not appear to be running, going to Entry."; qDebug() << "Home sandbox does not appear to be running, going to Entry.";
if (firstRun.get()) { if (firstRun.get()) {

View file

@ -13,10 +13,12 @@
#include <QtScript/QScriptContext> #include <QtScript/QScriptContext>
#include <avatar/AvatarManager.h>
#include <display-plugins/DisplayPlugin.h> #include <display-plugins/DisplayPlugin.h>
#include <display-plugins/CompositorHelper.h> #include <display-plugins/CompositorHelper.h>
#include <OffscreenUi.h> #include <OffscreenUi.h>
#include <avatar/AvatarManager.h> #include <plugins/PluginUtils.h>
#include "Application.h" #include "Application.h"
HMDScriptingInterface::HMDScriptingInterface() { HMDScriptingInterface::HMDScriptingInterface() {
@ -47,6 +49,14 @@ glm::vec2 HMDScriptingInterface::overlayToSpherical(const glm::vec2 & position)
return qApp->getApplicationCompositor().overlayToSpherical(position); return qApp->getApplicationCompositor().overlayToSpherical(position);
} }
bool HMDScriptingInterface::isHMDAvailable() {
return PluginUtils::isHMDAvailable();
}
bool HMDScriptingInterface::isHandControllerAvailable() {
return PluginUtils::isHandControllerAvailable();
}
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) { QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
glm::vec3 hudIntersection; glm::vec3 hudIntersection;
auto instance = DependencyManager::get<HMDScriptingInterface>(); auto instance = DependencyManager::get<HMDScriptingInterface>();

View file

@ -38,6 +38,9 @@ public:
Q_INVOKABLE QString preferredAudioInput() const; Q_INVOKABLE QString preferredAudioInput() const;
Q_INVOKABLE QString preferredAudioOutput() const; Q_INVOKABLE QString preferredAudioOutput() const;
Q_INVOKABLE bool isHMDAvailable();
Q_INVOKABLE bool isHandControllerAvailable();
Q_INVOKABLE bool setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const; Q_INVOKABLE bool setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const;
Q_INVOKABLE void disableHandLasers(int hands) const; Q_INVOKABLE void disableHandLasers(int hands) const;

View file

@ -68,6 +68,8 @@ public:
bool isSupported() const override { return true; } bool isSupported() const override { return true; }
const QString& getName() const override { return NAME; } const QString& getName() const override { return NAME; }
bool isHandController() const override { return false; }
void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); } void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); }
void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override; void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;

View file

@ -39,6 +39,8 @@ public:
virtual bool isSupported() const override; virtual bool isSupported() const override;
virtual const QString& getName() const override { return NAME; } virtual const QString& getName() const override { return NAME; }
bool isHandController() const override { return false; }
virtual void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); } virtual void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); }
virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override; virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;

View file

@ -19,7 +19,8 @@ namespace controller {
class InputPlugin : public Plugin { class InputPlugin : public Plugin {
public: public:
virtual void pluginFocusOutEvent() = 0; virtual void pluginFocusOutEvent() = 0;
virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) = 0; virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) = 0;
virtual bool isHandController() const = 0;
}; };

View file

@ -0,0 +1,35 @@
// PluginUtils.cpp
// input-plugins/src/input-plugins
//
// Created by Ryan Huffman on 9/22/16.
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "PluginUtils.h"
#include "DisplayPlugin.h"
#include "InputPlugin.h"
#include "PluginManager.h"
bool PluginUtils::isHMDAvailable() {
for (auto& displayPlugin : PluginManager::getInstance()->getDisplayPlugins()) {
if (displayPlugin->isHmd()) {
return true;
break;
}
}
return false;
}
bool PluginUtils::isHandControllerAvailable() {
for (auto& inputPlugin : PluginManager::getInstance()->getInputPlugins()) {
if (inputPlugin->isHandController()) {
return true;
break;
}
}
return false;
};

View file

@ -0,0 +1,17 @@
// PluginUtils.h
// input-plugins/src/input-plugins
//
// Created by Ryan Huffman on 9/22/16.
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
class PluginUtils {
public:
static bool isHMDAvailable();
static bool isHandControllerAvailable();
};

View file

@ -25,6 +25,8 @@ class NeuronPlugin : public InputPlugin {
public: public:
friend void FrameDataReceivedCallback(void* context, void* sender, _BvhDataHeaderEx* header, float* data); friend void FrameDataReceivedCallback(void* context, void* sender, _BvhDataHeaderEx* header, float* data);
bool isHandController() const override { return false; }
// Plugin functions // Plugin functions
virtual bool isSupported() const override; virtual bool isSupported() const override;
virtual const QString& getName() const override { return NAME; } virtual const QString& getName() const override { return NAME; }

View file

@ -26,6 +26,8 @@ public:
bool isSupported() const override; bool isSupported() const override;
const QString& getName() const override { return NAME; } const QString& getName() const override { return NAME; }
bool isHandController() const override { return false; }
void init() override; void init() override;
void deinit() override; void deinit() override;

View file

@ -31,6 +31,8 @@ public:
virtual const QString& getName() const override { return NAME; } virtual const QString& getName() const override { return NAME; }
virtual const QString& getID() const override { return HYDRA_ID_STRING; } virtual const QString& getID() const override { return HYDRA_ID_STRING; }
bool isHandController() const override { return true; }
virtual bool activate() override; virtual bool activate() override;
virtual void deactivate() override; virtual void deactivate() override;

View file

@ -26,6 +26,8 @@ public:
bool isSupported() const override; bool isSupported() const override;
const QString& getName() const override { return NAME; } const QString& getName() const override { return NAME; }
bool isHandController() const override { return true; }
bool activate() override; bool activate() override;
void deactivate() override; void deactivate() override;

View file

@ -35,6 +35,8 @@ public:
bool isSupported() const override; bool isSupported() const override;
const QString& getName() const override { return NAME; } const QString& getName() const override { return NAME; }
bool isHandController() const override { return true; }
bool activate() override; bool activate() override;
void deactivate() override; void deactivate() override;

View file

@ -8,20 +8,21 @@
}, },
enterEntity: function() { enterEntity: function() {
// send message to outer zone // send message to outer zone
print("ENTERED THE TUTORIAL START AREA"); print("Entered the tutorial start area");
var parentID = Entities.getEntityProperties(this.entityID, 'parentID').parentID; if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable()) {
print("HERE", parentID); var parentID = Entities.getEntityProperties(this.entityID, 'parentID').parentID;
if (parentID) { if (parentID) {
print("HERE2"); Entities.callEntityMethod(parentID, 'start');
Entities.callEntityMethod(parentID, 'start'); } else {
print("HERE4"); print("ERROR: No parent id found on tutorial start zone");
}
} else { } else {
print("HERE3"); Window.alert("To proceed with this tutorial, please connect your VR headset and hand controllers.");
print("ERROR: No parent id found on tutorial start zone"); location = "/";
} }
}, },
leaveEntity: function() { leaveEntity: function() {
print("EXITED THE TUTORIAL START AREA"); print("Exited the tutorial start area");
} }
}; };

View file

@ -27,8 +27,10 @@ if (!Function.prototype.bind) {
} }
(function() { (function() {
Script.include("ownershipToken.js"); var ownershipTokenPath = Script.resolvePath("ownershipToken.js");
Script.include("tutorial.js"); var tutorialPath = Script.resolvePath("tutorial.js");
Script.include(ownershipTokenPath);
Script.include(tutorialPath);
var TutorialZone = function() { var TutorialZone = function() {
this.token = null; this.token = null;
@ -37,17 +39,19 @@ if (!Function.prototype.bind) {
TutorialZone.prototype = { TutorialZone.prototype = {
keyReleaseHandler: function(event) { keyReleaseHandler: function(event) {
print(event.text); print(event.text);
if (event.text == ",") { if (event.isShifted && event.isAlt) {
if (!this.tutorialManager.startNextStep()) { if (event.text == ",") {
if (!this.tutorialManager.startNextStep()) {
this.tutorialManager.startTutorial();
}
} else if (event.text == "F11") {
this.tutorialManager.restartStep();
} else if (event.text == "F10") {
MyAvatar.shouldRenderLocally = !MyAvatar.shouldRenderLocally;
} else if (event.text == "r") {
this.tutorialManager.stopTutorial();
this.tutorialManager.startTutorial(); this.tutorialManager.startTutorial();
} }
} else if (event.text == "F11") {
this.tutorialManager.restartStep();
} else if (event.text == "F10") {
MyAvatar.shouldRenderLocally = !MyAvatar.shouldRenderLocally;
} else if (event.text == "r") {
this.tutorialManager.stopTutorial();
this.tutorialManager.startTutorial();
} }
}, },
preload: function(entityID) { preload: function(entityID) {