org.rajawali3d.renderer / SideBySideRenderer

SideBySideRenderer

abstract class SideBySideRenderer : Renderer
abstract class SideBySideRenderer : Renderer

This renderer is typically used by virtual reality glasses like the Open Dive. It renders the scene from two different viewpoints. The x position of the two cameras are slightly offset while the z and y position stay 0.

You can set up your scene like a regular Rajawali project. The only difference is that you should call super.initScene() at the end of the initScene() method.

Your application's activity should implement the SensorEventListener interface. The sensor to use is Sensor#TYPE_ROTATION_VECTOR. In SensorEventListener#onSensorChanged(android.hardware.SensorEvent) the this#setSensorOrientation(float[]) method should be called. Here's an example of how to do this.

In your RajawaliActivity:


  public void onCreate(Bundle savedInstanceState) {
  	// ...
  	mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
  	mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
  }
 
  // ...
 
  public void onSensorChanged(SensorEvent event) {
  	if(event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR_
  	{
  		SensorManager.getQuaternionFromVector(mQuaternion, event.values);
  		mRender.setSensorOrientation(mQuaternion);
  	}
  }
 
  // ...
 
  protected void onResume() {
  	super.onResume();
  	mSensorManager.registerListener(this, mSensor, 10000);
  }
 
  // ...
 
  protected void onPause() {
  	super.onPause();
  	mSensorManager.unregisterListener(this);
  }
  

Author
dennis.ippel