WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-09-2009, 06:39 AM
nasr nasr is offline
Member
 
Join Date: Apr 2009
Posts: 27
how to move seperately?

im trying to move the marker and ball seperately but both are moving simultaneously...how can i move both of them seperately?
<code>
import viz
viz.go()

import vizinfo
info = vizinfo.add( 'Demonstrates the single function creation of a grab object relationship.\nThe arrow keys move the hand object.\nThe w, a, s, d, keys rotate the hand.\nThe t, g, h, f, keys rotate the ball.' )

viz.clearcolor(viz.GRAY)


#Add the object that will do the grabbing
hand = viz.add( 'marker.wrl' )
hand.translate( 0, 1.5, 3 )

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

link = None #The handle to the link object

#Grab or let go of the ball
def toggleLink():
global link
if link:
#If link exits, stop grabbing
link.remove()
link = None
else:
#If no link, grab the ball with the hand
link = viz.grab( hand, ball )

vizact.onkeydown(' ',toggleLink)


#Setup keyboard control of hand and ball
vizact.whilekeydown(viz.KEY_UP,hand.translate,0,vi zact.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,v izact.elapsed(1),0,0,viz.RELATIVE_WORLD)
vizact.whilekeydown(viz.KEY_LEFT,hand.translate,vi zact.elapsed(-1),0,0,viz.RELATIVE_WORLD)


vizact.whilekeydown('w',hand.rotate,1,0,0,vizact.e lapsed(90),viz.RELATIVE_WORLD)
vizact.whilekeydown('s',hand.rotate,1,0,0,vizact.e lapsed(-90),viz.RELATIVE_WORLD)
vizact.whilekeydown('d',hand.rotate,0,1,0,vizact.e lapsed(90),viz.RELATIVE_WORLD)
vizact.whilekeydown('a',hand.rotate,0,1,0,vizact.e lapsed(-90),viz.RELATIVE_WORLD)


vizact.whilekeydown('t',ball.rotate,1,0,0,vizact.e lapsed(90),viz.RELATIVE_WORLD)
vizact.whilekeydown('g',ball.rotate,1,0,0,vizact.e lapsed(-90),viz.RELATIVE_WORLD)
vizact.whilekeydown('h',ball.rotate,0,1,0,vizact.e lapsed(90),viz.RELATIVE_WORLD)
vizact.whilekeydown('f',ball.rotate,0,1,0,vizact.e lapsed(-90),viz.RELATIVE_WORLD)
</code>
Reply With Quote
  #2  
Old 05-10-2009, 04:07 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,453
The code tags you used were not correct. Try using [code][/code] to preserve the indentation

The script you showed only moves the marker with keypresses. The ball can be linked to the marker and they will move together. In order to move the ball seperately you would have to define some keys that translate the ball just as its done for the marker
Reply With Quote
  #3  
Old 05-11-2009, 01:57 AM
nasr nasr is offline
Member
 
Join Date: Apr 2009
Posts: 27
how to disable the link between the first object and move the second object

Code:
def toggleLink():
    global link
    if link:
        #If link exits, stop grabbing
        link.remove()
        link = None
    else:
        #If no link, grab the ball with the hand
        link = viz.grab( hand,ball )
       
vizact.onkeydown(' ',toggleLink)
jeff thankyou very much for your suggestions..
im using more than one object. when im moving the first object with the marker its perfect but when im leaving the first object and trying to move the second object the first object is still moving along with the cursor. how can disable moving the first object and just move the second object..
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
how to move front and back nasr Vizard 2 05-11-2009 02:00 AM
how to pick up the object, move and rotate using mouse nasr Vizard 5 05-05-2009 03:11 AM
move animated camera around corner question nlfrnassimi Vizard 1 02-23-2009 09:45 AM
node3d.visible(viz.OFF) Problem Sandro Holzer Vizard 6 02-10-2009 06:20 AM
Move Objects Johannes Vizard 8 01-19-2005 10:15 AM


All times are GMT -7. The time now is 03:52 AM.


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