| nunomartins01 2005-07-03, 7:38 pm |
| Hello!
I'm triyng to diferenciate which object I have selecter in a x3d scene,
but not using buttons, simply click in the object.
I'm using 2 objects and 2 touch sensors.
I have a variable (sensor) thar I'm triyng to modify to identify if it
is selected
the object 1 (sensor=1), or the object 2 (sensor=2).
This is the problem, I don't know how to atribute the values to this
variable...
I have the code below...
Can anyone help me, this or other way ?
Thanks
Nuno
//-------------- TOUCH SENSOR 1 ---------------------
// Find the TouchSensor named TOUCH_SENSOR
X3DNode touch = mainScene.getNamedNode("TS");
if (touch == null) {
System.out.println("Couldn't find TouchSensor named: TS");
return;
}
SFTime ttime = (SFTime) touch.getField("touchTime");
// Listen for changes on the touchTime field
ttime.addX3DEventListener(this);
//-------------- TOUCH SENSOR 2 ---------------------
// Find the TouchSensor named TOUCH_SENSOR
X3DNode touch2 = mainScene.getNamedNode("TS2");
if (touch2 == null) {
System.out.println("Couldn't find TouchSensor named: TS2");
return;
}
SFTime ttime2 = (SFTime) touch2.getField("touchTime");
// Listen for changes on the touchTime field
ttime2.addX3DEventListener(this);
}
// -------------------------------------------------------
public void readableFieldChanged(X3DFieldEvent evt) {
if (sensor==1){
System.out.println("object 1 clicked");
}
else if (sensor==2){
System.out.println("Object 2 clicked");
}
}
|