{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorVRHandPose**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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 [[behavior_actoranimated|ECBehaviorActorAnimated]] for best performance. The bone names can be modified to adjust to rigs using different names.
The default bone names are these:
* Origin set to VR Hand: ''origin''
* Wrist: ''hand''
* Thumb: ''thumb1'', ''thumb2'', ''thumb3''
* Index: ''index1'', ''index2'', ''index3'', ''index4''
* Middle: ''middle1'', ''middle2'', ''middle3'', ''middle4''
* Ring: ''ring1'', ''ring2'', ''ring3'', ''ring4''
* Pinky: ''pinky1'', ''pinky2'', ''pinky3'', ''pinky4''
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.
* Full name: ''vrHandPose.boneOrigin'' or ''vrHandPose({id}).boneOrigin''
* Type: string
* Default Value: ''origin''
* Example (*.deeclass) origin
===== boneWrist =====
Set wrist bone name.
* Full name: ''vrHandPose.boneWrist'' or ''vrHandPose({id}).boneWrist''
* Type: string
* Default Value: ''wrist''
* Example (*.deeclass) wrist
===== boneThumb1 =====
Set thumb bone name (first segment).
* Full name: ''vrHandPose.boneThumb1'' or ''vrHandPose({id}).boneThumb1''
* Type: string
* Default Value: ''thumb1''
* Example (*.deeclass) thumb1
===== boneThumb2 =====
Set thumb bone name (second segment).
* Full name: ''vrHandPose.boneThumb2'' or ''vrHandPose({id}).boneThumb2''
* Type: string
* Default Value: ''thumb2''
* Example (*.deeclass) thumb2
===== boneThumb3 =====
Set thumb bone name (third segment).
* Full name: ''vrHandPose.boneThumb3'' or ''vrHandPose({id}).boneThumb3''
* Type: string
* Default Value: ''thumb3''
* Example (*.deeclass) thumb3
===== boneIndex1 =====
Set index bone name (first segment).
* Full name: ''vrHandPose.boneIndex1'' or ''vrHandPose({id}).boneIndex1''
* Type: string
* Default Value: ''index1''
* Example (*.deeclass) index1
===== boneIndex2 =====
Set index bone name (second segment).
* Full name: ''vrHandPose.boneIndex2'' or ''vrHandPose({id}).boneIndex2''
* Type: string
* Default Value: ''index2''
* Example (*.deeclass) index2
===== boneIndex3 =====
Set index bone name (third segment).
* Full name: ''vrHandPose.boneIndex3'' or ''vrHandPose({id}).boneIndex3''
* Type: string
* Default Value: ''index3''
* Example (*.deeclass) index3
===== boneIndex4 =====
Set index bone name (fourthed segment).
* Full name: ''vrHandPose.boneIndex4'' or ''vrHandPose({id}).boneIndex4''
* Type: string
* Default Value: ''index4''
* Example (*.deeclass) index4
===== boneMiddle1 =====
Set middle bone name (first segment).
* Full name: ''vrHandPose.boneMiddle1'' or ''vrHandPose({id}).boneMiddle1''
* Type: string
* Default Value: ''middle1''
* Example (*.deeclass) middle1
===== boneMiddle2 =====
Set middle bone name (second segment).
* Full name: ''vrHandPose.boneMiddle2'' or ''vrHandPose({id}).boneMiddle2''
* Type: string
* Default Value: ''middle2''
* Example (*.deeclass) middle2
===== boneMiddle3 =====
Set middle bone name (third segment).
* Full name: ''vrHandPose.boneMiddle3'' or ''vrHandPose({id}).boneMiddle3''
* Type: string
* Default Value: ''middle3''
* Example (*.deeclass) middle3
===== boneMiddle4 =====
Set middle bone name (fourthed segment).
* Full name: ''vrHandPose.boneMiddle4'' or ''vrHandPose({id}).boneMiddle4''
* Type: string
* Default Value: ''middle4''
* Example (*.deeclass) middle4
===== boneRing1 =====
Set ring bone name (first segment).
* Full name: ''vrHandPose.boneRing1'' or ''vrHandPose({id}).boneRing1''
* Type: string
* Default Value: ''ring1''
* Example (*.deeclass) ring1
===== boneRing2 =====
Set ring bone name (second segment).
* Full name: ''vrHandPose.boneRing2'' or ''vrHandPose({id}).boneRing2''
* Type: string
* Default Value: ''ring2''
* Example (*.deeclass) ring2
===== boneRing3 =====
Set ring bone name (third segment).
* Full name: ''vrHandPose.boneRing3'' or ''vrHandPose({id}).boneRing3''
* Type: string
* Default Value: ''ring3''
* Example (*.deeclass) ring3
===== boneRing4 =====
Set ring bone name (fourthed segment).
* Full name: ''vrHandPose.boneRing4'' or ''vrHandPose({id}).boneRing4''
* Type: string
* Default Value: ''ring4''
* Example (*.deeclass) ring4
===== bonePinky1 =====
Set pinky bone name (first segment).
* Full name: ''vrHandPose.bonePinky1'' or ''vrHandPose({id}).bonePinky1''
* Type: string
* Default Value: ''pinky1''
* Example (*.deeclass) pinky1
===== bonePinky2 =====
Set pinky bone name (second segment).
* Full name: ''vrHandPose.bonePinky2'' or ''vrHandPose({id}).bonePinky2''
* Type: string
* Default Value: ''pinky2''
* Example (*.deeclass) pinky2
===== bonePinky3 =====
Set pinky bone name (third segment).
* Full name: ''vrHandPose.bonePinky3'' or ''vrHandPose({id}).bonePinky3''
* Type: string
* Default Value: ''pinky3''
* Example (*.deeclass) pinky3
===== bonePinky4 =====
Set pinky bone name (fourthed segment).
* Full name: ''vrHandPose.bonePinky4'' or ''vrHandPose({id}).bonePinky4''
* Type: string
* Default Value: ''pinky4''
* Example (*.deeclass) pinky4
===== fingerTipDistance =====
Set distance between middle finger tip and wrist in fully stretched pose.
* Full name: ''vrHandPose.fingerTipDistance'' or ''vrHandPose({id}).fingerTipDistance''
* Type: float
* Default Value: ''0.165''
* Restriction: At least 0.01
* Example (*.deeclass) 0.165
===== enabled =====
Set enable hand pose.
* Full name: ''vrHandPose.enabled'' or ''vrHandPose({id}).enabled''
* Type: boolean
* Default Value: true
* Example (*.deeclass) false
===== onlyRotation =====
Set apply only rotation instead of position and rotation.
* Full name: ''vrHandPose.onlyRotation'' or ''vrHandPose({id}).onlyRotation''
* Type: boolean
* Default Value: true
* Example (*.deeclass) false
====== Events ======
This behavior has no events.
====== Required Behaviors ======
* [[behavior_vrhand|ECBehaviorVRHand]]
====== Optional Behaviors ======
This behavior does not support optional behaviors.
====== Persistency ======
This behavior does not required element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorVRHandPose.html,ECBehaviorVRHandPose~@#.
Since DragonScript Module Version ''1.7''
====== Use Cases ======
* Animate hand to match VR hand device supporting hand tracking.
====== 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:
right
left
right
0.15
...
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]