WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-28-2006, 02:21 PM
giancamati giancamati is offline
Member
 
Join Date: Jun 2006
Posts: 27
Smile 3D cursor with FlockOfBirds

Good Morning,

I am developing a 3D virtual environment in which I tracker my hands with flock of birds devices. Now, with the Vanda I would like to implement a 3D cursor. I visualize my 3D cursor as a sphere and I would like to understand if there is a way to fast determine in my sphere intersects an object in the scene. If there is an intersection I pick the object up and move, otherwise nothing happens.

Thank you so much.
Giancarlo
Reply With Quote
  #2  
Old 12-06-2006, 04:07 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Here is a sample script that does what you want. It uses physics shapes to check if models are colliding. If they are, it sets up a "grab" link between the models.

Code:
import viz
viz.go()
viz.clearcolor(viz.SKYBLUE)
viz.MainView.setPosition([0,0,-3])

viz.phys.enable()

logo = viz.add('logo.wrl', pos=[1,0,0])
logo.collideMesh()
marker = viz.add('marker.wrl', pos=[-1,0,0])
marker.collideMesh()
duck = viz.add('duck.cfg', pos=[0,1,0])
duck.collideMesh()

#Add the object that will do the grabbing
hand = viz.add( 'hand.cfg' )
hand.setScale([3,3,3])
hand.translate( 0, 0, 0 )
hand.collideMesh()

grabLink = None #The handle to the link object

#Grab or let go of the ball
def tryGrab():
	global grabLink
	nodes = viz.phys.intersectNode(hand)
	if len(nodes) > 0: #if list is not empty
		grabLink = viz.grab( hand, nodes[0] )
		
def drop():
	global grabLink
	grabLink.remove()
	grabLink = None

def grabOrDrop():
	if grabLink:
		drop()
	else:
		tryGrab()
		
vizact.onkeydown(' ',grabOrDrop)


#Setup keyboard control of hand
vizact.whilekeydown(viz.KEY_UP,hand.translate,0,vizact.elapsed(1),0,viz.RELATIVE_WORLD)
vizact.whilekeydown(viz.KEY_DOWN,hand.translate,0,vizact.elapsed(-1),0,viz.RELATIVE_WORLD)
vizact.whilekeydown(viz.KEY_RIGHT,hand.translate,vizact.elapsed(1),0,0,viz.RELATIVE_WORLD)
vizact.whilekeydown(viz.KEY_LEFT,hand.translate,vizact.elapsed(-1),0,0,viz.RELATIVE_WORLD)

vizact.whilekeydown('w',hand.rotate,1,0,0,vizact.elapsed(90),viz.RELATIVE_WORLD)
vizact.whilekeydown('s',hand.rotate,1,0,0,vizact.elapsed(-90),viz.RELATIVE_WORLD)
vizact.whilekeydown('d',hand.rotate,0,1,0,vizact.elapsed(90),viz.RELATIVE_WORLD)
vizact.whilekeydown('a',hand.rotate,0,1,0,vizact.elapsed(-90),viz.RELATIVE_WORLD)
Attached Files
File Type: zip selectingWithPhysicsShapes.zip (746 Bytes, 1047 views)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #3  
Old 12-07-2006, 09:10 AM
giancamati giancamati is offline
Member
 
Join Date: Jun 2006
Posts: 27
great

Thank you so much it works fine!.
Reply With Quote
Reply


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 10:22 AM.


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