WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Moving/grabbing 3D objects (https://forum.worldviz.com/showthread.php?t=3975)

kovitch 10-25-2011 09:30 AM

Moving/grabbing 3D objects
 
Hi,

Is there any kind of example (something to start from) to move&grab objects from a place to another with the mouse, like in the following video:

http://www.youtube.com/watch?v=7qHPwqSsFZU

Best regards,

Alex.

amith 12-01-2011 02:00 PM

how to grab and move objects using mouse
 
Can anyone please help me on how i can grab and move objects in vizard 4 using mouse.

Waiting for a reply.Thanks a ton in advance.

Regards

Amith

Jeff 12-01-2011 04:48 PM

You can use the viz.grab command to grab objects:
Code:

import viz
import vizact
import viztracker

viz.setMultiSample(4)
viz.fov(60)
viz.go()

viz.addChild('ground.osgb')
viz.clearcolor(viz.GRAY)

#Add the object that will do the grabbing
hand = viz.addChild('marker.wrl')

#link the hand to a 3D mousetracker
mouseTracker = viztracker.MouseTracker()
mouseTracker.scroll(-8)
viz.link(mouseTracker,hand)

#turn off mouse navigation and hide cursor
viz.mouse(viz.OFF)
viz.mouse.setVisible(viz.OFF)

#Add the object that the marker will grab
ball = viz.addChild( 'basketball.osgb',pos=[0.5,1.8,2.5],scale=[2,2,2])

link = None #The handle to the link object
def grabBall():
        global link
        link = viz.grab( hand, ball )
               
def releaseBall():
        global link
        link.remove()
        link = None
       
vizact.onmousedown(viz.MOUSEBUTTON_LEFT,grabBall)
vizact.onmouseup(viz.MOUSEBUTTON_LEFT,releaseBall)

If you want a hand model that's animated when it grabs take a look at Grabbing with viztracker. That requires a configuration file that you create using the viztrackersetup utility. Make sure have Keybd w/ Mouse Hands set for tracker type, as shown in the image.

amith 12-04-2011 12:11 AM

Thank you so much for the reply.

Do you have any idea about how i can do the similar thing using a Wii.

Thanks a ton in advance.

Jeff 12-05-2011 07:37 PM

There's documentation for the wiimote plug-in the Vizard Help. Also if you search for wiimote in these forums you'll find some example code. You can use vizact.onupdate or vizact.ontimer to register a callback function that gets called every frame. Within your function you can update the hand position based on wiimote data.


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

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