コード例 #1
0
ファイル: universe.py プロジェクト: luion/virtual-ar-museum
def init_settings(mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run):
	viz.MainWindow.visible(viz.OFF) #Hago invisible la main window
	viz.setMultiSample(8) # FSAA de 8
	viz.fogcolor = viz.BLACK # Color de sombra = negro
	viz.fog(0.15) # Agrega sombra de tipo exponencial
	viz.collision(viz.ON) # Habilita colisiones en el mundo
	viz.phys.enable() # Habilita la fisica

	#Desabilita mouse
	viz.mouse.setOverride(viz.ON)

	#Mouse invisible
	viz.mouse.setVisible(viz.OFF)

	#Subventana que renderea viz.MainWindow
	mainSceneWindow = viz.addWindow()
	mainSceneWindow.setSize(0.7,1)
	mainSceneWindow.setPosition(0,1)
	mainSceneWindow.fov(40, 1.3) # Coloca el FOV de la ventana principal en la actual con los valores de default (40 grados verticales, 1.3 aspect ratio)

	#Creando una ventana y un punto de vista para la camara
	cameraWindow = viz.addWindow(pos =[.7,1],size=(0.4,1)) #Creando la ventana
	cameraWindowView = viz.addView() #Creando un viewpoint
	cameraWindowView.setScene(2) #Poniendo la nueva ventana en la escena 2
	cameraWindow.setView(cameraWindowView) #Ligando el viewpoint con la nueva ventana

	#Vincular camara web a plugin de AR
	cam = ar.addWebCamera(window=cameraWindow) #Agregando una camara en la ventada nueva

	# Configuracion de mensajes de la pantalla
	message_screen = viz.addTexQuad(parent=viz.SCREEN, pos=[0.5,0.5,1], scale=[12.80,10.24,1]) 
	pause_screen = viz.add("PAUSA.png")
	nunchuck_disconnect_screen = viz.add("NUNCHUCK_DISCONNECTED.png")
	message_screen.texture(pause_screen)
	message_screen.visible(viz.OFF) #Cuando should_it_run sea False, viz.ON es el valor a usar.

	# Conecta al primer wiimote disponible
	wiimote = wii.addWiimote()
	# Prende el LED 1 del wiimote
	wiimote.led = wii.LED_1
	# Obten el nunchuck del wiimote
	nunchuck_wiimote = wiimote.nunchuk 

	#Determines wheter the program should run or not.
	#It will run if the Nunchuck is connected; otherwise, it won't.
	should_it_run = True

	#Ensures that the program won't run without the NUNCHUCK plug'd in.
	if(wiimote.getExtension() == wii.EXT_NUNCHUK):
		should_it_run = True
	else:
		print "Please plug-in the Wii NUNCHUCK."
		message_screen.texture(nunchuck_disconnect_screen)
		message_screen.visible(viz.ON)
		should_it_run = False
	
	return mainSceneWindow, cameraWindow, cameraWindowView, cam, pause_screen, nunchuck_disconnect_screen, message_screen, wiimote, nunchuck_wiimote, should_it_run
コード例 #2
0
 def initScreen(self):
   self.subwindow = viz.addWindow()
   self.subview = viz.addView()
   self.subwindow.setScene(self.scene)
   self.subwindow.setView(self.subview)
   self.subwindow.setPosition([0,1])
   self.subwindow.setSize([self.scale,self.scale])
