def initGroups(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawGroup = vizconnect.getRawGroupDict() #VC: initialize a new group _name = 'cave_manual_configuration' if vizconnect.isPendingInit('group', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: create the raw object rawGroup[_name] = viz.addGroup() #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addGroup(rawGroup[_name], _name, make='Virtual', model='Origin') #VC: set the parent of the node if initFlag & vizconnect.INIT_PARENTS: vizconnect.getGroup(_name).setParent( vizconnect.getTransport('wandmagiccarpet')) #VC: return values can be modified here return None
def __init__(self): vizconnect.go('vizconnect_config_cave_art.py') _startPos = [28, 2.45, 160] ### Collision ### Desktop #viz.collision(viz.ON) viz.MainView.setPosition(_startPos) ### Cave ac = view_collision.AvatarCollision() ac.setCollideList([vizconnect.AVATAR_HEAD]) ac.setTransport(vizconnect.getTransport().getNode3d()) #viz.MainView.gravity(9.81) self.view = vizconnect.getGroup( 'cave_manual_configuration').getNode3d() #self.setCameraPosition([120, 3.3, 87]) self.setCameraPosition(_startPos, viz.ABS_GLOBAL) #self.view.setEuler([-90,0,7],viz.ABS_LOCAL) ### Scene Lighting self.setupLighting()
def initGroups(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawGroup = vizconnect.getRawGroupDict() #VC: initialize a new group _name = 'cave_manual_configuration' if vizconnect.isPendingInit('group', _name, initFlag, initList): #VC: init the raw object if initFlag&vizconnect.INIT_RAW: #VC: create the raw object rawGroup[_name] = viz.addGroup() #VC: init the wrapper (DO NOT EDIT) if initFlag&vizconnect.INIT_WRAPPERS: vizconnect.addGroup(rawGroup[_name], _name, make='Virtual', model='Origin') #VC: set the parent of the node if initFlag&vizconnect.INIT_PARENTS: vizconnect.getGroup(_name).setParent(vizconnect.getDisplay('cave_manual_configuration')) #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 CAVE_CONFIG_NAME = 'cave_manual_configuration' if vizconnect.isPendingInit('display', CAVE_CONFIG_NAME, initFlag, initList): #VC: init which needs to happen before viz.go if initFlag & vizconnect.INIT_PREVIZGO: viz.setOption('viz.stereo', viz.QUAD_BUFFER) #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set the window for the display _window = viz.MainWindow #APG: constants, 5 total instances running... FRONT_WALL_CLUSTER_CLIENT = viz.CLIENT1 LEFT_WALL_CLUSTER_CLIENT = viz.CLIENT2 RIGHT_WALL_CLUSTER_CLIENT = viz.CLIENT3 FLOOR_LEFT_CLUSTER_CLIENT = viz.CLIENT4 FLOOR_RIGHT_CLUSTER_CLIENT = viz.CLIENT5 #These are determined by testing the monitors FRONT_WALL_MONITOR_ID = 1 LEFT_WALL_MONITOR_ID = 4 RIGHT_WALL_MONITOR_ID = 5 FLOOR_LEFT_MONITOR_ID = 3 FLOOR_RIGHT_MONITOR_ID = 2 #============================================== #Cave calculations #VC: create the raw object # Create a cave object import vizcave cave = vizcave.Cave(stereo=viz.QUAD_BUFFER) # get an origin node originName = CAVE_CONFIG_NAME initGroups(vizconnect.INIT_INDEPENDENT, [originName]) # ensure it's been created originNode = vizconnect.getGroup(originName).getNode3d() frontImageWidth = 5.5372 imageHeight = 2.2225 imageRise = 0.0 originLeft = 3.5503 originRight = 3.5503 sideImageWidth = 2.9591 shiftRight = 0 shiftUp = 0 shiftForward = 0 # 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 C8 = L, D, 0 C9 = R, D, 0 C10 = -0.19939, D, F C11 = 0.19939, D, F C12 = -0.19939, D, 0 C13 = 0.19939, D, 0 # wall_list = [C0, C1, C2, C3, C4, # C5, C6, C7, C8, # C9, C10, C11, C12, C13] # # for item in wall_list: # print(item) #============================================== WALL_CORNERS = "corners" WALL_NAME = "name" WALL_CLUSTER_ID = "cluster_id" WALL_MONITOR_ID = "monitor_id" #Creates wall, then adds it to the vizcave obj 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) #Create front wall #================================== wall_config = {} wall_config[WALL_CORNERS] = [C1, C2, C5, C6] wall_config[WALL_NAME] = "Front Wall" wall_config[WALL_CLUSTER_ID] = FRONT_WALL_CLUSTER_CLIENT wall_config[WALL_MONITOR_ID] = FRONT_WALL_MONITOR_ID config_wall(wall_config, _window) #Create right wall #================================== wall_config = {} wall_config[WALL_CORNERS] = [C2, C3, C6, C7] wall_config[WALL_NAME] = "Right Wall" wall_config[WALL_CLUSTER_ID] = RIGHT_WALL_CLUSTER_CLIENT wall_config[WALL_MONITOR_ID] = RIGHT_WALL_MONITOR_ID config_wall(wall_config, _window) # #Create left wall # #================================= wall_config = {} wall_config[WALL_CORNERS] = [C0, C1, C4, C5] wall_config[WALL_NAME] = "Left Wall" wall_config[WALL_CLUSTER_ID] = LEFT_WALL_CLUSTER_CLIENT wall_config[WALL_MONITOR_ID] = LEFT_WALL_MONITOR_ID config_wall(wall_config, _window) #Create floor_left #================================== wall_config = {} wall_config[WALL_CORNERS] = [C5, C11, C8, C13] wall_config[WALL_NAME] = "Floor Left" wall_config[WALL_CLUSTER_ID] = FLOOR_LEFT_CLUSTER_CLIENT wall_config[WALL_MONITOR_ID] = FLOOR_LEFT_MONITOR_ID config_wall(wall_config, _window) #Create floor_right #================================== wall_config = {} wall_config[WALL_CORNERS] = [C10, C6, C12, C9] wall_config[WALL_NAME] = "Floor Right" wall_config[WALL_CLUSTER_ID] = FLOOR_RIGHT_CLUSTER_CLIENT wall_config[WALL_MONITOR_ID] = FLOOR_RIGHT_MONITOR_ID config_wall(wall_config, _window) #================================== # 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[CAVE_CONFIG_NAME] = _window #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addDisplay(rawDisplay[CAVE_CONFIG_NAME], CAVE_CONFIG_NAME, make='Generic', model='Cave Manual Configuration') #VC: set the parent of the node if initFlag & vizconnect.INIT_PARENTS: vizconnect.getDisplay(CAVE_CONFIG_NAME).setParent( vizconnect.getAvatar('head_and_hand').getAttachmentPoint( 'head')) #VC: set the name of the default vizconnect.setDefault('display', 'cave_manual_configuration') #VC: return values can be modified here return None
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawAvatar = vizconnect.getRawAvatarDict() #VC: initialize a new avatar _name = 'head_and_hand' if vizconnect.isPendingInit('avatar', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set some parameters # rightHandFilename = 'glove.cfg' rightHandFilename = '' leftHandFilename = '' #VC: create the raw object # base avatar avatar = viz.addGroup() avatar._bodyPartDict = {} avatar._handModelDict = {} # head head = viz.addGroup() head.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head # left hand if leftHandFilename: leftHand = avatar.add(leftHandFilename) avatar.leftHandFilename = leftHandFilename else: leftHand = viz.addGroup() avatar.leftHandFilename = None leftHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand # right hand if rightHandFilename: rightHand = avatar.add(rightHandFilename) avatar.rightHandFilename = rightHandFilename else: rightHand = viz.addGroup() avatar.rightHandFilename = None rightHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand # done rawAvatar[_name] = avatar #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand') #VC: init the gestures if initFlag & vizconnect.INIT_GESTURES: #VC: need to get the raw input dict so we have access to signals import vizact rawInput = vizconnect.getConfiguration().getRawDict('input') #VC: gestures for the avatar's r_hand import hand # remove the old hand rightHand = rawAvatar[_name]._bodyPartDict[ vizconnect.AVATAR_R_HAND] if rightHand: rightHand.remove() # add a new hand def initHand(): sensor = hand.InputSensor() rawAvatar[_name].handSensor = sensor sensor.createHandRenderer = lambda *args, **kw: hand._InputDeviceRenderer( *args, **kw) def appliedGetData(): #VC: set the mappings for the gestures if rawInput['flystick'].isButtonDown( 0 ): # make=ART, model=Flystick, name=flystick, signal=Button 0 return (hand.GESTURE_FIST, False, False ) # GESTURE_FIST #VC: end gesture mappings return (hand.GESTURE_FLAT_HAND, False, False) sensor.getData = appliedGetData file = None if hasattr(rawAvatar[_name], "rightHandFilename"): file = rawAvatar[_name].rightHandFilename return hand.HandModel(left=False, type=hand.GLOVE_5DT, file=file, sensor=sensor) rightHand = initHand() rightHand.setParent(rawAvatar[_name]) rawAvatar[_name]._bodyPartDict[ vizconnect.AVATAR_R_HAND] = rightHand rawAvatar[_name]._handModelDict[ vizconnect.AVATAR_R_HAND] = rightHand #VC: gestures may change the raw avatar, so refresh the raw in the wrapper vizconnect.getAvatar(_name).setRaw(rawAvatar[_name]) #VC: init the animator if initFlag & vizconnect.INIT_ANIMATOR: # need to get the raw tracker dict for animating the avatars from vizconnect.util.avatar import animator from vizconnect.util.avatar import skeleton # get the skeleton from the avatar _skeleton = skeleton.Disembodied(rawAvatar[_name]) #VC: set which trackers animate which body part # format is: bone: (tracker, parent, degrees of freedom used) _trackerAssignmentDict = { vizconnect.AVATAR_HEAD: (vizconnect.getTracker('dtrack_head').getNode3d(), None, vizconnect.DOF_6DOF), vizconnect.AVATAR_R_HAND: (vizconnect.getTracker('dtrack_flystick').getNode3d(), None, vizconnect.DOF_6DOF), } #VC: create the raw object _rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict) #VC: set animator in wrapper (DO NOT EDIT) vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied') #VC: set the parent of the node if initFlag & vizconnect.INIT_PARENTS: vizconnect.getAvatar(_name).setParent( vizconnect.getGroup('cave_manual_configuration')) #VC: set the name of the default vizconnect.setDefault('avatar', 'head_and_hand') #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 = '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 initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawAvatar = vizconnect.getRawAvatarDict() #VC: initialize a new avatar _name = 'head_and_hand' if vizconnect.isPendingInit('avatar', _name, initFlag, initList): #VC: init the raw object if initFlag&vizconnect.INIT_RAW: #VC: set some parameters rightHandFilename = 'glove.cfg' leftHandFilename = '' #VC: create the raw object # base avatar avatar = viz.addGroup() avatar._bodyPartDict = {} avatar._handModelDict = {} # head head = viz.addGroup() head.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head # left hand if leftHandFilename: leftHand = avatar.add(leftHandFilename) avatar.leftHandFilename = leftHandFilename else: leftHand = viz.addGroup() avatar.leftHandFilename = None leftHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand # right hand if rightHandFilename: rightHand = avatar.add(rightHandFilename) avatar.rightHandFilename = rightHandFilename else: rightHand = viz.addGroup() avatar.rightHandFilename = None rightHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand # done rawAvatar[_name] = avatar #VC: init the wrapper (DO NOT EDIT) if initFlag&vizconnect.INIT_WRAPPERS: vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand') #VC: init the animator if initFlag&vizconnect.INIT_ANIMATOR: # need to get the raw tracker dict for animating the avatars from vizconnect.util.avatar import animator from vizconnect.util.avatar import skeleton # get the skeleton from the avatar _skeleton = skeleton.Disembodied(rawAvatar[_name]) #VC: set which trackers animate which body part # format is: bone: (tracker, parent, degrees of freedom used) _trackerAssignmentDict = { vizconnect.AVATAR_HEAD:(vizconnect.getTracker('headtracker').getNode3d(), None, vizconnect.DOF_6DOF), vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('wandtracker').getNode3d(), None, vizconnect.DOF_6DOF), } #VC: create the raw object _rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict) #VC: set animator in wrapper (DO NOT EDIT) vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied') #VC: set the parent of the node if initFlag&vizconnect.INIT_PARENTS: vizconnect.getAvatar(_name).setParent(vizconnect.getGroup('cave_manual_configuration')) #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 = 'cave_data_file' 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 stereo = viz.QUAD_BUFFER filename = 'C:/demos/Cave_settings.txt' #VC: create the raw object # Create a cave object import vizcave cave = vizcave.Cave(stereo=stereo) try: cave.load(filename) except IOError: viz.logError( "** Error: unable to load cave configuration file {}.". format(filename)) # get an origin node originName = _name initGroups(vizconnect.INIT_INDEPENDENT, [originName]) # ensure it's been created originNode = vizconnect.getGroup(originName).getNode3d() # 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 Data File') #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 initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawTracker = vizconnect.getRawTrackerDict() #VC: initialize a new tracker _name = 'dtrack_head' if vizconnect.isPendingInit('tracker', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set some parameters vrpnName = 'DTrack' ip = 'localhost' index = 0 #VC: create the raw object vrpn7 = viz.add('vrpn7.dle') rawTracker[_name] = vrpn7.addTracker(vrpnName + '@' + ip, index) #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addTracker(rawTracker[_name], _name, make='A.R.T.', model='DTrack') #VC: set the parent of the node if initFlag & vizconnect.INIT_PARENTS: vizconnect.getTracker(_name).setParent( vizconnect.getGroup('cave_data_file')) #VC: initialize a new tracker _name = 'dtrack_flystick' if vizconnect.isPendingInit('tracker', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set some parameters vrpnName = 'DTrack' #ip = '192.168.1.51' ip = 'localhost' index = 2 #VC: create the raw object vrpn7 = viz.add('vrpn7.dle') rawTracker[_name] = vrpn7.addTracker(vrpnName + '@' + ip, index) #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addTracker(rawTracker[_name], _name, make='A.R.T.', model='DTrack') #VC: initialize a new tracker _name = 'senso' if vizconnect.isPendingInit('tracker', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set some parameters vrpnName = 'DTrack' ip = '127.0.0.1' index = 1 #VC: create the raw object vrpn7 = viz.add('vrpn7.dle') rawTracker[_name] = vrpn7.addTracker(vrpnName + '@' + ip, index) #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addTracker(rawTracker[_name], _name, make='A.R.T.', model='DTrack') #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
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawAvatar = vizconnect.getRawAvatarDict() #VC: initialize a new avatar _name = 'main_avatar' if vizconnect.isPendingInit('avatar', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set some parameters head = False rightHand = False leftHand = False torso = False lowerBody = False rightArm = False leftArm = False #VC: create the raw object # base avatar import vizfx avatar = vizfx.addChild('mark.cfg') avatar._bodyPartDict = {} avatar._handModelDict = {} avatar.visible(head, r'mark_head.cmf') avatar.visible(rightHand, r'mark_hand_r.cmf') avatar.visible(leftHand, r'mark_hand_l.cmf') avatar.visible(torso, r'mark_torso.cmf') avatar.visible(lowerBody, r'mark_legs.cmf') avatar.visible(rightArm, r'mark_arm_r.cmf') avatar.visible(leftArm, r'mark_arm_l.cmf') rawAvatar[_name] = avatar #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addAvatar(rawAvatar[_name], _name, make='WorldViz', model='Mark') #VC: init the animator if initFlag & vizconnect.INIT_ANIMATOR: # need to get the raw tracker dict for animating the avatars from vizconnect.util.avatar import animator from vizconnect.util.avatar import skeleton # get the skeleton from the avatar _skeleton = skeleton.CompleteCharactersHD(rawAvatar[_name]) #VC: set which trackers animate which body part # format is: bone: (tracker, parent, degrees of freedom used) _trackerAssignmentDict = { vizconnect.AVATAR_HEAD: (vizconnect.getTracker('head_tracker').getNode3d(), None, vizconnect.DOF_POS), vizconnect.AVATAR_R_HAND: (vizconnect.getTracker('r_hand_tracker').getNode3d(), None, vizconnect.DOF_POS), } #VC: create the raw object _rawAnimator = animator.Direct(rawAvatar[_name], _skeleton, _trackerAssignmentDict) #VC: set animator in wrapper (DO NOT EDIT) vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Direct') #VC: set the parent of the node if initFlag & vizconnect.INIT_PARENTS: vizconnect.getAvatar(_name).setParent( vizconnect.getGroup('main_display')) #VC: set the name of the default vizconnect.setDefault('avatar', 'main_avatar') #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 = '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) #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 rightWall = -1 backWall = -1 leftWall = -1 floor = -1 ceiling = -1 frontImageWidth = 2 imageHeight = 2 imageRise = 0.1 originLeft = 1.4142 originRight = 1.4142 sideImageWidth = 0 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.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.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.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: return values can be modified here return None