can we reappear the shape by touchSensor in VRML?

101 views Asked by At

I have two Shape. It's called Shape1 and Shape2. And a TouchSensor. Can I make the Shape2 disappear when I touch to Shape1? And touch to Shape1 again, Shape2 will reappear?

Thank you for helping me!

1

There are 1 answers

0
ViennaMike On

It's been quite awhile since I did VRML, but here are some ideas:

Attach the TouchSensor to Shape1. Route the output so that it does one of the following:

1) Triggers Shape2 to be transparent (which might be all you need, but the object is still there) OR 2) Translate Shape 2 very far away, such that it won't be seen OR 3) goes to a Switch node, and Shape2 is in the Switch node, along with a null object (not sure if that's legal) or a tiny or very far away object. 4) Put Shape2 in a group node and route the trigger to a script that adds or removes it using add or remove child.

A complicating factor is that the TouchSensor only triggers when clicked, acting as a momentary switch, while what you probably want is a toggle switch. For that, you need to route the output to a short, simple switch that implements the toggle function, then the output of that script to however you choose to make Shape2 "disappear." See http://accad.osu.edu/~mlewis/VRML/Class/jsSwitchColor.html for a really simple example.