Example of a door that opens and closes with one click:
Some people have asked how to make a door which opens and closes. This is a simple
example, it would be easy to get more elaborate.
The idea is to make a door, then add it to an animation, and then add a touch sensor
which makes the door open (runs the animation). Here is a snapshot of the final product.
- Make a long thin box (a door), you don't have to get fancy and add a door jamb like I
did on your first time through. Get fancy after you understand the basics.
- Add a group, but when you add it click on the hingeline of the door (where you want the
door to rotate about). See the little green arrow on the left of the picture.
- In the scene Tree window, drag the door into the new group.
- Click on the Animation Icon (looks like a clock), then click on the door. This adds an
animation to the object and you will see it appear in the Tree window.
- In the Tree window double click on the animation symbol, this opens up the animation
- Click on Add Node, then in the scene Tree window, click on the Group you added in step
- Now you can add a Time Step. Click on the Insert After button and a middle time step
appears (0.5). You now have three times; beginning, middle, and end.
- Click the Edit Keys checkbox and hit the black up arrow to move the pointer to the
middle time step.
- Almost there. Select the Rotation Tab and hit the Rotate 90 -Y button.
- OK, now that we have a door and an animation to make it open, we need to give the user a
way to open it. Hit the Create Sensor icon (looks like a light switch) and click on the
door. This adds a touch sensor to the object and to the tree window. If you double click
on the sensor icon in the tree window you will open up the sensor properties panel.
- Select Add Trigger, then click on the animation icon in the scene tree window. Now you
should have a touch sensor which starts the animation when clicked.
OK, did it work? I hope so. As an exercise you can give the door a nice wood grain or a
steel and rivets texture. You can change the length of time of the animation to make it
slower. You could use a proximity sensor to open the door when the user gets near the door
and then close it when the user walks away (sorta like in the supermarket). You could have
two animations, one to open the door when the user approaches and another to close it when
they pass through it (see below). You could have two swinging doors (like a saloon door).
You could have a sliding door (pocket door).
Here is a link to a .spz file which I built this example with.
It may help you to download it (right click on link and do a "save target
as...") and examine it in Flux Studio.
Last, but not least, here is the door as a VRML world....
An example of a click once to open, click again to close door:
Some people want a door that opens when you click on it once, and closes
when you click on it the second time. Here is how Keith explains how to make this happen.
We discussed this same question a few months ago.....
There are two possible solutions to this problem using Flux Studio.
The attached door2.spz uses the following method:
A single touch sensor starts an animation. The animation node contains 3 keys: Close,
Open, Close. The trick is that you create a second animation node that is used as a
Delay mechanism. The Delay Starts when the door animation Starts. When the Delay Animation
Ends, it triggers the Door animation to Stop. So, if the Period of the Delay is Half of
the period of the Door, then the door will stop when it is fully open.
Click on it again, and it restarts the animation, and starts the Delay so the door closes,
then the delay will stop the animation when the door is closed again.
And so on and so on.......
Works great in the attachment.
( Huh. It would be cool if there was a wizard that created that. )
A second method offered by Duc Pham Hi uses a Switch node to change the Node after each
Click. (Sample is Not included )
Virtock Technologies, Inc.
Here is his example door2.spz file
For a touch of overkill; here is a link to the VRML .wrl of a door that our friend Duc
Pham Hi made.
OK, one last example: enter area to open, leave area to close.
Some folks want a door that opens and closes by itself like at the
supermarket. This can be done by two animations and a proximity sensor. One animation
starts with the door closed and ends with the door open. The other animation starts
with the door open and ends up with the door closed. You add a sensor which runs the first
animation when someone enters the area, and runs the first animation when they leave the
Proximity Sensor Properties
You hit Add Trigger, then select an animation on the Tree window. Then hit
Add Trigger again and select the second animation from the Tree window. If you select the
Open Animation, then on the pull down box below you select When the Sensor Region is
Entered, the triggered Node will Start at the beginning.
Then go back and select the Close Animation. Make the statement below it
read Region is Exited Trigger Node will Start at the beginning.
A view of the proximity sensor box.
Here is an example of the VRML and here is the
door_prox.spz file for you to look at.