View Full Version : Moving/grabbing 3D objects
kovitch
10-25-2011, 09:30 AM
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
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
You can use the viz.grab command to grab objects:
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 (http://kb.worldviz.com/articles/1500). That requires a configuration file that you create using the viztrackersetup (http://kb.worldviz.com/articles/1508) 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.
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.
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.