def __init__(self,path,name):
		self.model = None
		self.name = name
		self.path = path
		if not(SceneManager.doesModelExist(name)):
			SceneManager.loadPolygonModel(path,name)
			self.model = SceneManager.getModel(name)
			SceneManager.addNodeToScene(name,"mainView")
		else:
			self.model = SceneManager.getModel(name)
Example #2
0
	def __init__(self,path,name):
		self.model = None
		self.name = name
		self.path = path
		self.rigidBodyId = None
		if (SceneManager.doesModelExist(name) != True):
			SceneManager.loadPolygonModel(path,name)
			self.model = SceneManager.getModel(name)
			addToScene("mainView")
		else:
			self.model = SceneManager.getModel(name)
Example #3
0
def askForBone(expectedPosition):
	global CORRECT
	global verdict
	global CURRENT
	global usersAns
	global correctAns

	# Set up button
	buttonZ = polyModel(buttonPath, buttonModel)
	#buttonPosition = util.addTuple(buttonZ.getPositionOffset(), rbButton.getPositionOffset())
	buttonPosition = buttonZ.getPositionOffset()

	print("buttonPosition: " + str(buttonPosition))

	# Set up button hand and navigation hand
	hand = polyModel(handPath, handButtModel)
	navHand = polyModel(navPath, handNavModel)
	print("Waiting for button press")
	# Wait for button press
	while (1):
		#print(" Model: " + str(hand.getPositionOffset()))
		#print(str(rbButtHand)+" has id: "+str(rbButtHand.getID())) 
		#print(" Rigid: " + str(rbButtHand.getPosition()))
		handPosition = util.addTuple(hand.getPositionOffset(), rbButtHand.getPosition())
		#print("handPosition:" +str(handPosition))
		time.sleep(0.1)
		if (util.isOver(buttonPosition, handPosition, 0.3, 0.3)):
			# Get the position of the navigation hand and check if it is in the right place
			navPosition = util.addTuple(navHand.getPositionOffset(), rbNavHand.getPosition())
			#print("navPosition: " + str(navPosition))
			if (util.isOver(navPosition, expectedPosition, 0.3, 0.3)):
				CORRECT += 1
				verdict = "Correct!"
				print("Got the correct answer!")
			else:
				verdict = "Incorrect"
				print("Answer was wrong")

			navRBHand = rbNavHand.getPosition()
			SceneManager.getModel(greenModel).setPositionOffset(navRBHand[0], navRBHand[1], navRBHand[2])
			SceneManager.addNodeToScene(greenModel, "projectorView")
			
			# Results tab housekeeping
			CURRENT += 1
			usersAns = str(navPosition)
			correctAns = str(expectedPosition)
			break
	def loadPolygonModel(self,path,name):
		try:
			if not(SceneManager.doesModelExist(name)):
				SceneManager.loadPolygonModel(path,name)
				self.polyModelDict[name] = SceneManager.getModel(name)
			else:
				print("loadPolygonModel - a model with specified name already exists")
		except:
			print("loadPolygonModel - something happened")
			#print("path: "+path)
			#print("name: "+name)
			return 1
		return 0
#optitrack stuff
local_IP = "25.79.169.119"
OptiTrack_IP = "25.79.169.119"
OptiTrack_DataPort = 1511
OptiTrack_CmdPort = 1510

#ClientHandler.connect(local_IP,OptiTrack_IP,OptiTrack_DataPort,OptiTrack_CmdPort,ClientHandler.ConnectionType.Multicast)

#load model from path
#modelist = list([0]*len(paths))
#test loading multiple models
modellist = []
for i in range(3):
	print "loading"+name+paths[i]
	SceneManager.loadPolygonModel(paths[i],name+paths[i])
	modellist.append(SceneManager.getModel(name+paths[i]))

print str(len(modellist))+" length of list after adding models"
print modellist

for i in range(len(modellist)):
	SceneManager.deleteModel(name+paths[i])
	print "deleting"+name+paths[i]

