# GvrArmModel Class Reference

# 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](https://developers.google.com/vr/reference/unity/class/GvrBaseArmModel), [IGvrControllerInputDeviceReceiver](https://developers.google.com/vr/reference/unity/interface/IGvrControllerInputDeviceReceiver)

| ### Public attributes ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a698240cdb300e2667276eed88438b7bb = DEFAULT_ARM_EXTENSION_OFFSET` | `Vector3` Offset applied to the elbow position as the controller is rotated upwards. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1abe1e36e7c2ca06f92c3c7b0a47459ffd = DEFAULT_CONTROLLER_REST_POSITION` | `Vector3` Position of the controller joint relative to the wrist before the arm model is applied. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a9245253659ecf8b5625a378813e76856 = DEFAULT_ELBOW_BEND_RATIO` | `float` Ratio of the controller's rotation to apply to the rotation of the elbow. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a8ace7d40c203bd1253fc2b2eb0532532 = DEFAULT_ELBOW_REST_POSITION` | `Vector3` Position of the elbow joint relative to the head before the arm model is applied. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a60f5e95b7870c3802eff79b11dbacc94 = 0.0f` | `float` Offset in front of the controller to determine what position to use when determing if the controller should fade. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1ae48c9220378337df61125b149b955a4e = 0.25f` | `float` Controller distance from the front/back of the head after which the controller disappears (meters). |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a8cbc0cbe180348f397fea535a0bfff3f = 0.15f` | `float` Controller distance from the left/right of the head after which the controller disappears (meters). |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1afc49697a8ed60a4bc627dfc0cd91be31 = false` | `bool` If `true`, the root of the pose is locked to the local position of the player's neck. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a0a1c92fc504aff9fa6762203e372cb60 = 80` | `int` The maximum angle in degrees between the controller and head at which to show tooltips. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a5f90bd6da8fe5e76bde58a959918df82 = 0.45f` | `float` Controller distance from face after which the tooltips appear (meters). |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a1611cc188062e76071a70d6cbe3ee914 = DEFAULT_WRIST_REST_POSITION` | `Vector3` Position of the wrist joint relative to the elbow before the arm model is applied. |

| ### Protected attributes ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1aa096d578f031f72cbbf91891d0a12ceb = 4.0f` | `const float` Amount of normalized alpha transparency to change per second. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1acce8a2ce69432fa47eb87f84cfea0da0 = 0.4f` | `const float` Increases elbow bending as the controller moves up (unitless). |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a0dad5a7eccaa99b32df0044798eeb023 = 60.0f` | `const float` Maximum angle in degrees of the controller the for arm extension offset to end. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1abe3f7b67735636dcee869f02ef964ad1 = 7.0f` | `const float` Minimum angle in degrees of the controller the for arm extension offset to start. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a5ecf8eb83a454564f58796ac5ed99702` | `Vector3` The controller position based on this arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a6c3aff04b9bc8c952e3cf3e2203286b7` | `Quaternion` The controller rotation based on this arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1af43d560d20966185a3a087ba850cdd8f` | `Vector3` The elbow position based on this arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1ae6bbefad9b06695ca6fd2c89ed5ee564` | `Quaternion` The elbow rotation based on this arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1af150f969dec31b9aa57d7526e6b9c277` | `Vector3` Multiplier for handedness such that 1 = Right, 0 = Center, -1 = left. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a0d34c60cf40912e70bd5f8b11190247b` | `Vector3` The neck position based on this arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a79679a238d23743a02a6f127c72ab606` | `float` The preferred alpha. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a8437f502dab8c7cdb20c0742474dc853` | `float` The tooltip alpha value. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a1283ba1128fefb21a32585808878715e` | `Vector3` Forward direction of user's torso. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a01baece3af115f3c6323267e42a63317` | `Quaternion` Orientation of the user's torso. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1adb7c3d446cd465fe6c5e165c22c0af5f` | `Vector3` The wrist position based on this arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1aabad1742aafe3a0f195dc1c2638d1c1c` | `Quaternion` The wrist rotation based on this arm model. |

