예제 #1
0
파일: laser.py 프로젝트: deavid/soyamirror
	def render(self):
		
		self.points = []

		#list containing points
		to_draw = []
		
		pos   = self.position()
		direc = Vector(self, 0.0, 0.0, -1.0)
		if self.collide:
			i = 0
			raypicker = self.get_root()
			while direc is not None and (i <= self.max_reflect):
				i = i + 1

				impact = raypicker.raypick(pos, direc, -1.0)
				if not impact:
					pos   = pos + (direc * 32000.0)
					direc = None
				else:
					pos = impact[0]
					
					if self.reflect:
						normal = impact[1] % self
						normal.normalize() # changing coordsys can alterate normal size
						normal.set_length(-2.0 * direc.dot_product(normal))
						direc = normal + direc
						
					else:
						direc = None
						
				to_draw.append(pos)
				self.points.append(pos)
		else:
			pos   = pos + (direc * 32000.0)
			to_draw.append(pos)

		#rendering part
		DEFAULT_MATERIAL.activate()
		glDisable(GL_TEXTURE_2D)
		glDisable(GL_LIGHTING)
		
		glColor4f(*self.color)
		glBegin(GL_LINE_STRIP)
		glVertex3f(0.0, 0.0, 0.0)
		for pos in to_draw:
			glVertex3f(*self.transform_point(pos.x, pos.y, pos.z, pos.parent))
			
		glEnd()
		
		glEnable(GL_LIGHTING)
		glEnable(GL_TEXTURE_2D)