コード例 #1
0
ファイル: offscreen.py プロジェクト: amiller/legoscan
def draw(rotmat):
	clearcolor = [0,0,0,0]
	glClearColor(*clearcolor)
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
	glEnable(GL_DEPTH_TEST)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(60, 1, 0.3,20)
	glMatrixMode(GL_MODELVIEW)
	glLoadMatrixf(rotmat.transpose())
	lego.draw_pieces(tasks.taskconfig.model)
	global depthim
	depthim = glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT)
	depthim = 1/depthim[::-1,:]
	window.flip()
コード例 #2
0
ファイル: modelviewer.py プロジェクト: amiller/legoscan
def _on_draw():
	
	global drawstopped
	glEnable(GL_DEPTH_TEST)
	glClearColor(*clearcolor)
	window.clear()
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(60, 1, 0.3,20)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	
	# flush that stack
	try: 
		while 1: glPopMatrix()
	except: pass


	glPushMatrix()
		
	#glMultMatrixf(homoraphy.transpose())
	
	def mouse_rotate(xAngle, yAngle, zAngle):
		glRotatef(xAngle, 1.0, 0.0, 0.0);
		glRotatef(yAngle, 0.0, 1.0, 0.0);
		glRotatef(zAngle, 0.0, 0.0, 1.0);
	glTranslate(0, 0,-0.8)
	mouse_rotate(rotangles[0], rotangles[1], 0);
	global rotmat
	rotmat = glGetFloatv(GL_MODELVIEW_MATRIX)

	glDisable(GL_BLEND)

	# Draw the color pieces
	lego.draw_pieces(tasks.taskconfig.model)
	
	glPopMatrix()
	glFinish()
	drawstopped = True