WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Turn using keyboard when using Oculus (https://forum.worldviz.com/showthread.php?t=5581)

Seadna 12-11-2015 07:04 AM

Turn using keyboard when using Oculus
 
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:

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. These will explain how to use the vizconnect config file in your own script.


All times are GMT -7. The time now is 04:02 PM.

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