View Single Post
Old 05-02-2009, 11:59 PM
nasr nasr is offline
Join Date: Apr 2009
Posts: 27
thanks jeff for ur reply...i tried with ur code..the mouse pointer is linked with the marker, but why it isnot able to move the ball?
Originally Posted by Jeff View Post
The following code creates a mousetracker object from the Viztracker module. The hand gets linked to this mousetracker. When you pick an object it gets linked to the hand.

import viz


import viztracker
tracker = viztracker.MousePos()

#Add the object that will do the grabbing and link it to the tracker
hand = viz.add('marker.wrl'), hand)

#turn off mouse navigation

#Add the object that the marker will grab
ball = viz.add( 'ball.wrl' )
ball.translate( 0.5, 1.5, 3 )

link = None
#Grab or let go of the ball

def toggleLink():
	global link
	if link:
		#If link exits, stop grabbing
		link = None

	elif vizmat.Distance(hand.getPosition(), ball.getPosition()) < .5:
		link = viz.grab( hand, ball )

Reply With Quote