Пример #1
0
    global accx, accy, accz, acc_M, MAX_AMP
    for i in range (0, len(accx)):
        acc_M.append(math.sqrt(accx[i]*accx[i]+accy[i]*accy[i]+accz[i]*accz[i]))
        #print NOISE_AMP, acc_M[i], ' xyz:', accx[i],accy[i],accz[i]
        if acc_M[i] < NOISE_AMP:
            [accx[i], accy[i], accz[i]] = [0,0,0]
            print 'Filtered #%i; amp=%f' % (i, acc_M[i])

# Averaging of a list
def avg(val): return sum(val)/len(val)

# Zooming of the view
def zoom(amount):
    global dist
    dist *= (1+0.05*amount)
    
## Updates the transparancy and size of the elements in the trail
def updateAlpha():
    global tail, alpha
    for i in range (0,len(tail)-5):
        alpha[i] -= 0.1
        viz.VizChild(tail[i]).alpha(alpha[i])

loadcsv()
calc_abs()
endtime = float(ts[len(ts)-1])
t = (float(ts[len(ts)-1])-float(ts[0]))/len(ts)

vizact.onwheeldown(zoom,1)
vizact.onwheelup(zoom,-1)
viztask.schedule(runanimation())
Пример #2
0
	def __init__(self, screen, textArray, numberOfChoices = 1, doneText = globals_oa.DEFAULT_DONE_TEXT):
		self.instructionsQuestion = textArray[0]
		self.screen = screen
		readyToConfirm = False
#		self.sub_number = subject_number
		self.q1Cycle = viz.cycle([])
		self.valueCycle = viz.cycle([])
		
		q1Node = viz.addGroup()
		q1Node.disable(viz.INTERSECTION)
		q1Node.disable(viz.LIGHTING)
		q1Node.disable(viz.FOG)
		q1Node.drawOrder(100000000)
		q1Node.disable(viz.DEPTH_TEST)
		viz.link(self.screen, q1Node)		
		
		self.currQuestion = viz.addText("",parent=q1Node)
#		self.currQuestion.disable(viz.FOG)
		self.currQuestion.setScale([self.fontScale,self.fontScale,self.fontScale])
		self.currQuestion.alignment(viz.ALIGN_CENTER)
		self.currQuestion.setPosition([0,.1,self.zOffset])
		
		self.instructions = viz.addText("",parent=q1Node)
#		self.instructions.disable(viz.FOG)
#		self.instructions.setScale([self.fontScale/2,self.fontScale/2,self.fontScale/2])
		self.instructions.setScale([self.fontScale,self.fontScale,self.fontScale])
		self.instructions.alignment(viz.ALIGN_CENTER)
		self.instructions.setPosition([0,.6,self.zOffset])
		
		prev = viz.addGroup(parent=q1Node)
		self.q1Number = prev
		numberYOffset = -.7
		numberXOffset = -1.9
#		numberXOffset = -1
#		for i in range(1,8):
#			number = viz.addText(str(i) , parent=prev)
##			number.disable(viz.FOG)
#			number.alignment(viz.ALIGN_LEFT_CENTER)
#			
#			number.setPosition([2,0,0])
#			
#			if prev == self.q1Number:
#				number.alignment(viz.ALIGN_CENTER)
#				number.setPosition([numberXOffset,numberYOffset,self.zOffset])
#				number.setScale([self.fontScale,self.fontScale,self.fontScale]	)
#				
#			prev = number	
#			self.q1Cycle.append(number)

		#adding choices
		if numberOfChoices == 5:
			numberYOffset = -.7
			numberXOffset = -2.2
			separation = 4.5
		elif numberOfChoices == 3:
			numberYOffset = -.7
			numberXOffset = -1.3
			separation = 4.5
		elif numberOfChoices == 2:
			numberYOffset = -.7
			numberXOffset = -0.9
			separation = 4.5
		else:
			numberYOffset = -.7
			numberXOffset = -0.2
			separation = 4.5

		choiceScale = self.fontScale*(6.0/7.0)
		for i in range(1, numberOfChoices+1):
			choice = viz.addText(textArray[i], parent=prev)
			choice.alignment(viz.ALIGN_LEFT_CENTER)
			if i == 1:
				choice.setPosition([numberXOffset,numberYOffset,self.zOffset])
				firstChoice = choice
				choice.setScale([choiceScale,choiceScale,choiceScale])
			else:
				choice.setPosition([separation,0,0])
			prev = choice
			self.q1Cycle.append(choice)
		#adding the globals_oa.DEFAULT_DONE_TEXT text
