|
| hello..hi there...
i'm here..asking for help for my problem to add some object (from external file) to my world...i have some example that i search in the internet..but the example add obejct in the same scene...but i want from the other scene to my world..(example from catalog.wrl to floorplan.wrl)..anyone can help me?..
#VRML V2.0 utf8
# When the box is clicked on the 'Generate' Script
# creates a new yellow sphere which is linked to the existing 'Timer'
DEF Scene Group {
children [
DEF Sensor TouchSensor {}
Shape {
appearance Appearance {
material Material {
diffuseColor .1 .44 .22
shininess .1
specularColor .15 .15 .02
ambientIntensity 0
emissiveColor .04 .18 .09
}
}
geometry Box {
size 1 1 1
}
}
]
}
# existing TimeSensor we wish to utilize
# The new Object will have a ROUTE from this TimeSensor added
DEF Timer TimeSensor {
cycleInterval 1
startTime -1
loop TRUE
}
DEF AddedObject Group {
children [
]
}
DEF Generate Script {
eventIn SFTime touchTime
field SFNode addedObject USE AddedObject
field MFNode tempNode []
field SFString str ""
field SFNode timer USE Timer
directOutput TRUE
url "java script:
function touchTime (val,ts) {
// Create new object as a string
str+='Transform { ';
str+=' translation -2 0 0 ';
str+=' children [ ';
str+=' Shape { ';
str+=' appearance Appearance { ';
str+=' material DEF Yellow Material { ';
str+=' diffuseColor 1 1 0 ';
str+=' }';
str+=' }';
str+=' geometry Sphere { ';
str+=' radius 0.5 ';
str+=' }';
str+=' }';
str+=' ]';
str+='}';
// convert string to VRML and store in temporary
// node.
tempNode=Browser.createVrmlFromString(str);
// add the object to the scene
addedObject.addChildren=tempNode;
// Now add the ROUTE from the Timer to the Yellow Material
// tempNode[0].children[0].appearance.material is the pointer to the
// yellow material's DEFed name
// that is 1st node, then 1st child of node, then appearance,
// then material
Browser.addRoute(timer, 'fraction_changed', tempNode[0].children[0].appearance.material, 'transparency');
}
"
}
# ROUTE touchTime to Script
ROUTE Sensor.touchTime TO Generate.touchTime
# ROUTE touchTime to TimeSensor
ROUTE Sensor.touchTime TO Timer.startTime |
|