Exemplo n.º 1
0
    def __init__(self,
                 config=None,
                 planeName='floor',
                 isAFloor=1,
                 caveCornersFileName=None):

        self.config = config

        self.cave = vizcave.Cave()

        self.caveCornersFileName = caveCornersFileName
        self.cave.load(self.caveCornersFileName)

        self.cornerCoordinates_cIdx = [[0, 0, 0]] * 4

        #The powerwall, see vizard docs for info on powerwall
        self.powerwall = None

        self.planeName = planeName
        self.isAFloor = isAFloor

        ### Define the cave powerwall boundries in the world###
        if (None == caveCornersFileName):
            print 'Using default caveCorners'
            self.powerwall = vizcave.Wall(upperLeft=[-1, 0, 1],
                                          upperRight=[1, 0, 1],
                                          lowerRight=[1, 0, -1],
                                          lowerLeft=[-1, 0, -1],
                                          name=self.planeName)
        else:
            self.cave = vizcave.Cave()
            # This loads the contents of the file directly into the cave object
            self.cave.load(
                self.caveCornersFileName
            )  #if None is not self.caveWallFileName else self.cave.addWall(self.powerwall)
Exemplo n.º 2
0
    def __init__(self):
        viz.EventClass.__init__(self)

        self.EH = 1.2
        Proj_Dist = 1.0  #front projection distance to Eye

        Proj_V_F = 1.115  #vertical extent of projection (m)
        Proj_H_F = 1.985  #1.96#horizontal extent of projection (m)

        Proj_HfG = .665  #Front projection height from ground.

        FB = Proj_HfG  #FrontBottom
        FT = Proj_HfG + Proj_V_F  #FrontTop

        FL = -Proj_H_F / 2  #Front Left
        FR = Proj_H_F / 2  #Front Right

        FC0 = FL, FB, Proj_Dist  # Front  Wall: FC0,FC1,FC2,FC3
        FC1 = FR, FB, Proj_Dist
        FC2 = FL, FT, Proj_Dist
        FC3 = FR, FT, Proj_Dist

        self.FrontWall = vizcave.Wall(upperLeft=FC2,
                                      upperRight=FC3,
                                      lowerLeft=FC0,
                                      lowerRight=FC1,
                                      name='Front Wall')  #Create front wall

        viz.setMultiSample(8)  #set anti-aliasing

        #Initialize graphics window
        viz.go()
        #	viz.eyeheight(1.2)
        #for monitor in viz.window.getMonitorList():
        #    print monitor.name
        #    print '   ',monitor

        viz.window.setFullscreenMonitor(2)
        viz.window.setFullscreen(viz.ON)

        self.cave = vizcave.Cave(stereo=0)
        self.cave.addWall(self.FrontWall)  #,window=self.frontWindow)

        # print ("1_N: ", self.cave.getNearPlane()) #default is [.1, -1.]
        # print ("1_F: ", self.cave.getFarPlane())

        #set near and far plane.
        self.cave.setNearPlane(1.0)
        self.cave.setFarPlane(100.0)

        view = viz.MainView

        self.track = viztracker.Keyboard6DOF()  #tracker object
        self.track.setPosition(0, self.EH, 0)
        viz.link(self.track, view)  #linked to mainview
        self.cave.setTracker(pos=self.track)
        ##Create CaveView object for manipulating the entire cave environment
        ##The caveorigin is a node that can be adjusted to move the entire cave around the virtual environment, it needs a tracker object to initialise it.
        self.caveview = vizcave.CaveView(self.track)
            def config_wall(wall_config, window):
                points = wall_config[WALL_CORNERS]
                cluster_client_id = wall_config[WALL_CLUSTER_ID]
                monitor_id = wall_config[WALL_MONITOR_ID]

                new_wall = vizcave.Wall(upperLeft=points[0],
                                        upperRight=points[1],
                                        lowerLeft=points[2],
                                        lowerRight=points[3],
                                        name=wall_config[WALL_NAME])

                cave.addWall(new_wall, mask=cluster_client_id, window=window)

                with viz.cluster.MaskedContext(cluster_client_id):
                    viz.window.setFullscreenMonitor(monitor_id)
                    _window.setStereoSwap(False)
                    viz.window.setFullscreen(True)
