User Tools

Site Tools


dragengine:modules:dragonscript:behavior_controldesktop

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragengine:modules:dragonscript:behavior_controldesktop [2024/03/14 16:50] dragonlorddragengine:modules:dragonscript:behavior_controldesktop [2025/03/13 17:13] (current) dragonlord
Line 1: Line 1:
 {{tag>dragonscript behavior}} {{tag>dragonscript behavior}}
 <WRAP youarehere> <WRAP youarehere>
-[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorControlDesktop**+[[: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]] >> **ECBehaviorControlDesktop**
 </WRAP> </WRAP>
  
Line 27: Line 27:
 ====== Element Class Properties ====== ====== Element Class Properties ======
  
-Element class properties have the prefix **controlDesktop.** or **controlDesktop(id).** if id is not empty.+Element class properties have the prefix ''controlDesktop.'' or ''controlDesktop(id).'' if id is not empty.
  
 ===== lowerLeft ===== ===== lowerLeft =====
 Virtual plane lower left position in component space. Virtual plane lower left position in component space.
-  * Full name: "controlDesktop.lowerLeftor "controlDesktop(id).lowerLeft" +  * Full name: ''controlDesktop.lowerLeft'' or ''controlDesktop(id).lowerLeft'' 
-  * Type: vector +  * Type: 3-point float vector 
-  * Default value: //(-0.5, -0.5, 0)//+  * Default value: ''(-0.5, -0.5, 0)''
   * Example (*.deeclass): <code xml><vector name='controlDesktop.lowerLeft' x='-0.2' y='-0.3' z='0'/></code>   * Example (*.deeclass): <code xml><vector name='controlDesktop.lowerLeft' x='-0.2' y='-0.3' z='0'/></code>
  
 ===== lowerRight ===== ===== lowerRight =====
 Virtual plane lower right position. Virtual plane lower right position.
-  * Full name: "controlDesktop.lowerRightor "controlDesktop(id).lowerRight" +  * Full name: ''controlDesktop.lowerRight'' or ''controlDesktop(id).lowerRight'' 
-  * Type: vector +  * Type: 3-point float vector 
-  * Default value: //(0.5, -0.5, 0)//+  * Default value: ''(0.5, -0.5, 0)''
   * Example (*.deeclass): <code xml><vector name='controlDesktop.lowerRight' x='0.2' y='-0.3' z='0'/></code>   * Example (*.deeclass): <code xml><vector name='controlDesktop.lowerRight' x='0.2' y='-0.3' z='0'/></code>
  
 ===== upperLeft ===== ===== upperLeft =====
 Virtual plane upper left position. Virtual plane upper left position.
-  * Full name: "controlDesktop.upperLeftor "controlDesktop(id).upperLeft" +  * Full name: ''controlDesktop.upperLeft'' or ''controlDesktop(id).upperLeft'' 
-  * Type: vector +  * Type: 3-point float vector 
-  * Default value: //(-0.5, 0.5, 0)//+  * Default value: ''(-0.5, 0.5, 0)''
   * Example (*.deeclass): <code xml><vector name='controlDesktop.upperLeft' x='-0.2' y='0.3' z='0'/></code>   * Example (*.deeclass): <code xml><vector name='controlDesktop.upperLeft' x='-0.2' y='0.3' z='0'/></code>
  
 ===== 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.boneor "controlDesktop(id).bone"+  * Full name: ''controlDesktop.bone'' or ''controlDesktop(id).bone''
   * Type: string   * Type: string
-  * Default Value: //""//+  * Default Value: empty string
   * Example (*.deeclass): <code xml><string name='controlDesktop(right).bone'>display</string></code>   * Example (*.deeclass): <code xml><string name='controlDesktop(right).bone'>display</string></code>
  
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 ======
Line 73: Line 73:
 #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorControlDesktop.html,ECBehaviorControlDesktop~@#. #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorControlDesktop.html,ECBehaviorControlDesktop~@#.
  
-Since DragonScript Module Version **1.7**+Since DragonScript Module Version ''1.7''
  
 ====== Use Cases ====== ====== Use Cases ======
Line 92: Line 92:
        
    public func new()    public func new()
-      // Create component+      '' Create component
       component = ECBehaviorComponent.new(this, null)       component = ECBehaviorComponent.new(this, null)
              
-      // Create dynamic skin. This allows individual component textures +      '' Create dynamic skin. This allows individual component textures 
-      // to be dynamically defined at runtime.+      '' to be dynamically defined at runtime.
       dynamicSkin = ECBehaviorDynamicSkin.new(this, component)       dynamicSkin = ECBehaviorDynamicSkin.new(this, component)
              
-      // Create renderable desktop. This creates a Desktop widget which +      '' Create renderable desktop. This creates a Desktop widget which 
-      // is used as content for the component texture named "screen"+      '' is used as content for the component texture named "screen"
-      // The desktop widget has a size of 1024x868 pixels. +      '' The desktop widget has a size of 1024x868 pixels. 
-      // +      '' 
-      // By default the desktop is empty. You have to add windows to +      '' By default the desktop is empty. You have to add windows to 
-      // the desktop after the element has been created. A typical +      '' the desktop after the element has been created. A typical 
-      // solution is to create individual behaviors for all windows +      '' solution is to create individual behaviors for all windows 
-      // added to the desktop.+      '' added to the desktop.
       renderableDesktop = ECBehaviorRenderableDesktop.new(this, dynamicSkin)       renderableDesktop = ECBehaviorRenderableDesktop.new(this, dynamicSkin)
       renderableDesktop.getRenderable().setValue("screen")       renderableDesktop.getRenderable().setValue("screen")
       renderableDesktop.getSize().setPoint(Point.new(1024, 768))       renderableDesktop.getSize().setPoint(Point.new(1024, 768))
              
-      // Add support to control the desktop. Multiple desktops can be +      '' Add support to control the desktop. Multiple desktops can be 
-      // controlled individually by adding multiple behaviors with +      '' controlled individually by adding multiple behaviors with 
-      // unique identifiers each controlling one single renderable desktop.+      '' unique identifiers each controlling one single renderable desktop.
       controlDesktop = ECBehaviorControlDesktop.new(this, renderableDesktop)       controlDesktop = ECBehaviorControlDesktop.new(this, renderableDesktop)
   end   end
Line 129: Line 129:
       super.think(elapsed)       super.think(elapsed)
              
-      // Check if right hand controller is pointing at an element+      '' Check if right hand controller is pointing at an element
       if vrRightHandPointAt.hasVRHandPointAtElement()       if vrRightHandPointAt.hasVRHandPointAtElement()
                    
-         // Store the hit element and hit point in world space. Typically you want +         '' Store the hit element and hit point in world space. Typically you want 
-         // to test them against mulitple supported interactions.+         '' 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+         '' 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
-            // The call moveMouse() converts the hit point in world space to desktop +            '' The call moveMouse() converts the hit point in world space to desktop 
-            // coordinates. If the world position is outside the desktop area nothing +            '' coordinates. If the world position is outside the desktop area nothing 
-            // is done and false is returned. Otherwise the mouse position is updated +            '' is done and false is returned. Otherwise the mouse position is updated 
-            // and true is returned. In this example we stop here if we updated the +            '' and true is returned. In this example we stop here if we updated the 
-            // desktop mouse position in case more interactions are check below+            '' desktop mouse position in case more interactions are check below
             if controlDesktop.moveMouse(hitPoint)             if controlDesktop.moveMouse(hitPoint)
                return                return
Line 150: Line 150:
          end          end
                    
-         // Here you could check for other supported interactions+         '' Here you could check for other supported interactions
                    
       end       end
              
-      // The same could be done for vrLeftHandPointAt too+      '' The same could be done for vrLeftHandPointAt too
    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='1.0' encoding='UTF-8'?>
 +<elementClass name='MyClass' class='GenericBehaviorElement'>
 +  <behavior type='ECBehaviorComponent'/>
 +  <behavior type='ECBehaviorDynamicSkin'/>
 +  <behavior type='ECBehaviorRenderableDesktop'/>
 +  
 +  <behavior type='ECBehaviorControlDesktop'>
 +    <!-- set element properties. omit property prefix if used inside behavior tag -->
 +    <string name='.bone'>display</string>
 +  </behavior>
 +  
 +  <!-- for adding multiple behaviors use unique identifiers -->
 +  <behavior type='ECBehaviorControlDesktop' id='second'/>
 +</elementClass>
 +</code>
  
 ====== Live Examples ====== ====== Live Examples ======
  
   * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project.   * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]: ExampleVR project.
 +
dragengine/modules/dragonscript/behavior_controldesktop.1710435051.txt.gz · Last modified: 2024/03/14 16:50 by dragonlord