home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-20 | 972 b | 37 lines |
- //
- // a car running on the street.
- // you get on/off the car by clicking it.
- //
-
- import vrml.*;
- import vrml.node.*;
- import vrml.field.*;
-
- public class Car extends Script{
- SFBool bindCarViewpoint;
- SFBool bindDefaultViewpoint;
- boolean onCar = false;
-
- public void initialize(){
- // get the reference of the event out 'bindCarViewpoint'.
- bindCarViewpoint = (SFBool)getEventOut("bindCarViewpoint");
- // get the reference of the event out 'bindDefaultViewpoint'.
- bindDefaultViewpoint = (SFBool)getEventOut("bindDefaultViewpoint")
- ;
- }
-
- public void processEvent(Event e){
- if(e.getName().equals("touched") == true){
-
- // toggle the state.
- onCar = !onCar;
-
- if(true == onCar){
- bindCarViewpoint.setValue(true);
- }else{
- bindDefaultViewpoint.setValue(true);
- }
- }
- }
- }
-