Ejemplo n.º 1
0
// newCube's are often started with 1 corner, 2 edges, or 4 bottom side pieces.
func newCube(eng vu.Engine, part vu.Part, x, y, z, cubeSize float64) *cube {
	c := &cube{}
	// c.eng = eng
	c.part = part.AddPart()
	c.cells = []vu.Part{}
	c.cx, c.cy, c.cz, c.csize = x, y, z, cubeSize
	c.ccnt, c.cmax = 0, 8
	c.mergec = func() { c.merge() }
	c.trashc = func() { c.trash() }
	c.addc = func() { c.addCell() }
	c.remc = func() { c.removeCell() }

	// calculate the cell center locations (unsorted)
	qs := c.csize * 0.25
	c.centers = csort{
		&lin.V3{x - qs, y - qs, z - qs},
		&lin.V3{x - qs, y - qs, z + qs},
		&lin.V3{x - qs, y + qs, z - qs},
		&lin.V3{x - qs, y + qs, z + qs},
		&lin.V3{x + qs, y - qs, z - qs},
		&lin.V3{x + qs, y - qs, z + qs},
		&lin.V3{x + qs, y + qs, z - qs},
		&lin.V3{x + qs, y + qs, z + qs},
	}
	return c
}
Ejemplo n.º 2
0
// newPanel creates a panel with no cubes.  The cubes are added later using
// panel.addCube().
func newPanel(eng vu.Engine, part vu.Part, x, y, z float64, level int) *panel {
	p := &panel{}
	p.eng = eng
	p.part = part.AddPart()
	p.lvl = level
	p.cubes = []*cube{}
	p.cx, p.cy, p.cz = x, y, z
	p.ccnt, p.cmax = 0, (level-1)*(level-1)*8
	p.mergec = func() { p.merge() }
	p.trashc = func() { p.trash() }
	p.addc = func() { p.addCell() }
	p.remc = func() { p.removeCell() }
	return p
}
Ejemplo n.º 3
0
// getBox creates a visible box physics body.
func (cr *crtag) getBox(bod vu.Part) {
	bod.SetScale(2, 2, 2)
	bod.SetFacade("cube", "gouraud").SetMaterial("sphere")
	bod.SetBody(vu.Box(1, 1, 1), 1, 0)
}
Ejemplo n.º 4
0
// getBall creates a visible sphere physics body.
func (cr *crtag) getBall(bod vu.Part) {
	bod.SetFacade("sphere", "gouraud").SetMaterial("sphere")
	bod.SetBody(vu.Sphere(1), 1, 0.5)
}