Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
VR-demos
Commits
d5d879d3
Commit
d5d879d3
authored
Apr 11, 2018
by
Ruben Jesus Garcia Hernandez
Browse files
Merge branch 'master' of
https://gitlab.mpcdf.mpg.de/nomad-lab/VR-demos
parents
1dfdb958
c1df5eb6
Changes
49
Hide whitespace changes
Inline
Side-by-side
GoogleCardboardIOS/TreasureHuntViewController.mm
→
GoogleCardboardIOS/
NOMADVRIOS/
TreasureHuntViewController.mm
View file @
d5d879d3
/*# 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.
...
...
GoogleCardboardIOS/launch.xib
→
GoogleCardboardIOS/
NOMADVRIOS/
launch.xib
View file @
d5d879d3
File moved
GoogleCardboardIOS/main.m
→
GoogleCardboardIOS/
NOMADVRIOS/
main.m
View file @
d5d879d3
File moved
GoogleCardboardIOS/treasure_hunt_renderer.h
→
GoogleCardboardIOS/
NOMADVRIOS/
treasure_hunt_renderer.h
View file @
d5d879d3
...
...
@@ -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
);
float
UserTranslation
[
3
]
=
{
10
,
0
,
0
};
NSString
*
configfilename
=
nullptr
;
int
error
=
0
;
bool
openGLIsInitialized
=
false
;
};
#endif // TREASUREHUNT_APP_SRC_MAIN_JNI_TREASUREHUNTRENDERER_H_ // NOLINT
GoogleCardboardIOS/treasure_hunt_renderer.mm
→
GoogleCardboardIOS/
NOMADVRIOS/
treasure_hunt_renderer.mm
View file @
d5d879d3
...
...
@@ -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
)
{
...
...
@@ -164,22 +165,55 @@ static void CheckGLError(const char* label) {
}
// namespace
void
TreasureHuntRenderer
::
setConfigFile
(
NSString
*
filename
)
{
configfilename
=
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
)
{
//http://www.techotopia.com/index.php/Working_with_Directories_on_iPhone_OS#The_Application_Documents_Directory
NSArray
*
dirPaths
;
NSString
*
docsDir
;
dirPaths
=
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
docsDir
=
[
dirPaths
objectAtIndex
:
0
];
NSFileManager
*
filemgr
=
[
NSFileManager
defaultManager
];
if
(
configfilename
==
nullptr
)
return
;
if
([
filemgr
changeCurrentDirectoryPath
:
docsDir
]
==
NO
)
NSLog
(
@"Cannot change current directory"
);
if
((
error
=::
loadConfigFile
(
"cytosine.ncfg"
))
<
0
)
{
if
((
error
=::
loadConfigFile
(
configfilename
.
UTF8String
))
<
0
)
{
if
(
-
100
<
error
)
{
eprintf
(
loadConfigFileErrors
[
-
error
]);
eprintf
(
"Config file reading error"
);
...
...
@@ -211,13 +245,16 @@ TreasureHuntRenderer::TreasureHuntRenderer(
:
gvr_api_
(
gvr
::
GvrApi
::
WrapNonOwned
(
gvr_context
)),
scratch_viewport_
(
gvr_api_
->
CreateBufferViewport
())
{
loadConfigFile
();
controllers
=
[
GCController
controllers
];
//won't have config file until later
// loadConfigFile();
}
TreasureHuntRenderer
::~
TreasureHuntRenderer
()
{}
void
TreasureHuntRenderer
::
InitializeGl
()
{
gvr_api_
->
InitializeGl
();
gvr_api_
->
InitializeGl
();
glGenTextures
(
2
,
textures
);
glGenTextures
(
2
+
ZLAYERS
,
textDepthPeeling
);
...
...
@@ -288,9 +325,13 @@ void TreasureHuntRenderer::InitializeGl() {
viewport_list_
.
reset
(
new
gvr
::
BufferViewportList
(
gvr_api_
->
CreateEmptyBufferViewportList
()));
openGLIsInitialized
=
true
;
}
void
TreasureHuntRenderer
::
DrawFrame
()
{
if
(
!
openGLIsInitialized
)
return
;
viewport_list_
->
SetToRecommendedBufferViewports
();
if
(
animateTimesteps
)
{
...
...
@@ -332,8 +373,8 @@ void TreasureHuntRenderer::DrawFrame() {
}
glEnable
(
GL_DEPTH_TEST
);
gl
En
able
(
GL_CULL_FACE
);
glCullFace
(
GL_FRONT
);
gl
Dis
able
(
GL_CULL_FACE
);
//
glCullFace(GL_FRONT);
glDisable
(
GL_SCISSOR_TEST
);
glDisable
(
GL_BLEND
);
...
...
@@ -375,6 +416,7 @@ void TreasureHuntRenderer::DrawFrame() {
void
TreasureHuntRenderer
::
OnTriggerEvent
()
{
animateMovement
=!
animateMovement
;
AudioServicesPlayAlertSound
(
kSystemSoundID_Vibrate
);
}
void
TreasureHuntRenderer
::
OnPause
()
{
...
...
@@ -520,6 +562,8 @@ void TreasureHuntRenderer::RenderAtoms(const float *m) //m[16]
LOGW
(
"FIXME, No Tess code for atoms yet!"
);
return
;
}
else
{
//no tess
if
(
AtomVAO
==
nullptr
)
//not yet loaded
return
;
glBindVertexArray
(
AtomVAO
[
0
]);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
AtomIndices
[
0
]);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
...
...
@@ -774,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"
);
...
...
GoogleCardboardIOS/TreasureHuntNDK.xcworkspace/xcuserdata/lrz.xcuserdatad/UserInterfaceState.xcuserstate
deleted
100644 → 0
View file @
1dfdb958
File deleted
GoogleCardboardIOS/readme.md
0 → 100644
View file @
d5d879d3
This directory contains the demo for Google Cardboard using Google Cardboard SDK
for IOS.
Follow https://developers.google.com/vr/develop/ios/get-started to install
the SDK.
Copy NOMADVRIOS in gvr-ios-sdk/Samples
Enter gvr-ios-sdk/Samples/NOMADVRIOS and run
pod update
If you get this error
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
follow this:
https://stackoverflow.com/questions/38993527/cocoapods-failed-to-connect-to-github-to-update-the-cocoapods-specs-specs-repo
Open Xcode and select NOMADVR.xcworkspace
Setup Developer Account / Profiles / Code signing
Compile and run
NOMADVRLib/atomsGL.cpp
View file @
d5d879d3
...
...
@@ -56,17 +56,23 @@ GLenum atomTexture(GLuint t)
a
[(
i
+
atomsInPeriodicTable
)
*
4
+
3
]
=
extraAtomData
[
i
][
3
]
*
atomScaling
;
}
glBindTexture
(
GL_TEXTURE_2D
,
t
);
//atom texture
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
{
eprintf
(
"opengl error %d, atomTexture bind
\n
"
,
e
);
}
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
#ifdef __APPLE__
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA
,
finalatoms
,
1
,
0
,
GL_RGBA
,
GL_FLOAT
,
a
);
#else
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA32F
,
finalatoms
,
1
,
0
,
GL_RGBA
,
GL_FLOAT
,
a
);
#endif
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
{
eprintf
(
"opengl error %d, atomTexture parameter
\n
"
,
e
);
}
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA32F
,
finalatoms
,
1
,
0
,
GL_RGBA
,
GL_FLOAT
,
a
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
{
eprintf
(
"opengl error %d, atomTexture glTexImage2D
\n
"
,
e
);
}
glBindTexture
(
GL_TEXTURE_2D
,
0
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
{
eprintf
(
"opengl error %d, atomTexture
\n
"
,
e
);
}
...
...
README.md
View file @
d5d879d3
...
...
@@ -9,7 +9,8 @@ Context:
Requirements:
-Supported virtual reality hardware: HTC Vive or Oculus Rift, GearVR,
Google Cardboard for Android, or the LRZ CAVE environment.
Google Cardboard for Android or IOS, or the LRZ CAVE
environment.
Usage Instructions:
See https://www.nomad-coe.eu/the-project/graphics/VR-prototype
...
...
@@ -18,6 +19,9 @@ Subdirectories:
OpenVR: Demos for HTC Vive.
OculusMobile: Demos for GearVR.
GoogleCardboardAndroid: Demos for Google Cardboard (android)
GoogleCardboardIOS: Demo for Google Cardboard (IOS)
GoogleCardboard: Common files between Google Cardboard for Android
and for IOS
CAVE: Demos for LRZ CAVE-like environment (linux)
NOMADGearVRChooser: Android app to select the dataset for GearVR, which
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment