home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-06 | 773 b | 31 lines |
- import vrml.*;
- import vrml.field.*;
- import vrml.node.*;
-
- public class ChangeColor extends Script {
-
- private SFBool on; // status of on-off
- float red[] = { 1, 0, 0 }; // RGB(Red)
- float blue[] = { 0, 0, 1 }; // RGB(Blue)
- private SFColor newColor ;
-
- public void initialize() {
-
- newColor = (SFColor) getEventOut("newColor");
- on = (SFBool) getField("on");
- }
-
- public void processEvent(Event e) {
- ConstSFBool v = (ConstSFBool)e.getValue();
-
- if(v.getValue()){
- if (on.getValue()) {
- newColor.setValue(red); // set red to 'newColor'
- } else {
- newColor.setValue(blue); // set blue to 'newColor'
- }
- on.setValue(!on.getValue()); // = !on.getValue();
- }
- }
- }
-