示例#1
0
func (b *blockPistonHead) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0, 0, 0, 1.0, 1.0, 4.0/16.0),
			vmath.NewAABB(6.0/16.0, 6.0/16.0, 4.0/16.0, 10.0/16.0, 10.0/16.0, 1.0),
		}
		if !b.Short {
			b.bounds[1].Max[2] += 4.0 / 16.0
		}
		for i := range b.bounds {
			switch b.Facing {
			case direction.North:
			case direction.South:
				b.bounds[i] = b.bounds[i].RotateY(-math.Pi, 0.5, 0.5, 0.5)
			case direction.West:
				b.bounds[i] = b.bounds[i].RotateY(-math.Pi*1.5, 0.5, 0.5, 0.5)
			case direction.East:
				b.bounds[i] = b.bounds[i].RotateY(-math.Pi*0.5, 0.5, 0.5, 0.5)
			case direction.Up:
				b.bounds[i] = b.bounds[i].RotateX(-math.Pi*1.5, 0.5, 0.5, 0.5)
			case direction.Down:
				b.bounds[i] = b.bounds[i].RotateX(-math.Pi*0.5, 0.5, 0.5, 0.5)
			}
		}
	}
	return b.bounds
}
示例#2
0
func (b *blockFloorSign) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(-0.5, -4/16.0, -0.5/16.0, 0.5, 4/16.0, 0.5/16.0),
			vmath.NewAABB(7.5/16.0, 0, 7.5/16.0, 8.5/16.0, 9/16.0, 8.5/16.0),
		}
		b.bounds[0] = b.bounds[0].Shift(0.5, 0.5+5/16.0, 0.5)
		b.bounds[0] = b.bounds[0].RotateY((-float32(b.Rotation)/16)*math.Pi*2+math.Pi, 0.5, 0.5, 0.5)
	}
	return b.bounds
}
示例#3
0
文件: block.go 项目: num5/steven
func (b *baseBlock) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0, 0, 0, 1.0, 1.0, 1.0),
		}
	}
	return b.bounds
}
示例#4
0
func (b *blockRedstone) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0, 0, 0, 1.0, 1/64.0, 1.0),
		}
	}
	return b.bounds
}
示例#5
0
func (b *blockFarmland) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0.0, 0.0, 0.0, 1.0, 15.0/16.0, 1.0),
		}
	}
	return b.bounds
}
示例#6
0
func (b *blockRail) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0, 0, 0, 1.0, 1.0/16.0, 1.0),
		}
	}
	return b.bounds
}
示例#7
0
func (b *blockSnowLayer) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0.0, 0.0, 0.0, 1.0, (1.0/8.0)*float32(b.Layers), 1.0),
		}
	}
	return b.bounds
}
示例#8
0
文件: render.go 项目: num5/steven
func renderBuffer(ch *ChunkBuffer, po position, fr direction.Type, delta float64) {
	if ch == nil {
		return
	}
	rQueue.Append(renderRequest{ch, po, fr})

	slidy := slidyChunks.Value()

	for !rQueue.Empty() {
		req := rQueue.Take()
		if req.chunk.renderedOn == frameID {
			continue
		}
		req.chunk.renderedOn = frameID

		aabb := vmath.NewAABB(
			-float32((req.pos.X<<4)+16), -float32((req.pos.Y<<4)+16), float32((req.pos.Z<<4)),
			-float32((req.pos.X<<4)), -float32((req.pos.Y<<4)), float32((req.pos.Z<<4)+16),
		).Grow(1, 1, 1)
		if !frustum.IsAABBInside(aabb) {
			continue
		}
		renderOrder = append(renderOrder, req.chunk)

		req.chunk.Rendered = true

		if slidy {
			dx := req.pos.X - int(Camera.X)>>4
			dz := req.pos.Z - int(Camera.Z)>>4

			if req.chunk.progress < 1 && dx*dx+dz*dz > 6*6 {
				req.chunk.progress += delta * 0.015
			} else {
				req.chunk.progress = 1
			}
		} else {
			req.chunk.progress = 1
		}

		if req.chunk.count != 0 && req.chunk.buffer.IsValid() {
			shaderChunk.Offset.Int3(req.chunk.X, req.chunk.Y*4096-req.chunk.Y*int(4096*(1-req.chunk.progress)), req.chunk.Z)

			req.chunk.array.Bind()
			gl.DrawElements(gl.Triangles, req.chunk.count, elementBufferType, 0)
		}

		for _, dir := range direction.Values {
			c := req.chunk.neighborChunks[dir]
			if dir != req.from && c != nil && c.renderedOn != frameID &&
				(req.from == direction.Invalid || (req.chunk.IsVisible(req.from, dir) && validDirs[dir])) {
				ox, oy, oz := dir.Offset()
				pos := position{req.pos.X + ox, req.pos.Y + oy, req.pos.Z + oz}
				rQueue.Append(renderRequest{c, pos, dir.Opposite()})
			}
		}
	}
}
示例#9
0
func (b *blockSlab) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(0, 0, 0, 1.0, 0.5, 1.0),
		}
		if b.Half == slabTop {
			b.bounds[0] = b.bounds[0].Shift(0, 0.5, 0.0)
		}
	}
	return b.bounds
}
示例#10
0
func (b *blockPortal) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		b.bounds = []vmath.AABB{
			vmath.NewAABB(6/16.0, 0, 0, 10/16.0, 1.0, 1.0),
		}
		if b.Axis == axisX {
			b.bounds[0] = b.bounds[0].RotateY(math.Pi/2, 0.5, 0.5, 0.5)
		}
	}
	return b.bounds
}
示例#11
0
func (b *blockStainedGlassPane) CollisionBounds() []vmath.AABB {
	if b.bounds == nil {
		all := !b.North && !b.South && !b.West && !b.East
		aa := vmath.NewAABB(0, 0, 7.0/16.0, 1.0, 1.0, 9.0/16.0)
		bb := vmath.NewAABB(7.0/16.0, 0, 0, 9.0/16.0, 1.0, 1.0)
		if !b.North && !all {
			bb.Min[2] = 7.0 / 16.0
		}
		if !b.South && !all {
			bb.Max[2] = 9.0 / 16.0
		}
		if !b.West && !all {
			aa.Min[0] = 7.0 / 16.0
		}
		if !b.East && !all {
			aa.Max[0] = 9.0 / 16.0
		}
		b.bounds = []vmath.AABB{aa, bb}
	}
	return b.bounds
}
示例#12
0
文件: entities.go 项目: num5/steven
func newSheep() Entity {
	type sheep struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	s := &sheep{
		debugComponent: debugComponent{232, 232, 232},
	}
	s.NetworkID = 91
	s.bounds = vmath.NewAABB(-0.45, 0, -0.45, 0.9, 1.3, 0.9)
	return s
}
示例#13
0
文件: entities.go 项目: num5/steven
func newPig() Entity {
	type pig struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	p := &pig{
		debugComponent: debugComponent{252, 0, 194},
	}
	p.NetworkID = 90
	p.bounds = vmath.NewAABB(-0.45, 0, -0.45, 0.9, 0.9, 0.9)
	return p
}
示例#14
0
文件: entities.go 项目: num5/steven
func newChicken() Entity {
	type chicken struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	c := &chicken{
		debugComponent: debugComponent{217, 217, 217},
	}
	c.NetworkID = 93
	c.bounds = vmath.NewAABB(-0.2, 0, -0.2, 0.4, 0.7, 0.4)
	return c
}
示例#15
0
文件: entities.go 项目: num5/steven
func newCow() Entity {
	type cow struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	c := &cow{
		debugComponent: debugComponent{125, 52, 0},
	}
	c.NetworkID = 92
	c.bounds = vmath.NewAABB(-0.45, 0, -0.45, 0.9, 1.3, 0.9)
	return c
}
示例#16
0
文件: entities.go 项目: num5/steven
func newWolf() Entity {
	type wolf struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	w := &wolf{
		debugComponent: debugComponent{148, 148, 148},
	}
	w.NetworkID = 95
	w.bounds = vmath.NewAABB(-0.3, 0, -0.3, 0.6, 0.8, 0.6)
	return w
}
示例#17
0
文件: entities.go 项目: num5/steven
func newSquid() Entity {
	type squid struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	s := &squid{
		debugComponent: debugComponent{84, 39, 245},
	}
	s.NetworkID = 94
	s.bounds = vmath.NewAABB(-0.475, 0, -0.475, 0.95, 0.95, 0.95)
	return s
}
示例#18
0
文件: entities.go 项目: num5/steven
func newZombie() Entity {
	type zombie struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	z := &zombie{
		debugComponent: debugComponent{17, 114, 156},
	}
	z.NetworkID = 54
	z.bounds = vmath.NewAABB(-0.3, 0, -0.3, 0.6, 1.8, 0.6)
	return z
}
示例#19
0
文件: entities.go 项目: num5/steven
func newIronGolem() Entity {
	type ironGolem struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	i := &ironGolem{
		debugComponent: debugComponent{125, 125, 125},
	}
	i.NetworkID = 99
	i.bounds = vmath.NewAABB(-0.7, 0, -0.7, 1.4, 2.9, 1.4)
	return i
}
示例#20
0
文件: entities.go 项目: num5/steven
func newVillager() Entity {
	type villager struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	v := &villager{
		debugComponent: debugComponent{212, 183, 142},
	}
	v.NetworkID = 120
	v.bounds = vmath.NewAABB(-0.3, 0, -0.3, 0.6, 1.8, 0.6)
	return v
}
示例#21
0
文件: entities.go 项目: num5/steven
func newSpider() Entity {
	type spider struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	s := &spider{
		debugComponent: debugComponent{59, 7, 7},
	}
	s.NetworkID = 52
	s.bounds = vmath.NewAABB(-0.7, 0, -0.7, 1.4, 0.9, 1.4)
	return s
}
示例#22
0
文件: entities.go 项目: num5/steven
func newGuardian() Entity {
	type guardian struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	g := &guardian{
		debugComponent: debugComponent{69, 47, 71},
	}
	g.NetworkID = 68
	g.bounds = vmath.NewAABB(-0.425, 0, -0.425, 0.85, 0.85, 0.85)
	return g
}
示例#23
0
文件: entities.go 项目: num5/steven
func newSnowman() Entity {
	type snowman struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	s := &snowman{
		debugComponent: debugComponent{225, 225, 255},
	}
	s.NetworkID = 97
	s.bounds = vmath.NewAABB(-0.35, 0, -0.35, 0.7, 1.9, 0.7)
	return s
}
示例#24
0
文件: entities.go 项目: num5/steven
func newSkeleton() Entity {
	type skeleton struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	s := &skeleton{
		debugComponent: debugComponent{255, 255, 255},
	}
	s.NetworkID = 51
	s.bounds = vmath.NewAABB(-0.3, 0, -0.3, 0.6, 1.8, 0.6)
	return s
}
示例#25
0
文件: entities.go 项目: num5/steven
func newCreeper() Entity {
	type creeper struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	c := &creeper{
		debugComponent: debugComponent{16, 117, 55},
	}
	c.NetworkID = 50
	c.bounds = vmath.NewAABB(-0.2, 0, -0.2, 0.4, 1.5, 0.4)
	return c
}
示例#26
0
文件: entities.go 项目: num5/steven
func newMooshroom() Entity {
	type mooshroom struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	m := &mooshroom{
		debugComponent: debugComponent{145, 41, 0},
	}
	m.NetworkID = 96
	m.bounds = vmath.NewAABB(-0.45, 0, -0.45, 0.9, 1.3, 0.9)
	return m
}
示例#27
0
文件: entities.go 项目: num5/steven
func newHorse() Entity {
	type horse struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	h := &horse{
		debugComponent: debugComponent{191, 156, 0},
	}
	h.NetworkID = 100
	h.bounds = vmath.NewAABB(-0.7, 0, -0.7, 1.4, 1.6, 1.4)
	return h
}
示例#28
0
文件: entities.go 项目: num5/steven
func newOcelot() Entity {
	type ocelot struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	o := &ocelot{
		debugComponent: debugComponent{242, 222, 0},
	}
	o.NetworkID = 98
	o.bounds = vmath.NewAABB(-0.3, 0, -0.3, 0.6, 0.8, 0.6)
	return o
}
示例#29
0
文件: entities.go 项目: num5/steven
func newRabbit() Entity {
	type rabbit struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	r := &rabbit{
		debugComponent: debugComponent{181, 123, 42},
	}
	r.NetworkID = 101
	r.bounds = vmath.NewAABB(-0.3, 0, -0.3, 0.6, 0.7, 0.6)
	return r
}
示例#30
0
文件: entities.go 项目: num5/steven
func newEndermite() Entity {
	type endermite struct {
		networkComponent
		positionComponent
		rotationComponent
		targetRotationComponent
		targetPositionComponent
		sizeComponent

		debugComponent
	}
	e := &endermite{
		debugComponent: debugComponent{69, 47, 71},
	}
	e.NetworkID = 67
	e.bounds = vmath.NewAABB(-0.2, 0, -0.2, 0.4, 0.3, 0.4)
	return e
}