Exemple #1
0
import viz
import vizact
import vizinfo

viz.setMultiSample(4)
viz.fov(60)
viz.go()

#vizinfo.InfoPanel()
#
FRAME_RATE  = 30        # in Hertz

#Create cycle of textures
movieImages = viz.cycle( [ viz.addTexture('textures/Seq/TestTexture_00%d.jpg' % i) for i in range(1,98) ] )

#Add and position the movie screen
screen = viz.addTexQuad()
screen.setPosition([0, 1.82, 1.5])
screen.setScale([4.0/3, 1, 1])

#Setup timer to swap texture at specified frame rate
def NextMovieFrame():
    screen.texture(movieImages.next())

vizact.ontimer(1.0/FRAME_RATE, NextMovieFrame)
Exemple #2
0
MAX_BALLS = 20
MIN_POWER = 5
MAX_POWER = 10

#We need to enable physics
viz.phys.enable()

balls = []

for x in range(MAX_BALLS):
    ball = vizshape.addSphere(0.05, color=viz.BLACK)
    ball.collideSphere()
    balls.append(ball)

#Create a generator this will loop through the balls
nextBall = viz.cycle(balls)

#Add a green marker that will show where we are aiming, disable picking on it
import vizshape
marker = vizshape.addSphere(radius=0.1, color=viz.GREEN)
marker.visible(False)
marker.disable(viz.PICKING)

#Add a progress bar to the screen that will show how much power is charged up
power = viz.addProgressBar('Power', pos=(0.8, 0.1, 0))
power.disable()
power.set(0)

#Move the head position back and up and look at the origin
viz.MainView.setPosition([0, 5, -20])
viz.MainView.lookAt([0, 0, 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)
ballMaster.collideSphere( friction = .00000001, hardness = 1 )

balls = [] #list of all cloned balls

#Create clones of the master ball
for y in range(NUM_BALLS):
	ball = ballMaster.clone()
	ball.setPosition( [0, y, 0] )
	ball.setScale( [BUMPER_WIDTH*1.5]*3 )
	ball.collideCopy( ballMaster ) #Enable collisions with the ball based on a sphere shape
	balls.append( ball ) #Add the ball to the ball list

ballMaster.remove()

#Create cycle for balls
nextBall = viz.cycle( balls )

#Create object that drops the ball
ballDropper = viz.addAvatar( 'duck.cfg' )
ballDropper.setPosition( [0, 1.9, .2] )
ballDropper.setScale( [.2, .2, .2] )
ballDropper.setEuler( [180, 0, 0] )
ballDropper.state( 1 )

#Drop ball when spacebar is pressed
def dropBall():
	ball = nextBall.next() #get the next ball to drop
	ball.reset() #zero out physics forces
	ball.setPosition( ballDropper.getPosition() ) #drop ball at ballDropper's position
	ballDropper.execute( 2 )
Exemple #5
0
famicon = viz.add('resource/Famicom.osgb',
                  pos=[6.05, 1.4, 3.65],
                  euler=(-90, 0, 0))
famicon_sensor = vizproximity.Sensor(vizproximity.CircleArea(1.5),
                                     source=famicon)
manager.addSensor(famicon_sensor)
mario = viz.add('resource/NES+mario.osgb',
                pos=[5.9, 1.6, 3.9],
                scale=(0.007, 0.007, 0.007),
                euler=(-90, 0, 0),
                alpha=(0))
mario_bgm = viz.addAudio('sound/スーパーマリオブラザーズ 地上BGM.wav', viz.LOOP, volume=0.1)

# ギーラボの紹介プレゼン、画像の用意
movieImages = viz.cycle([
    viz.addTexture('resource/introduction/glnagano%d.jpeg' % i)
    for i in range(1, 39)
])
screen = viz.addTexQuad()
screen.setPosition([0, 2.67, 6.33])
screen.setScale([0.789 * 3.01, 0.62 * 2.19, 1])

# ギークラボ長野へようこそ
text3D = viz.addText3D('welcome to geeklab NAGANO',
                       pos=[0, 2.3, 2],
                       align=viz.ALIGN_CENTER_BOTTOM,
                       color=viz.YELLOW,
                       scale=[0.1, 0.05, 0.1],
                       font='Comic Sans MS')

text3D.add(
    vizact.sequence(vizact.moveTo((0, 2.0, 2), speed=0.1),