#VRML V2.0 utf8 # # DYNAMIC MODEL PROTOS # # fbm0proto.wrl - world with one function (change transparency) PROTO FBM [ eventIn SFFloat set_clock field SFVec3f position 0 0 0 field MFNode functions [] field MFNode traces [] ] { Transform { translation IS position children [ Group {children IS functions} Group {children IS traces} ] #children } #Transform } #PROTO FBM PROTO FBM_FUNCTION [ eventIn SFFloat set_clock eventIn SFTime clock_tick eventIn SFBool activate eventIn SFFloat float_data1_in field MFString name "Function" field SFVec3f text_position 0 0 0 field SFVec3f function_position 0 0 0 field SFBool process FALSE field SFFloat transparency_value 0.9 field SFFloat min_value 0.9 eventOut SFFloat new_transparency eventOut SFFloat float_data1_out eventOut SFBool done ] { Group { children [ Transform { translation IS text_position children Billboard { children Transform { translation IS text_position children Shape { geometry DEF Name Text { string IS name fontStyle FontStyle { family "SANS" justify "MIDDLE" size 0.8 spacing 1.2 style "BOLD" } # end font style } } #Shape } #Transform } #Billboard } #Transform Text Transform { translation IS function_position children [ Transform { translation IS function_position children Shape { geometry Box {} appearance Appearance { material DEF Mat Material { diffuseColor 1.0 0.0 0.0 transparency IS transparency_value } texture ImageTexture { repeatS TRUE repeatT TRUE url "tile.jpg" } # texture } # appearance }#Shape }#Transform ] }#Transform ] #children } #Group DEF S Script { eventIn SFFloat set_clock IS set_clock eventIn SFTime clock_tick IS clock_tick eventIn SFBool activate IS activate eventIn SFFloat float_data1_in IS float_data1_in field SFFloat transparency_value IS transparency_value field SFFloat min_value IS min_value field SFBool process IS process eventOut SFFloat new_transparency IS new_transparency eventOut SFFloat float_data1_out IS float_data1_out eventOut SFBool done IS done url "javascript: function set_clock(value,time) { behavior[0].set_clock = value; } function clock_tick(value,time) { if (process) { if (transparency_value <= min_value){ process = FALSE; done = TRUE; float_data1_out = min_value; transparency_value = min_value; } else transparency_value = transparency_value - 0.02; } new_transparency = transparency_value; } function float_data1_in (value,time) { min_value = value - 0.9; transparency_value = value; } function activate(value,time) { process = value; } " }# DEF S ROUTE S.new_transparency TO Mat.set_transparency # ROUTE S.float_data1_out TO S.float_data1_in }#PROTO FBM_FUNCTION PROTO FBM_TRACE [ exposedField MFNode geometry [] ] { Group { children [ Group {children IS geometry} ] #children } #Group } #PROTO FBM_TRACE # # OBJECT PROTO # PROTO FBMPATH [ field SFVec3f position 0 0 0 field SFVec3f translation 0 0 0 ] { Group { children [ Transform { translation IS position children Transform { translation IS translation children [ Transform { children Shape { # geometry Box { size 4 0.2 1.5} geometry Box { size 4 0.2 1.3} appearance Appearance { material DEF MAT Material { diffuseColor 1 0 0 transparency 0.2 } # material texture ImageTexture { repeatS TRUE repeatT TRUE url "marble.jpg" } # texture } # appearance } #Shape } #Transform ] #children } #Transform } #Transform ] #children } #Group } #PROTO FBMPATH