/********************************************************************************Redistribution and use in source and binary forms are prohibited without*express written permission from Bill Tomlinson.  Please contact him*(wmt@uci.edu) for more information.**THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND ANY*EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED*WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE*DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY*DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND*ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT*(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF*THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**All rights reserved.*Copyright (c) 2003 MASSACHUSETTS INSTITUTE OF TECHNOLOGY and Bill Tomlinson*******************************************************************************/package content.ac;import innards.math.linalg.Vec3;import pc.ui.UtilitySlider;import research.basics.*;import java.util.Vector;/*** @author Bill Tomlinson**/public class Demo extends BaseDemo {	/** Fields */	public static int[] NUM_PEOPLE = new int[20];	public static int TOTAL_PEOPLE = 0;	protected Vector allPeople = new Vector();	private static UtilitySlider speedSlider;	/** Methods */	//This method gets called once at the beginning of the program's execution.	public static void main(String[] args) {		parseArguments(args);		demo = new Demo();		demo.setUp();		if (!fullScreen)			speedSlider = new UtilitySlider("Speed slider", 1, 20, 1);		demo.play();		for (int i = 0; i < NUM_PEOPLE.length; i++) {			TOTAL_PEOPLE += NUM_PEOPLE[i];		}	}	//This method gets called once at the beginning of the demo	public void setUpCreatures() {	// add characters	{		Person thisOne = new User("User number 0");		Vec3 pos = new Vec3(0, 0, 0);		thisOne.setPosition(pos);		allPeople.add(thisOne);		System.out.println("added person 02");	}		for (int i = 0; i < NUM_PEOPLE[2]; i++) {					Person thisOne = new PersonACE_02("PersonACE_02 number " + i);					Vec3 pos = new Vec3(30 * i, 0, 0);					thisOne.setPosition(pos);					allPeople.add(thisOne);					System.out.println("added person 02");		}		for (int i = 0; i < NUM_PEOPLE[5]; i++) {					Person thisOne = new PersonACE_05("PersonACE_05 number " + i);					Vec3 pos = new Vec3(30 * i, 20, 0);					thisOne.setPosition(pos);					allPeople.add(thisOne);					System.out.println("added person 05");		}		for (int i = 0; i < NUM_PEOPLE[6]; i++) {					Person thisOne = new PersonACE_06("PersonACE_06 number " + i);					Vec3 pos = new Vec3(30 * i, 40, 0);					thisOne.setPosition(pos);					allPeople.add(thisOne);					System.out.println("added person 06");		}		for (int i = 0; i < NUM_PEOPLE[14]; i++) {					Person thisOne = new PersonACE_14("PersonACE_14 number " + i);					Vec3 pos = new Vec3(30 * i, 60, 0);					thisOne.setPosition(pos);					allPeople.add(thisOne);					System.out.println("added person 14");		}		//////////////////	}	//This method gets called once at the beginning, and deals with anything 	//you type into the command line when running the program	public static void parseArguments(String[] args) {		//if you don't specify how many people you want in each type, you get a 		//random number between 1 and 5 of each of the 4 types.		if (args.length <= 1) {		NUM_PEOPLE[2] =  (int)(Math.random()*4+1);		NUM_PEOPLE[5] =  (int)(Math.random()*4+1);		NUM_PEOPLE[6] =  (int)(Math.random()*4+1);		NUM_PEOPLE[14] =  (int)(Math.random()*4+1);		};		System.out.println("About to parse args");		for (int i = 0; i < args.length; i++) {			System.out.println("args " + i + " = " + args[i]);			if (args[i].equals("-numPeople")) {				while (i < args.length - 1) {					i++;					System.out.println("About to do " + i);					if (args[i].equals("xx"))						NUM_PEOPLE[0] += new Integer(args[i + 1]).intValue();					else						NUM_PEOPLE[new Integer(args[i]).intValue()] += new Integer(args[i + 1]).intValue();					i++;				}			} else if (args[i].equals("-fullScreen")) {				fullScreen = true;			} else {				System.err.println(					"\n Unknown command line parameter \""						+ args[i]						+ "\"\n Try \"-fullScreen\" or \"-numPeople 01 1\"");				System.exit(0);			}		}	}	//This method gets called once per time step.	public void update() {		//        System.out.println("\n-------Time = " + getTime() + "--------------");		if (speedSlider != null) {			try {				Thread.sleep((long) (speedSlider.getValue() * 300 / (TOTAL_PEOPLE + 20)));			} catch (Exception e) {			} //this should roughly normalize the frame rate			/*      try 		{Thread.sleep((long)(speedSlider.getValue()*200/(NUM_CREATURES+20)));} 		catch (Exception e){}//this should roughly normalize the frame rate		} else			try {				Thread.sleep((long) (300 / (TOTAL_PEOPLE + 20)));			} catch (Exception e) {*/			} //this should roughly normalize the frame rate				super.update();	}}ÿ