Exemplo n.º 1
0
func (c *Camera) project(pt mgl32.Vec2) mgl32.Vec2 {
	var (
		screen = pt.Vec4(1, 1)
		out    mgl32.Vec4
	)
	out = c.Projection.Mul4x1(screen)
	return out.Vec2()
}
Exemplo n.º 2
0
func (c *Camera) unproject(pt mgl32.Vec2) mgl32.Vec2 {
	var (
		screen = pt.Vec4(1, 1)
		out    mgl32.Vec4
	)
	out = c.Inverse.Mul4x1(screen)
	out = out.Mul(1.0 / out[3])
	return out.Vec2()
}
Exemplo n.º 3
0
func Unproject(invproj mgl32.Mat4, x float32, y float32) (wx, wy float32) {
	var (
		screen = mgl32.Vec4{x, y, 1, 1}
		out    mgl32.Vec4
	)
	out = invproj.Mul4x1(screen)
	out = out.Mul(1.0 / out[3])
	wx = out[0]
	wy = out[1]
	return
}