WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-05-2008, 01:53 AM
stefs stefs is offline
Member
 
Join Date: Mar 2008
Posts: 10
Example code for VizCave

Hi everybody,
I intend to create dynamic off-axis projections on a table-top 3D display and understand that the vizcave object provides all needed functionality for this. Unfortunately I do not get it to work. In particular when using manual update of the head position, I get unexpected results. I did not find some example code on the web or in this forum. Below is my simple beginner code to explore the vizcave functionality. Any pointers?
thanks
stefs

import viz
import viztracker
import vizcave

viz.go()

c0 = -2,3,0
c1 = 2,3,0
c2 = 2,0,0
c3 = -2,0,0
vp = -1, 1.8, -6

track = viztracker.add()
track.setPosition(vp)

cave = vizcave.Cave()
FrontWall = vizcave.Wall(upperLeft=c0,upperRight=c1,lowerLeft= c3,lowerRight=c2,name='Front Wall' )
cave.addWall(FrontWall, mask =None, window = viz.MainWindow)

def mytimer(num):
global cave
tposition = track.getPosition()
print tposition
cave.update(pos = tposition)

def drawWall():
viz.startlayer(viz.LINE_STRIP)
viz.vertex(c0)
viz.vertex(c1)
viz.vertex(c2)
viz.vertex(c3)
viz.vertex(c0)
viz.vertexcolor(1,1,0.1)
viz.startlayer(viz.LINES)
viz.vertex(c0)
viz.vertex(vp)
viz.vertex(c1)
viz.vertex(vp)
viz.vertex(c2)
viz.vertex(vp)
viz.vertex(c3)
viz.vertex(vp)
wall_frame = viz.endlayer()

viz.add('tut_ground.wrl')
mini = viz.add("mini.osgx")
mini.translate(0,1,-1)
mini.setScale(0.5, 0.5, 0.5)
mini.add(vizact.spin(0,1,0,15))
drawWall()

viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.01,viz.FOREVER)
Reply With Quote
  #2  
Old 03-05-2008, 02:46 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Are the wall corner position values in the same coordinate frame as your track object?
Reply With Quote
  #3  
Old 03-05-2008, 11:51 PM
stefs stefs is offline
Member
 
Join Date: Mar 2008
Posts: 10
Example code for VizCave

The printout of tposition shows the coordinates are in the same system.
I also tried to cave.update(pos=vp), with constant vp as defined along with the corner points. Should give me a slightly skewed projection - yet it doesn't.
I am currently using the trial/evaluation version of Vizard - can this explain things?
Reply With Quote
  #4  
Old 03-06-2008, 09:17 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
It seems to work fine for me. I created this small test that uses the arrow keys to move the view left/right/up/down. As you move to the edges of the cave wall, the image starts to skew.
Code:
import viz
import vizcave

viz.go()

c0 = -2,3,0
c1 = 2,3,0
c2 = 2,0,0
c3 = -2,0,0
vp = [0, 1.8, -2]

cave = vizcave.Cave()
FrontWall = vizcave.Wall(upperLeft=c0,upperRight=c1,lowerLeft= c3,lowerRight=c2,name='Front Wall' )
cave.addWall(FrontWall, mask =None, window = viz.MainWindow)

def UpdateCave():
	if viz.key.isDown(viz.KEY_LEFT):
		vp[0] -= 1*viz.elapsed()
	if viz.key.isDown(viz.KEY_RIGHT):
		vp[0] += 1*viz.elapsed()
	if viz.key.isDown(viz.KEY_UP):
		vp[1] += 1*viz.elapsed()
	if viz.key.isDown(viz.KEY_DOWN):
		vp[1] -= 1*viz.elapsed()
	cave.update(pos = vp)
	viz.MainView.translate(vp)
vizact.ontimer(0,UpdateCave)

viz.add('gallery.ive')
Reply With Quote
  #5  
Old 03-07-2008, 04:52 AM
stefs stefs is offline
Member
 
Join Date: Mar 2008
Posts: 10
VizCave problem resolved

Thank you very much for providing this code, which helped me to resolve the problem. Apparently one has to update the current head position i two different places to make this work. BOTH in the cave object (cave.update()) AND in the main view (viz.MainView.translate()). This appears a little counterintuitive - but once you know it you can live with it...
Thanks again,
stefs
Reply With Quote
  #6  
Old 03-07-2008, 08:51 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, this seems to confuse a lot of people. The reason is that the the cave.update() function only needs to know the physical head position. The virtual head position can be something completely different, in this case it happens to be the same as the physical head position.
Reply With Quote
  #7  
Old 01-08-2013, 11:43 AM
jpriede jpriede is offline
Member
 
Join Date: Dec 2012
Posts: 10
Quote:
Originally Posted by farshizzo View Post
Yes, this seems to confuse a lot of people. The reason is that the the cave.update() function only needs to know the physical head position. The virtual head position can be something completely different, in this case it happens to be the same as the physical head position.
I am not understanding this. Any CAVE environment should have the virtual camera in the same position of the physical head position (relative to the CAVE frame of reference), right? If the virtual and physical head positions differ (again, relative to the CAVE frame of reference), than the perspective will not work out.... it would be like sitting in the front row at a movie theatre. In order for it to look right, the camera must be where your viewpoint is.

The CAVE can be moved around anywhere within the environment, but that doesn't change the virtual or physical head locations relative to the CAVE frame of reference, right?
Reply With Quote
Reply

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
Same code in different files but one not working tacbob Vizard 3 03-05-2007 09:30 AM
Vizard 3.0 beta activation code vnacooper Vizard 3 09-21-2006 12:03 PM
starter code for 3 ppt lights vsully Vizard 1 09-21-2005 11:23 AM
Code Jumps under load Johannes Vizard 11 03-29-2005 12:27 PM
Vizard Crashes: causes are hard to determine, possible problem with the viz code vr_boyko Vizard 1 01-07-2005 10:52 AM


All times are GMT -7. The time now is 10:22 AM.


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