コード例 #3
0
ファイル: Window.py プロジェクト: tokola/GitHub_OLiVE
	def __init__(self, view=None, win=None, winPos=[], player=None, fact=None, data=None, sm=None, fmap=None, lang=None):
		if view == None:
			view = viz.addView()
		self._view = view
		if win == None:
			win = viz.addWindow()
		self._window = win
		self._window.fov(60)
		self._window.setSize(.5,.5)
		self._window.setPosition(winPos)
		self._window.setView(self._view)
		self._size = self._window.getSize(viz.WINDOW_ORTHO)
		self._player = player
		self.LoadToolTips(lang)
		#check if this is a player window
		if player in [1,2,3]:
			self.PLAYERS[player] = self	#list of all player instances (used by FSM_Actions)
			self._name = data['name']
			self._view.setPosition(data['pos'])
			self._view.stepSize(0.1)
			self._view.collisionBuffer(0.25)
			self._view.getHeadLight().disable()
			self._window.clearcolor(viz.SKYBLUE)
			self.AddPanel(lang)
			#reset other variables
			self._toolbox = OrderedDict()
			self._selected = None	#object name being currently held/selected
			self._holding = None	#object being currently held/selected
			self._picking = None	#object name being intersected by cursor
			self._iMach = None		#machine interacting with (one of its components)
			self._nearMachine = None#machine being near to (based on proximity)
			self._updateAlerts = []	#a list of tuples (machine, error) for checking the alert update
			self._factory = fact	#factory object
			self.AddToToolbox('hand')
			self._fsm = sm			#FSM with all machine states
			self._mapWin = fmap		#the map (storing all alerts and messages)
			self._pressed = False	#True is player presses a button
			self._pickcolor = viz.GREEN
			self._feedback = None	#feedback message as result of interaction (not in FSM)
			self._iLog = []			#for logging picked and dropped tools from inventory
			self._proxLog = []		#for logging proximity to machines (enter, exit)
			self._pLog = []			#for logging position data
			self._collabAction = ''	#stores the collab action in 1P mode
			#set an update function to take care of window resizing (priority=0)
			self._updateFunc = vizact.onupdate(0, self.Update)
			#FSM_Actions.FSM_Actions.__init__(self)
		else:	#this is the map view
			self._window.clearcolor([.3,.3,.3])
			self._window.ortho(-25,25,-15,20,-1,1)
			self._view.setPosition(-3.8,0,0)
			self._view.setEuler(0,90,0)
			self._alerts = {}
			self._messages = OrderedDict()
			self.AddMap()
コード例 #4
0
import subprocess
import vizfx

#global cpps
#cpps = subprocess.Popen('"C:/Users/Gelsey Torres-Oviedo/Documents/Visual Studio 2013/Projects/Vicon2Python_DK2_rev2/x64/Release/Vicon2Python_DK2_rev2.exe"')
#time.sleep(3)

viz.splashScreen(
    'C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final_DK2.jpg'
)
viz.setMultiSample(8)
viz.go(
    #viz.FULLSCREEN #run world in full screen
)

monoWindow = viz.addWindow(size=(1, 1), pos=(0, 1), scene=viz.addScene())
monoQuad = viz.addTexQuad(parent=viz.ORTHO, scene=monoWindow)
monoQuad.setBoxTransform(viz.BOX_ENABLED)
monoQuad.setTexQuadDisplayMode(viz.TEXQUAD_FILL)
texture = vizfx.postprocess.getEffectManager().getColorTexture()


def UpdateTexture():
    monoQuad.texture(texture)


vizact.onupdate(0, UpdateTexture)

global hmd
view = viz.addView
hmd = oculus.Rift()
コード例 #5
0
ファイル: Vizard51.py プロジェクト: willpower2727/VR_scripts
import vizact
import struct
import array
import math
import vizlens
import imp
oculus = imp.load_source('oculus', 'C:\Program Files\WorldViz\Vizard5\python\oculus.py')
import subprocess
import vizfx

viz.splashScreen('C:\Users\Gelsey Torres-Oviedo\Desktop\VizardFolderVRServer\Logo_final_DK2.jpg')
viz.setMultiSample(8)
viz.go(
#viz.FULLSCREEN #run world in full screen
)
monoWindow = viz.addWindow(size=(1,1), pos=(0,1), scene=viz.addScene())
monoQuad = viz.addTexQuad(parent=viz.ORTHO, scene=monoWindow)
monoQuad.setBoxTransform(viz.BOX_ENABLED)
monoQuad.setTexQuadDisplayMode(viz.TEXQUAD_FILL)
texture = vizfx.postprocess.getEffectManager().getColorTexture()

def UpdateTexture():
    monoQuad.texture(texture)

global hmd
view = viz.addView
hmd = oculus.Rift()
hmd.getSensor()

viz.MainView.setPosition(0,0.15,-1.27*3/2+0.002)
viz.MainView.setEuler(0,0,0)
コード例 #6
0
ファイル: Main.py プロジェクト: QuillanC/TaxiGame
# set size (in pixels) and title of application window
viz.window.setSize(640, 480)
viz.window.setName("Taxi Driver!")

# get graphics window
window = viz.MainWindow

sound = viz.addAudio('MoonlightSonata.wav')
sound.volume(.5)
#sound.setTime(1)
#sound.setRate(0.7)
sound.play()

