WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   joystick position (https://forum.worldviz.com/showthread.php?t=4098)

nmohandes 01-08-2012 03:06 AM

joystick position
 
Hi

I am writing a program and i need to take the joystick position when clicking on certain objects on the screen

like the user will select one object from the screen and then rotate it and then move the joystick to select another object ...

I have the code that have the position and move on empty screen

import viz
import vizjoy
viz.go()
import vizinfo
#IMPORTANT: Need to add a joystick. This will return the first detected joystick
joy = vizjoy.add()
#Add textures
hand = viz.addTexture('hand.jpg')
#Add the texture quad for the joystick position
joystick = viz.addTexQuad(viz.SCREEN)
joystick.setScale([0.3,0.3,1])
#Set the joystick texture to the dot
joystick.texture(hand)
JOY_CENTER_X = 0.5
JOY_CENTER_Y = 0.35
JOY_SCALE = 10.0
#Joystick position has changed, update dot
def joymove(e):
joystick.setPosition(JOY_CENTER_X+(e.pos[0]),JOY_CENTER_Y-(e.pos[1]))

#Set all the joystick callbacks
viz.callback(vizjoy.MOVE_EVENT,joymove)


How i can select one specific object on the screen ... do some action ( rotate) and then select another one ..

any ideas or hints

thank you

Jeff 01-11-2012 01:47 PM

Take a look the viz.pick command. When you're not picking with the mouse you can specify the position on screen to perform the pick. In your case that's the quad position. Register a callback function using vizact.onupdate that calls the pick command every frame. If an object is returned then apply the action to it.

nmohandes 01-16-2012 10:03 AM

Thank you
I was able to pick using the joystick

def pickone(object):
object = viz.pick()
if object.valid():
pos = joystick.getPosition()
object.setEuler([90,0,0])
viz.callback(vizjoy.BUTTONDOWN_EVENT,pickone)
viz.callback(vizjoy.BUTTONUP_EVENT,buttonup)


All times are GMT -7. The time now is 11:14 AM.

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