This repository has been archived by the owner on Dec 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Migrate 2.x to 3.x
Yuya Matsuo edited this page Feb 3, 2017
·
8 revisions
Package name is changed from 3.x. New package name is org.meganekkovr
. All classes should be imported from it (or its sub packages).
- 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 toposition="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>
- 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">
.
- Replace
setSceneFromXML
tosetSceneFromXml
- Replace
getScene().getViewOrientation()
togetCenterViewRotation()
public void update() {
}
To:
public void update(FrameInput frame) {
}
- Replace
getViewOrientation()
toHeadTransform.getInstance().getQuaternion()
- Replace
animate().start(app)
toanimate().start()
(start()
has no arguments) - Replace
findObjectById
tofindById
Functional alternative to Material
is SurfaceRendererComponent
but APIs are drastically changed.
Material material = Material.from(mediaPlayer);
object.material(material);
To:
SurfaceRendererComponent surfaceRenderer = new SurfaceRendererComponent();
surfaceRenderer.setContinuousUpdate(true);
mediaPlayer.setSurface(surfaceRenderer.getSurface());
entity.add(surfaceRenderer);
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); |