#1
|
|||
|
|||
Is that possible to add some actions to the "grabbed object"
Is that possible to add some actions to the "grabbed object"
the object is grabbed on the mouse or other equipment and I want to add some action to the grabbed object such as spinTo, sizeTo, but different signal input trigger different actions it is not the "grabber.GRAB_EVENT", this event can only trigger one movement after it is grabbed. I want to trigger different movement. Thanks |
#2
|
|||
|
|||
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) |
#3
|
|||
|
|||
Quote:
is that possible to do these in VizChild object like osgb file |
#4
|
|||
|
|||
Quote:
|
#5
|
|||
|
|||
Yes, you can also define an attribute such as
Code:
torus.grabbed = False I'm not getting the same error. What version of Vizard are you running? |
#6
|
|||
|
|||
Quote:
I forgot to add the code "viz.callback(grab.GRAB_EVENT,onGrab)" |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
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 |