[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
EAI callback
Help!
I have a PROTOTYPE called lamp. It has three rotation points:
The LampShade
The FirstArm
The SecondArm
Anytime these rotation points change, I want to inform my
applet.
The Problem:
I am not informed of all three events. It will only informs
me of one of the three. Usually, the first part of the lamp
I rotate will be the event sent. The other events are ignored.
Attached is a short WORKING example of the problem.
Any help would greatly be appreciated.
Chris Gokey
**************************** TEST.WRL **************************
#VRML V2.0 utf8
PROTO Lamp [
exposedField SFRotation rotation1 1.0 0.0 0.0 -0.7
exposedField SFRotation rotation2 1.0 0.0 0.0 1.9
exposedField SFRotation rotation3 1.0 0.0 0.0 -1.25
] {
Group {
children [
# Lamp
DEF MoveLamp PlaneSensor { },
DEF Lamp Transform {
children [
# Lamp base
Shape {
appearance DEF White Appearance {
material Material { }
}
geometry Cylinder {
radius 0.1
height 0.01
}
},
# Base - First arm joint
Group {
children [
DEF MoveFirstArm SphereSensor {
offset 1.0 0.0 0.0 -0.7
},
DEF FirstArm Transform {
translation 0.0 0.15 0.0
rotation IS rotation1
center 0.0 -0.15 0.0
children [
# Lower arm
DEF LampArm Shape {
appearance USE White
geometry Cylinder {
radius 0.01
height 0.3
}
},
# First arm - second arm joint
Group {
children [
DEF MoveSecondArm SphereSensor {
offset 1.0 0.0 0.0 1.9
},
DEF SecondArm Transform {
translation 0.0 0.3 0.0
rotation IS rotation2
center 0.0 -0.15 0.0
children [
# Second arm
USE LampArm,
# Second arm - shade joint
Group {
children [
DEF MoveLampShade SphereSensor {
offset 1.0 0.0 0.0 -1.25
},
DEF LampShade Transform {
translation 0.0 0.075 0.0
rotation IS rotation3
center 0.0 0.075 0.0
children [
# Shade
Shape {
appearance USE White
geometry Cone {
height 0.15
bottomRadius 0.12
bottom FALSE
}
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
ROUTE MoveFirstArm.rotation_changed TO FirstArm.set_rotation
ROUTE MoveSecondArm.rotation_changed TO SecondArm.set_rotation
ROUTE MoveLampShade.rotation_changed TO LampShade.set_rotation
}
Transform {
children DEF LampA Lamp {}
}
*************************** test.java ***************************
import netscape.javascript.JSObject;
public class test extends java.applet.Applet implements
EventOutObserver{
Browser browser;
Node root;
public void init() {
// get the browser
JSObject win = JSObject.getWindow(this);
JSObject doc = (JSObject)win.getMember("document");
JSObject embeds = (JSObject)doc.getMember("embeds");
browser=(Browser)embeds.getSlot(0);
}
public void start() {
// Setup Callback Routines for Lamp Events
Node x=browser.getNode("LampA");
x.getEventOut("rotation1_changed").advise(this,x);
x.getEventOut("rotation2_changed").advise(this,x);
x.getEventOut("rotation3_changed").advise(this,x);
}
public void callback(EventOut value, double timestamp, Object data) {
EventOutSFRotation x = (EventOutSFRotation)value;
float[] y = x.getValue();
System.out.println("\nRotation Changed");
for (int i=0; i<4; i++)
System.out.println(y[i]);
}
}
******************************** TEST.HTML *************************
<HTML>
<BODY>
<EMBED SRC="test.wrl" WIDTH="750" HEIGHT="750">
<APPLET CODE="test.class" MAYSCRIPT>
</APPLET>
</BODY>
</HTML>
-------------------------------------------------------------------
*** Please send administrative requests to <majordomo@sdsc.edu> ***
-------------------------------------------------------------------

