Android Open Source - gdx-vr Head






From Project

Back to project page gdx-vr.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUC...

If you think the Android project gdx-vr 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

/*******************************************************************************
 * Copyright 2011 See AUTHORS file.//from   w  ww  .jav  a  2 s .c om
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx.vr;

import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.math.Quaternion;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

/**
 * 
 * @author Daniel Holderbaum
 */
public class Head {

  private float interpupillaryDistance = 0.064f;
  private float eyeHeight = 1.61f;

  private Vector3 position = new Vector3();
  private Quaternion orientation = new Quaternion();

  private Vector3 positionOrigin = new Vector3();
  private Quaternion orientationOrigin = new Quaternion();

  private Viewport leftEye = new ScreenViewport(new PerspectiveCamera());
  private Viewport rightEye = new ScreenViewport(new PerspectiveCamera());
  private Viewport cyclopsEye = new ScreenViewport(new PerspectiveCamera());

  private boolean cyclops;

  public Viewport getCyclopsEye() {
    return cyclopsEye;
  }

  public void setCyclopsEye(Viewport cyclopsEye) {
    this.cyclopsEye = cyclopsEye;
  }

  public boolean isCyclops() {
    return cyclops;
  }

  /**
   * Enables or disables VR rendering mode.
   * 
   * Controls stereo rendering and distortion correction. Disabled by default.
   * 
   * If disabled, no interpupillary distance will be applied to the eye
   * transformations and automatic distortion correction will not take place.
   */
  public void setCyclops(boolean cyclops) {
    this.cyclops = cyclops;
  }

  /**
   * Gets the interpupillary distance (in meters). By default it is 64mm (
   * {@code 0.064f}).
   * 
   * @return The interpupillary distance in meters.
   */
  public float getInterpupillaryDistance() {
    return interpupillaryDistance;
  }

  /**
   * Sets the interpupillary distance to use (in meters). Each eye's position
   * is offset by half of this value.
   * 
   * In reality it can range from 54mm to 72mm with 64mm being the average
   * (thus the default value).
   * 
   * The provided distance will be used to compute the matrix returned by
   * EyeTransform.getEyeView(). Changes will be effective from the first frame
   * after this call.
   * 
   * @param interpupillaryDistance
   *            The interpupillary distance (in meters).
   */
  public void setInterpupillaryDistance(float interpupillaryDistance) {
    this.interpupillaryDistance = interpupillaryDistance;
  }

  /**
   * Gets the eye height in meters. By default it is {@code 1.61f}. The head
   * is offset by half of this value from the {@link Body#position}.
   * 
   * @return The eye height in meters.
   */
  public float getEyeHeight() {
    return eyeHeight;
  }

  /**
   * Sets the eye height in meters. The head is offset by half of this value
   * from the {@link Body#position}.
   * 
   * The average eye-height of a human being is about 1.61m (thus the default
   * value). If one wants to model a realistic environment and uses real-world
   * scales, this has to be adjusted to fit the player. Otherwise he will feel
   * smaller or bigger in-game, compared to real life.
   * 
   * @param eyeHeight
   *            The eye height to be used (in meters).
   */
  public void setEyeHeight(float eyeHeight) {
    this.eyeHeight = eyeHeight;
  }

  /**
   * Returns the position of the head. It is the offset of the position from
   * the last time {@link #resetHeadPose()} has been called. It should not be
   * changed, because it is automatically set via head tracking of the head
   * mounted display.
   * 
   * @return The position of the head.
   */
  public Vector3 getPosition() {
    return position;
  }

  public Quaternion getOrientation() {
    return orientation;
  }

  public Viewport getLeftEye() {
    return leftEye;
  }

  public void setLeftEye(Viewport leftEye) {
    this.leftEye = leftEye;
  }

  public Viewport getRightEye() {
    return rightEye;
  }

  public void setRightEye(Viewport rightEye) {
    this.rightEye = rightEye;
  }

  /**
   * The current position and orientation will be used
   */
  public void resetHeadPose() {
    positionOrigin.set(position);
    orientationOrigin.set(orientation);
  }

}




Java Source Code List

com.badlogic.gdx.vr.Body.java
com.badlogic.gdx.vr.CardboardDistortionRenderer.java
com.badlogic.gdx.vr.CardboardDistortion.java
com.badlogic.gdx.vr.CardboardHMD.java
com.badlogic.gdx.vr.CardboardImplementation.java
com.badlogic.gdx.vr.CardboardMetaInformation.java
com.badlogic.gdx.vr.CardboardOpticsInformation.java
com.badlogic.gdx.vr.CardboardScreenInformation.java
com.badlogic.gdx.vr.DeviceMetaInformation.java
com.badlogic.gdx.vr.DeviceOpticsInformation.java
com.badlogic.gdx.vr.DeviceScreenInformation.java
com.badlogic.gdx.vr.DistortionRenderer.java
com.badlogic.gdx.vr.Distortion.java
com.badlogic.gdx.vr.HeadMountedDisplay.java
com.badlogic.gdx.vr.Head.java
com.badlogic.gdx.vr.MeshBuilder.java
com.badlogic.gdx.vr.OculusDistortionRenderer.java
com.badlogic.gdx.vr.OculusHMD.java
com.badlogic.gdx.vr.OculusImplementation.java
com.badlogic.gdx.vr.OculusMetaInformation.java
com.badlogic.gdx.vr.OculusOpticsInformation.java
com.badlogic.gdx.vr.OculusScreenInformation.java
com.badlogic.gdx.vr.SoftwareAntiDistortionRenderer.java
com.badlogic.gdx.vr.SplitViewport.java
com.badlogic.gdx.vr.Stage3D.java
com.badlogic.gdx.vr.TypeTransformer.java
com.badlogic.gdx.vr.TypeTransformer.java
com.badlogic.gdx.vr.VirtualRealityDeviceListener.java
com.badlogic.gdx.vr.VirtualRealityImplementation.java
com.badlogic.gdx.vr.VirtualRealityRenderListener.java
com.badlogic.gdx.vr.VirtualRealityRenderer.java
com.badlogic.gdx.vr.VirtualReality.java
com.badlogic.gdx.vr.simpleroom.IOSLauncher.java
com.badlogic.gdx.vr.simpleroom.SimpleRoom.java
com.badlogic.gdx.vr.simpleroom.android.AndroidLauncher.java
com.badlogic.gdx.vr.simpleroom.desktop.DesktopLauncher.java