Exemplo n.º 1
0
func (s *FpsController) SetupCamera() {
	hor := v.MatrixRotate(v.Angle(-s.HorAxis), 0, 1, 0)
	ver := v.MatrixRotate(v.Angle(-s.VerAxis), 1, 0, 0)
	tr := v.MatrixTranslate(-s.Pos.X, -s.Pos.Y, -s.Pos.Z)

	rot := ver.Mul(hor)
	mat := rot.Mul(tr)
	s.Camera.SetCustomModelview(s.Pos.X, s.Pos.Y, s.Pos.Z, &mat)
}
Exemplo n.º 2
0
func (self *MCPlayAppState) Process(time_step float32) {
	glutils.Clear()

	self.gameState.Physics.Process(time_step)

	self.gameState.UpdatePlayerCtrl(
		self.moveDir.Mul(0.2), v.Angle(self.Controller.HorAxis))

	self.gameState.ObjectManager.Process(time_step)

	self.Controller.Pos = self.gameState.Player.Position

	self.Controller.SetupCamera()

	self.gameState.VoxelsMesh.SetCenter(
		self.Controller.Pos)

	self.gameState.VoxelsMesh.Render(self.Camera,
		self.shader,
		self.bindFunc)

	self.gameState.ObjectManager.ForAllObjects(func(ob *wobject.WObject) {
		if ob.RendererModule != nil {
			ob.RendererModule.Render()
		}
	})

	sdl.GL_SwapBuffers()

	if self.frameStats.FrameFinished(int64(time_step * 1000)) {
		fmt.Printf("%v\n", &self.frameStats)
	}
}