View Single Post
  #1  
Old 05-08-2008, 09:00 AM
aznan aznan is offline
Member
 
Join Date: Apr 2008
Posts: 11
Prioritize Director thread

Hi!
I have some custom stereo code that runs in an eternal loop in a Director thread like so:
Code:
def updateView():
	eye = False
	IPD = 0.064
	while True:
		eye = not eye
		pos = PPT.getPosition()
		
		if eye: #right eye
			pos[0] += IPD/2
		else: #left eye
			pos[0] -= IPD/2
		
		window.update(viewpos = pos) #updates perspective
		viz.waitframe(1)

viz.director(updateView)
This produces a fine stereo effect.

I have another function, newLayout(), that removes the objects in the world and replaces them with new objects in random locations. This function is called at the push of a button.

Problems arise when newLayout() is run however, as the adding of new objects demands quite a bit of CPU time. This keeps the stereo loop from executing, which might cause the stereo to be reversed - the right-eye image gets shown to the left eye and vice versa. But this shouldn't happen since updateView() is run in its own thread, right?

Is there a way to ensure that the stereo loop will always execute?
Reply With Quote