#1
|
|||
|
|||
Picking up Vizard Objects on mouse down with collisions
I'm trying to pick up vizard objects using a vizshape sphere as an end effector.
Because I have multiple objects I'm using onCollideBegin to grab the objects when the end effect collides with the object to be picked up. This work fine but the end effector doesn't let go of the object and it is automatic, however I want to be able to pick up objects when I touch them and hold them as long as the left mouse button is pressed. Releasing the object once the left mouse button is released. I have the below code in my updateview method: Code:
def onCollideBegin(e): #while vizact.whilemousedown(viz.MOUSEBUTTON_LEFT): if e.obj1 == sphere: if e.obj2 == cube: link = viz.grab(sphere,cube) #viz.playSound( 'crashNew.wav' ) libc.haDeviceSendString(dev, "set myDamper enable",response) if e.obj2 == cube2: link = viz.grab(sphere,cube2) libc.haDeviceSendString(dev, "set myDamper enable",response) if e.obj2 == ball: link = viz.grab(sphere,ball) libc.haDeviceSendString(dev, "set myDamper enable",response) viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin) #vizact.whilemousedown(viz.MOUSEBUTTON_LEFT,onCollideBegin) def onCollideEnd(e): if e.obj1 == sphere: if e.obj2 == cube: link = None libc.haDeviceSendString(dev, "set myDamper disable",response) if e.obj2 == cube2: link = None libc.haDeviceSendString(dev, "set myDamper disable",response) if e.obj2 == ball: link = None libc.haDeviceSendString(dev, "set myDamper disable",response) viz.callback(viz.COLLIDE_END_EVENT,onCollideEnd) vizact.onmousedown(viz.MOUSEBUTTON_LEFT,onCollideBegin) #vizact.whilemousedown(viz.MOUSEBUTTON_LEFT,onCollideBegin) vizact.onmouseup(viz.MOUSEBUTTON_LEFT,onCollideEnd) #vizact.whilemouseup(viz.MOUSEBUTTON_LEFT,onCollideEnd) Many thanks. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Vizard 4 Beta Testing | farshizzo | Announcements | 0 | 02-01-2011 10:46 AM |
Vizard 4 Beta Testing | farshizzo | Vizard | 0 | 02-01-2011 10:46 AM |
Trouble picking text3d objects | Salvar | Vizard | 4 | 12-01-2010 03:07 PM |
Vizard tech tip: Using the Python Imaging Library (PIL) | Jeff | Vizard | 0 | 03-23-2009 11:13 AM |
Pivot points for child objects in Vizard with 3ds Max | Gladsomebeast | Vizard | 0 | 09-19-2006 11:21 AM |