WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 03-17-2009, 05:57 PM
durf durf is offline
Join Date: Feb 2009
Posts: 61
stop and starting a .wrl file


Im trying to make a animation happen once if. Im planning on using it in a def.

Do i initate the .wrl file before the def?

How can I make the .wrl disapear after the animation runs once?
Reply With Quote
Old 03-18-2009, 12:07 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,466
Use the viz.ACTION_END_EVENT to notify you that the action has completed on your object and then within your callback function use <node3D>.remove() to permanently remove the object from the scene.
import viz

spin = vizact.spin(0,1,0,90,5)

ball = viz.add('ball.wrl',pos=(0,1.8,2))

def onActionEnd(e):
	if e.object is ball and e.action is spin:
		print 'Ball is removed'

Reply With Quote
Old 03-18-2009, 05:53 AM
durf durf is offline
Join Date: Feb 2009
Posts: 61
Well I dont want a spinning action to happen. The animation(the .wrl file) moves. This is an example. We have the sun. The sun rise from one area and sets in another area. On a certain cue I want to trigger the animation(the sun). Let it arc through the air for about 5 seconds and when its at its set point I want it to disappear. And then if that certain cue happens again I want to repeat that process. Ive been going through the index trying to find some code that could fit this but Im not having the best of luck.

Reply With Quote
Old 03-19-2009, 08:51 AM
durf durf is offline
Join Date: Feb 2009
Posts: 61
Not sure if Im understanding how these def really works. Im trying to calculate speed. When that speed is between 3 and 5 I want it to kick in the animation. This animation is a looping animation. Kind of like the above post from yesterday about the sun. Anyways, when I run this it kicks off the animation when it shouldn't because the speed should be 0. Then it only runs once. I was thinking that since CalculateSpeed always stays runnning that it would keep checking the speed between 3 and 5. If that was true it would kick it into the showFlower() and run once. SO I need help, any suggestions would be much appreciated.

One more thing. I want it to create a new image everytime its speed is between 3 and 5 and then removes that image after 3.5 seconds.


def CalculateSpeed(obj):
	#Get current and last position
	current_pos = obj.getPosition()
	last_pos = getattr(obj, 'last_pos', None)

	if last_pos is None:
		#This is first call, so save position and set speed to 0
		obj.last_pos = current_pos
		obj.speed = 0.0
		#Compute speed using last position
		obj.speed = vizmat.Distance(current_pos,last_pos) / viz.elapsed()
		obj.last_pos = current_pos
		if obj.speed > 3 and obj.speed < 5:


def showFlower():
	flower = viz.add('flower_02.wrl')  #creates new flower
	yield viztask.waitTime( 3.5 )  #waits 3.5 seconds
	flower.remove()  #then removes flower
viztask.schedule( showFlower() )
Reply With Quote
Old 03-19-2009, 10:20 AM
durf durf is offline
Join Date: Feb 2009
Posts: 61
Nevermind I got it... I just moved the def up into the if statement and now it works YEAH!
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 05:58 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC