2023-02-18 03:51:43 +03:00
|
|
|
package gx
|
|
|
|
|
|
|
|
// Implements the camera component
|
|
|
|
// for the main window.
|
|
|
|
type Camera struct {
|
2023-05-30 13:24:14 +03:00
|
|
|
Transform
|
2023-02-18 03:51:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the matrix satysfying camera
|
|
|
|
// position, scale and rotation to apply
|
|
|
|
// it to the objects to get the real
|
|
|
|
// transform to display on the screen.
|
2023-05-04 19:31:33 +03:00
|
|
|
// (Should implement buffering it so we do not
|
|
|
|
// need to calculate it each time for each object. )
|
2023-02-18 15:38:28 +03:00
|
|
|
func (c *Camera)RealMatrix(
|
|
|
|
e *Engine,
|
|
|
|
) Matrix {
|
2023-02-18 03:51:43 +03:00
|
|
|
g := &Matrix{}
|
2023-05-30 22:35:49 +03:00
|
|
|
g.Translate(-c.P.X, -c.P.Y)
|
|
|
|
g.Rotate(c.R)
|
2023-06-15 20:25:16 +03:00
|
|
|
g.Scale(c.S.X, c.S.Y)
|
2023-05-30 22:35:49 +03:00
|
|
|
g.Translate(c.RA.X, c.RA.Y)
|
2023-02-18 03:51:43 +03:00
|
|
|
|
|
|
|
return *g
|
|
|
|
}
|
|
|
|
|