GvrArmModel

Standard implementation for a mathematical model to make the virtual controller approximate the physical location of the Daydream controller.

Summary

Inheritance

Inherits from: GvrBaseArmModel, IGvrControllerInputDeviceReceiver

Public attributes

DEFAULT_ELBOW_BEND_RATIO = 0.6f
const float
armExtensionOffset = DEFAULT_ARM_EXTENSION_OFFSET
Vector3
Offset applied to the elbow position as the controller is rotated upwards.
controllerRestPosition = DEFAULT_CONTROLLER_REST_POSITION
Vector3
Position of the controller joint relative to the wrist before the arm model is applied.
elbowBendRatio = DEFAULT_ELBOW_BEND_RATIO
float
Ratio of the controller's rotation to apply to the rotation of the elbow.
elbowRestPosition = DEFAULT_ELBOW_REST_POSITION
Vector3
Position of the elbow joint relative to the head before the arm model is applied.
fadeControllerOffset = 0.0f
float
Offset in front of the controller to determine what position to use when determing if the controller should fade.
fadeDistanceFromHeadForward = 0.25f
float
Controller distance from the front/back of the head after which the controller disappears (meters).
fadeDistanceFromHeadSide = 0.15f
float
Controller distance from the left/right of the head after which the controller disappears (meters).
isLockedToNeck = false
bool
If true, the root of the pose is locked to the local position of the player's neck.
tooltipMaxAngleFromCamera = 80
int
When the angle (degrees) between the controller and the head is larger than this value, the tooltips disappear.
tooltipMinDistanceFromFace = 0.45f
float
Controller distance from face after which the tooltips appear (meters).
wristRestPosition = DEFAULT_WRIST_REST_POSITION
Vector3
Position of the wrist joint relative to the elbow before the arm model is applied.

Properties

ControllerInputDevice
ControllerPositionFromHead
override Vector3
Represents the controller's position relative to the user's head.
ControllerRotationFromHead
override Quaternion
Represent the controller's rotation relative to the user's head.
ElbowPosition
Vector3
Represent the elbow's position relative to the user's head.
ElbowRotation
Quaternion
Represent the elbow's rotation relative to the user's head.
NeckPosition
Vector3
Represent the neck's position relative to the user's head.
PreferredAlpha
override float
The suggested rendering alpha value of the controller.
ShoulderPosition
Vector3
Represent the shoulder's position relative to the user's head.
ShoulderRotation
Quaternion
Represent the shoulder's rotation relative to the user's head.
TooltipAlphaValue
override float
The suggested rendering alpha value of the controller tooltips.
WristPosition
Vector3
Represent the wrist's position relative to the user's head.
WristRotation
Quaternion
Represent the wrist's rotation relative to the user's head.

Protected attributes

DELTA_ALPHA = 4.0f
const float
Amount of normalized alpha transparency to change per second.
EXTENSION_WEIGHT = 0.4f
const float
Increases elbow bending as the controller moves up (unitless).
MAX_EXTENSION_ANGLE = 60.0f
const float
MIN_EXTENSION_ANGLE = 7.0f
const float
Angle ranges the for arm extension offset to start and end (degrees).
controllerPosition
Vector3
controllerRotation
Quaternion
elbowPosition
Vector3
elbowRotation
Quaternion
handedMultiplier
Vector3
Multiplier for handedness such that 1 = Right, 0 = Center, -1 = left.
neckPosition
Vector3
preferredAlpha
float
tooltipAlphaValue
float
torsoDirection
Vector3
Forward direction of user's torso.
torsoRotation
Quaternion
Orientation of the user's torso.
wristPosition
Vector3
wristRotation
Quaternion

Public static attributes

DEFAULT_ARM_EXTENSION_OFFSET = new Vector3(-0.13f, 0.14f, 0.08f)
readonly Vector3
DEFAULT_CONTROLLER_REST_POSITION = new Vector3(0.0f, 0.0f, 0.05f)
readonly Vector3
DEFAULT_ELBOW_REST_POSITION = new Vector3(0.195f, -0.5f, 0.005f)
readonly Vector3
DEFAULT_WRIST_REST_POSITION = new Vector3(0.0f, 0.0f, 0.25f)
readonly Vector3

Protected static attributes

NECK_OFFSET = new Vector3(0.0f, 0.075f, 0.08f)
readonly Vector3
Neck offset used to apply the inverse neck model when locked to the head.
SHOULDER_POSITION = new Vector3(0.17f, -0.2f, -0.03f)
readonly Vector3
Rest position for shoulder joint.

Protected functions

