WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 01-05-2016, 11:53 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could set a flag when the object is grabbed. When the input signal is sent, check to see if the object is grabbed before applying the action:

Code:
import viz
import vizconnect
import vizshape
import vizact

vizconnect.go('vizconnect_config.py')

dojo = viz.addChild('dojo.osgb')

torus = vizshape.addTorus(radius=0.1,tubeRadius=0.015,axis=vizshape.AXIS_X, pos=[0,1.7,1])
torus.texture(viz.addTexture('images/tile_wood.jpg'))
torus.addAction(vizact.spin(0,1,0,15))
torus.grabbed = False

grabber = vizconnect.getRawTool('grabber')
grabber.setItems([torus])

def onGrab(e):
	if e.grabbed == torus:
		torus.grabbed = True
	
def onRelease(e):
	if e.released == torus:
		torus.grabbed = False

from tools import grabber
viz.callback(grabber.GRAB_EVENT, onGrab)
viz.callback(grabber.RELEASE_EVENT, onRelease)

scaleAction = vizact.sequence([vizact.sizeTo(size=[1.3,1.3,1.3],time=1),vizact.sizeTo(size=[1,1,1],time=1)], viz.FOREVER)

def applyScale():
	if torus.grabbed:
		torus.runAction(scaleAction,pool=1)
		
def removeScale():
	if torus.grabbed:
		torus.clearActions(pool=1)

vizact.onkeydown('1',applyScale)
vizact.onkeydown('2',removeScale)
Reply With Quote
 


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
Simultaneous Actions on Multiple Objects javadi Vizard 2 07-19-2013 03:54 PM
adding actions in front of actionlist IGoudt Vizard 1 01-25-2010 10:55 AM
Trouble with adding actions vijaykiran Vizard 0 10-05-2009 03:18 PM
Speech during actions zoltantoth Vizard 2 05-02-2007 03:11 PM
Weird lagging/choppiness when avatars perform actions vjonshih Vizard 8 11-30-2004 04:08 PM


All times are GMT -7. The time now is 07:09 AM.


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