Beispiel #1
0
// draws a box around the target block using the collision
// box for the shape
func (c *ClientState) highlightTarget() {
	if c.GameMode == gmSpecator {
		return
	}
	const lineSize = 1.0 / 128.0
	t, b, _, _ := c.targetBlock()
	if b.Is(Blocks.Air) {
		return
	}
	for _, b := range b.CollisionBounds() {
		b = b.Shift(float32(t.X), float32(t.Y), float32(t.Z))

		points := [][2]float64{
			{float64(b.Min.X()), float64(b.Min.Z())},
			{float64(b.Min.X()), float64(b.Max.Z())},
			{float64(b.Max.X()), float64(b.Min.Z())},
			{float64(b.Max.X()), float64(b.Max.Z())},
		}

		for _, p := range points {
			render.DrawBox(
				p[0]-lineSize, float64(b.Min.Y())-lineSize, p[1]-lineSize,
				p[0]+lineSize, float64(b.Max.Y())+lineSize, p[1]+lineSize,
				0, 0, 0, 255,
			)
		}

		topPoints := [][4]float64{
			{float64(b.Min.X()), float64(b.Min.Z()), float64(b.Max.X()), float64(b.Min.Z())},
			{float64(b.Min.X()), float64(b.Max.Z()), float64(b.Max.X()), float64(b.Max.Z())},
			{float64(b.Min.X()), float64(b.Min.Z()), float64(b.Min.X()), float64(b.Max.Z())},
			{float64(b.Max.X()), float64(b.Min.Z()), float64(b.Max.X()), float64(b.Max.Z())},
		}
		for _, p := range topPoints {
			p2 := p[2:]
			render.DrawBox(
				p[0]-lineSize, float64(b.Min.Y())-lineSize, p[1]-lineSize,
				p2[0]+lineSize, float64(b.Min.Y())+lineSize, p2[1]+lineSize,
				0, 0, 0, 255,
			)
			render.DrawBox(
				p[0]-lineSize, float64(b.Max.Y())-lineSize, p[1]-lineSize,
				p2[0]+lineSize, float64(b.Max.Y())+lineSize, p2[1]+lineSize,
				0, 0, 0, 255,
			)
		}
	}
}
Beispiel #2
0
func esDrawOutline(p PositionComponent, s SizeComponent, d DebugComponent) {
	x, y, z := p.Position()
	bounds := s.Bounds().Shift(float32(x), float32(y), float32(z))

	r, g, b := d.DebugColor()
	render.DrawBox(
		float64(bounds.Min.X()),
		float64(bounds.Min.Y()),
		float64(bounds.Min.Z()),
		float64(bounds.Max.X()),
		float64(bounds.Max.Y()),
		float64(bounds.Max.Z()),
		r, g, b, 255,
	)
}