print str(len(modellist))+" length of list after removing the models"
print modellist
#todo: remove all the references to the model after removing model (aka: call delete on list on specified index) 


#output test, replace with infinite loop with a keyboard event to break 
#something = ""
Example #6
0
	def run(self):
		old = 0
		new = 0

		print("Running the Test")

		# Begin timer
		startTime = time.time()
		print("Start Timer")

		for i in range(ITERATIONS):
			# Randomly choose a bone. Make sure we don't ask for same bone twice.
			print("Starting For Loop")
			while new == old:
				new = randint(1, 3)

			print("After While Loop")
			if new == 1:
				print("C1")
				SceneManager.getModel(C1Model).setPositionOffset(0.35, 0, -0.09)
				SceneManager.addNodeToScene(C1Model, "projectorView")
				askForBone(C1)
				SceneManager.removeNodeFromScene(MODEL1, "projectorView")
				SceneManager.addNodeToScene(C1Ans,"projectorView")
				time.sleep(4)
				SceneManager.removeNodeFromScene(C1Ans,"projectorView")
				SceneManager.removeNodeFromScene(C1Model, "projectorView")
			elif new == 2:
				print("T1")
				SceneManager.getModel(T1Model).setPositionOffset(0.35, 0, -0.09)
				SceneManager.addNodeToScene(T1Model, "projectorView")
				askForBone(T1)
				SceneManager.removeNodeFromScene(MODEL1, "projectorView")
				SceneManager.addNodeToScene(T1Ans,"projectorView")
				time.sleep(4)
				SceneManager.removeNodeFromScene(T1Ans,"projectorView")
				SceneManager.removeNodeFromScene(T1Model, "projectorView")
			else:
				print("L1")
				# Display text for bone we want in projector view
				SceneManager.getModel(L1Model).setPositionOffset(0.35, 0, -0.09)
				SceneManager.addNodeToScene(L1Model, "projectorView")
				askForBone(L1)
				SceneManager.removeNodeFromScene(MODEL1, "projectorView")
				SceneManager.addNodeToScene(L1Ans,"projectorView")
				time.sleep(4)
				SceneManager.removeNodeFromScene(L1Ans,"projectorView")
				SceneManager.removeNodeFromScene(L1Model, "projectorView")

			old = new
			SceneManager.removeNodeFromScene(greenModel, "projectorView")
			SceneManager.addNodeToScene(MODEL1,"projectorView")

		# Get the time after the 10 iterations
		endTime = time.time()
		elapsedTime = endTime - startTime
		elapsedTime = str(elapsedTime)+" Seconds"

		# Calculate the accuracy
		accuracy = str((CORRECT/ITERATIONS) * 100);

		# Write results to a file
		date = datetime.datetime.now().strftime("%B %d %I:%M%p")
		testName = "Skeleton Full"


		# Terminate the thread when we are done!!
		self.terminate()
