WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   viewpoint direction (https://forum.worldviz.com/showthread.php?t=5879)

bbb 10-30-2016 05:30 AM

viewpoint direction
 
Dear Jeff,
Is there a way to get participant's head direction in angles (degrees), which are not euler rotation ones, from some module or from the Oculus itself?
I'm basically trying to know the direction in degrees (not have to be degrees but i want to be able to understand there meaning) participant's are looking at and based on that i would like to know what they are looking at at the scene.

Thanks.

Jeff 10-31-2016 11:38 AM

It sounds like you maybe looking for the yaw component of the euler angle. The following example shows the yaw, pitch, and roll values every frame:

Code:

import viz
import vizact
import vizinfo

viz.go()

info = vizinfo.InfoPanel('Head Ori Data')
yaw = info.addLabelItem('yaw',viz.addText(''))
pitch = info.addLabelItem('pitch',viz.addText(''))
roll = info.addLabelItem('roll',viz.addText(''))

viz.add('dojo.osgb')

def updateInfo():
        ori = viz.MainView.getEuler()
        yaw.message('{:.2f}'.format(ori[0]))
        pitch.message('{:.2f}'.format(ori[1]))
        roll.message('{:.2f}'.format(ori[2]))

vizact.onupdate(0,updateInfo)


bbb 11-01-2016 01:49 AM

Hi Jeff,
I thought that myself but in an earlier post i asked you a question regarding the yaw of the euler angles and based on that i understood that i cannot use this so i guess i have some miss understanding, so i will ask again.
I asked you this: if i'm looking on the same thing from different positions in the scene, will i get the same euler angle? your answer was no. So, if i don't get the same euler angle for specific thing in the scene, how can i be able to conclude that from different positions i'm looking at the same thing, based on yaw?

I would appreciate a clarify and thank you for your efforts to solve my issue.

Jeff 11-01-2016 05:39 PM

Vizard's built-in functions for determining what objects are in view include the window.pickRect command and window.pick command. You can use the viz.intersect command to see if a line segment intersects objects in the scene.

The yaw rotation of the viewpoint or tracker is not enough information to determine what object(s) are in view. You would also need the object and viewpoint positions to determine this. And if the user is looking up or down the object might be in line with their yaw rotation but not be in view. There is not a built-in function but you could probably use commands from the Python math library or Vizard's vizmat library to help do these calculations on your own. However I'm not sure why you would go this route since the pickRect and pick commands are an easy way to determine what objects are in view.

bbb 11-02-2016 04:54 AM

Dear Jeff,
Is there a way to get the nodes that in the center of the view from pick command? since it gave me an error of "object is not iterable" when trying to use this like pickRect command.

Here is a sample code:

def objectOfInterest(normPos):

picked=viz.MainWindow.pick(normPos)
for node in picked:
if node==triangle:
print "triangle view"

Thanks.

Jeff 11-02-2016 01:33 PM

Here's an example that performs the pick command on the center of the window:

Code:

import viz
import vizact

viz.go()

viz.clearcolor(viz.SLATE)

soccerball = viz.addChild('soccerball.osgb',pos=[-1,1.8,2])
basketball = viz.addChild('basketball.osgb',pos=[0,1.8,2])
volleyball = viz.addChild('volleyball.osgb',pos=[1,1.8,2])

crosshair = viz.addTexQuad(parent=viz.SCREEN,texture=viz.add('crosshair.png'),pos=[0.5,0.5,0])

def pickObject():
        node = viz.pick(pos=[0.5,0.5])
        if node == soccerball:
                print 'soccerball'
        elif node == basketball:
                print 'basketball'
        elif node == volleyball:
                print 'volleyball'
        else:
                print 'none'
       
vizact.onupdate(0,pickObject)

Also, the gazetime example script in this thread maybe helpful.


All times are GMT -7. The time now is 07:30 AM.

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