View Single Post
  #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