//import processing.opengl.*; import damkjer.ocd.*; //import processing.opengl.*; String wintype = P3D; // OPENGL or P3D String version = "v0021"; Nav nav; PFont font24; Graph graph; Bounds bounds; Output out; Output logOut; InfoPanel help; LineGraphs lineGraph; BillBoard billboard; color backgroundColor = color(0,0,0); color baseStrokeColor=color(200,200,200,40), baseFillColor=color(60,60,60,40); //Data double agentVelocitySum; double agentVelocitySquareSum; float agentCount; void setup() { //size(1000, 700, wintype); //JAVA2D OPENGL or P3D size(750, 600, wintype); //JAVA2D OPENGL or P3D //size(1500, 1000, wintype); //JAVA2D OPENGL or P3D //(750,600) is minimum for full help screen display out = new Output(); logOut = new Output(); help = new InfoPanel(); out.outputtoconsole = true; if(stopAtStep>0) { writeAgents = true; } font24 = loadFont("Arial-Black-24.vlw"); billboard = new BillBoard((PGraphics3D) (this.g) ); setupGraph(true); if(!readFile&&writeFile) ((ToyGraph)graph).writeGraph("data/toystadium.txt"); test(); } void checkAgentWriter() { if(agentWriter != null) { println("Closing agent file."); closeWriter(agentWriter); agentWriter = null; } } void setupLineGraphs() { lineGraph = new LineGraphs(0,0,width,height/4-height/10,font24); lineGraph.makeNewGraph("Bomb Injured",color(255,0,0)); lineGraph.makeNewGraph("Trampled",color(0,255,255)); lineGraph.makeNewGraph("Exited",color(255,0,255)); //lineGraph.makeNewGraph("Agents Evacuating",color(255,255,0)); lineGraph.setMin(0); } void setupGraph (boolean newNav) { done = false; checkAgentWriter(); println(readFile?"Reading Stadium from file.":"Creating Stadium internally"); if(readFile) graph = new FileGraph(stadiumFile, numAgents, agentShape); else graph = new ToyGraph(numAgents, agentShape); bounds = graph.getBounds(); println("Bounds: "+bounds); if(newNav) nav = new Nav(this ,bounds.midX, bounds.midY-.5f*bounds.lenZ, bounds.midZ+bounds.lenZ ,bounds.midX, bounds.midY, bounds.midZ); String dataOutputName = agentFileName(); if(writeAgents) { agentWriter=openBufferedWriter(dataOutputName); graph.writeAgents(agentWriter); } println("Nodes="+Nodes.size()+" Edges="+Edges.size()+" Agents="+Agents.size()+ " Total="+(Nodes.size()+Edges.size()+Agents.size())+ " agentShape="+agentShape+" NextBaseID="+NextBaseID+" useLights: "+graph.useLights); println("ExitNodes:"+ExitNodes.size()+" Ramps:"+Ramps.size()+ " Corridors:"+Corridors.size()+" Aisles:"+Aisles.size()+" Rows:"+Rows.size()+ " Total:"+(ExitNodes.size()+Ramps.size()+Corridors.size()+Aisles.size()+Rows.size())); println(writeAgents?"Writing agents, filename="+dataOutputName:"Agent writing off."); } String agentFileName() { //return "data"+File.separatorChar+"agents"+MDY(":")+":"+HM(""); return "agents"+MDY("_")+"_"+HM("")+".txt"; } void draw() { if(skip) { // comment this out to return to old behavior .. fixes processing bug skip = false; return; } if (mouseY0) { out.println("Edge: " + e.id + " Num trampled: " + e.trampled); } } noLoop(); } } if (showinfo) out.showInfo(); if (showlinegraph) lineGraph.draw(); if (showHelpPanel) { background(0); help.showInfo(); } //nav.showAxes(width/100, font24); if (recordimages) { saveFrame("movie/Stadium" + (confusion?"_confused":"_guided") + ( fieldEgress?"_fieldEgress":"_noFieldEgress") + "_######.tga"); } } void showBase(float X, float Y, float Z, float W, float H) { stroke(baseStrokeColor); fill(baseFillColor); pushMatrix(); translate(X,Y,Z); box(W,1,H); popMatrix(); } void mousePressed() { if (showHelpPanel) { showHelpPanel = false; return; } if (mouseY>out.getTopOfPanel()) out.toggleMaxRows(); if(pause) { skip = true; loop(); } } void mouseReleased() { if(pause) noLoop(); } void keyReleased() { if(pause) noLoop(); } void setAgentSpeed(final float speed) { //REMIND: final for Ask .. remove when lib Agents.ask(new Ask(){ void ask(Object o) { ((Agent)o).setSpeed(speed); } } ); } Node getClosestNodeToMouse() { float dist = Float.MAX_VALUE; Node ret = null; for(int i = 0; i * * USER INTERACTION FOR STADIUM MODEL * * Mouse: Rotate * Shift+mouse: Zoom * Alt+mouse: Translate/Pan * Mouse pressed in log view panel: toggle maximise of log view. * * Keyboard: * "/","?" Key: Show this help view. * 0-9 Key: Change number of agents to 10,000*n (0==10) and restart the model. * "b" Key: Set off a bomb at the mouse location. * "g" Key: Toggles the ground plane to the stadium visual. * "f" Key: Toggles real/prototype stadium * "t" Key: Toggles display of rows with injured and dead. * "i" Key: Changes way labels are displayed: (Type/ID) * "l" Key: Turn Labels On/Off. * "p" Key: Pause. * "h" Key: Home view (reset view). * "o" Key: Show log view. * "[","]" Key: Show more or less log lines in log view. * "=" Key: Show graph * "z" Key: Show people/occupied links view. * "r" Key: Re-start model with current number of agents etc. * "s" Key: Change agent shape between point, rect, and box. * "w" Key: Toggle writing agent data. * "<",">" Key: Decrease, Increase agent speed. * * * Questions on use? * email techSupport@redfish.com or mobile (505) 995-0206 * */