Beispiel #1
0
func RenderArrow(pos, dir *Vec3) {
	const tolerance = 0.0001
	arrow := Get("arrow")
	l := dir.Length()
	d0 := dir.Unit()
	zaxis := V3(0, 0, 1)
	arrow.Mat = mat4.Scaling(V3(.1*l, .1*l, .5*l))
	angle := zaxis.Angle(d0)
	if angle > tolerance && math.Pi-angle > tolerance {
		arrow.Mat = arrow.Mat.Mul(mat4.RotationAxis(zaxis.Add(d0).Unit(), math.Pi))
	} else if math.Pi-angle <= tolerance {
		arrow.Mat = arrow.Mat.Mul(mat4.Scaling(V3(1, 1, -1)))
	}
	arrow.Mat = arrow.Mat.Mul(mat4.Translation(pos.Add(dir.Muls(.5))))
	arrow.Render()
}
Beispiel #2
0
func (t *Nurbs) DebugRender() {
	t.Render()
	m := model.Get("cube")
	t.ForEachNode(func(n *Node) {
		m.Mat = mat4.Scaling(V3(1, 1, 1).Muls(1.1))
		m.Mat = m.Mat.Mul(mat4.Translation(n.P))
		m.Render()
		model.RenderArrow(n.P, n.Tu.Muls(1.0))
		model.RenderArrow(n.P, n.Tv.Muls(1.0))
	})
}