Skip to content
This repository has been archived by the owner on Dec 26, 2018. It is now read-only.

ejeinc/Meganekko

Repository files navigation

Meganekko

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.

Features

Documentation

Usage

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/

Hello World

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!".

Build from source

Open Android Studio with this repository. Select samplev3 from module list and click Run button.