ApplyArmModel()
virtual void
ApplyExtensionOffset(float extensionRatio)
virtual void
Offset the elbow by the extension offset.
ApplyInverseNeckModel(Vector3 headPosition)
virtual Vector3
Transform the head position into an approximate neck position.
ApplyRotationToJoints()
virtual void
Apply the joint rotations to the positions of the joints to determine the final pose.
CalculateExtensionRatio(float xAngle)
virtual float
Calculate the extension ratio based on the angle of the controller along the x axis.
CalculateFinalJointRotations(Quaternion controllerOrientation, Quaternion xyRotation, Quaternion lerpRotation)
virtual void
Determine the final joint rotations relative to the head.
CalculateLerpRotation(Quaternion xyRotation, float extensionRatio)
virtual Quaternion
Calculate the lerp rotation, which is used to control how much the rotation of the controller impacts each joint.
GetControllerRotation(out Quaternion rotation, out Quaternion xyRotation, out float xAngle)
void
Get the controller's orientation.
OnControllerInputUpdated()
virtual void
OnDisable()
virtual void
OnEnable()
virtual void
SetUntransformedJointPositions()
virtual void
Set the starting positions of the joints before they are transformed by the arm model.
UpdateHandedness()
virtual void
UpdateNeckPosition()
virtual void
UpdateTorsoDirection(bool forceImmediate)
virtual void
UpdateTransparency()
virtual void
Controls the transparency of the controller to prevent the controller from clipping through the user's head.

Public attributes

DEFAULT_ELBOW_BEND_RATIO

const float DEFAULT_ELBOW_BEND_RATIO = 0.6f

armExtensionOffset

Vector3 armExtensionOffset = DEFAULT_ARM_EXTENSION_OFFSET

Offset applied to the elbow position as the controller is rotated upwards.

controllerRestPosition

Vector3 controllerRestPosition = DEFAULT_CONTROLLER_REST_POSITION

Position of the controller joint relative to the wrist before the arm model is applied.

elbowBendRatio

float elbowBendRatio = DEFAULT_ELBOW_BEND_RATIO

Ratio of the controller's rotation to apply to the rotation of the elbow.

The remaining rotation is applied to the wrist's rotation.

elbowRestPosition

Vector3 elbowRestPosition = DEFAULT_ELBOW_REST_POSITION

Position of the elbow joint relative to the head before the arm model is applied.

fadeControllerOffset

float fadeControllerOffset = 0.0f

Offset in front of the controller to determine what position to use when determing if the controller should fade.

This is useful when objects are attached to the controller.

fadeDistanceFromHeadForward

float fadeDistanceFromHeadForward = 0.25f

Controller distance from the front/back of the head after which the controller disappears (meters).

fadeDistanceFromHeadSide

float fadeDistanceFromHeadSide = 0.15f

Controller distance from the left/right of the head after which the controller disappears (meters).

isLockedToNeck

bool isLockedToNeck = false

If true, the root of the pose is locked to the local position of the player's neck.

tooltipMaxAngleFromCamera

int tooltipMaxAngleFromCamera = 80

When the angle (degrees) between the controller and the head is larger than this value, the tooltips disappear.

If the value is 180, then the tooltips are always shown. If the value is 90, the tooltips are only shown when they are facing the camera.

tooltipMinDistanceFromFace

float tooltipMinDistanceFromFace = 0.45f

Controller distance from face after which the tooltips appear (meters).

wristRestPosition

Vector3 wristRestPosition = DEFAULT_WRIST_REST_POSITION

Position of the wrist joint relative to the elbow before the arm model is applied.

Properties

ControllerInputDevice

GvrControllerInputDevice ControllerInputDevice

ControllerPositionFromHead

override Vector3 ControllerPositionFromHead

Represents the controller's position relative to the user's head.

ControllerRotationFromHead

override Quaternion ControllerRotationFromHead

Represent the controller's rotation relative to the user's head.

ElbowPosition

Vector3 ElbowPosition

Represent the elbow's position relative to the user's head.

ElbowRotation

Quaternion ElbowRotation

Represent the elbow's rotation relative to the user's head.

NeckPosition

Vector3 NeckPosition

Represent the neck's position relative to the user's head.

If isLockedToNeck is true, this will be the InputTracking position of the Head node modified by an inverse neck model to approximate the neck position. Otherwise, it is always zero.

PreferredAlpha

override float PreferredAlpha

The suggested rendering alpha value of the controller.

This is to prevent the controller from intersecting the face. The range is always 0 - 1.

ShoulderPosition

Vector3 ShoulderPosition

Represent the shoulder's position relative to the user's head.

This is not actually used as part of the arm model calculations, and exists for debugging.

ShoulderRotation

Quaternion ShoulderRotation

Represent the shoulder's rotation relative to the user's head.

This is not actually used as part of the arm model calculations, and exists for debugging.

TooltipAlphaValue

override float TooltipAlphaValue

The suggested rendering alpha value of the controller tooltips.

