Android Open Source - StorySphere A R Activity






From Project

Back to project page StorySphere.

License

The source code is released under:

GNU General Public License

If you think the Android project StorySphere listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ruselabs.storysphere.activities;
/*from w w  w. ja va2s  . c o m*/
import android.os.Bundle;
import android.view.View;

import com.google.vrtoolkit.cardboard.sensors.HeadTracker;

import rajawali.util.RajLog;
import rajawali.vr.RajawaliVRRenderer;
import rajawali.vuforia.RajawaliVuforiaActivity;

/**
 * This class is the entry point for the StorySphere experience.
 * All we're doing is extending {@link rajawali.RajawaliActivity}
 * to connect our custom renderer, which will handle all things graphics.
 *
 *  @author David Brodsky (dbro@dbro.pro)
 */
public class ARActivity extends RajawaliVuforiaActivity {
    private HeadTracker mHeadTracker;
    private RajawaliVRRenderer mRenderer;
    private boolean mSetRenderer = false;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        mSurfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
//                | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
//                | View.SYSTEM_UI_FLAG_IMMERSIVE);
        mHeadTracker = new HeadTracker(this);
    }

    @Override
    protected void createSurfaceView() {
        super.createSurfaceView();

        if (!mSetRenderer) super.setRenderer(mRenderer);

        mSurfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                | View.SYSTEM_UI_FLAG_IMMERSIVE);
    }

    protected void setRenderer(RajawaliVRRenderer renderer) {
        mRenderer = renderer;
        mRenderer.setHeadTracker(mHeadTracker);

        if (mSurfaceView == null) return; // We'll process this call on createSurfaceView
        mSetRenderer = true;
        super.setRenderer(renderer);
    }

    @Override
    public void onResume() {
        super.onResume();
        mHeadTracker.startTracking();
    }

    @Override
    public void onPause() {
        super.onPause();
        mHeadTracker.stopTracking();
    }

    @Override
    protected void setupTracker() {
        int result = initTracker(TRACKER_TYPE_MARKER);
        if (result == 1) {
            result = initTracker(TRACKER_TYPE_IMAGE);
            if (result == 1) {
                super.setupTracker();
            } else {
                RajLog.e("Couldn't initialize image tracker.");
            }
        } else {
            RajLog.e("Couldn't initialize marker tracker.");
        }
    }

    @Override
    protected void initApplicationAR() {
        super.initApplicationAR();

        createFrameMarker(1, "Marker1", 50, 50);
        createFrameMarker(2, "Marker2", 50, 50);

        createImageMarker("StonesAndChips.xml");

        // -- this is how you add a cylinder target:
        // https://developer.vuforia.com/resources/dev-guide/cylinder-targets
        // createImageMarker("MyCylinderTarget.xml");

        // -- this is how you add a multi-target:
        // https://developer.vuforia.com/resources/dev-guide/multi-targets
        // createImageMarker("MyMultiTarget.xml");
    }
}




Java Source Code List

com.ruselabs.storysphere.activities.ARActivity.java
com.ruselabs.storysphere.activities.StorySphereActivity.java
com.ruselabs.storysphere.renderer.StorySphereRenderer.java
com.ruselabs.storysphere.tricks.CameraScreen.java
com.ruselabs.storysphere.tricks.ChromaVideoScreen.java
com.ruselabs.storysphere.tricks.PhotosphereBlender.java
com.ruselabs.storysphere.tricks.VideoScreen.java
com.ruselabs.storysphere.tricks.VideoSphereScreen.java