Gil_MSc Thesis_appendix E_2000

Reviews
Shared by: Jorge Gil
Categories
Tags
Stats
views:
6
rating:
not rated
reviews:
0
posted:
7/1/2009
language:
English
pages:
0
A P PEN DIX E : SOU RCE CO DE BLACK BOX #VRML V2.0 utf8 # External data structures EXTERNPROTO InfoSource [ ] "info_source.wrl" EXTERNPROTO InfoLandscape [ eventIn SFFloat info_type eventIn SFVec3f info_location eventIn SFRotation orientation_changed field MFString tagsList field MFColor coloursList eventOut MFFloat surface_types eventOut SFVec3f agent_height ] "info_landscape.wrl" EXTERNPROTO UserInterface [ eventIn MFString set_description eventIn MFString set_url eventIn SFBool isOver eventIn SFBool isActive exposedField SFVec3f position_changed exposedField SFRotation orientation_changed ] "user_interface.wrl" # Global environment Background { skyColor [.07 0 .25, .03 0 .10, .07 0 .25] skyAngle [1.75, 3.14] } NavigationInfo { type ["EXAMINE" , "ANY"] speed 10 headlight FALSE } DEF SENSOR ProximitySensor { size 5000 5000 5000 center 0 0 0 } DEF TIMER TimeSensor {} DEF VIEWPOINTS Group { children [ Viewpoint { fieldOfView 0.9 orientation -1 0 0 1.07 position 0 100 60 description "Overview [1]" } Viewpoint { fieldOfView 0.9 orientation 1 0 0 -1.57 position 0 120 0 description "Surface" } Viewpoint { fieldOfView 0.9 orientation 0 1 0 0 position 0 12 47 description "Enter Surface" } 71 Viewpoint { fieldOfView 0.9 orientation 0 1 0 0 position 0 7 120 description "Front view" } Viewpoint { fieldOfView 0.9 orientation 1 0 0 2.1 position 0 -90 -60 description "Overview [2]" } Viewpoint { fieldOfView 0.9 orientation 1 0 0 1.57 position 0 -110 0 description "Info Source" } Transform { rotation 0 0 1 3.14 children Viewpoint { fieldOfView 0.9 orientation 0 1 0 3.14 position 0 2 -47 description "Enter Grid" } } Viewpoint { fieldOfView 0.9 orientation 0 1 0 3.14 position 0 2 0 description "Source" } Viewpoint { fieldOfView 1.1 orientation 1 0 0 -1.57 position 0 10 0 description "Over the Source" } Viewpoint { fieldOfView 0.9 orientation 0 1 0 3.14 position 0 0 -10 description "At Grid Level" } DEF FOLLOW_INFO Transform { children Viewpoint { fieldOfView 0.9 orientation 0 1 0 3.14 position 0 1 -2 description "Follow Info-agent" } } DEF FOLLOW_ARCH Transform { children Viewpoint { fieldOfView 1.1 orientation 1 0 0 -1.57 position 0 10 0 72 description "Follow Arch-agent" } } ] } # The different components DEF ROOT Group { children[ # Global Lights DirectionalLight DirectionalLight DirectionalLight DirectionalLight # Scene objects Transform { translation 0 10 0 children DEF LANDSCAPE InfoLandscape {} } DEF SOURCE InfoSource {} ] } # User Interface DEF DISPLAY UserInterface {} ROUTE SENSOR.position_changed TO DISPLAY.position_changed ROUTE SENSOR.orientation_changed TO DISPLAY.orientation_changed ROUTE SENSOR.orientation_changed TO LANDSCAPE.orientation_changed # To reorient surface links # Dynamic creation of agents and routes # To change agent number edit field agentNumber # To add new routes place them in Browser.addRoute for loop DEF AGENT_CREATOR Script { eventIn SFBool active field SFNode surface USE LANDSCAPE field SFNode display USE DISPLAY field SFNode follow USE FOLLOW_INFO field SFFloat agentNumber 30 eventOut MFNode new_agents url ["vrmlscript: function initialize(){ agentString = ''; for (n=0; n Math.PI) desiredAngle += -twopi; else if(desiredAngle < -Math.PI) desiredAngle += twopi; // clamp the angle to our turnLimit to slow turn changeAngle = clamp(desiredAngle, -turnLimit, turnLimit); } function isOver(val){ if(val){ set_info = currentDescription; over = TRUE; } else over = FALSE; } function isActive(val){ if(val == TRUE && currentUrl[0] != ''){ set_url = currentUrl; active = TRUE; } else active = FALSE; } function surface_types (val) { surfaceTypes = val; } function beat(val) { if(lastBeat == 0) { lastBeat = val; } else { timeElapsed = val - lastBeat; move (timeElapsed); } lastBeat = val; } function move (timeElapsed) { // check if goal is hit dif = position.subtract(goal); l = dif.length(); if ( l < 0.1 ) change_state(); position = position.add(direction.multiply(speed*timeElapsed)); if (position.x<-48) position.x = -48; if (position.x>48) position.x = 48; if (position.z<-48) position.z = -48; if (position.z>48) position.z = 48; position_changed = position; // update direction and rotation maxAngleThisBeat = turnLimit * timeElapsed; angle = clamp(changeAngle, -maxAngleThisBeat, maxAngleThisBeat); rotation += angle; if (rotation < 0) rotation = rotation + twopi; if (rotation > twopi) rotation = rotation - twopi; r = new SFRotation(0, 1, 0, rotation); 79 rotation_changed = r; direction = r.multVec(new SFVec3f(0, 0, 1)); } function change_state (){ if (state == -1) { set_type(); set_colour = colour_list[type]; a= Math.round(Math.random()*3.5)+type*4; currentDescription[0] = infoDescription[a]; currentUrl[0] = infoUrl[a]; set_goal(); state = 1; } else { i = Math.round (goal.x/6)+8; j = Math.round (goal.z/6)+8; localType = surfaceTypes[j*17+i]; if (localType == type || localType == -1){ drop_type = type; drop_location = goal; set_colour = empty_colour; currentDescription[0] = 'collecting information'; currentUrl[0] = ''; goal = source; state = -1; } else { goal = source; set_goal(); state = 1; } } } // clamp val between min and max numbers function clamp(val, min, max) { if(val max) return max; else return val; } function set_goal() { while (goal.x < 7 && goal.x >-7 && goal.z < 7 && goal.z >-7){ goal.x =Math.round(Math.random()*14-7)*6; goal.z =Math.round(Math.random()*14-7)*6; } } function set_type() { type = Math.random()*3.5; type = Math.round(type); } " } ROUTE ROUTE ROUTE ROUTE ROUTE ROUTE } InfoAgent {} HEART.time TO BEHAVIOUR.beat BEHAVIOUR.position_changed TO GEOMETRY.set_translation BEHAVIOUR.rotation_changed TO GEOMETRY.set_rotation BEHAVIOUR.set_colour TO AGENT_MAT.set_diffuseColor TOUCH.isOver TO BEHAVIOUR.isOver TOUCH.isActive TO BEHAVIOUR.isActive 80 INFORMATION LANDSCAPE #VRML V2.0 utf8 PROTO InfoLandscape [ eventIn SFFloat info_type eventIn SFVec3f info_location eventIn SFRotation orientation_changed field MFString tagsList ["URGENT","DOCUMENTS","IMAGES","SOUNDS"] field MFColor coloursList [.6 0 0, .6 .6 0, 0 0 .6, 0 .6 0] eventOut MFFloat surface_types eventOut SFVec3f agent_height ] { Group { children [ Transform { translation -48 0 -48 children Shape { appearance Appearance { material Material { diffuseColor .8 .8 .8 shininess .4 } } geometry DEF GEOMETRY ElevationGrid { solid FALSE xDimension 17 zDimension 17 xSpacing 6 zSpacing 6 creaseAngle 3 } } } DEF HEART TimeSensor { cycleInterval 1 loop TRUE } DEF LINKS Group {} ] } DEF BEHAVIOUR Script { directOutput TRUE eventIn eventIn eventIn eventIn field field field field field field field field field field field field field field SFFloat info_type IS info_type SFVec3f info_location IS info_location SFRotation orientation_changed IS orientation_changed SFTime beat DEF TAGS Group {} SFNode LANDSCAPE USE GEOMETRY SFNode BEHAVIOUR USE BEHAVIOUR MFFloat height [] SFFloat change 1.5 SFFloat change_n 0 SFFloat reverse -.4 SFFloat reverse_n 0 SFFloat new_type 0 SFVec3f new_height 0 0 0 MFFloat types [] MFFloat top [] MFFloat time_stamp [] SFFloat stamp_value 10 SFFloat y_value 0 81 field field field field field field field MFString tagsList IS tagsList MFNode tagNode [] MFNode linkNode [] SFNode emptyNode Transform {} MFColor coloursList IS coloursList SFRotation rotate 0 0 0 0 SFVec3f coord 0 0 0 MFFloat surface_types IS surface_types SFVec3f newTranslation SFRotation newOrientation MFNode addTag MFNode addLink MFNode removeTag MFNode removeLink SFVec3f agentHeight IS agent_height # # eventOut eventOut eventOut eventOut eventOut eventOut eventOut eventOut url "vrmlscript: function initialize () { for ( i=0; i<17*17; i++) { time_stamp[i] = 0; height[i] = 0; types[i] = -1; top[i] = -1; } change_n = change*0.6; reverse_n = reverse*0.6; update(0,165); } function orientation_changed (val) { rotate = val; newOrientation = val; } function info_type (val) { new_type = val; } function beat(val) { for ( i=0; i<17*17; i++){ if (time_stamp[i] > 0){ time_stamp[i] -= 1; if (time_stamp[i] == 0){ get_coord(i); grow_hill(i,reverse,types[i],reverse_n,coord); if (height[i] <= 0){ height[i] = 0; // removeTag = tagNode; // removeLink = linkNode; tagNode[i] = emptyNode; linkNode[i] = emptyNode; select_neighbourhood(i,types[i],1); // to clear the neighbourhood grow_hill(i,0,types[i],0,coord); } else time_stamp[i] = stamp_value; update(height[i],i); } } } } function get_coord(val){ x = (Math.abs(val%17)-8)*6; z = (Math.abs(val/17)-8)*6; coord = new SFVec3f (x, 0, z); 82 } function info_location(val){ i = Math.round(val.x/6)+8; j = Math.round(val.z/6)+8; n = j*17+i; if (types[n] == -1){ top[n] = new_type types[n] = new_type; new_tag(n,tagsList[new_type],val,coloursList[new_type]); new_link(n,tagsList[new_type],val,coloursList[new_type]); select_neighbourhood (n,-1, new_type); // this marks the neighbourhood grow_hill(n,change,types[n],change_n,val); } if (top[n] == -1) find_top(n,types[n]); else grow_hill(n,change,top[n],change_n,val); update(height[n],n); } function update(val,n){ addTag = tagNode; addLink = linkNode; LANDSCAPE.set_height = height; surface_types = types; if (n==165){ y_value = val; agentHeight = new SFVec3f (24, y_value, 6); } } function grow_hill(n,val,control,val_n,coord){ height[n] += val; coord.y = height[n]; linkNode[n].set_translation = coord; if (types [n+17]== control) height [n+17]+= val_n; if (types [n+16]== control) height [n+16]+= val_n; if (types [n+1]== control) height [n+1]+= val_n; if (types [n-1]== control) height [n-1]+= val_n; if (types [n-17]== control) height if (types [n-16]== control) height if (types [n-18]== control) height if (types [n+18]== control) height time_stamp[n] = stamp_value; } function select_neighbourhood (n, control, type){ // checks the neighbours in a Moore if (types [n+17]== control) types [n+17]= type; // neighbourhood. loc is the center if (types [n+16]== control) types [n+16]= type; // agent; control is the type to check if (types [n+1]== control) types [n+1] = type; neigh. for; type is the replacement if (types [n-1]== control) types [n-1] = type; if if if if } function find_top(n,control){ e=0; while (e==0){ (types (types (types (types [n-17]== [n-16]== [n-18]== [n+18]== control) control) control) control) types types types types [n-17] [n-16] [n-18] [n+18] = = = = type; type; type; type; [n-17]+= [n-16]+= [n-18]+= [n+18]+= val_n; val_n; val_n; val_n; // the 83 if if if if if if if if (top (top (top (top (top (top (top (top [n+17]== control){ n = n+17; e=1;} [n+16]== control){ n = n+16; e=1;} [n+1]== control){ n = n+1; e=1;} [n-1]== control){ n = n-1; e=1;} [n-17]== [n-16]== [n-18]== [n+18]== control){ control){ control){ control){ n n n n = = = = n-17; n-16; n-18; n+18; e=1;} e=1;} e=1;} e=1;} } get_coord(n); grow_hill (n,change,control,change_n,coord); } function new_tag(n,tag,pos,colour) { tagNode[n] = new SFNode ('Transform { '+ 'translation '+pos+ ' rotation 1 0 0 1.575'+ ' children [ Shape {'+ ' appearance Appearance { material Material '+ '{ diffuseColor '+colour+'}}'+ ' geometry Text { string \"'+tag+'\" fontStyle FontStyle {'+ ' family \"TYPEWRITER\" style \"BOLD\" justify \"MIDDLE\" size 1.7}}'+ '}'+ ']}'); } function new_link (n,tag,pos,colour) { linkNode[n] = new SFNode ('DEF LINK'+n+' Transform { '+ 'translation '+pos+ 'rotation '+rotate+ ' children [ TouchSensor {}'+ ' Shape {'+ ' appearance Appearance { material Material '+ '{ diffuseColor '+colour+'}}'+ ' geometry Text { string \"'+tag+'\" fontStyle FontStyle {'+ ' family \"TYPEWRITER\" style \"BOLD\" justify \"MIDDLE\" size 1.7}}'+ '}'+ ']}'); Browser.addRoute (BEHAVIOUR, 'newOrientation', linkNode[n], 'set_rotation'); } " } ROUTE HEART.cycleTime TO BEHAVIOUR.beat ROUTE BEHAVIOUR.addTag TO TAGS.addChildren ROUTE BEHAVIOUR.addLink TO LINKS.addChildren #ROUTE BEHAVIOUR.removeTag TO TAGS.removeChildren #ROUTE BEHAVIOUR.removeLink TO LINKS.removeChildren } 84

