Libgdx-CardBoard-Extension
Libgdx-CardBoard-Extension copied to clipboard
What module are you rendering in?
@yangweigbh I noticed that your extension has rendering directly in the android module (instead of the core module). Was there a reasoning behind deviating from the typical structure of a LibGdx app?
Or am I just doing something wrong? I cannot seem to get my project to work.
actually you have the libgdx core module included(in the gradle build script). As the libgdx core and android module is included, we don't have to follow the typical structure of libgdx app. So what's your problem, can you please give more detail?
I think the concern here is about cross platform? Should it support both android and iOS?
@yangweigbh as @xeoshow mentions, I have my codebase structured the typical LibGDX way for cross platform support. I'm wondering what would be required to get your extension to work with such a structure.
Cross platform is nice for several reasons (even if google cardboard sdk isn't ready for integration with LibGDX on iOS, desktop or web:
- The LibGDX setup tool structures a project that way by default (even if you only select the android platform in the setup gui).
- Existing projects will benefit from the extension immediately without a major code refactor.
- Cross platform code will be ready to go, in case google releases an SDK for iOS that doesn't require Unity (another refactor wouldn't be necessary).
- Some apps / games may offer "fallback" to a non-cardboard experience for devices that do not yet have support for cardboard sdk with LibGDX.
I began trying to create an abstract class called CardboardApplicationAdapter which implements CardboardApplicationListener (an analogue to ApplicationAdapter, which implements ApplicationListener). The problem is, I don't know where this would go. I believe it belongs in core, but the methods onNewFrame, onDrawEye, and onFinishFrame have arguments HeadTransform, Eye, and Viewport respectively, which are not present in core (only the android module).
Is an interface (for cardboard) necessary in core for this to work?
Do you have any advice on how to proceed? I'm interesting in contributing to this project, and could make any such additions available as PRs, but I'd like to confirm that this is a sane approach. What are your thoughts?
If this is still an issue, I can write code you can add into the main module that will interface well with this. Do remember, this is a backend, and it's not capable of porting your render code to its format well (due to cameras and transforms).
If you want to write the code yourself, essentially extend the class you're rendering from (for example Screen) so that the render() method calls a render(Matrix4) function that you do the actual rendering in. In your desktop you'll need to give it the camera's matrix, and in cardboard you'll give it the eye's matrices.