WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   how to pick up the object, move and rotate using mouse (https://forum.worldviz.com/showthread.php?t=1987)

nasr 04-26-2009 11:35 PM

how to pick up the object, move and rotate using mouse
 
hello all,

im trying to develop an application using which i have to pick, drag, move and rotate the object using mouse...i have download the boxstacker and turbine demos for grabbing the objects...but they are executing when im launching the applications... could some one plz tell the code how this could be accomplished..


thankyou..

Jeff 04-27-2009 05:15 PM

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)


nasr 05-02-2009 11:59 PM

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?
Quote:

Originally Posted by Jeff (Post 7747)
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)



Jeff 05-04-2009 09:10 AM

It works, you just have to line up the marker with the ball in the z coordinate. In order to do that you need to move the mouse wheel until the marker is right on top of the ball.

nasr 05-05-2009 12:34 AM

its working....thankyou jefff..

nasr 05-05-2009 03:11 AM

jeff....how rotation can be applied for the ball using the mouse.....i want to rotate the object...is it possible?


All times are GMT -7. The time now is 01:57 PM.

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