Created
January 20, 2016 18:31
-
-
Save marktani/daa8c678238aa747c0fe to your computer and use it in GitHub Desktop.
CardboardCube article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle; | |
import android.os.Vibrator; | |
import android.util.Log; | |
import com.google.vrtoolkit.cardboard.CardboardActivity; | |
import com.google.vrtoolkit.cardboard.CardboardView; | |
public class MainActivity extends CardboardActivity { | |
private SceneRenderer sceneRenderer; | |
private Vibrator vibrator; | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.common_ui); | |
CardboardView cardboardView = (CardboardView) findViewById(R.id.cardboard_view); | |
// enable for performance boost - make sure to reset state before drawing yourself | |
// cardboardView.setRestoreGLStateEnabled(false); | |
sceneRenderer = new SceneRenderer(); | |
cardboardView.setRenderer(sceneRenderer); | |
setCardboardView(cardboardView); | |
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); | |
} | |
@Override | |
public void onCardboardTrigger() { | |
// trigger the renderer | |
sceneRenderer.trigger(); | |
// Give user feedback. | |
vibrator.vibrate(50); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment