Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorVRHandPose

ECBehaviorVRHandPose

Behavior adding support to apply hand pose to VR Hand.

Behavior queries VR hand device for bone poses and applies them to the VR hand component.

Creates an animator to apply the states. This allows to chain other animators like ECBehaviorActorAnimated for best performance. The bone names can be modified to adjust to rigs using different names.

The default bone names are these:

Models of varying size can be used.

By default only rotation of bones are used. If you want to use also positions you have first to set onlyRotation element class property to false. Using models with position transfer requires some additional care to work properly. In particular the model rig has to match as closely as possible the rig used by the VR runtime except for scaling. The behavior scales the input data to fit the model size. For this process to wor you have to measure the distance from the middle finger tip bone to the wrist bone. Use the base of these bones not their tails (in Blender3D). Set this values as the fingerTipDistance element class property:

getFingerTipDistance().setValue(0.165)

The default distance is 0.165 which is a measuring of a typical VR hand model.

Instance Counts

This behavior can be added twice to an element to add support for left and right hand controller. Use the behavior identifier to tell them apart.

Element Class Properties

Element class properties have the prefix vrHandPose. or vrHandPose({id}). if id is not empty.

boneOrigin

Set origin bone name.

boneWrist

Set wrist bone name.

boneThumb1

Set thumb bone name (first segment).

boneThumb2

Set thumb bone name (second segment).

boneThumb3

Set thumb bone name (third segment).

boneIndex1

Set index bone name (first segment).

boneIndex2

Set index bone name (second segment).

boneIndex3

Set index bone name (third segment).

boneIndex4

Set index bone name (fourthed segment).

boneMiddle1

Set middle bone name (first segment).

boneMiddle2

Set middle bone name (second segment).

boneMiddle3

Set middle bone name (third segment).

boneMiddle4

Set middle bone name (fourthed segment).

boneRing1

Set ring bone name (first segment).

boneRing2

Set ring bone name (second segment).

boneRing3

Set ring bone name (third segment).

boneRing4

Set ring bone name (fourthed segment).

bonePinky1

Set pinky bone name (first segment).

bonePinky2

Set pinky bone name (second segment).

bonePinky3

Set pinky bone name (third segment).

bonePinky4

Set pinky bone name (fourthed segment).

fingerTipDistance

Set distance between middle finger tip and wrist in fully stretched pose.

enabled

Set enable hand pose.

onlyRotation

Set apply only rotation instead of position and rotation.

Events

This behavior has no events.

Required Behaviors

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

This behavior does not required element class to be persistable (setPersistable).

API Documentation

ECBehaviorVRHandPose.

Since DragonScript Module Version 1.7

Use Cases

Element Class Example

This example defines an element which supports hand tracking.

class MyElement extends BehaviorElementClass
  public var ECBehaviorVRPlayspace vrPlayspace
  public var ECBehaviorVRHand vrHandRight
  public var ECBehaviorVRHand vrHandLeft
  public var ECBehaviorVRHandPointAt vrRightHandPointAt
  public var ECBehaviorVRHandPointAt vrLeftHandPointAt
  public var ECBehaviorVRHandPose vrHandPoseRight
  public var ECBehaviorVRHandPose vrHandPoseLeft
  func new()
    vrPlayspace = ECBehaviorVRPlayspace.new(this)
    vrHandRight = ECBehaviorVRHand.new(this, vrPlayspace, InputDeviceType.vrRightHand, BaseVRActorClass.idVRRightHand)
    vrHandLeft = ECBehaviorVRHand.new(this, vrPlayspace, InputDeviceType.vrLeftHand, BaseVRActorClass.idVRLeftHand)
    vrRightHandPointAt = ECBehaviorVRHandPointAt.new(this, vrRightHand, BaseVRActorClass.idVRRightHand)
    vrLeftHandPointAt = ECBehaviorVRHandPointAt.new(this, vrLeftHand, BaseVRActorClass.idVRLeftHand)
    vrHandPoseRight = ECBehaviorVRHandPose.new(this, vrHandRight)
    vrHandPoseLeft = ECBehaviorVRHandPose.new(this, vrHandLeft)
  end
end

Behavior Factory

Using element class supporting adding behaviors the behavior can be added like this:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorVRPlayspace'/>
  <behavior type='ECBehaviorVRHand' id='right'/>
  <behavior type='ECBehaviorVRHand' id='left'/>
  <behavior type='ECBehaviorVRHandPointAt' id='right'>
    <string name='vrHand'>right</string>
  </behavior>
  <behavior type='ECBehaviorVRHandPointAt' id='left'>
    <string name='vrHand'>left</string>
  </behavior>
 
  <behavior type='ECBehaviorVRHandPose' id='right'>
    <!-- required: use vr hand with id. -->
    <string name='vrHand'>right</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <float name='.fingerTipDistance'>0.15</float>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorVRHandPose' id='left'>
    ...
  </behavior>
</elementClass>

Live Examples