def debugger(self):
        """
		Activates debuggin' tools
		"""
        self.manager.setDebug(viz.TOGGLE)
        if self.dogCenter.getVisible() == viz.ON:
            self.dogCenter.visible(viz.OFF)
            self.outlineCenter.visible(viz.OFF)
            self.dogTargetMold.visible(viz.OFF)
            self.mainAxes.remove()
            self.outlineAxes.remove()
            self.dogAxes.remove()
        else:
            self.dogCenter.visible(viz.ON)
            self.outlineCenter.visible(viz.ON)
            self.dogTargetMold.visible(viz.ON)
            self.outlineAxes = vizshape.addAxes(parent=self.outlineCenter)
            self.dogAxes = vizshape.addAxes(parent=self.dogCenter)
    def debugger(self):
        """
		Activates debuggin' tools
		"""
        self.manager.setDebug(viz.TOGGLE)
        if self.dogCenter.getVisible() == viz.ON:
            self.dogCenter.visible(viz.OFF)
            self.outlineCenter.visible(viz.OFF)
            self.dogTargetMold.visible(viz.OFF)
            self.mainAxes.remove()
            self.outlineAxes.remove()
            self.dogAxes.remove()
        else:
            self.dogCenter.visible(viz.ON)
            self.outlineCenter.visible(viz.ON)
            self.dogTargetMold.visible(viz.ON)
            self.outlineAxes = vizshape.addAxes(parent=self.outlineCenter)
            self.dogAxes = vizshape.addAxes(parent=self.dogCenter)
def CreateVisualObjects(room):

    global MarkerObject

    MarkerObject = []
    ColorList = [
        viz.WHITE, viz.GREEN, viz.BLUE, viz.YELLOW, viz.BLACK, viz.PURPLE,
        viz.GRAY, viz.RED
    ]

    room.origin = vizshape.addAxes()
    room.origin.setPosition(0, 0, 0)
Exemple #4
0
	def detatchMainViewFromHead(self):
		print 'Helmet-mainview link removed'
		
		helmetRigid = self.allRigids_ridx[self.rigidHMDIdx]
		helmetRigid.vizNodeLink.remove()
		self.mainViewLinkedToHead = 0
		
		helmetRigid.vizNode.isVisible = 1
		helmetRigid.vizNode.visible( viz.ON ) #Make the object visible.
		
		self.headAxes = vizshape.addAxes(parent = self.allRigids_ridx[self.rigidHMDIdx].vizNode, pos=[0,0,0],scale=[0.2,0.2,0.2])
		rigidBody.toggleVisibility(self.allRigids_ridx[self.rigidHMDIdx])
Exemple #5
0
	def __init__(self,use_keyboard = True, desktop_mode = False):
		"""Initialization function."""
		#
		viz.phys.enable()
		self.view = viz.MainView;
		
		caveapp.CaveApplication.__init__(self,desktop_mode) #call constructor of super class, you have to do this explicitly in Python		
		
		self.wand = vizshape.addAxes()#load axis model to represent the wand\
		self.cylinder = vizshape.addCylinder(15,0.002,axis=vizshape.AXIS_X)
		self.cylinder.setEuler([0,0,0])
		#self.cylinder.setCenter([0,0,-1])
		self.cylinder.setPosition(7.5,0.08,0)
		
		self.stuff = vizshape.addSphere(0.0001)
		self.cylinder.setParent(self.stuff)
		
#		temp = vizshape.addSphere(0.05)
#		temp.setParent(self.cylinder)
#		temp.setPosition(self.cylinder.getCenter())
		
		self.wand = self.stuff
#		self.wand.setPosition(.5,-1,0)
#		self.cm = self.wand.getMatrix()
#		self.Room = viz.addChild('D:\Cave software\NFI Cave\Scene\ScannedRoom.3DS')
#		self.Room.collidePlane()
#		self.Room.setScale([1.25,1.25,1.25])
#		self.Room.setEuler([90,0,0])
#		self.Room.setPosition([-1.5,0,1.55])
		self.Room = viz.addChild('scene/ScannedRoom.3DS')
		self.Room.collidePlane()
		self.Room.setScale([0.002,0.002,0.002])
		self.Room.setEuler([90,0,0])
		self.Room.setPosition([-1.5,0.015,1.58])
		"""
		mylight = viz.addLight() 
		mylight.enable() 
		mylight.position(0, 1, 0) 
		mylight.spread(180) 
		mylight.intensity(2)
#		vizact.onkeydown('f', dance)
		"""
		
		viz.disable(viz.LIGHTING)
		self.headLight = viz.MainView.getHeadLight() #disable the headlight
		self.headLight.disable() #the headlight is disabled because the piazza.osgb is already shaded
		
		self.use_keyboard = use_keyboard #store if we want to use the keyboard
		
		
		self.time = 0.0 #note that to 0.0 is important because it is a double precision floating point number
