ParkVR bluetooth controller support added.

Icons added.
parent eaa823d4
{
"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>
......
......@@ -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>
......@@ -26,13 +26,28 @@
@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);
}
......@@ -42,6 +57,8 @@ NSString * filename;
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -89,12 +106,55 @@ NSString * 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];
}
- (void)handleCommand:(UIKeyCommand *)command
{
_renderer->keypress (command.input.UTF8String[0]);
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
// GVR only supports landscape right orientation for inserting the phone in the viewer.
return UIInterfaceOrientationMaskLandscapeRight;
......
......@@ -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
......@@ -75,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);
/**
......
......@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "AudioToolbox/AudioToolbox.h"
#include "treasure_hunt_renderer.h"
#include <assert.h>
......@@ -153,7 +154,7 @@ static gvr::Recti CalculatePixelSpaceRect(const gvr::Sizei& texture_size,
static_cast<int>(rect.bottom), static_cast<int>(rect.top)};
return result;
}
static void CheckGLError(const char* label) {
int gl_error = glGetError();
if (gl_error != GL_NO_ERROR) {
......@@ -170,6 +171,41 @@ void TreasureHuntRenderer::setConfigFile (NSString * filename)
loadConfigFile();
}
void TreasureHuntRenderer::keypress (int k)
{
switch (k) { //A B C D -> Y A X B
//case 'u':
case 'h':
animateMovement=!animateMovement;
break;
case 'y':
animateTimesteps=!animateTimesteps;
break;
//case 'j':
//up down left right
case 'w':
currentSet++;
if (currentSet>TIMESTEPS-1)
currentSet=0;
break;
case 'x':
currentSet--;
if (currentSet<0)
currentSet=TIMESTEPS-1;
break;
case 'a':
currentIso++;
if (currentIso>ISOS)
currentIso=0;
break;
case 'd':
currentIso--;
if (currentIso<0)
currentIso=ISOS;
break;
}
}
void TreasureHuntRenderer::loadConfigFile(void)
{
......@@ -209,6 +245,8 @@ TreasureHuntRenderer::TreasureHuntRenderer(
: gvr_api_(gvr::GvrApi::WrapNonOwned(gvr_context)),
scratch_viewport_(gvr_api_->CreateBufferViewport())
{
controllers=[GCController controllers];
//won't have config file until later
// loadConfigFile();
}
......@@ -335,8 +373,8 @@ void TreasureHuntRenderer::DrawFrame() {
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glDisable(GL_CULL_FACE);
//glCullFace(GL_FRONT);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
......@@ -378,6 +416,7 @@ void TreasureHuntRenderer::DrawFrame() {
void TreasureHuntRenderer::OnTriggerEvent() {
animateMovement=!animateMovement;
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
}
void TreasureHuntRenderer::OnPause() {
......@@ -779,6 +818,7 @@ void TreasureHuntRenderer::DrawEye(gvr::Eye eye, const gvr::Mat4f& view_matrix,
pixel_rect.right - pixel_rect.left,
pixel_rect.top - pixel_rect.bottom);
CheckGLError("Before glClear");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CheckGLError("ColorParam");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment