PROTO
Savez-vous
planter les choux ? proto_carots.wrlIci c'est une carotte , mais on peut mettre les shapes que l'on veut .Le script ira chercher le PROTO pour pouvoir les planter à chaque click sur le sol : DEF AddSheep-Sc Script { eventIn SFVec3f set_hitPoint eventIn SFTime touchTime eventIn MFNode set_sheeps field SFNode SheepsGp USE Sheeps-Gp field MFString sheepUrl "proto_carots.wrl" field SFVec3f hitPoint 0 0 0 directOutput TRUE url "javascript: function set_hitPoint (vec) { hitPoint = vec; } function touchTime () { Browser.createVrmlFromURL( sheepUrl, SheepsGp, 'addChildren' ); } function set_sheeps (sp) { var id = sp.length - 1; var packet = new MFFloat(); packet[0] = id; packet[1] = hitPoint.x; packet[2] = 0; packet[3] = hitPoint.z; sp[id].packet_in = packet; for ( var i = 0; i < id; i++ ) { Browser.addRoute( sp[i], 'packet_out', sp[id], 'packet_in' ); Browser.addRoute( sp[id], 'packet_out', sp[i], 'packet_in' ); } } " } ROUTE ThS.hitPoint_changed TO AddSheep-Sc.set_hitPoint ROUTE ThS.touchTime TO AddSheep-Sc.touchTime ( copyright Kekenken ) Pourquoi
"sheeps" et non pas "carottes" ?
http://dumenieu.free.fr/vrml/pierray/pierraycarots.wrl http://dumenieu.free.fr/vrml/pierray/pierrayinlineetmonster.wrl
_________________________________________________________________________ |
Vrml............................ |
artvrml/wrl/kekenkencarots.wrl______________________________________________________________________ |
Sommaire................... |
______________________________________________________________________ |
PROTO
A script to add dynamicaly objects in your world : From Kekenken an
excellent and funny programer in VRML proto_carots.wrlHere it is a carot , but you could add what you want .DEF AddSheep-Sc Script { eventIn SFVec3f set_hitPoint eventIn SFTime touchTime eventIn MFNode set_sheeps field SFNode SheepsGp USE Sheeps-Gp field MFString sheepUrl "proto_carots.wrl" field SFVec3f hitPoint 0 0 0 directOutput TRUE url "javascript: function set_hitPoint (vec) { hitPoint = vec; } function touchTime () { Browser.createVrmlFromURL( sheepUrl, SheepsGp, 'addChildren' ); } function set_sheeps (sp) { var id = sp.length - 1; var packet = new MFFloat(); packet[0] = id; packet[1] = hitPoint.x; packet[2] = 0; packet[3] = hitPoint.z; sp[id].packet_in = packet; for ( var i = 0; i < id; i++ ) { Browser.addRoute( sp[i], 'packet_out', sp[id], 'packet_in' ); Browser.addRoute( sp[id], 'packet_out', sp[i], 'packet_in' ); } } " } ROUTE ThS.hitPoint_changed TO AddSheep-Sc.set_hitPoint ROUTE ThS.touchTime TO AddSheep-Sc.touchTime ( copyright Kekenken ) Here the
original : ( I played months ago with that :
http://dumenieu.free.fr/vrml/pierray/pierraycarots.wrl http://dumenieu.free.fr/vrml/pierray/pierrayinline.wrl http://dumenieu.free.fr/vrml/pierray/pierrayinlineetmonster.wrl_________________________________________________________________________ |
Vrml........................... |
______________________________________________________________________ |
Contents.................... |
_______________________________________________________________________ |