示例#1
0
文件: aufg2.py 项目: 2bt/Stupid-2
	def __init__(self):
		Entity.__init__(self)
		b = shit.Brick(1, 1, 1)
		self.cubes = b.gen_list(), b.scale(-1, -1, -1).gen_list()
		self.orb = shit.Orb(0.1).gen_list()

		self.p = vec(0, 0, -0.5)
		self.bfc = False
		self.inverse = False
示例#2
0
文件: aufg5.py 项目: 2bt/Stupid-2
	def __init__(self, obj):
		Entity.__init__(self)
		self.obj = obj
		v = """
uniform vec3 light_pos;
varying vec3 pos, eye, normal, lpos, light_diff;
void main(void) {
	pos = gl_Vertex.xyz;
	lpos = vec3(gl_ModelViewMatrix * vec4(light_pos, 0.0));
	eye = vec3(gl_ModelViewMatrix * gl_Vertex);
	light_diff = pos - light_pos;
	normal = gl_NormalMatrix * gl_Normal;
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}"""
		self.toon = Shade(v, """
uniform bool blinn;
uniform float shininess, sections;
uniform vec4 color, diffuse, ambient, specular;
varying vec3 pos, normal, eye, light_diff;
void main(void) {
	vec3 n = normalize(normal);
	vec3 ldir = normalize(-light_diff);
	vec3 vdir = normalize(eye);
	vec3 lhalf = normalize(ldir - vdir);
	float intensity = max(dot(n, ldir), 0.0);
	float foo = max(blinn ? dot(n, lhalf) : dot(vdir, reflect(ldir, n)), 0.0);

	intensity = floor(intensity * sections) / sections;
	foo = pow(foo, shininess);
	foo = foo > 0.1 ? 1.0 : 0.0;
	vec4 cl = (color * ambient + specular * foo) * diffuse;
	gl_FragColor = vec4(cl.rgb * intensity, cl.a);
}""")

		self.phong = Shade(v, """
uniform bool blinn;
uniform float shininess;
uniform vec4 color, diffuse, ambient, specular;
varying vec3 pos, normal, eye, light_diff;
void main(void) {
	vec3 n = normalize(normal);
	vec3 ldir = normalize(-light_diff);
	vec3 vdir = normalize(eye);
	vec3 lhalf = normalize(ldir - vdir);
	float intensity = max(dot(n, ldir), 0.0);
	float foo = max(blinn ? dot(n, lhalf) : dot(vdir, reflect(ldir, n)), 0.0);
	foo = pow(foo, shininess);
	vec4 cl = (color * ambient + specular * foo) * diffuse;
	gl_FragColor = vec4(cl.rgb * intensity, cl.a);
}""")
		self.switch = 0
		self.blinn = 0
		self.sections = 5
		self.shininess = 30
示例#3
0
文件: aufg3.py 项目: 2bt/Stupid-2
	def __init__(self, obj_name):
		Entity.__init__(self)

		self.obj = ObjObject(obj_name)

		self.surface = 0
		self.volume = 0
		self.sigma = 0.01
		self.alpha = 0.3

		self.silhouette = True
示例#4
0
文件: aufg5.py 项目: 2bt/Stupid-2
	def __init__(self, obj):
		Entity.__init__(self)
		self.obj = obj
		self.shade = Shade("""
varying vec3 normal;
void main(void) {
	normal = gl_Normal;
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}""", """
varying vec3 normal;
void main(void) {
	vec3 h = vec3(0.5, 0.5, 0.5);
	gl_FragColor = vec4(normalize(normal.xyz) * h + h, 1);
}""")
示例#5
0
文件: aufg2.py 项目: 2bt/Stupid-2
	def __init__(self):
		Entity.__init__(self)

		img = pygame.image.load('gorilla.bmp')
		data = pygame.image.tostring(img, "RGBA", 1)

		self.tex = glGenTextures(1)
		glBindTexture(GL_TEXTURE_2D, self.tex)
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.get_width(), img.get_height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data)
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER)
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER)
		glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, (1, 1, 1, 1))

		self.orb = shit.Orb(5, 3).gen_list()
		self.dot = shit.Orb(0.1).gen_list()

		self.eye = vec(0, 0, 7)
		self.target = vec(0, 0, 0)
		self.up = vec(0, 1, 0)

		self.q = 0