WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-27-2009, 05:15 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.

Code:
import viz

viz.go()

import viztracker
tracker = viztracker.MousePos()

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

#turn off mouse navigation
viz.mouse(viz.OFF)

#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.remove()
		link = None

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

vizact.onpick(ball,toggleLink)
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


All times are GMT -7. The time now is 09:19 PM.


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