WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-02-2015, 02:16 PM
MissingAFew MissingAFew is offline
Member
 
Join Date: Apr 2015
Posts: 15
Updating a Postprocessing effect

I'd like to be able to modify and update a postprocessing effect in a loop for a particular effect. Specifically, I'm wanting to modify BulgeAmount such that it loops and interpolates between -0.5 and 0.5:


Code:
effect = BulgeEffect(BulgeAmount)
vizfx.postprocess.addEffect(effect)

I tried using the director function to create a new thread and have it loop separately from the main thread but it crashed. This is the code I tried:

Code:
import viz
import viztask

import vizfx.postprocess
from vizfx.postprocess.distort import PincushionEffect

def UpdateDrunkEffect():
	DrunkValue = 0
	Modulate = True
	
	Length = 60
	
	while True:
		if DrunkValue <= 0:
			Modulate = True
				
		if DrunkValue >= 1:
			Modulate = False
			Length -= 1
				
		if Modulate:
			DrunkValue += .01
		else:
			DrunkValue -= .01
	
		effect = PincushionEffect(DrunkValue)
		vizfx.postprocess.addEffect(effect)
		
		if Length == 0:
			effect = PincushionEffect(0)
			vizfx.postprocess.addEffect(effect)
			break
		
viz.director( UpdateDrunkEffect )
Is there a better way to do this that I'm just not thinking of? How can I go about changing the postprocessing effect in a loop without it freezing the application?
Reply With Quote
  #2  
Old 05-04-2015, 02:37 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Here's an example that uses the viztask.waitCall command to call effect.setBulge and waits until the vizact.mix parameters are complete.

Code:
import viz
import vizact
import viztask

viz.go()
viz.addChild('gallery.osgb')

import vizfx.postprocess
from vizfx.postprocess.distort import BulgeEffect
effect = BulgeEffect(0,radius=1)
vizfx.postprocess.addEffect(effect)

def BulgeTask():
	
	increase = vizact.mix(-0.5,0.5,time=2)
	decrease = vizact.mix(0.5,-0.5,time=2)

	while True:

		yield viztask.waitCall(effect.setBulge,increase)
		yield viztask.waitCall(effect.setBulge,decrease)

viztask.schedule( BulgeTask() )
Reply With Quote
  #3  
Old 05-07-2015, 09:58 AM
MissingAFew MissingAFew is offline
Member
 
Join Date: Apr 2015
Posts: 15
Thank you Jeff! This is exactly what I was trying to do. You make my life easy.
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
anaglyph effect at front view of cave g.vannan Vizard 1 02-03-2015 05:29 AM
Updating object color sxu04 Vizard 4 01-04-2012 06:47 AM
Peek Effect in Inspector pcatalano Vizard 1 03-17-2011 03:44 PM
special effect shahramy Vizard 1 06-14-2010 03:22 PM
How can I do the flip effect of poker? superantTTY Vizard 2 05-27-2010 01:15 AM


All times are GMT -7. The time now is 01:23 AM.


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