Forgot that this is only useful for camera

This commit is contained in:
Carlos Sanchez 2024-08-02 01:02:33 -04:00
parent 362ed0802c
commit 78565064ef
2 changed files with 6 additions and 6 deletions

View File

@ -158,8 +158,8 @@ func (m *Mat44f) SetRotationZ(radang float32) {
m[2] = -m[4] m[2] = -m[4]
} }
// TODO: need roll too // Camera is easier to deal with using yaw and pitch, since we're not supporting roll
func (m *Mat44f) SetModel(loc *Vec3f, yaw float32, pitch float32, scale float32, up *Vec3f) Vec3f { func (m *Mat44f) SetCamera(loc *Vec3f, yaw float32, pitch float32, up *Vec3f) Vec3f {
// Use sphere equation to compute lookat vector through the two // Use sphere equation to compute lookat vector through the two
// player-controled angles (pitch and yaw) // player-controled angles (pitch and yaw)
lookvec := Vec3f{ lookvec := Vec3f{
@ -168,9 +168,9 @@ func (m *Mat44f) SetModel(loc *Vec3f, yaw float32, pitch float32, scale float32,
Y: float32(math.Cos(float64(pitch))), Y: float32(math.Cos(float64(pitch))),
} }
m.SetLookAt(loc, loc.Add(&lookvec), up) m.SetLookAt(loc, loc.Add(&lookvec), up)
m.Set(0, 0, m.Get(0, 0)*scale) //m.Set(0, 0, m.Get(0, 0)*scale)
m.Set(1, 1, m.Get(1, 1)*scale) //m.Set(1, 1, m.Get(1, 1)*scale)
m.Set(2, 2, m.Get(2, 2)*scale) //m.Set(2, 2, m.Get(2, 2)*scale)
return lookvec return lookvec
} }

View File

@ -162,7 +162,7 @@ func main() {
camtrans = *camtrans.Add(&newcamtrans) camtrans = *camtrans.Add(&newcamtrans)
// The camera is really just a model // The camera is really just a model
lookvec := camera.SetModel(&camtrans, yaw, pitch, 1.0, &camup) lookvec := camera.SetCamera(&camtrans, yaw, pitch, &camup)
screenmat := camera.Inverse().Multiply(&projection) screenmat := camera.Inverse().Multiply(&projection)
screenmat = screenmat.Multiply(&viewport) screenmat = screenmat.Multiply(&viewport)