2023-02-18 03:51:43 +03:00
|
|
|
package gx
|
|
|
|
|
|
|
|
// Implements the camera component
|
|
|
|
// for the main window.
|
|
|
|
type Camera struct {
|
|
|
|
*Object
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
func (c *Camera)Matrix(scale bool) Matrix {
|
|
|
|
g := &Matrix{}
|
|
|
|
|
|
|
|
g.Translate(
|
2023-02-18 07:46:33 +03:00
|
|
|
-c.Object.T.RA.X,
|
|
|
|
-c.Object.T.RA.Y,
|
2023-02-18 03:51:43 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
g.Rotate(c.Object.T.R)
|
|
|
|
|
|
|
|
g.Translate(
|
|
|
|
-c.Object.T.P.X,
|
|
|
|
-c.Object.T.P.Y,
|
|
|
|
)
|
|
|
|
|
|
|
|
if scale {
|
|
|
|
g.Scale(
|
|
|
|
c.Object.T.S.X,
|
|
|
|
c.Object.T.S.Y,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return *g
|
|
|
|
}
|
|
|
|
|