# get mini map
miniMap = viz.addWindow()
miniMap.setSize([.3, .4])
miniMap.setPosition([0, 1])
miniMap.fov(70)
miniMapView = viz.addView()
miniMap.setView(miniMapView)

miniMapView.setPosition([250, 450, 275])
miniMapView.setEuler([90, 90, 0])

# set background color of window to gray
viz.MainWindow.clearcolor([150, 150, 150])

# allows mouse to rotate, translate, and zoom in/out on object
#pivotNav = vizcam.PivotNavigate()
コード例 #7
0
    def getOutputTexture(self):
        return self._output_texture

    def remove(self):
        self._cam.remove()
        self._projector.remove()
        viz.VizNode.remove(self)


if __name__ == '__main__':
    import vizshape
    import vizcam

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

    vizcam.WalkNavigate()

    piazza = viz.addChild('piazza.osgb')

    capture = ViewAccumulator(frame_weight=0.5, aperture_scale=0.5)
    capture.setPosition(0, 1.8, 3.0)

    # add debug quad
    output_quad = vizshape.addQuad()
    output_quad.texture(capture.getOutputTexture())
    output_quad.disable(viz.LIGHTING)
    output_quad.renderOnlyToWindows(
        [viz.addWindow(pos=[0.5, 0.5], size=[0.5, 0.5])])
    viz.link(capture, output_quad)
コード例 #8
0
    dm = viz.getFrameElapsed() * MOVE_SPEED
    rm = viz.getFrameElapsed() * ROTATION_SPEED
    #get move of Joystick
    x, y, z = joy.getPosition()
    m.preTrans([0, 0, -y * dm])
    navigationNode.setPosition(m.getPosition(), viz.REL_PARENT)
    #Get the twist of the joystick
    #	twist = joy.getTwist()
    m.setEuler(x * rm)
    navigationNode.setEuler(m.getEuler(), viz.REL_LOCAL)


current_scene = 0

ARscene = viz.addScene()
ARsubWindow = viz.addWindow(pos=[0, 1], size=[0.25, 0.25])
ARsubView = viz.addView()
ARsubView.setScene(ARscene)
ARsubWindow.setView(ARsubView)

cam = ar.addWebCamera(window=ARsubWindow)

ARitem = viz.addChild(item['gem3'], scene=ARscene)
mark1 = cam.addMatrixMarker(0, width=1000)
viz.link(mark1, ARitem)

#AR2item = viz.addChild(item['gem4'], scene=ARscene)
#mark2 = cam.addMarker("ar\patt.hiro")
#viz.link(mark2, AR2item)