Related docs
Gil_MSc Thesis_appendix A_2000
Views: 9  |  Downloads: 0
Gil_MSc Thesis_appendix C_2000
Views: 3  |  Downloads: 0
Gil_MSc Thesis_appendix D_2000
Views: 3  |  Downloads: 0
Gil_MSc Thesis_appendix B_2000
Views: 2  |  Downloads: 0
premium docs
Other docs by Jorge Gil
Proceedings_Workshop_1_DCC08_2008
Views: 10  |  Downloads: 0
JorgeGil_PhD Proposal_2008
Views: 19  |  Downloads: 2
JorgeGil_PhD Proposal Diagrams_2009
Views: 39  |  Downloads: 0
JorgeGil_CV_2008
Views: 15  |  Downloads: 0
Gil_Virtual Environments Essay_1999
Views: 1  |  Downloads: 0
Gil_Urban Evaluation Summary_ETHZ 2008
Views: 10  |  Downloads: 0
Gil_Urban Evaluation Abstract_ETHZ 2008
Views: 2  |  Downloads: 0
Gil_Standard Application SmartGeometry_2008
Views: 8  |  Downloads: 0
Gil_MSc Thesis_appendix D_2000
Views: 3  |  Downloads: 0
Gil_MSc Thesis_appendix C_2000
Views: 3  |  Downloads: 0
Gil_MSc Thesis_appendix B_2000
Views: 2  |  Downloads: 0
Gil_MSc Thesis_appendix A_2000
Views: 9  |  Downloads: 0