Forgot that this is only useful for camera
This commit is contained in:
parent
362ed0802c
commit
78565064ef
@ -158,8 +158,8 @@ func (m *Mat44f) SetRotationZ(radang float32) {
|
||||
m[2] = -m[4]
|
||||
}
|
||||
|
||||
// TODO: need roll too
|
||||
func (m *Mat44f) SetModel(loc *Vec3f, yaw float32, pitch float32, scale float32, up *Vec3f) Vec3f {
|
||||
// Camera is easier to deal with using yaw and pitch, since we're not supporting roll
|
||||
func (m *Mat44f) SetCamera(loc *Vec3f, yaw float32, pitch float32, up *Vec3f) Vec3f {
|
||||
// Use sphere equation to compute lookat vector through the two
|
||||
// player-controled angles (pitch and yaw)
|
||||
lookvec := Vec3f{
|
||||
@ -168,9 +168,9 @@ func (m *Mat44f) SetModel(loc *Vec3f, yaw float32, pitch float32, scale float32,
|
||||
Y: float32(math.Cos(float64(pitch))),
|
||||
}
|
||||
m.SetLookAt(loc, loc.Add(&lookvec), up)
|
||||
m.Set(0, 0, m.Get(0, 0)*scale)
|
||||
m.Set(1, 1, m.Get(1, 1)*scale)
|
||||
m.Set(2, 2, m.Get(2, 2)*scale)
|
||||
//m.Set(0, 0, m.Get(0, 0)*scale)
|
||||
//m.Set(1, 1, m.Get(1, 1)*scale)
|
||||
//m.Set(2, 2, m.Get(2, 2)*scale)
|
||||
return lookvec
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ func main() {
|
||||
camtrans = *camtrans.Add(&newcamtrans)
|
||||
|
||||
// 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 = screenmat.Multiply(&viewport)
|
||||
|
Loading…
Reference in New Issue
Block a user