Exemple #6
0
    def detatchMainViewFromHead(self):
        print 'Helmet-mainview link removed'

        helmetRigid = self.allRigids_ridx[self.rigidHMDIdx]
        helmetRigid.vizNodeLink.remove()
        self.mainViewLinkedToHead = 0

        helmetRigid.vizNode.isVisible = 1
        helmetRigid.vizNode.visible(viz.ON)  #Make the object visible.

        self.headAxes = vizshape.addAxes(
            parent=self.allRigids_ridx[self.rigidHMDIdx].vizNode,
            pos=[0, 0, 0],
            scale=[0.2, 0.2, 0.2])
        rigidBody.toggleVisibility(self.allRigids_ridx[self.rigidHMDIdx])
def CreateVisualObjects():

    global ball, Head, Hand, GazeLine, EyeBallLine;
    #creats a sphere(the ball) with radius of 5cm
    ball = vizshape.addSphere(radius = .05)
    #colors the ball red
    ball.color(viz.YELLOW)
    ball.visible(True)

    Origin = vizshape.addAxes()
    Origin.setPosition(0,0,0)
    #creats a sphere(the ball) with radius of 5cm
    #Head = vizshape.addCone( radius = 0.5, height = 0.8)
    Head = vizshape.addArrow(1, color = viz.YELLOW_ORANGE)
    #colors the ball red
    Head.color(viz.PURPLE)
    Head.visible(True)
    Head.setScale(.2,.2,.3)

    #creats a sphere(the hand) with radius of 10cm
    Hand = vizshape.addCylinder( height = 0.02, radius = 0.2)
    #colors the hand red
    Hand.color(viz.RED)
    Hand.visible(True)

    # Creating a Line to represent Gaze Vector
    viz.startLayer(viz.LINES)
    viz.vertex(0,0,0)
    viz.vertex(0,0,3)
    viz.vertexColor(viz.GREEN)
    GazeLine = viz.endLayer() # Object will contain both points and lines
    GazeLine.visible(True)
    GazeLine.setScale(5,5,5)


    # Creating a Line to represent Eye-Ball Vector
    viz.startLayer(viz.LINES)
    viz.vertex(0,0,0)
    viz.vertex(0,0,3)
    viz.vertexColor(viz.YELLOW)
    EyeBallLine = viz.endLayer() # Object will contain both points and lines
    EyeBallLine.visible(True)
    EyeBallLine.setScale(5,5,5)
	def __init__(self, meshes):
		"""
		Populate environment with bounding boxes allowing easy manipulation
		of subassemblies of the entire model. Currently partitioned by region.
		"""
		
		self.name				= ''		
		self._alpha				= 0.3
		self._members			= []
		self._keystones 		= []
		self._pureKeystones		= []
		self.wireFrame			= None
		self._showGroupFlag 	= True
		
		self.finishedRegion = False
		
		self.axis = vizshape.addAxes()
		self.cube = vizshape.addCube()
		
		super(BoundingBox, self).__init__(self.cube.id)
		
		self.cube.disable(viz.RENDERING)
		self.axis.setParent(self)
		self.axis.setScale([0.2, 0.2, 0.2])
		
		self.addSensor()
		self.addMembers(meshes)
		
		self.regionGroup = RegionGroup([self])
#		self.moveToCenter()

		# Add Bounding Box checker
		self.checker = vizshape.addCube(0.001)
		self.checker.setParent(self)
		self.checker.disable([viz.RENDERING,viz.INTERSECTION,viz.PHYSICS])

		self.highlight(False)
		
		self._imploded = False
def computeFrustumPyramid(vfov, hfov):
	z = 10
	
	# Calculate x and y
	x = 2 * z * math.tan(hfov/2)
	y = 2 * z * math.tan(vfov/2)

	# Make pyramid
	pyr = vizshape.addPyramid(base=[x,y], height=z, axis=vizshape.AXIS_Z)
	pyrInner = vizshape.addPyramid(base=[x,y], height=z, axis=vizshape.AXIS_Z, flipFaces=True)
	pyrInner.setParent(pyr)

	axes = vizshape.addAxes()
	axes.setScale([5]*3)
	axes.setParent(pyr)
	
	# Link to MainView
	pyrlink = viz.link(viz.MainView, pyr)
	pyrlink.preTrans([0,0,z])
	pyrlink.preEuler([180,0,0])
	vizact.onkeydown('b', pyrlink.disable)
	vizact.onkeydown('n', pyrlink.enable)
