This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_controldesktop [2021/11/05 00:11] – created dragonlord | dragengine:modules:dragonscript:behavior_controldesktop [2025/03/13 17:13] (current) – dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
{{tag> | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
- | [[: | + | [[: |
</ | </ | ||
Line 13: | Line 13: | ||
The behavior allows player (or other actors) to move the mouse pointer on a [[behavior_renderabledesktop|ECBehaviorRenderableDesktop]] by looking or pointing at the desired position. Also the player can simulate a left or right mouse click by using an input binding defined by the actor himself. This kind of input is typically used for VR games but can be also used for non VR games like first person shooters. | The behavior allows player (or other actors) to move the mouse pointer on a [[behavior_renderabledesktop|ECBehaviorRenderableDesktop]] by looking or pointing at the desired position. Also the player can simulate a left or right mouse click by using an input binding defined by the actor himself. This kind of input is typically used for VR games but can be also used for non VR games like first person shooters. | ||
- | The behavior defines three corner points of a virtual rectangular plane. The player looking or pointing direction is intersected with this virtual plane. The relative position of this hit point is mapped to the [[https:// | + | The behavior defines three corner points of a virtual rectangular plane. The player looking or pointing direction is intersected with this virtual plane. The relative position of this hit point is mapped to the # |
Optionally a bone name can be specified. If the bone name is not empty the virtual plane corners are relative to the bone. This allows to create desktop input zones which can be displaced. | Optionally a bone name can be specified. If the bone name is not empty the virtual plane corners are relative to the bone. This allows to create desktop input zones which can be displaced. | ||
Line 27: | Line 27: | ||
====== Element Class Properties ====== | ====== Element Class Properties ====== | ||
- | Element class properties have the prefix | + | Element class properties have the prefix |
===== lowerLeft ===== | ===== lowerLeft ===== | ||
Virtual plane lower left position in component space. | Virtual plane lower left position in component space. | ||
- | * Full name: "controlDesktop.lowerLeft" | + | * Full name: '' |
- | * Type: vector | + | * Type: 3-point float vector |
- | * Default value: | + | * Default value: |
* Example (*.deeclass): | * Example (*.deeclass): | ||
===== lowerRight ===== | ===== lowerRight ===== | ||
Virtual plane lower right position. | Virtual plane lower right position. | ||
- | * Full name: "controlDesktop.lowerRight" | + | * Full name: '' |
- | * Type: vector | + | * Type: 3-point float vector |
- | * Default value: | + | * Default value: |
* Example (*.deeclass): | * Example (*.deeclass): | ||
===== upperLeft ===== | ===== upperLeft ===== | ||
Virtual plane upper left position. | Virtual plane upper left position. | ||
- | * Full name: "controlDesktop.upperLeft" | + | * Full name: '' |
- | * Type: vector | + | * Type: 3-point float vector |
- | * Default value: | + | * Default value: |
* Example (*.deeclass): | * Example (*.deeclass): | ||
===== bone ===== | ===== bone ===== | ||
Name of bone to use as coordinate system for the virtual plane or empty string to use the component coordinate system. | Name of bone to use as coordinate system for the virtual plane or empty string to use the component coordinate system. | ||
- | * Full name: "controlDesktop.bone" | + | * Full name: '' |
* Type: string | * Type: string | ||
- | * Default Value: | + | * Default Value: |
* Example (*.deeclass): | * Example (*.deeclass): | ||
Line 67: | Line 67: | ||
====== Persistency ====== | ====== Persistency ====== | ||
- | This behavior does not use persistency. | + | This behavior does not required element class to be persistable (setPersistable). |
====== API Documentation ====== | ====== API Documentation ====== | ||
- | [[https:// | + | # |
- | Since DragonScript Module Version | + | Since DragonScript Module Version |
====== Use Cases ====== | ====== Use Cases ====== | ||
Line 92: | Line 92: | ||
| | ||
- | | + | |
component = ECBehaviorComponent.new(this, | component = ECBehaviorComponent.new(this, | ||
| | ||
- | | + | |
- | | + | |
dynamicSkin = ECBehaviorDynamicSkin.new(this, | dynamicSkin = ECBehaviorDynamicSkin.new(this, | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
renderableDesktop = ECBehaviorRenderableDesktop.new(this, | renderableDesktop = ECBehaviorRenderableDesktop.new(this, | ||
renderableDesktop.getRenderable().setValue(" | renderableDesktop.getRenderable().setValue(" | ||
renderableDesktop.getSize().setPoint(Point.new(1024, | renderableDesktop.getSize().setPoint(Point.new(1024, | ||
| | ||
- | | + | |
- | | + | |
- | | + | |
controlDesktop = ECBehaviorControlDesktop.new(this, | controlDesktop = ECBehaviorControlDesktop.new(this, | ||
end | end | ||
Line 129: | Line 129: | ||
super.think(elapsed) | super.think(elapsed) | ||
| | ||
- | | + | |
if vrRightHandPointAt.hasVRHandPointAtElement() | if vrRightHandPointAt.hasVRHandPointAtElement() | ||
- | // Store the hit element and hit point in world space. Typically you want | + | '' |
- | // to test them against mulitple supported interactions. | + | '' |
var BehaviorElement element = vrRightHandPointAt.getPointAtBehaviorElement() | var BehaviorElement element = vrRightHandPointAt.getPointAtBehaviorElement() | ||
var DVector hitPoint = vrRightHandPointAt.getPointAtHitPoint() | var DVector hitPoint = vrRightHandPointAt.getPointAtHitPoint() | ||
- | // Move mouse on the desktop controller if present in the pointed at element | + | '' |
var ECBehaviorControlDesktop.Instance controlDesktop = ECBehaviorControlDesktop.getInstanceIn(element) | var ECBehaviorControlDesktop.Instance controlDesktop = ECBehaviorControlDesktop.getInstanceIn(element) | ||
if controlDesktop != null | if controlDesktop != null | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
if controlDesktop.moveMouse(hitPoint) | if controlDesktop.moveMouse(hitPoint) | ||
| | ||
Line 150: | Line 150: | ||
end | end | ||
- | // Here you could check for other supported interactions | + | '' |
end | end | ||
| | ||
- | | + | |
end | end | ||
end | end | ||
Line 160: | Line 160: | ||
The same example can be done using [[behavior_lookat|ECBehaviorLookAt]] instead of [[behavior_vrhandpointat|ECBehaviorVRHandPointAt]]. | The same example can be done using [[behavior_lookat|ECBehaviorLookAt]] instead of [[behavior_vrhandpointat|ECBehaviorVRHandPointAt]]. | ||
+ | |||
+ | ====== Behavior Factory ====== | ||
+ | |||
+ | Using element class supporting adding behaviors the behavior can be added like this: | ||
+ | <code xml> | ||
+ | <?xml version=' | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | | ||
+ | < | ||
+ | <!-- set element properties. omit property prefix if used inside behavior tag --> | ||
+ | <string name=' | ||
+ | </ | ||
+ | | ||
+ | <!-- for adding multiple behaviors use unique identifiers --> | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
====== Live Examples ====== | ====== Live Examples ====== | ||
* [[https:// | * [[https:// | ||
+ |