예제 #1
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
func lamp(n uint) {
	//
	if !lightInitialized[n] {
		return
	}
	xx, yy, zz := lightSource[n].Coord3()
	x, y, z := C.GLdouble(xx), C.GLdouble(yy), C.GLdouble(zz)
	r := C.GLdouble(0.1)
	C.glBegin(TRIANGLE_FAN)
	C.glColor3ub(C.GLubyte(lightColour[n].R), C.GLubyte(lightColour[n].G), C.GLubyte(lightColour[n].B))
	C.glNormal3d(C.GLdouble(0.0), C.GLdouble(0.0), C.GLdouble(-1.0))
	C.glVertex3d(C.GLdouble(x), C.GLdouble(y), C.GLdouble(z+r))
	r0 := r * sin[1]
	z0 := z + r*cos[1]
	for l := 0; l <= nLamp; l++ {
		C.glNormal3d(-sin[1]*cos[l], -sin[1]*sin[l], -cos[1])
		C.glVertex3d(x+r0*cos[l], y+r0*sin[l], z0)
	}
	C.glEnd()
	C.glBegin(QUAD_STRIP)
	var r1, z1 C.GLdouble
	for b := 1; b <= nLamp/2-2; b++ {
		r0, z0 = r*sin[b], z+r*cos[b]
		r1, z1 = r*sin[b+1], z+r*cos[b+1]
		for l := 0; l <= nLamp; l++ {
			C.glNormal3d(-sin[b+1]*cos[l], -sin[b+1]*sin[l], -cos[b+1])
			C.glVertex3d(x+r1*cos[l], y+r1*sin[l], z1)
			C.glNormal3d(-sin[b]*cos[l], -sin[b]*sin[l], -cos[b])
			C.glVertex3d(x+r0*cos[l], y+r0*sin[l], z0)
		}
	}
	C.glEnd()
	C.glBegin(TRIANGLE_FAN)
	C.glNormal3d(0., 0., 1.)
	C.glVertex3d(x, y, z-r)
	r0, z0 = r*sin[1], z-r*cos[1]
	b := nLamp/2 - 1
	for l := 0; l <= nLamp; l++ {
		C.glNormal3d(-sin[b]*cos[l], -sin[b]*sin[l], -cos[b])
		C.glVertex3d(x+r0*cos[l], y+r0*sin[l], z0)
	}
	C.glEnd()
}
예제 #2
0
파일: vertex.go 프로젝트: Nvveen/gl
//void glVertex3d (float64 x, float64 y, float64 z)
func Vertex3d(x float64, y float64, z float64) {
	C.glVertex3d(C.GLdouble(x), C.GLdouble(y), C.GLdouble(z))
}