Exemplo n.º 4
0
    def updatePowerwall(self):

        if (self.cave == None):
            self.cave = vizcave.Cave()
        else:
            self.cave.removeWall(self.powerwall)
            self.cave.clear()

        self.powerwall = vizcave.Wall(
            upperLeft=self.cornerCoordinates_cIdx[0],
            upperRight=self.cornerCoordinates_cIdx[1],
            lowerRight=self.cornerCoordinates_cIdx[2],
            lowerLeft=self.cornerCoordinates_cIdx[3],
            name=self.planeName)

        print "Updating powerwall to reflect new corner positions"

        self.cave.addWall(self.powerwall)
        self.cave.update()
        self.cave.save('caveWallDimensions.cave')
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawDisplay = vizconnect.getRawDisplayDict()
	

	#VC: initialize a new display
	_name = 'cave_manual_configuration'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init which needs to happen before viz.go
		if initFlag&vizconnect.INIT_PREVIZGO:
			#viz.setOption('viz.stereo', viz.QUAD_BUFFER)
			viz.setOption('viz.fullscreen', 1)
			viz.setOption('viz.antialias', 8)
	
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			frontWall = [1,2]
			rightWall = [3,4]
			backWall = -1
			leftWall = [5,6]
			floor = -1
			ceiling = -1
			frontImageWidth = 3.6
			imageHeight = 2.5
			imageRise = 0.02
			originLeft = 1.725
			originRight = 2.205
			sideImageWidth = 4
			shiftRight = 0
			shiftUp = 0
			shiftForward = 0
			stereo = viz.QUAD_BUFFER
			frontWallSwapStereo = False
			rightWallSwapStereo = False
			backWallSwapStereo = False
			leftWallSwapStereo = False
			floorSwapStereo = False
			ceilingSwapStereo = False
			
			#VC: create the raw object
			# Create a cave object
			import vizcave
			cave = vizcave.Cave(stereo=stereo)
			
			# get an origin node
			originName = _name
			initGroups(vizconnect.INIT_INDEPENDENT, [originName])# ensure it's been created
			originNode = vizconnect.getGroup(originName).getNode3d()
			
			if sideImageWidth == 0:
				sideImageWidth = frontImageWidth
			
			# extra configuration options to more explicitly control which wall goes where.
			frontWallClientIndex=-1
			rightWallClientIndex=-1
			backWallClientIndex=-1
			leftWallClientIndex=-1
			floorClientIndex=-1
			ceilingClientIndex=-1
			
			# get the originLeft angle from the origin measurements
			import math
			aOR = math.pi/4.0
			aAOR = (originRight**2 - originLeft**2 - frontImageWidth**2)/(-2*originLeft*frontImageWidth)
			if abs(aAOR) <= 1:
				aOR = math.acos(aAOR)
			
			# convert the angle to front and right shifts
			Sr =-(math.cos(aOR)*originLeft-frontImageWidth/2.0)
			Sf = (math.sin(aOR)*originLeft-sideImageWidth/2.0)
			
			# find left/right, up/down, front/back (x,y,z) extent of caves
			R = frontImageWidth/2.0+Sr+shiftRight# right
			L =-frontImageWidth/2.0+Sr+shiftRight# left
			U = imageRise+imageHeight+shiftUp# up/top
			D = imageRise+shiftUp# bottom/down
			F = sideImageWidth/2.0+Sf+shiftForward# front
			B =-sideImageWidth/2.0+Sf+shiftForward# back
			
			# find corners
			# e.g.
			# Front Wall: C1,C2,C5,C6
			# Left  Wall: C0,C1,C4,C5
			# Right Wall: C2,C3,C6,C7
			C0 = L, U, B
			C1 = L, U, F
			C2 = R, U, F
			C3 = R, U, B
			C4 = L, D, B
			C5 = L, D, F
			C6 = R, D, F
			C7 = R, D, B
			
			clients = 0
			
			#Create front wall
			if frontWall >= 0:
				wall = vizcave.Wall(	upperLeft=C1,
										upperRight=C2,
										lowerLeft=C5,
										lowerRight=C6,
										name='Front Wall' )
				
				if frontWallClientIndex == -1:
					frontWallClientIndex = clients
				cave.addWall(wall, mask=2**frontWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**frontWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(frontWall)
					_window.setStereoSwap(frontWallSwapStereo)
					viz.window.setFullscreenRectangle([2563, 15, 2260, 1585])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create right wall
			if rightWall >= 0:
				wall = vizcave.Wall(	upperLeft=C2,
										upperRight=C3,
										lowerLeft=C6,
										lowerRight=C7,
										name='Right Wall' )
				
				if rightWallClientIndex == -1:
					rightWallClientIndex = clients
				cave.addWall(wall, mask=2**rightWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**rightWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(rightWall)
					_window.setStereoSwap(rightWallSwapStereo)
					viz.window.setFullscreenRectangle([5120, 12, 2526, 1587])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create back wall
			if backWall >= 0:
				wall = vizcave.Wall(	upperLeft=C3,
										upperRight=C0,
										lowerLeft=C7,
										lowerRight=C4,
										name='Back Wall' )
				
				if backWallClientIndex == -1:
					backWallClientIndex = clients
				cave.addWall(wall, mask=2**backWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**backWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(backWall)
					_window.setStereoSwap(backWallSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create left wall
			if leftWall >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C1,
										lowerLeft=C4,
										lowerRight=C5,
										name='Left Wall' )
				
				leftWallClientIndex = clients
				cave.addWall(wall, mask=2**leftWallClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**leftWallClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(leftWall)
					_window.setStereoSwap(leftWallSwapStereo)
					viz.window.setFullscreenRectangle([32, 20, 2525, 1580])
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create floor
			if floor >= 0:
				wall = vizcave.Wall(	upperLeft=C5,
										upperRight=C6,
										lowerLeft=C4,
										lowerRight=C7,
										name='Floor' )
				
				floorClientIndex = clients
				cave.addWall(wall, mask=2**floorClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**floorClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(floor)
					_window.setStereoSwap(floorSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			#Create ceiling
			if ceiling >= 0:
				wall = vizcave.Wall(	upperLeft=C0,
										upperRight=C3,
										lowerLeft=C1,
										lowerRight=C2,
										name='Ceiling' )
				
				ceilingClientIndex = clients
				cave.addWall(wall, mask=2**ceilingClientIndex, window=_window)
				
				with viz.cluster.MaskedContext(2**ceilingClientIndex):
					# check if the fullscreen monitor is defined.
					viz.window.setFullscreenMonitor(ceiling)
					_window.setStereoSwap(ceilingSwapStereo)
					viz.window.setFullscreen(True)
				clients += 1
			
			# We need to pass an object which will be used to update the projection
			# or the display to the view's position, typically this would be the
			# node attached to an avatar's head tracker. 
			viewpoint = viz.addGroup()
			cave.setTracker(viewpoint)
			
			# Create a CaveView object for manipulating the entire cave environment.
			# The caveView is a node that can be adjusted to move the entire 
			# cave around the virtual environment.
			caveView = vizcave.CaveView(viewpoint)
			
			_window.originLink = viz.link(originNode, caveView, dstFlag=viz.ABS_GLOBAL, srcFlag=viz.ABS_GLOBAL)
			_window.caveView = caveView
			_window.originNode = originNode
			_window.displayNode = cave
			_window.viewpointNode = viewpoint
			
			
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Cave Manual Configuration')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getAvatar('head_and_hand').getAttachmentPoint('head'))

	#VC: return values can be modified here
	return None
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawDisplay = vizconnect.getRawDisplayDict()

    #VC: initialize a new display
    _name = 'main_display'
    if vizconnect.isPendingInit('display', _name, initFlag, initList):
        #VC: init which needs to happen before viz.go
        if initFlag & vizconnect.INIT_PREVIZGO:
            viz.setOption('viz.stereo', viz.QUAD_BUFFER)
            viz.setOption('viz.fullscreen', 1)

        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set the window for the display
            _window = viz.MainWindow

            #VC: set some parameters
            imageWidth = 3
            imageHeight = 2.25
            imageRise = 0.045
            originLeft = 2.897
            originRight = 2.934
            shiftRight = 0
            shiftUp = 0
            shiftForward = 0
            stereo = viz.QUAD_BUFFER
            swapStereo = False

            #VC: create the raw object
            # Create a cave object
            import vizcave
            cave = vizcave.Cave(stereo=stereo)

            # get an origin node
            originName = _name
            initGroups(vizconnect.INIT_INDEPENDENT,
                       [originName])  # ensure it's been created
            originNode = vizconnect.getGroup(originName).getNode3d()

            # get the originLeft angle from the origin measurements
            import math
            aOR = math.pi / 4.0
            aAOR = (originRight**2 - originLeft**2 -
                    imageWidth**2) / (-2 * originLeft * imageWidth)
            if abs(aAOR) <= 1:
                aOR = math.acos(aAOR)

            # convert the angle to front and right shifts
            Sr = -(math.cos(aOR) * originLeft - imageWidth / 2.0)
            distanceToFront = math.sin(aOR) * originLeft

            # find left/right, up/down, front/back (x,y,z) extent of caves
            R = imageWidth / 2.0 + Sr + shiftRight  # right
            L = -imageWidth / 2.0 + Sr + shiftRight  # left
            U = imageRise + imageHeight + shiftUp  # up/top
            D = imageRise + shiftUp  # bottom/down
            F = distanceToFront + shiftForward  # front

            C0 = L, U, F
            C1 = R, U, F
            C2 = L, D, F
            C3 = R, D, F

            #Create front wall
            wall = vizcave.Wall(upperLeft=C0,
                                upperRight=C1,
                                lowerLeft=C2,
                                lowerRight=C3,
                                name='Front Wall')

            cave.addWall(wall, window=_window)

            _window.setStereoSwap(swapStereo)

            #_window.setSize([1, 1])

            # We need to pass an object which will be used to update the projection
            # or the display to the view's position, typically this would be the
            # node attached to an avatar's head tracker.
            viewpoint = viz.addGroup()
            cave.setTracker(viewpoint)

            # Create a CaveView object for manipulating the entire cave environment.
            # The caveView is a node that can be adjusted to move the entire
            # cave around the virtual environment.
            caveView = vizcave.CaveView(viewpoint, view=_window.getView())
            _window.originLink = viz.link(originNode,
                                          caveView,
                                          dstFlag=viz.ABS_GLOBAL,
                                          srcFlag=viz.ABS_GLOBAL)
            _window.caveView = caveView
            _window.originNode = originNode
            _window.displayNode = cave
            _window.viewpointNode = viewpoint

            rawDisplay[_name] = _window

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addDisplay(rawDisplay[_name],
                                  _name,
                                  make='Generic',
                                  model='Powerwall')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getDisplay(_name).setParent(
                vizconnect.getAvatar('main_avatar').getAttachmentPoint('head'))

    #VC: set the name of the default
    vizconnect.setDefault('display', 'main_display')

    #VC: return values can be modified here
    return None