home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-24 | 1.0 KB | 38 lines |
- //
- // Walking man in prototype.
- //
-
- import java.util.*;
- import vrml.*;
- import vrml.node.*;
- import vrml.field.*;
-
- public class ProtoMan extends Script{
- MFVec3f setPath;
- float path[] = new float[3 * 2];
- Random randomNumGenerator = new Random();
-
- public void initialize(){
- // get the reference of the event out 'setPath'.
- setPath = (MFVec3f)getEventOut("setPath");
- // initialize the path.
- path[0] = 0.0f; // start position
- path[1] = 0.0f;
- path[2] = 0.0f;
- path[3] = 0.0f; // end position
- path[4] = 0.0f;
- path[5] = 10.0f;
- }
-
- public void processEvent(Event e){
- if(e.getName().equals("cycleEnd") == true){
- // decide how far the walking man goes in the next cycle.
- // the distance is between 10.0 and 20.0
- path[5] = 10.0f + randomNumGenerator.nextFloat() * 10.0f;
- // send the event.
- setPath.setValue(3 * 2, path);
- }
- }
- }
-
-