| ### Protected static attributes ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a9d4ccf85277eadba664aadc3ab84ed52 = new Vector3(0.0f, 0.075f, 0.08f)` | `readonly Vector3` Neck offset used to apply the inverse neck model when locked to the head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a553565b20858df31d8abe68428318497 = new Vector3(0.17f, -0.2f, -0.03f)` | `readonly Vector3` Rest position for shoulder joint. |

| ### Properties ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1abdff9d2e76d14b084323b61cc1d7e9e7` | `https://developers.google.com/vr/reference/unity/class/GvrControllerInputDevice#classGvrControllerInputDevice` Gets or sets the controller input device. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a9bd6ef8dc41e1f53e1a3b667bac584a6` | `override Vector3` |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a765e219b64e5a93680105afe23090f4b` | `override Quaternion` |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a80e4793f5a6fa82c6fe90a3b1b7acb98` | `Vector3` Gets the elbow's position relative to the user's head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1af453b9fc2d51307c995ad499b919fbdb` | `Quaternion` Gets the elbow's rotation relative to the user's head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1ad09b0fcab018a2b00fb4d2d2140000c4` | `Vector3` Gets the neck's position relative to the user's head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a2795d5fcdc69f9d4287899feaf6c559e` | `override float` |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a5de149d3e77b0b2c32731d1f5c34f014` | `Vector3` Gets the shoulder's position relative to the user's head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1af1950d310371933879fb9f1a15678172` | `Quaternion` Gets the shoulder's rotation relative to the user's head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a1c716360fda143279d5484a027fc6e80` | `override float` |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a17b7a88404e5c417d6ef8c444d0f7b8f` | `Vector3` Gets the wrist's position relative to the user's head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a05e2c048c3b493f7da4370bf8907d2ca` | `Quaternion` Gets the wrist's rotation relative to the user's head. |

| ### Protected functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1ab30361a1e28d82d25e3148155a9f7aad()` | `virtual void` Applies the arm model parameters to update the orientation and position. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1ac9a0e622265561435f3e09420f2d7ee3(float extensionRatio)` | `virtual void` Offset the elbow by the extension offset. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1aa177d568ac62ab2e70a43fdec159d4be(Vector3 headPosition)` | `virtual Vector3` Transform the head position into an approximate neck position. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a6e014ecb38907319d1cc6337740b1263()` | `virtual void` Apply the joint rotations to the positions of the joints to determine the final pose. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a2109e0cb5699f68bb42570cfb684fb89(float xAngle)` | `virtual float` Calculate the extension ratio based on the angle of the controller along the x axis. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1acb35f6aec59a969f77b413bf383f2572(Quaternion controllerOrientation, Quaternion xyRotation, Quaternion lerpRotation)` | `virtual void` Determine the final joint rotations relative to the head. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a93c8062dffa10e1aba068f0ace3932eb(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. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a08ef986043291981ef591e53800a6d17(out Quaternion rotation, out Quaternion xyRotation, out float xAngle)` | `void` Get the controller's orientation. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a03124ef889c9d2572c95c5e35a41e3bb()` | `virtual void` Set the starting positions of the joints before they are transformed by the arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a982dddc1938010da7b25587450b70c69()` | `virtual void` Updates the arm model handedness. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a2671117b0cdebe807b6d28fd23fe9a53()` | `virtual void` Updates the neck position in the arm model. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a82389e993755f07ad4fe00ee4753f2d4(bool forceImmediate)` | `virtual void` Updates the arm model torso direction. |
| `https://developers.google.com/vr/reference/unity/class/GvrArmModel#classGvrArmModel_1a763f7aa379e0a9ead158f4f27af5d8be()` | `virtual void` Controls the transparency of the controller to prevent the controller from clipping through the user's head. |

## Public attributes

### armExtensionOffset

```c#
Vector3 armExtensionOffset = DEFAULT_ARM_EXTENSION_OFFSET
```
Offset applied to the elbow position as the controller is rotated upwards.

