Xj3D Particle System Examples

Requesting an input device

#X3D V3.0 utf8

PROFILE Immersive
COMPONENT xj3d_iodevice:2

DEF TG Transform {
  rotation 0 1 0 0.78
  children Shape {
    geometry Box {}
    appearance Appearance {
      material Material {
        diffuseColor 1 0 0
      }
    }
  }
}

DEF PI PositionInterpolator {
  key [ -1 -0.5 0 0.5 1 ]
  keyValue [
     0 0 0
    -1 0 0
    -1 1 0
     0 1 0
     0 0 0
  ]
}

ROUTE PI.value_changed TO TG.translation

DEF GP GamepadSensor { name "Gamepad-0" }

ROUTE GP.leftStickY TO PI.set_fraction

Fetching a generic device handle

#X3D V3.0 utf8

PROFILE Immersive
COMPONENT xj3d_iodevice:2

DEF TG Transform {
  rotation 0 1 0 0.78
  children Shape {
    geometry Box {}
    appearance Appearance {
      material Material {
        diffuseColor 1 0 0
      }
    }
  }
}

DEF PI PositionInterpolator {
  key [ -1 -0.5 0 0.5 1 ]
  keyValue [
     0 0 0
    -1 0 0
    -1 1 0
     0 1 0
     0 0 0
  ]
}

ROUTE PI.value_changed TO TG.translation

DEF DM DeviceManager {}

DEF DEVICE_HANDLER Script {
   inputOnly MFNode newDevice
   initializeOnly SFNode interpolator USE PI
   url ["ecmascript:
       function newDevice(val) {
           for(int i=0; i < val.length; i++) {
               if (val[i].getNodeName().equals('GamepadSensor')) {
                   // Connect the left stick Y to the interps key field
                   Browser.addRoute(val[i], 'leftStickY', interpolator, 'set_fraction');
               } else {
                   // Need to handle generic device
               }
           }
       }
   "]
}

ROUTE DM.newDevice TO DEVICE_HANDLER.newDevice


[ Xj3D Homepage | Xj3D @ Web3d | Screenshots | Dev docs | Dev Releases | Contributors | Getting Started ]
Last updated: $Date: 2004-10-13 19:52:16 $