ARsubWindow.visible(False)
コード例 #9
0
ファイル: setupDK2Cluster.py プロジェクト: EvanKrueger/CatchB
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawDisplay = vizconnect.getRawDisplayDict()

	#VC: initialize a new display
	_name = 'exp_display'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set the window for the display
			_window = viz.addWindow()
			_window.setView(viz.addView())
			
			#VC: set placement with alignment: free
			_window.setPosition(0, 1, mode=viz.WINDOW_NORMALIZED)
			_window.setSize(1, 1, mode=viz.WINDOW_NORMALIZED)
			
			#VC: make the window visible only for certain clients
			_clusterMask = viz.CLIENT1
			with viz.cluster.MaskedContext(viz.ALLCLIENTS&~_clusterMask):# hide
				_window.visible(False)
			with viz.cluster.MaskedContext(_clusterMask):# show
				_window.visible(True)
			
			#VC: set the fullscreen monitor
			with viz.cluster.MaskedContext(viz.CLIENT1):# only for clients with this display
				viz.window.setFullscreenMonitor(3)
				viz.window.setFullscreen(True)
			
			#VC: set some parameters
			VFOV = 60
			aspect = viz.AUTO_COMPUTE
			stereo = viz.OFF
			
			#VC: create the raw object
			_window.fov(VFOV,aspect)
			_window.stereo(stereo)
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Custom Window')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getTracker('head_tracker'))

	#VC: initialize a new display
	_name = 'rift_display'
	if vizconnect.isPendingInit('display', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			
			#VC: set the window for the display
			_window = viz.MainWindow
			
			#VC: set some parameters
			autoDetectMonitor = True
			timeWarpEnabled = True
			
			#VC: create the raw object
			import oculus
			try:
				display = oculus.Rift(window=_window, autoDetectMonitor=autoDetectMonitor)
				_window.displayNode = display
				viz.window.setFullscreen(True)
			except AttributeError:
				_window.displayNode = None
			rawDisplay[_name] = _window
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addDisplay(rawDisplay[_name], _name, make='Oculus VR', model='DK2')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getDisplay(_name).setParent(vizconnect.getTracker('head_tracker'))

	#VC: return values can be modified here
	return None
コード例 #10
0
This script demonstrates how to add multiple windows.
The upper right window is a rear view of the scene
The upper left window is a birds eye view
"""

import viz
import vizact

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

import vizinfo

# Create a new window in the upper left corner
UpperLeftWindow = viz.addWindow(pos=(0, 1.0), size=(0.2, 0.2))

#Create a new window in the upper right corner
UpperRightWindow = viz.addWindow(pos=(0.7, 1.0), size=(0.2, 0.2))

# Create a new viewpoint
BirdView = viz.addView()

#Attach the bird's eye view to the upper left window
UpperLeftWindow.setView(BirdView)

#Move the view above the center of the room
BirdView.setPosition([0, 500, 0])

#Rotate the view so that it looks down
BirdView.setEuler([0, 90, 0])
コード例 #11
0
ファイル: Flying_Demo_2015.py プロジェクト: vhilab/Demos
SS_CURRENTLY_PAUSED = 4
SS_CURRENTLY_PULLED_TOWARDS_CHILD = 5
SS_CURRENTLY_LANDED_AT_CHILD = 6

#The different helicopter models
HELI_MODEL1 = 'passenger cockpit'
HELI_MODEL2 = 'cockpit2'
HELI_MODEL = HELI_MODEL2

# City Model: see CityModel.py for reference
cityModel = CityModel()

#Sounds to play on building collisions
CRASH_SOUND = viz.playSound('BuildingCrashSound.wav', viz.SOUND_PRELOAD)

BirdEyeWindow = viz.addWindow()
BirdEyeWindow.fov(60)
BirdEyeWindow.visible(0,viz.SCREEN)
BirdEyeView = viz.addView()
BirdEyeWindow.setView(BirdEyeView)
BirdEyeWindow.setPosition([0,25,0])
BirdEyeView.setEuler([0,90,0])

###User tracking with lines###
viz.startLayer(viz.LINE_STRIP)
viz.vertexColor(viz.YELLOW)
lines = viz.endLayer(parent=viz.ORTHO,scene=BirdEyeWindow)

lines.dynamic()

def UpdatePath():
コード例 #12
0
ファイル: 3DSnake.py プロジェクト: xiazhiyi99/3DSnake
import scipy as sp
from scipy.spatial.transform import Rotation as R

viz.go()
#vizshape.addAxes()

SIZE = 20

#viz.MainView.setEuler(-45,0,0)
viz.MainView.setPosition(0, 0, 0)
viz.MainWindow.fov(100)

newView = viz.addView()
newView.setPosition([SIZE / 2, SIZE / 2, SIZE / 2])
newView.lookAt([0, 0, 0])
newwindow = viz.addWindow()
newwindow.setView(newView)
newwindow.fov(80)


def build_env():
    spaceSize = SIZE
    half = SIZE / 2
    borders = [viz.addTexQuad(size=spaceSize) for x in range(6)]
    borders[0].setPosition([half, 0, 0])
    borders[1].setPosition([-half, 0, 0])
    borders[2].setPosition([0, half, 0])
    borders[3].setPosition([0, -half, 0])
    borders[4].setPosition([0, 0, half])
    borders[5].setPosition([0, 0, -half])
コード例 #13
0
                            name='Bottom' )

walls = [FrontWall,LeftWall,RightWall,BottomWall]

wall_frustum = CaveFrustum(parent=cave_origin)

def setActiveWall(wall):
	wall_frustum.setWallAndTracker(wall,cave.getPositionTracker())
	cave.activeWall = wall
	for w in walls:
		w.window.visible(w is wall)

# Setup cave
cave = vizcave.Cave()
for index,wall in enumerate(walls):
	wall.window = viz.addWindow(pos=(0.5,1),size=(0.5,1),view=caveView)
	wall.window.visible(False)
	cave.addWall(wall,window=wall.window)
	vizact.onkeydown(str(index+1),setActiveWall,wall)

cave.setTracker(hatRigid.vizNode)

setActiveWall(FrontWall)

def addCaveWall(cave):
	"""Create visualization of cave walls"""

	walls = cave.getWalls()

	group = viz.addGroup()