View Single Post
  #1  
Old 09-12-2012, 07:42 AM
pwsnow pwsnow is offline
Member
 
Join Date: Apr 2012
Posts: 23
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)
Because def onCollideBegin/End is using an event how would I "wrap up" these two methods with the mouse down/up?

Many thanks.
Reply With Quote