parents 1dfdb958 c1df5eb6
Thumbs.db
\ No newline at end of file
Thumbs.db
.DS_Store
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include <math.h>
#include "aux.h"
gvr::Mat4f TranslationMatrix (float x, float y, float z)
{
gvr::Mat4f mvs;
mvs.m[0][0]=1;mvs.m[0][1]=0;mvs.m[0][2]=0; mvs.m[0][3]=x;
mvs.m[1][0]=0;mvs.m[1][1]=1;mvs.m[1][2]=0;mvs.m[1][3]=y;
mvs.m[2][0]=0;mvs.m[2][1]=0;mvs.m[2][2]=1; mvs.m[2][3]=z;
mvs.m[3][0]=0;mvs.m[3][1]=0;mvs.m[3][2]=0; mvs.m[3][3]=1;
return mvs;
}
gvr::Mat4f TranslationMatrix (float v[3])
{
return TranslationMatrix (v[0], v[1], v[2]);
}
gvr::Mat4f ScalingMatrix (float x, float y, float z)
{
gvr::Mat4f mvs;
mvs.m[0][0]=x;mvs.m[0][1]=0;mvs.m[0][2]=0; mvs.m[0][3]=0;
mvs.m[1][0]=0;mvs.m[1][1]=y;mvs.m[1][2]=0;mvs.m[1][3]=0;
mvs.m[2][0]=0;mvs.m[2][1]=0;mvs.m[2][2]=z; mvs.m[2][3]=0;
mvs.m[3][0]=0;mvs.m[3][1]=0;mvs.m[3][2]=0; mvs.m[3][3]=1;
return mvs;
}
gvr::Mat4f ScalingMatrix (float v[3])
{
return ScalingMatrix(v[0], v[1], v[2]);
}
gvr::Mat4f ScalingMatrix (float s)
{
return ScalingMatrix(s,s,s);
}
float getCofactor(float m0, float m1, float m2,
float m3, float m4, float m5,
float m6, float m7, float m8)
......@@ -13,7 +65,7 @@ float getCofactor(float m0, float m1, float m2,
//adapted from
//openvr-0.9.19\samples\shared\matrices.cpp
static gvr::Mat4f invert (const gvr::Mat4f& m)
gvr::Mat4f invert (const gvr::Mat4f& m)
{
gvr::Mat4f r;
// get cofactors of minor matrices
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include "vr/gvr/capi/include/gvr.h"
const float EPSILON = 0.00001f;
gvr::Mat4f TranslationMatrix (float x, float y, float z);
gvr::Mat4f TranslationMatrix (float v[3]);
gvr::Mat4f ScalingMatrix (float x, float y, float z);
gvr::Mat4f ScalingMatrix (float v[3]);
gvr::Mat4f ScalingMatrix (float s);
float getCofactor(float m0, float m1, float m2,
float m3, float m4, float m5,
float m6, float m7, float m8);
static gvr::Mat4f invert (const gvr::Mat4f& m);
gvr::Mat4f invert (const gvr::Mat4f& m);
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-40@3x-1.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-20.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-20@2x-1.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-29@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-20@2x-2.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40@2x-1.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-83_5@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>NOMAD VR</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict/>
<key>CFBundleIcons~ipad</key>
<dict/>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<key>CFBundleVersion</key>
<string>2.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Used to scan QR codes</string>
<key>NSMainNibFile</key>
<string>launch</string>
<key>UIFileSharingEnabled</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>launch</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>magnetometer</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
......@@ -3,13 +3,7 @@
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>TreasureHuntNDK.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<dict/>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>12BEE99D1C8F53AB002F8361</key>
......
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:NOMADVRSDK.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
target 'NOMADVRSDK' do
target 'NOMADVR' do
pod 'GVRSDK'
pod 'GVRAudioSDK'
source 'https://github.com/CocoaPods/Specs.git'
......
......@@ -2,7 +2,7 @@
<Workspace
version = "1.0">
<FileRef
location = "group:/Users/lrz/gvr-ios-sdk/Samples/TreasureHuntNDK/NOMADVRSDK.xcodeproj">
location = "group:/Users/lrz/gvr-ios-sdk/Samples/TreasureHuntNDK/NOMADVR.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
......
......@@ -15,9 +15,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "12BEE99D1C8F53AB002F8361"
BuildableName = "NOMADVRSDK.app"
BlueprintName = "NOMADVRSDK"
ReferencedContainer = "container:NOMADVRSDK.xcodeproj">
BuildableName = "NOMADVR.app"
BlueprintName = "NOMADVR"
ReferencedContainer = "container:NOMADVR.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
......@@ -56,9 +56,9 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "12BEE99D1C8F53AB002F8361"
BuildableName = "NOMADVRSDK.app"
BlueprintName = "NOMADVRSDK"
ReferencedContainer = "container:NOMADVRSDK.xcodeproj">
BuildableName = "NOMADVR.app"
BlueprintName = "NOMADVR"
ReferencedContainer = "container:NOMADVR.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
......@@ -70,16 +70,6 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "12BEE99D1C8F53AB002F8361"
BuildableName = "NOMADVRSDK.app"
BlueprintName = "NOMADVRSDK"
ReferencedContainer = "container:NOMADVRSDK.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>TreasureHuntNDK.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
/*# Copyright 2016-2018 The NOMAD Developers Group*/
/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
......@@ -19,18 +20,45 @@
#import "GVROverlayView.h"
#import "treasure_hunt_renderer.h"
#include "FileBrowser/FileBrowser.h"
#include "FileBrowser-Swift.h"
@interface TreasureHuntViewController ()<GLKViewControllerDelegate, GVROverlayViewDelegate> {
gvr_context *_gvrContext;
std::unique_ptr<TreasureHuntRenderer> _renderer;
NSMutableArray *mycommands;
}
@end
NSString * filename;
@implementation TreasureHuntViewController
//https://stackoverflow.com/questions/3717141/how-to-detect-keyboard-events-on-hardware-keyboard-on-iphone-ios
- (BOOL)canBecomeFirstResponder
{
return YES;
}
- (NSArray *)keyCommands
{
return mycommands;
}
- (void)dealloc {
gvr_destroy(&_gvrContext);
}
- (UIViewController *)presentingViewControllerForSettingsDialog {
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -47,6 +75,7 @@
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapGLView:)];
[self.view addGestureRecognizer:tapGesture];
// Create an OpenGL ES context and assign it to the view loaded from storyboard
GLKView *glkView = (GLKView *)self.view;
glkView.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
......@@ -62,10 +91,68 @@
// Create GVR context.
_gvrContext = gvr_create();
FileBrowser *fb=[[FileBrowser alloc] initWithInitialPath: nullptr allowEditing:NO showCancelButton:NO];
void (^ _Nullable didSelectFileCallback)(FBFile * _Nonnull) = ^(FBFile * _Nonnull file)
{
filename=[[file filePath] path];
NSFileManager *filemgr = [NSFileManager defaultManager];
//http://www.techotopia.com/index.php/Working_with_Directories_on_iPhone_OS#The_Application_Documents_Directory
if ([filemgr changeCurrentDirectoryPath: [filename stringByDeletingLastPathComponent]] == NO)
NSLog(@"Cannot change current directory");
_renderer->setConfigFile (filename);
_renderer->InitializeGl();
};
//https://gist.github.com/ferbass/0ddea86e6b2eb5915fabdbfe9f151a5e
fb.didSelectFile=didSelectFileCallback;
//[self.navigationController pushViewController:fb animated:YES];
[self presentViewController:fb animated:YES completion:nil];
_renderer.reset(new TreasureHuntRenderer(_gvrContext));
//keys
NSMutableArray *commands = [[NSMutableArray alloc] init];
/* Up */
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]];
/* Down */
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]];
/* Left */
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]];
/* Right */
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]];
//VRPark, ABCD=uhyj, arrows: up down left right = wxad
UIKeyModifierFlags f[]={
//UIKeyModifierAlphaShift,
//UIKeyModifierShift,
//UIKeyModifierControl,
//UIKeyModifierAlternate,
//UIKeyModifierCommand,
//UIKeyModifierControl | UIKeyModifierAlternate,
//UIKeyModifierControl | UIKeyModifierCommand,
//UIKeyModifierAlternate | UIKeyModifierCommand,
//UIKeyModifierControl | UIKeyModifierAlternate | UIKeyModifierCommand,
kNilOptions
};
NSString *characters = @"uhyjwxad";
for (NSInteger i = 0; i < characters.length; i++) {
for (int j=0;j<1;j++) {
NSString *input = [characters substringWithRange:NSMakeRange(i, 1)];
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:f[j] action:@selector(handleCommand:)]];
}
}
mycommands = commands.copy;
// [self.addKeyCommand:mycommands];
}
// Initialize TreasureHuntRenderer.
_renderer.reset(new TreasureHuntRenderer(_gvrContext));
_renderer->InitializeGl();
- (void)handleCommand:(UIKeyCommand *)command
{
_renderer->keypress (command.input.UTF8String[0]);
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
......@@ -104,9 +191,6 @@
NSLog(@"User pressed back button");
}
- (UIViewController *)presentingViewControllerForSettingsDialog {
return self;
}
- (void)didPresentSettingsDialog:(BOOL)presented {
// The overlay view is presenting the settings dialog. Pause our rendering while presented.
......
......@@ -20,6 +20,9 @@
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
//https://www.raywenderlich.com/66532/ios-7-game-controller-tutorial
#include "GameController/GameController.h"
#include <memory>
#include <string>
#include <thread> // NOLINT
......@@ -45,6 +48,10 @@ class TreasureHuntRenderer {
*/
~TreasureHuntRenderer();
void setConfigFile (NSString * filename);
/**
* Initialize any GL-related objects. This should be called on the rendering
* thread with a valid GL context.
......@@ -71,7 +78,11 @@ class TreasureHuntRenderer {
*/
void OnResume();
void keypress (int k);
private:
NSArray<GCController *> *controllers=nullptr;
int CreateTexture(int width, int height, int textureFormat, int textureType);
/**
......@@ -106,7 +117,7 @@ class TreasureHuntRenderer {
gvr::BufferViewport scratch_viewport_;
gvr::Mat4f head_view_;
gvr::Mat4f model_cube_;
//gvr::Mat4f model_cube_;
gvr::Mat4f camera_;
gvr::Mat4f view_;
gvr::Mat4f modelview_projection_cube_;
......@@ -148,8 +159,10 @@ class TreasureHuntRenderer {
void RenderAtomTrajectories(const gvr::Mat4f eyeViewProjection);
void RenderIsos(const gvr::Mat4f eyeViewProjection, int curDataPos);