#		doneButtonPos = [1.7, -1.0, 0.0]
		doneButtonPos = [0.0, -1.2, 0.0]
		self.doneChoice = viz.addText(doneText, parent=self.q1Number)
		self.doneChoice.alignment(viz.ALIGN_CENTER)
		self.doneChoice.setPosition(doneButtonPos)
		self.doneChoice.setScale([choiceScale,choiceScale,choiceScale])
		self.doneChoice.visible(False)
#		self.q1Cycle.append(self.doneChoice)
			
#		choice = viz.addText('Colder', parent=prev)
#		choice = viz.addText(textArray[2], parent=prev)
#		choice.alignment(viz.ALIGN_LEFT_CENTER)
#		choice.setPosition([separation,0,0])
#		prev = choice
#		self.q1Cycle.append(choice)

##		choice = viz.addText('Same as\nbefore', parent=prev)
#		choice = viz.addText(textArray[3], parent=prev)
#		choice.alignment(viz.ALIGN_LEFT_CENTER)
#		choice.setPosition([separation,0,0])
#		prev = choice
#		self.q1Cycle.append(choice)
#
##		choice = viz.addText('Warmer', parent=prev)
#		choice = viz.addText(textArray[4], parent=prev)
#		choice.alignment(viz.ALIGN_LEFT_CENTER)
#		choice.setPosition([separation + 0.4,0,0])
#		prev = choice
#		self.q1Cycle.append(choice)
#
##		choice = viz.addText(' A lot\nwarmer', parent=prev)
#		choice = viz.addText(textArray[5], parent=prev)
##		choice.get
#		choice.alignment(viz.ALIGN_LEFT_CENTER)
#		choice.setPosition([separation,0,0])
#		prev = choice
#		lastChoice = choice
#		self.q1Cycle.append(choice)
		
		vizact.onwheelup( self.cycleToNextValue ) 
		if globals_oa.wiimote is not None: vizact.onsensordown(globals_oa.wiimote, globals_oa.wii.BUTTON_PLUS,self.cycleToNextValue)
		vizact.onwheeldown( self.cycleToPreviousValue )
		if globals_oa.wiimote is not None: vizact.onsensordown(globals_oa.wiimote, globals_oa.wii.BUTTON_MINUS,self.cycleToPreviousValue)

		if globals_oa.rhViveTracker is not None: vizact.onsensordown(globals_oa.rhViveTracker, steamvr.BUTTON_TRIGGER,self.cycleToNextValue)
		if globals_oa.lhViveTracker is not None: vizact.onsensordown(globals_oa.lhViveTracker, steamvr.BUTTON_TRIGGER,self.onSelect)
		
#		verticalSeparationBetweenScaleAndText = 0.25
#		#adding a visual cue for the temperature scale
#		viz.startLayer(viz.LINES)
#		viz.lineWidth(4)
#		viz.vertexColor(viz.BLUE)
##		print "firstChoice.getPosition(mode = viz.ABS_PARENT) = " + str(firstChoice.getPosition(mode = viz.ABS_PARENT))
#		viz.vertex([(numberXOffset + 0.1), numberYOffset+verticalSeparationBetweenScaleAndText, 0.0])
#		viz.vertexColor(viz.GREEN)
##		print "lastChoice.getPosition(mode = viz.ABS_PARENT) = " + str(lastChoice.getPosition(mode = viz.ABS_PARENT))
#		viz.vertex([-(numberXOffset + 0.1), numberYOffset+verticalSeparationBetweenScaleAndText, 0.0])
#		tempScale = viz.endLayer()
#		tempScale.setParent(q1Node)
#		if not showTempScale: tempScale.visible(False)
			
#		valueNamesYOffset = numberYOffset - .2	
#		self.lowValue = viz.addText("", parent=q1Node)
##		self.lowValue.disable(viz.FOG)
#		self.lowValue.setScale([self.valueFont,self.valueFont,self.valueFont])
#		self.lowValue.alignment(viz.ALIGN_CENTER)
#		self.lowValue.setPosition([numberXOffset,valueNamesYOffset, self.zOffset])
#				
#		self.midValue = viz.addText("", parent=q1Node)
##		self.midValue.disable(viz.FOG)
#		self.midValue.setScale([self.valueFont,self.valueFont,self.valueFont])
#		self.midValue.alignment(viz.ALIGN_CENTER)
#		self.midValue.setPosition([0,valueNamesYOffset, self.zOffset])
#		
#		self.highValue = viz.addText("", parent=q1Node)
##		self.highValue.disable(viz.FOG)
#		self.highValue.setScale([self.valueFont,self.valueFont,self.valueFont])
#		self.highValue.alignment(viz.ALIGN_CENTER)
#		self.highValue.setPosition([-numberXOffset + .45,valueNamesYOffset,self.zOffset])		
		
