View Single Post
  #5  
Old 03-15-2016, 09:57 PM
prilpi prilpi is offline
Member
 
Join Date: Feb 2016
Posts: 11
Well..

I'm kinda new to this so i try to catch up with you..
Thing is i dont need to import vizconnect in for the oculus or the controller to work. vizard detects them

In that case (if i understand correctly) why is the vizconnect config matters ?
Is there a vizconnect config to each scene ?

If i get it right there is a kind of conflict with the mainview link (?)
(linked to the oculus / linked to the xbox controller)

I have the feeling its a minor thing i'm missing here
I just need the oculus for the view and the controller to walk in the maze demo instead of the keypad (sounds simple..

Attached is the script for the controller
(i disabled the oculus) and the controller works fine.
Again, when i enables the oculus the controller doesn't respond (thou all its buttons responding..)

Guess i just need the correct script for running them both together

the script i use -
(basicly connect oculus + maze + controller):

import viz
import vizact
import vizcam
import sys
import vizinfo
import oculus

# Initialize window
viz.setMultiSample(8)
viz.go()
"""
# Setup Oculus Rift HMD
hmd = oculus.Rift()
if not hmd.getSensor():
sys.exit('Oculus Rift not detected')

# Setup navigation node and link to main view
navigationNode = viz.addGroup()
viewLink = viz.link(navigationNode,viz.MainView)
viewLink.preMultLinkable(hmd.getSensor())

# Apply user profile eye height to view
profile = hmd.getProfile()
if profile:
viewLink.setOffset([0,profile.eyeHeight,0])
else:
viewLink.setOffset([0,1.8,0])
"""
# Add environment model
viz.addChild('maze.osgb')

# Load DirectInput plug-in
dinput = viz.add('DirectInput.dle')

# Add first available joystick
joy = dinput.addJoystick()

# Set dead zone threshold so small movements of joystick are ignored
joy.setDeadZone(0.2)

def UpdateMovement():

elapsed = viz.elapsed()

# Get the joystick position
x,y,z = joy.getPosition()

# Get the twist of the joystick
twist = joy.getTwist()

# Move the viewpoint based on xy-axis value
move_amount = 5 * elapsed
viz.MainView.move([x*move_amount,0,y*move_amount], viz.BODY_ORI)
# Turn the viewpoint left/right based on twist value
turn_amount = 90 * elapsed
viz.MainView.setEuler([twist*turn_amount,0,0], viz.BODY_ORI, viz.REL_PARENT)

vizact.ontimer(0, UpdateMovement)
Reply With Quote