WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 07-03-2016, 06:03 AM
dcnieho dcnieho is offline
Join Date: Feb 2011
Posts: 59
Different projection matrix per viewpoint

Dear Jeff,

I have implemented a solution where i can change the viewpoint with a toggle button, so i can see a topview instead of a view through the "virtual eyes". In very brief:
BirdEyeView   = viz.addView()
BirdEyeView.setPosition([0, 50, 0])	# move camera up
BirdEyeView.lookAt([0,0,0], 0)
I would however like to view the scene in topview with an orthographic projection matrix instead of the usual stereo perspective setup (this is in the Vive HMD). How would i go about setting the orthographic projection? It seems projection is set for a window, not a view.

In that case, is there a way to backup the stereo projection setup and later restore it? I see you can get the projection matrix, but which one should i get, left eye, right eye, both eyes, all? the <window>.setProjectionMatrix documentation suggests if specifying a matrix for both eyes, it is automatically adjusted for the individual eyes... (NB: i see that the steamVR module has an apply method to set the projection matrix, but i am searching for a general solution, that would e.g. also work when developing on the desktop with a single non-stereo window.)

Thanks and all the best,
Reply With Quote
Old 07-03-2016, 08:06 AM
dcnieho dcnieho is offline
Join Date: Feb 2011
Posts: 59
Dear Jeff,

Perhaps it is useful if i provide some more background.

I am trying to get some items i render with parent=viz.SCREEN or parent=viz.ORTHO to show up on the Vive.

Since my last post, i have found this: So I am trying a canvas. But i'd like the vizshapes i parent to this canvas to be rendered with orthographic projection. If i set
canvas = viz.addGUICanvas()
canvas.setReferenceFrame(viz.RF_VIEW) # with or without doesn't make a difference
my elements only show up on the desktop view of the vive that is automatically opened, not the vive itself.
Does work, but then its a perspective rendering.

Could you let me know how i can get things rendered orthographically to show up on the Vive?
Reply With Quote
Old 07-07-2016, 04:59 AM
dcnieho dcnieho is offline
Join Date: Feb 2011
Posts: 59
And i have a related question. In an overlay, the sizes I should specify my objects in are in pixels, after setting the overlay to the correct resolution. I am having difficulty getting the size of the HMD's screen.

With the vive, I open a window with the default vizconnect setup for the Vive. I then try to get screen resolution:
print viz.MainWindow.getSize(mode=viz.WINDOW_PIXELS)
What is returned is [3840.0, 1080.0], which is the resolution of my desktop (two 1920x1080 screens, side by side) and not the Vive's resolution of 1080x1200 per eye. Similarly, the returned aspect ratio is 1.77777777778, which is the aspect ratio of one of my 1920x1080 screens.

Would you know how i can get the size of the Vive (or other HMD's) screen, instead of of those automatically opened desktop windows? And specifically, how to get the size of a single eye's screen, which is what I (think I) need?

Reply With Quote
Old 07-07-2016, 05:16 AM
dcnieho dcnieho is offline
Join Date: Feb 2011
Posts: 59
Sorry to keep adding. to the last message:
specifically, i am trying to get the following info:

w,h = viz.MainWindow.getSize()
params.resolution = (w,h)
params.refreshRate= viz.getOption('viz.monitor.refresh_rate',type=int)
params.FOVy    = viz.MainWindow.getVerticalFOV()
params.aspectr = viz.MainWindow.getAspectRatio()
print (params.resolution,params.refreshRate,params.FOVy,params.aspectr)
What i get is:
((3840, 1080), 60, 40.0, 1.7777777777777775)

which is not the Vive, but my desktop. How to get each of these from the Vive?

This is what i get after calling vizconnect.go(), with the vive setup file as argument (which works fine, 3D world looks good)
Reply With Quote
Old 07-08-2016, 01:13 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,466
I'll check in with our developers and get back to you on both questions, orthographic projection and getting Vive specs. I'm not sure there is a Vizard command that will return the resolution and FOV of the Vive. You can use vizconnect or vizard commands to find out if a Vive is connected. Then you could retrieve specs saved to variables or a file. Would that work?
Reply With Quote
Old 07-08-2016, 01:41 AM
dcnieho dcnieho is offline
Join Date: Feb 2011
Posts: 59
Hi Jeff,

Thanks for getting back to me! First off, is it perhaps better if we handle this through a support ticket and then post the final results here?

I have hacked together the following to get Vive specs:
display_node = vizconnect.getRawDisplay('main_display').displayNode
	if type(display_node.getSensor()).__name__=='SteamVRHMD':
		resolution = (1080.*2,1200.)
		refreshRate= 90.
		# get FOVy and aspectr from the Vive's projection matrices
		import vizmat
		left = a.getPerspective()
		right = a.getPerspective()
		FOVy 	  = (left[0]+right[0])/2.
		aspectr   = (left[1]+right[1])/2.
That is, i hardcoded the resolution and refresh rate as i saw no way to query that (the getRenderSize() size call returns something bigger than the screen), but i got the FOVy and aspectratio from the Vive's projection matrix. This as i could not find clear info about the FoV anywhere, only rough estimates. (Interestingly enough, they weren't exactly the same for the two eyes, hence the averaging.) I do wonder however why Vizard returns information about the auxiliary screen when the user wants to work with the HMD, its counter intuitive and, frankly, a little useless (from my point of view at least). Perhaps augmenting the auxiliary view is handy to give observers extra info, but there should be a way to distinguish the HMD screen from the auxiliary screen, and query then separately, I think.

This also leaves me with a new question. In this situation, should i open the overlay (setRenderWorldOverlay())with the resolution of the two screens combined (i.e., 2160x1200), or should i open it at a single eye size, 1080x1200? When i do the latter, things are positioned way off in the HMD, so i used the former which seems to work ok. Its however hard to know if things are positioned correctly, since we can't use a ruler to measure.

Thank you and all the best,
Reply With Quote
Old 07-08-2016, 05:06 AM
dcnieho dcnieho is offline
Join Date: Feb 2011
Posts: 59
Hi Jeff,

I just realize that more is affected by the fact that viz.MainWindow refers to the auxiliary window on the desktop: calls to functions such as viz.MainWindow.worldToScreen() don't do the right thing either, returning values in desktop screen instead of HMD screen pixel-coordinates.

I hope there is some "he, dude, tell me about the HMD screen please" flag somewhere

All the best,
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding Viconnect viewpoint rajnishv Precision Position Tracker (PPT) 3 03-20-2017 11:03 PM
Regarding viewpoint with vizconfig,addFloatRangeItem&Storing viewpoint in PREFERENCES rajnishv Vizard 0 06-27-2016 03:57 AM
Projection Matrix (onto oblique near plane) andrewjworz Vizard 1 07-13-2012 09:10 AM
projection matrix control & child window kwkim Vizard 0 08-31-2011 12:53 AM

All times are GMT -7. The time now is 05:00 AM.

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