[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [x3d-public] Dynamically create TouchSensor



Right, thanx... I was missing that as I was searching the bugzilla with "sensor"...
 
George
 
----- Original Message -----
Sent: Monday, March 27, 2006 3:35 PM
Subject: AW: [x3d-public] Dynamically create TouchSensor

i posted this problem a few weeks ago. this is a bug, see:

http://bugzilla.xj3d.org/show_bug.cgi?id=161 

http://bugzilla.xj3d.org/show_bug.cgi?id=200

mirko


Von: owner-x3d-public@web3d.org [mailto:owner-x3d-public@web3d.org] Im Auftrag von George Anastassakis
Gesendet: Montag, 27. März 2006 14:10
An: x3d-public@web3d.org
Betreff: [x3d-public] Dynamically create TouchSensor

With Xj3D M10, is it possible to dynamically create a TouchSensor node with a createNode call? The code I wrote to try that does not work:
 
- the TouchSensor does not generate any events, i.e. the readableFieldChanged method is never called...
- the cursor does not change to a hand when over the Sphere...
 
However the message "Warning: does not update released mouse correctly for TouchSensors. Must fix" does appear on System.out when the sphere is clicked, so I guess the TouchSensor node is getting mouse input. The code follows (suppose an X3DComponent has been created and the browser added to some frame):
 
X3DScene scene = x3dComponent.getBrowser().createScene(
    x3dComponent.getBrowser().getProfile("Interactive"),
    null
);
x3dComponent.getBrowser().replaceWorld(scene);
X3DNode transform = scene.createNode("Transform");
X3DNode shape = scene.createNode("Shape");
X3DNode sphere = scene.createNode("Sphere");
X3DNode touchSensor = scene.createNode("TouchSensor");
 
SFNode geometry = (SFNode) shape.getField("geometry");
geometry.setValue(sphere);
 
MFNode children = (MFNode) transform.getField("children");
children.setValue(2, new X3DNode[] {shape, touchSensor});
 
SFTime touchTime = (SFTime) touchSensor.getField("touchTime");
touchTime.addX3DEventListener(new X3DFieldEventListener() {
    public void readableFieldChanged(X3DFieldEvent e) {
        System.out.println("TouchSensor touchTime changed");
    }
});
 
scene.addRootNode(transform);
George