Skip to content

cwei/GVR-SceneKit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GVR-SceneKit

This is an example of using Apple SceneKit with iOS Google Virtual Reality SDK for using with Google Cardboard.

Currently (early June 2016) it is the easiest way to develop VR app on iPhone. Hope this is going to change after WWDC 2016.

The project codename is ’VRBoilerplate’ and initially it was prepared for iOS programming competition for uadevchallenge 2016. It supports both Objective-C and Swift.

Installing

Install CocoaPods, open VRBoilerplate.xcworkspace, start coding.

Usage

To create and manage scene, you need to implement a class based on VRControllerProtocol.

Than specify that class in Info.plist under VRControllerClass key.

If you’re using Swift, you need to specify Obj-C runtime class name

@objc(VRControllerSwift)
class VRControllerSwift : NSObject, VRControllerProtocol {
// ...

VRControllerProtocol

Very simple protocol that contains init-constructor and three methods.

- scene

Read-only property that should return SCNScene. Can’t be null, the scene should not be changed during VRController object lifetime.

- prepareFrameWithHeadTransform:

The method is called before each frame (one time for both eyes). Argument is head rotation from GVR SDK.

You can use prepareFrameWithHeadTransform: as a game loop body.

- eventTriggered

This method is called when magnet on Cardboard is ‘clicked’ (or if there there are tap on Simulator window)

Implementation Details

  • Viewer is at the point (0, 0, 0) looking around. The project does not takes into account SCNCamera objects in Scene. After app start the viewer is looking at the direction (0, 0, -1). The direction which viewer is holding Cardboard in the real word is going to be (0, 0, -1) in VR.

  • There are number of problems with integration of GVR and SceneKit. Since GVR is closed source, they are more like ‘known issues’ like now.

    • reflectivity (.reflectivity > 0) does not work for SCNFloor

    • SpriteKit scenes are not working as a materials

    • There are two warning during build: … direct access in gvr::Singleton gvr::ServerLogger ::GetInstance() to global weak symbol — see issue in GVR project.

  • Scene time is always 0, however SceneKit is not using scene time by default. It is possible to change this in SceneKitVRRenderer.

About

Example of iOS SceneKit + Google VR SDK app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 74.4%
  • Objective-C 25.4%
  • Ruby 0.2%