Exemple #10
0
	def __init__(self, use_keyboard = True, desktop_mode = True):
		caveapp.CaveApplication.__init__(self, desktop_mode) #call constructor of super class, you have to do this explicitly in Python		
		
		self.wand = vizshape.addAxes()#load axis model to represent the wand
		self.thing = viz.addChild('plant.osgb') #load plant model to represent the thing
		
		self.horse = viz.addChild('horse.wrl') #load a horse model (this model will be animated in cave space)
		
		self.horse.color(0.5,0.5,0.5)#make the horse gray
		
		self.horse.disable(viz.LIGHTING) #disable the shading of the horse
		
		self.worldModel = viz.add('piazza.osgb') #load a world model
		
		self.headLight = viz.MainView.getHeadLight() #disable the headlight
		self.headLight.disable() #the headlight is disabled because the piazza.osgb is already shaded
		
		self.use_keyboard = use_keyboard #store if we want to use the keyboard
		
		
		self.time = 0.0 #note that to 0.0 is important because it is a double precision floating point number
		
		self.forwardVelocity = 0.0
Exemple #11
0
import viz
import vizshape
import vizact
from vhil_devkit import *

HOME_POS = [0,5,0]
HOME_ORI = [0,90,0]
vhilGo(homePos=HOME_POS, homeOri=HOME_ORI)

grid = vizshape.addGrid()

point1 = vizshape.addSphere(.1)
point1.setPosition([1,0,0])
point2 = vizshape.addSphere(.1)

obj = vizshape.addAxes()
obj.setPosition([.5,0,.5])
obj.setEuler([45,0,0])
child = vizshape.addAxes()
child.setScale([.1]*3)

localCenter = [1,0,0]
mat = obj.getMatrix()
mat.setEuler([0,0,0])
mat.setPosition(localCenter)
mat.setEuler([45,0,0])

obj.setCenter(localCenter)
#child.setPosition(mat.getPosition())
child.setMatrix(mat)
Exemple #12
0
import viz
import vizshape

viz.go()

# load the pre-made scene
piazza = viz.addChild('piazza.osgb')

# enable collision detection so we can't move through objects
viz.collision(viz.ON)


# add the axes model
vizshape.addAxes()

# add the plant
plant = viz.addChild('plant.osgb')
# plant will be at X=4, Y=0, Z=6; relative to the origin
plant.setPosition(4, 0, 6)