This is to only display the tooltips when the player is looking at the controller, and also to prevent the tooltips from intersecting the player's face.

WristPosition

Vector3 WristPosition

Represent the wrist's position relative to the user's head.

WristRotation

Quaternion WristRotation

Represent the wrist's rotation relative to the user's head.

Protected attributes

DELTA_ALPHA

const float DELTA_ALPHA = 4.0f

Amount of normalized alpha transparency to change per second.

EXTENSION_WEIGHT

const float EXTENSION_WEIGHT = 0.4f

Increases elbow bending as the controller moves up (unitless).

MAX_EXTENSION_ANGLE

const float MAX_EXTENSION_ANGLE = 60.0f

MIN_EXTENSION_ANGLE

const float MIN_EXTENSION_ANGLE = 7.0f

Angle ranges the for arm extension offset to start and end (degrees).

controllerPosition

Vector3 controllerPosition

controllerRotation

Quaternion controllerRotation

elbowPosition

Vector3 elbowPosition

elbowRotation

Quaternion elbowRotation

handedMultiplier

Vector3 handedMultiplier

Multiplier for handedness such that 1 = Right, 0 = Center, -1 = left.

neckPosition

Vector3 neckPosition

preferredAlpha

float preferredAlpha

tooltipAlphaValue

float tooltipAlphaValue

torsoDirection

Vector3 torsoDirection

Forward direction of user's torso.

torsoRotation

Quaternion torsoRotation

Orientation of the user's torso.

wristPosition

Vector3 wristPosition

wristRotation

Quaternion wristRotation

Public static attributes

DEFAULT_ARM_EXTENSION_OFFSET

readonly Vector3 DEFAULT_ARM_EXTENSION_OFFSET = new Vector3(-0.13f, 0.14f, 0.08f)

DEFAULT_CONTROLLER_REST_POSITION

readonly Vector3 DEFAULT_CONTROLLER_REST_POSITION = new Vector3(0.0f, 0.0f, 0.05f)

DEFAULT_ELBOW_REST_POSITION

readonly Vector3 DEFAULT_ELBOW_REST_POSITION = new Vector3(0.195f, -0.5f, 0.005f)

DEFAULT_WRIST_REST_POSITION

readonly Vector3 DEFAULT_WRIST_REST_POSITION = new Vector3(0.0f, 0.0f, 0.25f)

Protected static attributes

NECK_OFFSET

readonly Vector3 NECK_OFFSET = new Vector3(0.0f, 0.075f, 0.08f)

Neck offset used to apply the inverse neck model when locked to the head.

SHOULDER_POSITION

readonly Vector3 SHOULDER_POSITION = new Vector3(0.17f, -0.2f, -0.03f)

Rest position for shoulder joint.

Protected functions

ApplyArmModel

virtual void ApplyArmModel()

ApplyExtensionOffset

virtual void ApplyExtensionOffset(
  float extensionRatio
)

Offset the elbow by the extension offset.

ApplyInverseNeckModel

virtual Vector3 ApplyInverseNeckModel(
  Vector3 headPosition
)

Transform the head position into an approximate neck position.

ApplyRotationToJoints

virtual void ApplyRotationToJoints()

Apply the joint rotations to the positions of the joints to determine the final pose.

CalculateExtensionRatio

virtual float CalculateExtensionRatio(
  float xAngle
)

Calculate the extension ratio based on the angle of the controller along the x axis.

CalculateFinalJointRotations

virtual void CalculateFinalJointRotations(
  Quaternion controllerOrientation,
  Quaternion xyRotation,
  Quaternion lerpRotation
)

Determine the final joint rotations relative to the head.

CalculateLerpRotation

virtual Quaternion CalculateLerpRotation(
  Quaternion xyRotation,
  float extensionRatio
)

Calculate the lerp rotation, which is used to control how much the rotation of the controller impacts each joint.

GetControllerRotation

void GetControllerRotation(
  out Quaternion rotation,
  out Quaternion xyRotation,
  out float xAngle
)

Get the controller's orientation.

OnControllerInputUpdated

virtual void OnControllerInputUpdated()

OnDisable

virtual void OnDisable()

OnEnable

virtual void OnEnable()

SetUntransformedJointPositions

virtual void SetUntransformedJointPositions()

Set the starting positions of the joints before they are transformed by the arm model.

UpdateHandedness

virtual void UpdateHandedness()

UpdateNeckPosition

virtual void UpdateNeckPosition()

UpdateTorsoDirection

virtual void UpdateTorsoDirection(
  bool forceImmediate
)

UpdateTransparency

virtual void UpdateTransparency()

Controls the transparency of the controller to prevent the controller from clipping through the user's head.

Also, controls the transparency of the tooltips so they are only visible when the controller is held up.