### controllerRestPosition

```c#
Vector3 controllerRestPosition = DEFAULT_CONTROLLER_REST_POSITION
```
Position of the controller joint relative to the wrist before the arm model is applied.

### elbowBendRatio

```c#
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

```c#
Vector3 elbowRestPosition = DEFAULT_ELBOW_REST_POSITION
```
Position of the elbow joint relative to the head before the arm model is applied.

### fadeControllerOffset

```c#
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

```c#
float fadeDistanceFromHeadForward = 0.25f
```
Controller distance from the front/back of the head after which the controller disappears (meters).

### fadeDistanceFromHeadSide

```c#
float fadeDistanceFromHeadSide = 0.15f
```
Controller distance from the left/right of the head after which the controller disappears (meters).

### isLockedToNeck

```c#
bool isLockedToNeck = false
```
If `true`, the root of the pose is locked to the local position of the player's neck.

### tooltipMaxAngleFromCamera

```c#
int tooltipMaxAngleFromCamera = 80
```
The maximum angle in degrees between the controller and head at which to show tooltips.

When the angle 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

```c#
float tooltipMinDistanceFromFace = 0.45f
```
Controller distance from face after which the tooltips appear (meters).

### wristRestPosition

```c#
Vector3 wristRestPosition = DEFAULT_WRIST_REST_POSITION
```
Position of the wrist joint relative to the elbow before the arm model is applied.

## Protected attributes

### DELTA_ALPHA

```c#
const float DELTA_ALPHA = 4.0f
```
Amount of normalized alpha transparency to change per second.

### EXTENSION_WEIGHT

```c#
const float EXTENSION_WEIGHT = 0.4f
```
Increases elbow bending as the controller moves up (unitless).

### MAX_EXTENSION_ANGLE

```c#
const float MAX_EXTENSION_ANGLE = 60.0f
```
Maximum angle in degrees of the controller the for arm extension offset to end.

This is the range of controller X-axis values in which the modeled arm rotates with the controller, outside of which the modeled arm doesn't rotate with the controller, only the controller rotates. Above this value, the wrist is primarily responsible for controller rotation, not the arm.

### MIN_EXTENSION_ANGLE

```c#
const float MIN_EXTENSION_ANGLE = 7.0f
```
Minimum angle in degrees of the controller the for arm extension offset to start.

This is the range of controller X-axis values in which the modeled arm rotates with the controller, outside of which the modeled arm doesn't rotate with the controller, only the controller rotates. Below this value, the wrist is primarily responsible for controller rotation, not the arm.

### controllerPosition

```c#
Vector3 controllerPosition
```
The controller position based on this arm model.

### controllerRotation

```c#
Quaternion controllerRotation
```
The controller rotation based on this arm model.

### elbowPosition

```c#
Vector3 elbowPosition
```
The elbow position based on this arm model.

### elbowRotation

```c#
Quaternion elbowRotation
```
The elbow rotation based on this arm model.

### handedMultiplier

```c#
Vector3 handedMultiplier
```
Multiplier for handedness such that 1 = Right, 0 = Center, -1 = left.

### neckPosition

```c#
Vector3 neckPosition
```
The neck position based on this arm model.

### preferredAlpha

```c#
float preferredAlpha
```
The preferred alpha.

### tooltipAlphaValue

```c#
float tooltipAlphaValue
```
The tooltip alpha value.

### torsoDirection

```c#
Vector3 torsoDirection
```
Forward direction of user's torso.

### torsoRotation

```c#
Quaternion torsoRotation
```
Orientation of the user's torso.

### wristPosition

```c#
Vector3 wristPosition
```
The wrist position based on this arm model.

### wristRotation

```c#
Quaternion wristRotation
```
The wrist rotation based on this arm model.

## Protected static attributes

### NECK_OFFSET

