Log in

View Full Version : Turn using keyboard when using Oculus


Seadna
12-11-2015, 07:04 AM
Hi guys,

I cannot figure out how to get the viewpoint to turn using a key binding. I can obviously turn my head in the oculus rift, but this is not practical for the application. I need to be able to turn using a key on the keyboard (or controller). Is this possible? I'm using the sample Oculus code that came with Vizard.

Any help much appreciated,

Seadna.

haohaoxuexi1
12-11-2015, 08:51 AM
I think there is a demo using keyboard to control a BMW car, and that one should work

mamort
12-11-2015, 02:57 PM
have a look at "vizconnect" section in particular input, tracker and transport section. I think from memory you want to tie a keyboard input to the driving transport or maybe even pivot depends if you want to move around scene or just rotate.

Seadna
01-11-2016, 04:19 AM
Could you provide an example code snippet of how this would be done? I'm new to python and currently learning it through using Vizard.

Jeff
01-11-2016, 05:37 AM
Take a look at the 'Oculus Desktop Configuration' option in the vizconnect presets page. That adds a transport controlled by keyboard input signals.

Seadna
01-11-2016, 07:22 AM
Great I think i have found what I need. Now i need to figure out how to fit it into what i have already coded.

Thank you Jeff.

Seadna
01-11-2016, 08:15 AM
OK I'm struggling with getting this into my code:

# Setup arrow key navigation
MOVE_SPEED = 2.0
def UpdateView():
yaw,pitch,roll = viewLink.getEuler()
m = viz.Matrix.euler(yaw,0,0)
dm = viz.getFrameElapsed() * MOVE_SPEED
if viz.key.isDown(KEYS['forward']):
m.preTrans([0,0,dm])
if viz.key.isDown(KEYS['back']):
m.preTrans([0,0,-dm])
if viz.key.isDown(KEYS['left']):
m.preTrans([-dm,0,0])
if viz.key.isDown(KEYS['right']):
m.preTrans([dm,0,0])
if viz.key.isDown(KEYS['up']):
m.preTrans([0,dm,0])
if viz.key.isDown(KEYS['down']):
m.preTrans([0,-dm,0])
if viz.key.isDown(KEYS['lt']):
m.turnLeft
if viz.key.isDown(KEYS['rt']):
m.turnRight
navigationNode.setPosition(m.getPosition(), viz.REL_PARENT)

vizact.ontimer(0,UpdateView)


You can see the lines I have put in with m.turnLeft and m.turnRight. These do not work like in the vizconnect example. I'm sure i need to add much more code or replace what I have here but there is so much in there that i dont know what to do with it.

I tried putting in m.preEuler(0,dm,0) and adding navigationMode.setEuler(m.getEuler(), viz.REL_PARENT) but that causes the view to rapidly spin constantly.

Jeff
01-12-2016, 01:48 AM
Is there a reason you're trying to do this in your own script rather than use vizconnect?

Seadna
01-12-2016, 04:04 AM
I hadn't used visconnect until you mentioned it here and I already have a lot of script put together. I'm not sure how to integrate my script with the mass of script that visconnect created or how to take the script I need from visconnect to integrate with my own.

Its seems like it should be much easier than this but then I'm quite new to this so i don't really know. I have learned everything so far from looking at the demos and samples and the help file that came with Vizard, but i can't find out how to do this.

Any help would be much appreciated!

Jeff
01-12-2016, 10:54 PM
Take a look at the vizconnect tutorials (http://docs.worldviz.com/vizard/#vizconnect_tutorial_displays_and_trackers.htm). These will explain how to use the vizconnect config file in your own script.