#		q4Node = viz.addGroup()
#		self.q4Link = viz.link(self.screen, q4Node)
		
#		imageInstructions = viz.addText(self.imageInstructions,parent=q4Node)
#		imageInstructions.disable(viz.FOG)
#		imageInstructions.setScale([self.fontScale,self.fontScale,self.fontScale])
#		imageInstructions.alignment(viz.ALIGN_CENTER)
#		imageInstructions.setPosition([0,1.2,self.zOffset])
		
#		self.questionaire_data = open('./data/questionaire.txt', 'a')
#		self.questionaire_data.write('Subject number: ' + str(subject_number) + ';')
#		self.questionaire_data.flush()
#		
#		# Load texture 
#		pics = [viz.addTexture("resources/q4_images/SOIQ%ds.jpg" % (slideNum + 1)) for slideNum in range(7)]
#		for pic in pics:
#			pic.hint(viz.PRELOAD_HINT)
#		answers = [viz.addTexQuad(texture=pic, parent=q4Node) for pic in pics]
		
#		counter = 0
#		for i in [self.imageYScale, 0]:
#			for j in [-self.imageXScale, 0, self.imageXScale]:
#				answers[counter].setPosition([j,i,self.zOffset])
#				counter+=1
#
#		answers[6].setPosition([0,-self.imageYScale,self.zOffset])
#		
#		counter = 1
#		for answer in answers:
#			answer.scale([.5, .5, .5])
#			number = viz.addText(str(counter) , parent=answer)
##			number.disable(viz.FOG)
#			number.setScale([self.fontScale,self.fontScale,self.fontScale])
#			number.alignment(viz.ALIGN_CENTER_BOTTOM)
#			
#			number.setPosition([0,-.75,0])
#
#			self.q4Cycle.append(number)
#			counter +=1
			
	
#		prev = viz.addGroup(parent=q1Node)
#		self.q5Number = prev
#		for i in range(1,6):
#			number = viz.addText(str(i) , parent=prev)
##			number.disable(viz.FOG)
#			
#			number.alignment(viz.ALIGN_LEFT_CENTER)
#			
#			number.setPosition([3,0,0])
#			
#			if prev == self.q5Number:
#				number.alignment(viz.ALIGN_CENTER)
#				number.setPosition([numberXOffset-.1,numberYOffset,self.zOffset])
#				number.setScale([self.fontScale,self.fontScale,self.fontScale]	)
#				
#			prev = number	
#			self.q5Cycle.append(number)
		
		self.q1Link = q1Node
#		self.q4Link = q4Node

		self.setVisibleType(0)
				
		viz.callback(viz.MOUSEDOWN_EVENT,self.onMouseDown) 
		viz.callback(viz.MOUSEUP_EVENT,self.onMouseUp) 
#		vizact.onsensordown(globals_oa.wiimote, globals_oa.wii.BUTTON_HOME,self.onSelect)
		if globals_oa.wiimote is not None: vizact.onsensordown(globals_oa.wiimote, globals_oa.wii.BUTTON_B,self.onSelect)
Пример #3
0
            [accx[i], accy[i], accz[i]] = [0, 0, 0]
            print 'Filtered #%i; amp=%f' % (i, acc_M[i])


# Averaging of a list
def avg(val):
    return sum(val) / len(val)


# Zooming of the view
def zoom(amount):
    global dist
    dist *= (1 + 0.05 * amount)


## Updates the transparancy and size of the elements in the trail
def updateAlpha():
    global tail, alpha
    for i in range(0, len(tail) - 5):
        alpha[i] -= 0.1
        viz.VizChild(tail[i]).alpha(alpha[i])


loadcsv()
calc_abs()
endtime = float(ts[len(ts) - 1])
t = (float(ts[len(ts) - 1]) - float(ts[0])) / len(ts)

vizact.onwheeldown(zoom, 1)
vizact.onwheelup(zoom, -1)
viztask.schedule(runanimation())