PDA

View Full Version : Use Controller as Grabing tool


Patrick
10-20-2016, 05:55 AM
Hello,
im trying to use the controller as a tracker.
the basic idea is i want to move the right/left arm with a controller to grab things and replace them in my 3d world.
My program currently runs via a oculus rift dk2 display and has the dk2 tracker to move around in the world.
What i am basicly aiming for is to add an avatar whos arm i can move with the controller. But all i found was just the input which reacts to my controller orders but i cant connect to for example the left arm of my "head and arms" avatar cause you can only connect trackers to body parts of avatars, as it seems.
I dont want to create a transport in via i want to controll a body part of my avatar to prevent confusions.
So i assume i have to create a new tracker right? do i have to use an merged tracker and give him the Xbox settings? if thats the case how do i setup that merge tracker? or am i completely wrong and i have to do sth completely different?

Thanks in advance
Patrick

Jeff
10-20-2016, 04:44 PM
One way to do this is create a group tracker for each hand in the trackers tab. Then apply the group tracker to the avatar hand in the animator section of the avatar. In the events tab create events for moving the hand in different directions and map the events to controller signals. Then in either the postInit function of the vizconnect file or in the calling script, handle the events and update the group tracker position. I've attached an example that moves the hand with keypresses instead of Xbox controller signals. The code to update the group hand tracker is in the postInit function. Press 1 and 2 to move the hand in and out.

Patrick
10-21-2016, 06:34 AM
Ok i now understand how you can assign the keys to the tracker via the input but i am missing the code for that

def update(event):
if rawInput['keyboard'].isButtonDown(3):
event.sendEvent(e=viz.Event(mag=1))
rawEvent[_name].setUpdateFunction(update)

basicly here i realise that .isButtonDown(3): is the command for the 2 key on the keyboard
but how do i for example trigger the B button on my xbox controller? i just dont seem to find the documentation for that.
All i found was the joystick basics: http://docs.worldviz.com/vizard/Vizjoy_basics.htm

I added the joystick as input to your example and tried to setup the event code afterwards but i cant really complete these lines

def update (event):
if raw_input['joystick'] <-i guess here is sth missing
event.sendEvent(e=viz.Event(mag=1))
rawEvent[_name].setUpdateFunction(update)

Sorry for bothering with that cause it feels like that must be one of the simpliest things but i just dont know how to go on :confused:
really appreciate your help

Patrick
10-31-2016, 02:52 AM
After a bit more trying i get the following Error:
TypeError: 'function' object has no attribute '__getitem__' in my move_hand_out Event Code
I just added the .XBOX_BUTTON_DPAD_UP line in
I attached my Input code and the event code maybe you could help me there
846
847

Jeff
10-31-2016, 04:19 PM
The vizconnect configuration file I attached before can be modified to move the hand in/out using the Xbox controller without manually changing the code. Run the config and go to the advanced menu. In the Inputs tab add the Xbox controller. In the Events tab, press the mapping button for each of the events. Then change the input from keyboard to xbox controller and assign the button that will trigger the event.

Patrick
11-01-2016, 02:25 AM
Worked perfectly fine - thank you very much ;)