```c#
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

```c#
readonly Vector3 SHOULDER_POSITION = new Vector3(0.17f, -0.2f, -0.03f)
```
Rest position for shoulder joint.

## Properties

### ControllerInputDevice

```c#
GvrControllerInputDevice ControllerInputDevice
```
Gets or sets the controller input device.

The controller input device.

### ControllerPositionFromHead

```c#
override Vector3 ControllerPositionFromHead
```

### ControllerRotationFromHead

```c#
override Quaternion ControllerRotationFromHead
```

### ElbowPosition

```c#
Vector3 ElbowPosition
```
Gets the elbow's position relative to the user's head.

The elbow position.

### ElbowRotation

```c#
Quaternion ElbowRotation
```
Gets the elbow's rotation relative to the user's head.

The elbow rotation.

### NeckPosition

```c#
Vector3 NeckPosition
```
Gets the neck's position relative to the user's head.

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

The neck position.

### PreferredAlpha

```c#
override float PreferredAlpha
```

### ShoulderPosition

```c#
Vector3 ShoulderPosition
```
Gets 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.

The shoulder position.

### ShoulderRotation

```c#
Quaternion ShoulderRotation
```
Gets 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.

The shoulder rotation.

### TooltipAlphaValue

```c#
override float TooltipAlphaValue
```

### WristPosition

```c#
Vector3 WristPosition
```
Gets the wrist's position relative to the user's head.

The wrist position.

### WristRotation

```c#
Quaternion WristRotation
```
Gets the wrist's rotation relative to the user's head.

The wrist rotation.

## Protected functions

### ApplyArmModel

```c#
virtual void ApplyArmModel()
```
Applies the arm model parameters to update the orientation and position.

### ApplyExtensionOffset

```c#
virtual void ApplyExtensionOffset(
  float extensionRatio
)
```
Offset the elbow by the extension offset.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `extensionRatio` | The extension ratio of the elbow to apply. | |

### ApplyInverseNeckModel

```c#
virtual Vector3 ApplyInverseNeckModel(
  Vector3 headPosition
)
```
Transform the head position into an approximate neck position.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `headPosition` | Head position. | |
| **Returns** | The inverse neck model. |

### ApplyRotationToJoints

```c#
virtual void ApplyRotationToJoints()
```
Apply the joint rotations to the positions of the joints to determine the final pose.

### CalculateExtensionRatio

```c#
virtual float CalculateExtensionRatio(
  float xAngle
)
```
Calculate the extension ratio based on the angle of the controller along the x axis.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `xAngle` | The X angle of the controller along the x axis. | |
| **Returns** | The extension ratio of the elbow. |

### CalculateFinalJointRotations

```c#
virtual void CalculateFinalJointRotations(
  Quaternion controllerOrientation,
  Quaternion xyRotation,
  Quaternion lerpRotation
)
```
Determine the final joint rotations relative to the head.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `controllerOrientation` | Controller orientation. | | `xyRotation` | The xy rotation of the controller. | | `lerpRotation` | Lerp rotation. | |

### CalculateLerpRotation

```c#
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.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `xyRotation` | The xy rotation of the controller. | | `extensionRatio` | The extension ratio of the elbow. | |
| **Returns** | The lerp rotation. |

### GetControllerRotation

```c#
void GetControllerRotation(
  out Quaternion rotation,
  out Quaternion xyRotation,
  out float xAngle
)
```
Get the controller's orientation.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `rotation` | The output rotation which will be written to. | | `xyRotation` | The output xy-only rotation. | | `xAngle` | The output angle from the X axis. | |

### SetUntransformedJointPositions

```c#
virtual void SetUntransformedJointPositions()
```
Set the starting positions of the joints before they are transformed by the arm model.

### UpdateHandedness

```c#
virtual void UpdateHandedness()
```
Updates the arm model handedness.

### UpdateNeckPosition

```c#
virtual void UpdateNeckPosition()
```
Updates the neck position in the arm model.

### UpdateTorsoDirection

```c#
virtual void UpdateTorsoDirection(
  bool forceImmediate
)
```
Updates the arm model torso direction.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `forceImmediate` | If `true`, uses the gaze direction, otherwise uses slerp to update the direction smoothly. | |

### UpdateTransparency

```c#
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.