Example #7
0
	def selectTest(self):
		# Grab currently displayed test from combo box
		chosenTest = str(self.combo.currentText())

		# Based on displayed test, send model to projectDr
		if chosenTest == TEST1:
			model = MODEL1
		else:
			model = MODEL2

		# Before we try to add a model, we should make sure one doesn't already exist
		if SceneManager.doesModelExist(MODEL1) or SceneManager.doesModelExist(MODEL2):
			title = "A skeleton model is already loaded!"
			error = "Please wait for current test to finish before attempting to start another."
			QtGui.QMessageBox.critical(None, title, error, QtGui.QMessageBox.Close)
			return

		# We can load the model in projectDr now
		if model == MODEL1:
			path = PATH1
		else:
			path = PATH2

		# Notify the user that model was successfully loaded.
		title = "Model Loaded"
		error = "Model was successfully loaded into ProjectDr."
		QtGui.QMessageBox.information(None, title, error, QtGui.QMessageBox.Ok)

		# Send the model to scene manager

		print("LOADING NEW TEST")

		# Load Skeleton
		SceneManager.loadPolygonModel(path, model)

		#Scale Skeleton
		SceneManager.getModel(model).setScale(.025,.025,.025)
		SceneManager.getModel(model).setRotationOffset(0,0,-1,1)
		SceneManager.getModel(model).setPositionOffset(0.105,0.15,-0.711)
		SceneManager.addNodeToScene(model,"mainView")
		SceneManager.addNodeToScene(model,"projectorView")

		# Load Skeleton C1 Answer
		SceneManager.loadPolygonModel(C1Ans, C1Ans)

		#Scale Skeleton
		SceneManager.getModel(C1Ans).setScale(.025,.025,.025)
		SceneManager.getModel(C1Ans).setRotationOffset(0,0,-1,1)
		SceneManager.getModel(C1Ans).setPositionOffset(0.105,0.15,-0.711)
		SceneManager.addNodeToScene(C1Ans,"mainView")

		# Load Skeleton T1 Answer
		SceneManager.loadPolygonModel(T1Ans, T1Ans)

		#Scale Skeleton
		SceneManager.getModel(T1Ans).setScale(.025,.025,.025)
		SceneManager.getModel(T1Ans).setRotationOffset(0,0,-1,1)
		SceneManager.getModel(T1Ans).setPositionOffset(0.105,0.15,-0.711)
		SceneManager.addNodeToScene(T1Ans,"mainView")

		# Load Skeleton
		SceneManager.loadPolygonModel(L1Ans, L1Ans)

		#Scale Skeleton
		SceneManager.getModel(L1Ans).setScale(.025,.025,.025)
		SceneManager.getModel(L1Ans).setRotationOffset(0,0,-1,1)
		SceneManager.getModel(L1Ans).setPositionOffset(0.105,0.15,-0.711)
		SceneManager.addNodeToScene(L1Ans,"mainView")

		# Start thread for running test!
		self.thread = WorkThread()
		self.thread.start()
		return
Example #8
0


if __name__ == '__main__':
	import sys

	print("Starting")
	# Load button and hand models
	SceneManager.loadPolygonModel(navPath, handNavModel)
	SceneManager.loadPolygonModel(handPath, handButtModel)
	SceneManager.loadPolygonModel(buttonPath, buttonModel)
	SceneManager.loadPolygonModel(greenPath, greenModel)


	# Scale the Green Circle
	SceneManager.getModel(greenModel).setScale(0.01, 0.01, 0.01)
	SceneManager.addNodeToScene(greenModel, "mainView")

	# Create text but do not load into view
	SceneManager.loadPolygonModel("C1.OSGB", C1Model)
	SceneManager.getModel(C1Model).setScale(0.005, 0.005, 0.005)
	SceneManager.getModel(C1Model).setPositionOffset(0.350, 0, -0.090)
	SceneManager.getModel(C1Model).setRotationOffset(0, 0, -1, 1)
	SceneManager.addNodeToScene(C1Model,"mainView")
	#print("Added C1")

	SceneManager.loadPolygonModel("T1.OSGB", T1Model)
	SceneManager.getModel(T1Model).setScale(0.005, 0.005, 0.005)
	SceneManager.getModel(T1Model).setPositionOffset(0.350, 0, -0.090)
	SceneManager.getModel(T1Model).setRotationOffset(0, 0, -1,1)
	SceneManager.addNodeToScene(T1Model,"mainView")
Example #9
0
import ClientHandler
import SceneManager
import glob

path = "C:\Users\w\Documents\Models\osg-data-master\glider.osg"
name = "somethingyouwant"

paths = glob.glob("C:\Users\Aedan\Desktop\Homework Folder\CMPUT 302\DICOM Models\COU\*.dcm")
for i in paths:
	i = i[66:]
	print i


local_IP = "25.79.169.119"
OptiTrack_IP = "25.79.169.119"
OptiTrack_DataPort = 1511
OptiTrack_CmdPort = 1510


ClientHandler.connect(local_IP,OptiTrack_IP,OptiTrack_DataPort,OptiTrack_CmdPort,ClientHandler.ConnectionType.Multicast)
SceneManager.loadPolygonModel(path,name)
model = SceneManager.getModel(name)