Esempio n. 1
0
// TODO the switch number
func (t *SwitchModel) Draw() {
	modelViewBackup := t.modelView
	s := t.sw
	var rotatemv mathgl.Mat4f
	if s.rotate == 0 {
		rotatemv = mathgl.Ident4f()
	} else {
		rotatemv = mathgl.HomogRotate3D(t.sw.rotate, [3]float32{0, 0, 1})
	}
	var scalemv mathgl.Mat4f
	if s.scale == 0 {
		scalemv = mathgl.Ident4f()
	} else {
		scalemv = mathgl.Scale3D(s.scale, s.scale, 0)
	}
	blockmv := scalemv.Mul4(rotatemv)

	// Draw the associated blocks
	// top left block
	t.drawBlock(g.level.blocks[s.line][s.col], blockmv.Mul4(topLeftModelView))
	// top right block
	t.drawBlock(g.level.blocks[s.line][s.col+1], blockmv.Mul4(topRightModelView))
	// bottom right block
	t.drawBlock(g.level.blocks[s.line+1][s.col+1], blockmv.Mul4(bottomRightModelView))
	// bottom left block
	t.drawBlock(g.level.blocks[s.line+1][s.col], blockmv.Mul4(bottomLeftModelView))

	t.ModelBase.Draw()

	t.modelView = modelViewBackup
}
Esempio n. 2
0
func (t *Background) Draw() {
	if t.angle > math.Pi {
		t.angle = t.angle - math.Pi
	} else {
		t.angle += 0.03
	}
	modelViewBackup := t.modelView
	t.modelView = t.modelView.Mul4(mathgl.HomogRotate3D(-t.angle, [3]float32{0, 0, 1}))

	t.ModelBase.Draw()

	t.modelView = modelViewBackup
}
Esempio n. 3
0
func (c *Cube) Rotate(angle float32, axis mathgl.Vec3f) {
	c.model = mathgl.HomogRotate3D(angle, axis)
}