en fr

Calerga VR Sysquake Extensions

In Calerga VR, Sysquake extensions add the following features.

Nodes

SysquakeFigure

[in,out] SFString code  
[] SFBool enabled  
[in,out] SFNode metadata  
[] SFVec2f size  

Node SysquakeFigure is a geometry whose shape is a rectangle in plane z=0 with a size specified by field size (default: 2 2). It contains an SQ file instance (a Sysquake program with interactive graphics) which is displayed in the rectangular shape, on both sides, inverted on the back. User interactions (mouse clicks and drags in the figures) are intepreted by Sysquake. The code of the SQ file is provided in SFString field code (default: "").

Sysquake code in Script nodes

Inline Sysquake code (LME) is supported, with url starting with sysquake:.

In Script nodes, fields are declared the same way as in JavaScript Script nodes. In the script itself, fields are accessed with the following functions:

val = x3dGetField(name)
Get the value of a field (access initializeOnly or inputOutput).
x3dSetField(name, val)
Set the value of a field (access initializeOnly or inputOutput). For fields with access inputOutput, an event whose name is suffixed with _changed is sent.
x3dSendEvent(name, val)
Send an outputOnly event.

The script should implement all inputOnly events as functions, and optionnally initialize(), eventsProcessed(), prepareEvents(timestamp) and shutdown().

Example: oscillating cube

#X3D V3.3 utf8

PROFILE com/calerga/sysquake

DEF t Transform {
  children [
    Shape {
      geometry Box {}
    }
  ]
}

DEF clock TimeSensor {
  loop TRUE
  cycleInterval 1
}

DEF rotationOscillator Script {
  initializeOnly SFFloat amplitude 0.3
  inputOnly SFFloat set_fraction
  outputOnly SFRotation rotation_changed
  url [
    "sysquake:
      function set_fraction(f)
        theta = x3dGetField('amplitude') * sin(2 * pi * f);
        x3dSendEvent('rotation_changed', [1, 0, 0, theta]);
    "
  ]
}

ROUTE clock.fraction_changed TO rotationOscillator.set_fraction
ROUTE rotationOscillator.rotation_changed TO t.set_rotation