rsanchezsaez / CardboardSDK-iOS

iOS port of Google's CardboardSDK (mobile VR toolkit)
Other
334 stars 104 forks source link

Prepare for update to SceneKit version? #19

Closed ljfdestiny closed 8 years ago

ljfdestiny commented 8 years ago

Hi @rsanchezsaez ,thanks for providing a terrific framework to us. Now i want to move the code to Scenekit.But I met problems with Scenekit + CardboardSDK-iOS.In my code i use SCNRenderer to match with CBDViewController's openGL Context.But the [SCNRenderer render] function is deprecated: deprecated in iOS 9.0.And Particle Effects can not show correctly. So,is there possible to change the project to Scenekit? Thanks.

CacheLine commented 8 years ago

Hi Ijfdestiny, I have been trying render an SCNScene into GLKView's EAGLContext using the SCNRenderer, but it only renders black. I made a SceneKit replacement for the TreasureRenderer in the sample code as a test. The same scene renders into an SCNView, even one using the same EAGLContext.

- (void)setupRendererWithView:(GLKView *)glView
{
         [EAGLContext setCurrentContext:glView.context];
         self.renderer =  [SCNRenderer rendererWithContext:glView.context options:nil];
         self.renderer.scene = self.scene;
   ...

Did you manage to get a scene rendered into the Cardboard EAGLContext?

ljfdestiny commented 8 years ago

Hi CacheLine,maybe you forgotten to call [renderer render] in drawEyeWithEye:(CBDEye *)eye ?

CacheLine commented 8 years ago

Thanks Ijfdestiny, I just triple checked. Nothing as easy as that :-( I had also tried calling [renderer renderAtTime:] since they say [renderer render] is deprecated. It didn't help.

ljfdestiny commented 8 years ago

How about the view matrix and perspective of the cameraNode,did you tramsform then to SCNMatrix format?

CacheLine commented 8 years ago

Thank you IjfDestiny! I was neglecting the glClear, without which everything was black. I also missed the setProjectionTransform, and most annoyingly, the use of the transpose of the GL matrix to get the node transform. Thank you again

rsanchezsaez commented 8 years ago

It seems this have been resolved. Can this issue be closed? :)

rsanchezsaez commented 8 years ago

I'm closing this issue now, let me know if there are any more issues.

In case it helps, a CBDSceneKit example project has just been added, demonstrating usage of the CardboardSDK with SceneKit+SpriteKit.