Caution: This project is no longer being actively developed. Recommended alternative solution is GearVR Framework.
Gear VR Application Framework.
The aim of the project is to create an easy to use, lightweight, application framework for Gear VR. The library enables to write an app entirely in Java.
- No C++ (NDK) required (for apps)
- Simple XML scene-graph
- entity-component-system
- Use View, Layouts, Drawable or Canvas as texture
- Multi-View rendering
- Playing 360 videos
- Easy integration with Facebook 360 Spatial Workstation Rendering SDK and Google VR Spatial Audio
- Built in support for Oculus's Reserved User Interactions (it can be overrided if you want)
Add a dependency in your module's build.gradle.
dependencies {
implementation 'org.meganekkovr:meganekko:3.2.1'
implementation 'com.android.support:support-v4:27.0.1'
implementation 'org.joml:joml:1.9.2'
// Optional for org.meganekkovr.audio_engine.AudioEngine
implementation 'com.google.vr:sdk-audio:1.101.0'
}
Click "Sync Now".
Note: Meganekko uses multi-view rendering. This feature is not working on prior Android M devices. See also https://developer3.oculus.com/documentation/mobilesdk/latest/concepts/release/
Meganekko app is started from subclass of MeganekkoApp
.
import org.meganekkovr.MeganekkoApp;
public class MyApp extends MeganekkoApp {
@Override
public void init() {
super.init();
// Init application here
}
}
Create VR scene with XML. XML file can be localed from xml resource. For example: res/xml/scene.xml.
<scene>
<view src="@layout/hello_world" position="0 0 -5" />
</scene>
@layout/hello_world
is normal layout file put in res/layout/hello_world.xml.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textColor="#fff" />
</FrameLayout>
Call setSceneFromXML
in MyApp
.
public class MyApp extends MeganekkoApp {
@Override
public void init() {
super.init();
setSceneFromXml(R.xml.scene); // Set scene
}
}
You have to modify AndroidManifest. Add recommended attributes and elements. See Oculus developer document.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<!-- You have to declare to require Gear VR -->
<meta-data
android:name="com.samsung.android.vr.application.mode"
android:value="vr_only" />
<!-- Declare your App class extends MeganekkoApp -->
<meta-data
android:name="org.meganekkovr.App"
android:value="org.meganekkovr.sample.MyApp"/>
<activity
android:name="org.meganekkovr.GearVRActivity"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
android:excludeFromRecents="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="landscape">
<!-- Only in debugging. Remove this when upload to Oculus Store. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
osig file is required to launch Meganekko app in Gear VR. See Oculus developer document for more information.
Put your osig file in app/src/main/assets
.
That's all! Build, Connect Galaxy device to PC, install APK, and launch app. You will see white text "Hello World!".
Open Android Studio with this repository. Select samplev3 from module list and click Run button.