Exemple #13
0
    def findDevices(self):
        """ Enumerate SteamVR devices and set up models """

        # HMD
        hmd = steamvr.HMD()
        self.hmd['sensor'] = hmd.getSensor()

        hmd_ui = viz.addText('N/A')
        self._ui.addItem(viz.addText('Headset'))        
        self._ui.addLabelItem('0', hmd_ui)
        self._ui.addSeparator()
        self.hmd['ui'] = hmd_ui

        hud = viz.addText3D('X: 0.00 (123.0°)', scale=(self.VALUE_SCALE * 2.5,) * 3, color=viz.GRAY)
        hud_link = viz.link(viz.MainView, hud)
        hud_link.preTrans(self.HUD_POS, viz.REL_LOCAL)
        self.hmd['hud'] = hud
        self._obj.append(hud)

        # Lighthouses
        for lidx, lighthouse in enumerate(steamvr.getCameraList()):
            lighthouse.model = lighthouse.addModel(parent=self._root)
            if not lighthouse.model:
                lighthouse.model = viz.addGroup()
            lighthouse.model.setCompositeAlpha(self.DEBUG_ALPHA)
            lighthouse.model.disable(viz.INTERSECTION)
            viz.link(lighthouse, lighthouse.model)
            
            l_text = viz.addText3D(str(lidx), scale=(self.LABEL_SCALE,) * 3, color=viz.YELLOW,
                                parent=lighthouse.model, pos=(0.1, 0, 0))
            l_text.setEuler(180, 0, 0)
            
            # Lighthouse normal vector
            l_normal = addRayPrimitive(origin=[0,0,0], direction=[0,0,1], color=viz.YELLOW, parent=lighthouse.model)
            l_normal.visible(False)

            self.lighthouses[lidx] = {'model': lighthouse.model,
                                      'normal': l_normal,
                                      'text': l_text}
            self._obj.append(lighthouse.model)
            print('* Found Lighthouse: {:d}'.format(lidx))

        # Controllers
        if steamvr.getControllerList():
            self._ui.addItem(viz.addText('Controllers'))

            for cidx, controller in enumerate(steamvr.getControllerList()):
                
                controller.model = controller.addModel(parent=self._root)
                if not controller.model:
                    controller.model = viz.addGroup(parent=self._root)
                controller.model.setCompositeAlpha(self.DEBUG_ALPHA)
                controller.model.disable(viz.INTERSECTION)
                viz.link(controller, controller.model)
                
                c_axes = vizshape.addAxes(scale=(0.1, 0.1, 0.1))
                viz.link(controller, c_axes)

                markers = {'axes': c_axes}
                for m in self._markers:
                    markers[m] = self._markers[m].copy()
                    markers[m].visible(False)
                    viz.link(controller, markers[m])

                c_text = viz.addText3D(str(cidx), scale=(self.LABEL_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.05, 0, 0))
                val_x = viz.addText3D('X: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.18, 0.04, 0), color=viz.RED)
                val_y = viz.addText3D('Y: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.18, 0.02, 0), color=viz.GREEN)
                val_z = viz.addText3D('Z: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=controller.model, pos=(-0.18, 0, 0), color=viz.BLUE)
                
                self.controllers[cidx] = {'model': controller.model,
                                          'axes': c_axes,
                                          'text': c_text,
                                          'values': [val_x, val_y, val_z],
                                          'ui': viz.addText('N/A'),
                                          'markers': markers,
                                          'active_marker': 'axes'}

                self._ui.addLabelItem(str(cidx), self.controllers[cidx]['ui'])
                self._obj.extend([controller.model, c_axes, val_x, val_y, val_z])
                print('* Found Controller: {:d}'.format(cidx))

                self._callbacks.append(vizact.onsensordown(controller, steamvr.BUTTON_TRIGGER, self._storePoint, controller, cidx))
                self._callbacks.append(vizact.onsensordown(controller, steamvr.BUTTON_TRACKPAD, self._switchMarker, cidx))
                self._callbacks.append(vizact.onsensordown(controller, 1, self.savePoints))
                self._callbacks.append(vizact.onsensordown(controller, 0, self.saveScreenshot))
        else:
            print('* No controllers detected.')

        # Trackers
        if steamvr.getTrackerList():
            self._ui.addSeparator()
            self._ui.addItem(viz.addText('Trackers'))

            for tidx, tracker in enumerate(steamvr.getTrackerList()):
                
                tracker.model = tracker.addModel(parent=self._root)
                if not tracker.model:
                    tracker.model = viz.addGroup(parent=self._root)
                tracker.model.setCompositeAlpha(self.DEBUG_ALPHA)
                tracker.model.disable(viz.INTERSECTION)
                viz.link(tracker, tracker.model)

                t_axes = vizshape.addAxes(scale=(0.1, 0.1, 0.1))
                viz.link(tracker, t_axes)

                t_text = viz.addText3D(str(tidx), scale=(0.05, 0.05, 0.05), color=viz.BLUE,
                                    parent=tracker.model, pos=(-0.1, 0, 0))
                val_x = viz.addText3D('X: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=tracker.model, pos=(0.18, 0.04, 0), color=viz.RED)
                val_x.setEuler([180, 0, 0], mode=viz.REL_LOCAL)
                val_y = viz.addText3D('Y: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=tracker.model, pos=(0.18, 0.02, 0), color=viz.GREEN)
                val_y.setEuler([180, 0, 0], mode=viz.REL_LOCAL)
                val_z = viz.addText3D('Z: 0.00 (123.0°)', scale=(self.VALUE_SCALE,) * 3, 
                                    parent=tracker.model, pos=(0.18, 0, 0), color=viz.BLUE)
                val_z.setEuler([180, 0, 0], mode=viz.REL_LOCAL)

                self.trackers[tidx] = {'model': tracker.model,
                                       'axes': t_axes,
                                       'text': t_text,
                                       'values': [val_x, val_y, val_z],
                                       'ui': viz.addText('N/A')}
                self._ui.addLabelItem(str(tidx), self.trackers[tidx]['ui'])
                self._obj.extend([tracker.model, t_axes, val_x, val_y, val_z])
                print('* Found Vive tracker: {:d}'.format(tidx))
        else:
            print('* No trackers detected.')
Exemple #14
0
import viz

#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)

viz.go()

#Increase the Field of View
viz.MainWindow.fov(60)

#viz.MainView.move([3,0,-7])
viz.MainView.setPosition([0, 20, 0])
viz.MainView.setEuler([0, 90, 0])

piazza = viz.addChild('piazza.osgb')
#viz.collision(viz.ON)
import vizshape
vizshape.addAxes()

plant = viz.addChild('plant.osgb')
plant.setPosition([4, 0, 6])
Exemple #15
0
import viz
import vizact
import vizshape

viz.go()

VRPN_SOURCE = '[email protected]'
#VRPN_SOURCE = 'Nexus@localhost'

viz.move([0,-1,-5])

axes = vizshape.addAxes(length=0.5)

vrpn = viz.add('vrpn7.dle')
headtracker = vrpn.addTracker(VRPN_SOURCE)
headtracker.swapPos([-1,3,-2])

#viz.link(headtracker,axes)

def showData():
	print('position')
	print headtracker.getPosition()
#	print headtracker.getEuler()
	
vizact.ontimer(1,showData)
Exemple #16
0
        #import oculus
        #hmd = oculus.Rift()

        import nvis
        hmd = nvis.nvisorSX111()

        #print "HMD IPD: " + str(hmd.getIPD())
        #print "Mainvtiew IPD: " + str(viz.MainWindow.getIPD())

    viz.window.setFullscreenMonitor([1, 2])
    viz.setMultiSample(4)

    viz.go(viz.FULLSCREEN)
    #Add a world axis with X,Y,Z labels
    world_axes = vizshape.addAxes()
    X = viz.addText3D('X',
                      pos=[1.1, 0, 0],
                      color=viz.RED,
                      scale=[0.3, 0.3, 0.3],
                      parent=world_axes)
    Y = viz.addText3D('Y',
                      pos=[0, 1.1, 0],
                      color=viz.GREEN,
                      scale=[0.3, 0.3, 0.3],
                      align=viz.ALIGN_CENTER_BASE,
                      parent=world_axes)
    Z = viz.addText3D('Z',
                      pos=[0, 0, 1.1],
                      color=viz.BLUE,
                      scale=[0.3, 0.3, 0.3],
Exemple #17
0
    def __init__(self, enable=False, hotkey=viz.KEY_F12):
        
        self._enable = enable
        self._hotkey = hotkey
        self._next_screenshot = 1
        self._points = []
        
        # Visualization parameters
        self.GRID_COLOR = [1, 1, 1]
        self.DEBUG_ALPHA = 0.6
        self.LABEL_SCALE = 0.05
        self.VALUE_SCALE = 0.015
        self.MARKER_SIZE = 0.05
        self.HUD_POS = [0.4, 0.3, 1] # Works for Vive / Vive Pro

        # SteamVR devices
        self.hmd = {}
        self.controllers = {}
        self.trackers = {}
        self.lighthouses = {}
        self.nodes = {}

        # Set up scene objects
        self._root = viz.addGroup()
        self._obj = []
        self._obj.append(vizshape.addGrid((100, 100), color=self.GRID_COLOR, pos=[0.0, 0.001, 0.0], parent=self._root))
        self._obj.append(vizshape.addAxes(pos=(0,0,0), scale=(0.5, 0.5, 0.5), parent=self._root))
        
        # Set up possible marker objects
        self._markers = {'sphere_red': vizshape.addSphere(radius=self.MARKER_SIZE / 2, color=viz.RED, parent=self._root),
                         'sphere_green': vizshape.addSphere(radius=self.MARKER_SIZE / 2, color=viz.GREEN, parent=self._root),
                         'sphere_blue': vizshape.addSphere(radius=self.MARKER_SIZE / 2, color=viz.BLUE, parent=self._root),
                         'sphere_yellow': vizshape.addSphere(radius=self.MARKER_SIZE / 2, color=viz.YELLOW, parent=self._root),
                         'cube_red': vizshape.addCube(size=self.MARKER_SIZE, color=viz.RED, parent=self._root),
                         'cube_green': vizshape.addCube(size=self.MARKER_SIZE, color=viz.GREEN, parent=self._root),
                         'cube_blue': vizshape.addCube(size=self.MARKER_SIZE, color=viz.BLUE, parent=self._root),
                         'cube_yellow': vizshape.addCube(size=self.MARKER_SIZE, color=viz.YELLOW, parent=self._root)
        }
        for marker in self._markers.keys():
            self._markers[marker].visible(False)

        # Note: X/Z axis rays moved up (y) by 1 mm to avoid z-fighting with the ground plane
        self._obj.append(addRayPrimitive(origin=[0,0.001,0], direction=[1, 0.001, 0], color=viz.RED, parent=self._root))   # x
        self._obj.append(addRayPrimitive(origin=[0,0.001,0], direction=[0, 0.001, 1], color=viz.BLUE, parent=self._root))  # z
        self._obj.append(addRayPrimitive(origin=[0,0,0], direction=[0, 1, 0], color=viz.GREEN, parent=self._root)) # y
        
        # Set up UI
        txt = 'Hotkeys:\nS - Save collected points data\nC - Clear point data\nL - Toggle Lighthouse rays\nX - Export debug scene\n\n'
        txt += 'Controller Buttons:\nTrigger - place point axes\nA - Save point data\nB - Take screenshot'
        self._ui = vizinfo.InfoPanel(txt, icon=True, align=viz.ALIGN_RIGHT_TOP, title='SteamVR Debug Tool')
        self._ui.renderToEye(viz.RIGHT_EYE)
        self._ui.addSeparator()
        self._obj.append(self._ui)

        # Register key callbacks
        self._callbacks = []
        self._callbacks.append(vizact.onkeydown('s', self.savePoints))
        self._callbacks.append(vizact.onkeydown('c', self.clearPoints))
        self._callbacks.append(vizact.onkeydown('l', self.showLighthouseRays, viz.TOGGLE))
        self._callbacks.append(vizact.onkeydown('x', self.saveDebugScene))

        self.findDevices()
        self.enable(self._enable)
        self._hotkey_callback = vizact.onkeydown(self._hotkey, self.enable, viz.TOGGLE)
        self._ui_callback = vizact.onupdate(viz.PRIORITY_LINKS+1, self._updateUI)
        print('* SteamVR Debug Overlay initialized.')
Exemple #18
0
    def addDebugModel(self, node, label, model=None, color=None, size=None):
        """ Add a debug model, axes and label for any node3d object. 
        Debug nodes are shown in UI and displayed/hidden together with 
        the rest of the debug scene. 

        Args:
            node: any Vizard node, group, or sensor object
            label (str): Brief text to identify the node in UI and VR
            model (str): One of:
                - 'sphere', 'cube', 'axes': use a vizshape primitive
                - a valid model file name ('test.osg'): load and use model
            color (3-tuple): RGB color, None for random (ignored for model files)
            size (float): Size of primitive, or scaling factor for model files
        """
        if label in self.nodes.keys():
            raise ValueError('Label already exists - node labels must be unique!')
            return None

        if color is None:
            color = colorsys.hsv_to_rgb(random.uniform(0.0, 1.0), 
                                        random.uniform(0.4, 1.0), 
                                        random.uniform(0.5, 1.0))
        # Add model and label text objects
        if model is not None and os.path.isfile(model):
            if size is None:
                size = 1.0
            _m = viz.addChild(model, parent=node)
            _m.setScale([size,] * 3)

        else:
            if size is None:
                size = 0.05

            if model is None:
                _m = viz.addGroup(parent=node)
                
            elif model == 'sphere':
                _m = vizshape.addSphere(radius=size, color=color, parent=node)
        
            elif model == 'cube':
                _m = vizshape.addCube(size=size, color=color, parent=node)

            elif model == 'axes':
                _m = vizshape.addAxes(length=size, color=color, parent=node)

        _m.disable(viz.INTERSECTION)
        _text = viz.addText3D(str(label), scale=(self.VALUE_SCALE,) * 3,
                              color=color, parent=_m, pos=(size * 1.1, 0.01, 0))
        _text.alignment(alignment=viz.ALIGN_LEFT_CENTER)
        _text.setEuler(0, 45, 0)

        # Add UI section for debug nodes if this is the first one
        if len(self.nodes) == 0:
            self._ui.addSeparator()
            self._ui.addItem(viz.addText('Other Nodes'))

        _ui = viz.addText('N/A')
        lbl = self._ui.addLabelItem(str(label), _ui)
        lbl.label.color(color)
        self._obj.extend([_m, _text])
        _m.visible(self._enable)
        _text.visible(self._enable)

        self.nodes[str(label)] = {'model': _m,
                                  'text': _text,
                                  'ui': _ui}

        print('* Added extra node entry: {:s}'.format(str(label)))
        return _m
    def createVisualObjects(self):

        self.IOD = 0.06
        
        # create a node3D leftEyeNode
        self.cyclopEyeNode = vizshape.addSphere(0.015, color = viz.GREEN)
        self.cyclopEyeNode.alpha(0.3)
        #cyclopEyeNode.visible(viz.OFF)
        self.cyclopEyeNode.setPosition(*self.rawDataStruct['view_Pos_XYZ'][:,0])
        self.cyclopEyeNode.setQuat(*self.rawDataStruct['view_Quat_WXYZ'][:,0])

        # create a node3D rightEyeNode
        self.rightEyeNode = vizshape.addSphere(0.015, color = viz.RED)
        #rightEyeNode.visible(viz.OFF)
        self.rightEyeNode.setParent(self.cyclopEyeNode)
        self.rightEyeNode.setPosition(self.IOD/2, 0, 0.0,viz.ABS_PARENT)
        self.rightEyeNode.alpha(0.3)
    #    right_sphere = gazeSphere(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],sphereColor=viz.ORANGE)
    #    rightGazeVector = gazeVector(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],gazeVectorColor=viz.ORANGE)
    #    right_sphere.toggleUpdate()
    #    rightGazeVector.toggleUpdate()
    #    right_sphere.node3D.alpha(0.7)    


        # create a node3D leftEyeNode
        self.leftEyeNode = vizshape.addSphere(0.015, color = viz.BLUE)
        #leftEyeNode.visible(viz.OFF)
        self.leftEyeNode.setParent(self.cyclopEyeNode)
        self.leftEyeNode.setPosition(-self.IOD/2, 0, 0.0,viz.ABS_PARENT)
        self.leftEyeNode.alpha(0.3)
    #    left_sphere = gazeSphere(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],sphereColor=viz.YELLOW)
    #    leftGazeVector = gazeVector(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],gazeVectorColor=viz.YELLOW)
    #    left_sphere.toggleUpdate()
    #    leftGazeVector.toggleUpdate()
    #    left_sphere.node3D.alpha(0.7)
        self.hmdDisplay = vizshape.addPlane([0.126, 0.071], axis = -vizshape.AXIS_Z, color = viz.GRAY)
        self.hmdDisplay.alpha(0.3)
        self.hmdDisplay.setParent(self.cyclopEyeNode)
        self.hmdDisplay.setPosition([0,0,0.0725], viz.ABS_PARENT) # 0.0725

        self.pixelatedBall = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.WHITE)
        self.pixelatedBall.setParent(self.hmdDisplay)
        self.pixelatedBall.setPosition([0,0,0])
        self.pixelatedBall.alpha(1)
        
        self.eyePOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.GREEN)
        self.eyePOR.setParent(self.hmdDisplay)
        self.eyePOR.setPosition([0,0,0])
        self.eyePOR.alpha(1)

        self.rightPOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.RED)
        self.rightPOR.setParent(self.hmdDisplay)
        self.rightPOR.setPosition([0,0,0])
        self.rightPOR.alpha(1)

        self.leftPOR = vizshape.addCircle(0.001, axis = -vizshape.AXIS_Z, color = viz.BLUE)
        self.leftPOR.setParent(self.hmdDisplay)
        self.leftPOR.setPosition([0,0,0])
        self.leftPOR.alpha(1)



        #creats a sphere(the ball) with radius of 5cm
        self.ball = vizshape.addSphere(radius = .08)
        #colors the ball red
        self.ball.color(viz.YELLOW)
        self.ball.visible(True)
        self.ball.setParent(self.cyclopEyeNode)

        self.Origin = vizshape.addAxes()
        self.Origin.setPosition(-5.5,0.1,8)
    #    #creats a sphere(the ball) with radius of 5cm
    #    #Head = vizshape.addCone( radius = 0.5, height = 0.8)
    #    Head = vizshape.addArrow(1, color = viz.YELLOW_ORANGE)
    #    #colors the ball red
    #    Head.color(viz.PURPLE)
    #    Head.visible(True)
    #    Head.setScale(.2,.2,.3)

        #creats a sphere(the hand) with radius of 10cm
        self.Hand = vizshape.addCylinder( height = 0.02, radius = 0.2, axis = vizshape.AXIS_Z)
        #colors the hand red
        self.Hand.color(viz.RED)
        self.Hand.visible(True)

        # Creating a Line to represent Cyclopean Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.GREEN)
        self.eyeGazeVector = viz.endLayer() # Object will contain both points and lines
        self.eyeGazeVector.visible(True)
        self.eyeGazeVector.setParent(self.cyclopEyeNode)
        self.eyeGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.eyeGazeSphere = vizshape.addSphere(0.02, color = viz.GREEN)
        self.eyeGazeSphere.setParent(self.cyclopEyeNode)


        # Creating a Line to represent Right Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.RED)
        self.rightGazeVector = viz.endLayer() # Object will contain both points and lines
        self.rightGazeVector.visible(True)
        #rightGazeVector.setParent(rightEyeNode)
        self.rightGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.rightGazeSphere = vizshape.addSphere(0.02, color = viz.RED)
        self.rightGazeSphere.setParent(self.rightEyeNode)
        self.rightGazeSphere.visible(False)

        # Creating a Line to represent Left Eye Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.BLUE)
        self.leftGazeVector = viz.endLayer() # Object will contain both points and lines
        self.leftGazeVector.visible(True)
        #leftGazeVector.setParent(leftEyeNode)
        #leftGazeVector.setScale(5,5,5)
        self.leftGazeSphere = vizshape.addSphere(0.02, color = viz.BLUE)
        self.leftGazeSphere.setParent(self.leftEyeNode)
        self.leftGazeSphere.visible(False)


        # Creating a Line to represent Eye-Ball Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.YELLOW)
        self.EyeBallLine = viz.endLayer() # Object will contain both points and lines
        self.EyeBallLine.visible(False)
        #EyeBallLine.setScale(5,5,5)

        self.male = viz.add('ktex.obj') 
        #male.state(1) #looping idle animation
        #self.headBone = self.male.getBone('Bip01 Head')
        #self.headBone.lock()
        self.male.setParent(self.cyclopEyeNode)
Exemple #20
0
import viz
import vizact
import vizshape

viz.go()

VRPN_SOURCE = '[email protected]'
#VRPN_SOURCE = 'Nexus@localhost'

viz.move([0, -1, -5])

axes = vizshape.addAxes(length=0.5)

vrpn = viz.add('vrpn7.dle')
headtracker = vrpn.addTracker(VRPN_SOURCE)
headtracker.swapPos([-1, 3, -2])

#viz.link(headtracker,axes)


def showData():
    print('position')
    print headtracker.getPosition()


#	print headtracker.getEuler()

vizact.ontimer(1, showData)
#    print 'Viewpoint position',viewpoint.getPosition()
#    print 'Movable position',movable.getPosition(),'\n'
#vizact.ontimer(5, printData)
## Setup tracking if this is the main script
#if __name__ == "__main__":
#	import viztracker
#	viztracker.DEFAULT_HANDS = True
#	viztracker.go()

#so far so good

viz.setMultiSample(4)
viz.fov(60)
viz.go()
#Add a world axis with X,Y,Z labels
world_axes = vizshape.addAxes()
X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#grids are good
grid = vizshape.addGrid(color=[0.2]*3)
viz.clearcolor(viz.GRAY)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)



#create our bisecting plane
mid_plane= vizshape.addPlane(size=(.00001,.00001),axis=vizshape.AXIS_X, cullFace=False)
    def createVisualObjects(self):

        #creats a sphere(the ball) with radius of 5cm
        self.ball = vizshape.addSphere(radius = .05)
        #colors the ball red
        self.ball.color(viz.YELLOW)
        self.ball.visible(True)

        self.Origin = vizshape.addAxes()
        self.Origin.setPosition(-5.5,0.1,8)
    #    #creats a sphere(the ball) with radius of 5cm
    #    #Head = vizshape.addCone( radius = 0.5, height = 0.8)
    #    Head = vizshape.addArrow(1, color = viz.YELLOW_ORANGE)
    #    #colors the ball red
    #    Head.color(viz.PURPLE)
    #    Head.visible(True)
    #    Head.setScale(.2,.2,.3)

        #creats a sphere(the hand) with radius of 10cm
        self.Hand = vizshape.addCylinder( height = 0.02, radius = 0.2, axis = vizshape.AXIS_Z)
        #colors the hand red
        self.Hand.color(viz.RED)
        self.Hand.visible(True)

        self.IOD = 0.06
        
        # create a node3D leftEyeNode
        self.cyclopEyeNode = vizshape.addSphere(0.015, color = viz.GREEN)
        #cyclopEyeNode.visible(viz.OFF)
        self.cyclopEyeNode.setPosition(*self.rawDataStruct['view_Pos_XYZ'][:,0])
        self.cyclopEyeNode.setQuat(*self.rawDataStruct['view_Quat_WXYZ'][:,0])

        # create a node3D rightEyeNode
        self.rightEyeNode = vizshape.addSphere(0.015, color = viz.RED)
        #rightEyeNode.visible(viz.OFF)
        self.rightEyeNode.setParent(self.cyclopEyeNode)
        self.rightEyeNode.setPosition(self.IOD/2, 0, 0.0,viz.ABS_PARENT)
    #    right_sphere = gazeSphere(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],sphereColor=viz.ORANGE)
    #    rightGazeVector = gazeVector(eyeTracker,viz.RIGHT_EYE,rightEyeNode,[clientWindowID],gazeVectorColor=viz.ORANGE)
    #    right_sphere.toggleUpdate()
    #    rightGazeVector.toggleUpdate()
    #    right_sphere.node3D.alpha(0.7)    


        # create a node3D leftEyeNode
        self.leftEyeNode = vizshape.addSphere(0.015, color = viz.BLUE)
        #leftEyeNode.visible(viz.OFF)
        self.leftEyeNode.setParent(self.cyclopEyeNode)
        self.leftEyeNode.setPosition(-self.IOD/2, 0, 0.0,viz.ABS_PARENT)
    #    left_sphere = gazeSphere(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],sphereColor=viz.YELLOW)
    #    leftGazeVector = gazeVector(eyeTracker,viz.LEFT_EYE,leftEyeNode,[clientWindowID],gazeVectorColor=viz.YELLOW)
    #    left_sphere.toggleUpdate()
    #    leftGazeVector.toggleUpdate()
    #    left_sphere.node3D.alpha(0.7)

        # Creating a Line to represent Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.GREEN)
        self.eyeGazeVector = viz.endLayer() # Object will contain both points and lines
        self.eyeGazeVector.visible(True)
        self.eyeGazeVector.setParent(self.cyclopEyeNode)
        self.eyeGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.eyeGazeSphere = vizshape.addSphere(0.02, color = viz.GREEN)
        self.eyeGazeSphere.setParent(self.cyclopEyeNode)


        # Creating a Line to represent Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.RED)
        self.rightGazeVector = viz.endLayer() # Object will contain both points and lines
        self.rightGazeVector.visible(True)
        #rightGazeVector.setParent(rightEyeNode)
        self.rightGazeVector.pointSize(10)
        #rightGazeVector.setScale(5,5,5)
        self.rightGazeSphere = vizshape.addSphere(0.02, color = viz.RED)
        self.rightGazeSphere.setParent(self.rightEyeNode)

        # Creating a Line to represent Gaze Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.BLUE)
        self.leftGazeVector = viz.endLayer() # Object will contain both points and lines
        self.leftGazeVector.visible(True)
        #leftGazeVector.setParent(leftEyeNode)
        #leftGazeVector.setScale(5,5,5)
        self.leftGazeSphere = vizshape.addSphere(0.02, color = viz.BLUE)
        self.leftGazeSphere.setParent(self.leftEyeNode)


        # Creating a Line to represent Eye-Ball Vector
        viz.startLayer(viz.LINES)
        viz.vertex(0,0,0)
        viz.vertex(0,0,3)
        viz.vertexColor(viz.YELLOW)
        self.EyeBallLine = viz.endLayer() # Object will contain both points and lines
        self.EyeBallLine.visible(True)