WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-12-2009, 12:15 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
For your elif block:

if link is not none: remove link
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #2  
Old 05-12-2009, 12:22 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Better. Replace elif with if.
Code:
def toggleLink():
	global link
	if link:
		#If link exits, stop grabbing
		link.remove()
		link = None

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

vizact.onpick(ball,toggleLink)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #3  
Old 05-13-2009, 01:09 AM
nasr nasr is offline
Member
 
Join Date: Apr 2009
Posts: 27
paul thank you very much for your reply.this is my full program
Code:
import viz

viz.go()

viz.MainView.setPosition(0,1.5,-4)
import viztracker
tracker = viztracker.MousePos()
myroom=viz.add('room.wrl')
#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 )
table=viz.add('table.wrl')
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:
		vizact.onpick(ball,toggleLink)

now i want to move the ball and the table seperately. now could you please tell me how to make the changes.
Reply With Quote
  #4  
Old 05-13-2009, 06:46 AM
nasr nasr is offline
Member
 
Join Date: Apr 2009
Posts: 27
vizmat.Distance(hand.getPosition(), ball.getPosition()) < .5: link = viz.grab( hand, ball )

vizact.onpick(ball,toggleLink)
paul

in the above code im able to grab the ball only. if im trying this loop with an if condition, after selecting the ball im not able to stop the ball how to change the code?
Reply With Quote
  #5  
Old 05-13-2009, 01:05 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
My last post from yesterday will fix your problem. Notice how I changed the elif to if in the toggleLink function.

Also, you will want to call toggleLink whenever the mouse button is pressed, so replace vizact.onpick with vizact.onmousebutton.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #6  
Old 05-13-2009, 01:45 PM
nasr nasr is offline
Member
 
Join Date: Apr 2009
Posts: 27
paul thanks for your quick reply... if i want to rotate the object how can i do it?
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any ideas on linking chess 3ds file with source code? djones1010 Vizard 1 04-24-2009 10:56 PM
Trying to integrate Source Code with Vizard djones1010 Vizard 1 03-10-2009 03:58 PM
Vizard Tip of the Month: Use Tasks to Simplify your Code Gladsomebeast Vizard 5 05-02-2008 05:30 PM
3D Music Interface Psirus Vizard 3 02-26-2008 12:48 PM
Vizard Crashes: causes are hard to determine, possible problem with the viz code vr_boyko Vizard 1 01-07-2005 11:52 AM


All times are GMT -7. The time now is 06:04 PM.


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