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

Migrate 2.x to 3.x

Yuya Matsuo edited this page Feb 3, 2017 · 8 revisions

Package name

Package name is changed from 3.x. New package name is org.meganekkovr. All classes should be imported from it (or its sub packages).

XML

  • Replace <globe> to <entity geometry="primitive: globe">
  • Replace <object texture="@layout/xxx"> to <view src="@layout/xxx">
  • Replace <object texture="@drawable/xxx"> to <img src="@layout/xxx">
  • Replace x,y,z attributes to position="x y z"
  • Replace <object> to <entity>

Example:

<scene>
    <globe id="@+id/player"/>

    <object id="@+id/waiting">

        <object
            id="@+id/text"
            texture="@layout/waiting"
            z="-5"/>

        <globe
            opacity="0.7"
            texture="@drawable/background"/>
    </object>
</scene>

To:

<scene>
    <entity
        geometry="primitive: globe"
        id="@+id/player"/>

    <entity id="@+id/waiting">

        <view
            id="@+id/text"
            position="0 0 -5"
            src="@layout/waiting"/>

        <entity
            geometry="primitive: globe;"
            opacity="0.7"
            surface="renderer: @drawable/background"/>
    </entity>
</scene>

AndroidManifest.xml

  • Add <application theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> if not specified.
  • Add <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/> if omitted.
  • Replace <meta-data android:name="com.eje_c.meganekko.App"> to <meta-data android:name="org.meganekkovr.App">.

MeganekkoApp

  • Replace setSceneFromXML to setSceneFromXml
  • Replace getScene().getViewOrientation() to getCenterViewRotation()

update()

public void update() {
}

To:

public void update(FrameInput frame) {
}

Scene

  • Replace getViewOrientation() to HeadTransform.getInstance().getQuaternion()

Entity (SceneObject)

  • Replace animate().start(app) to animate().start() (start() has no arguments)
  • Replace findObjectById to findById

Material

Functional alternative to Material is SurfaceRendererComponent but APIs are drastically changed.

Video rendering

Material material = Material.from(mediaPlayer);
object.material(material);

To:

SurfaceRendererComponent surfaceRenderer = new SurfaceRendererComponent();
surfaceRenderer.setContinuousUpdate(true);
mediaPlayer.setSurface(surfaceRenderer.getSurface());
entity.add(surfaceRenderer);

Mesh

Functional alternative to Mesh is GeometryComponent. It has similar APIs to Mesh.

Mesh mesh = Mesh.createQuad(width, height);
object.mesh(mesh);

To:

GeometryComponent geometry = new GeometryComponent();
geometry.buildQuad(width, height);
entity.add(geometry);
Old method New method
Threads.spawn(runnable) new Thread(runnable).start()
MeganekkoApp.setSceneFromXML() MeganekkoApp.setSceneFromXml()
MeganekkoApp.update() MeganekkoApp.update(FrameInput frame)
MeganekkoApp.runOnGlThread(runnable, delay) new Handler(Looper.getMainLooper()).postDelayed(() -> runOnGlThread(runnable), delay);
SceneObject Entity
SceneObject.animate().start(app) Entity.animate().start()
SceneObject.updateViewLayout(true) Entity.remove(GeometryComponent.class); Entity.remove(SurfaceRendererComponent.class); Entity.add(GeometryComponent.from(view)); Entity.add(SurfaceRendererComponent.from(view));
SceneObject.getChildrenCount() Entity.getChildren().size()
SceneObject.getChildByIndex(i) Entity.getChildren().get(i)
SceneObject.findObjectById() Entity.findById()
Scene.getViewOrientation() HeadTransform.getInstance().getQuaternion()
Scene.onResume() Scene.onStartRendering()
Scene.onPause() Scene.onStopRendering()
Scene.initialize(app) Scene.init()
Scene.isLookingAt(obj) LookDetector.getInstance().isLookingAt(obj)
Scene.getLookingPoint(obj) LookDetector.getInstance().getLookingPoint(obj)
Material.StereoMode SurfaceRendererComponent.StereoMode
MeganekkoApp.recenter() OVRApp.getInstance().recenterYaw(true)
MeganekkoApp.onKeyShortPress() MeganekkoApp.onKeyPressed()
Mesh.createQuad(width, height) new GeometryComponent(); geometry.buildQuad(width, height);
Clone this wiki locally