This commit is contained in:
bloeys
2022-10-01 01:44:22 +04:00
parent 62194c4cad
commit 0da031aa57

19
main.go
View File

@ -195,19 +195,20 @@ func (g *OurGame) Init() {
}
func vecRotByQuat(v *gglm.Vec3, q *gglm.Quat) *gglm.Vec3 {
// @TODO: Add this to gglm
// func vecRotByQuat(v *gglm.Vec3, q *gglm.Quat) *gglm.Vec3 {
// Reference: https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion
qVec := gglm.NewVec3(q.X(), q.Y(), q.Z())
// // Reference: https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion
// qVec := gglm.NewVec3(q.X(), q.Y(), q.Z())
rotatedVec := qVec.Clone().Scale(2 * gglm.DotVec3(v, qVec))
// rotatedVec := qVec.Clone().Scale(2 * gglm.DotVec3(v, qVec))
t1 := q.W()*q.W() - gglm.DotVec3(qVec, qVec)
rotatedVec.Add(v.Clone().Scale(t1))
// t1 := q.W()*q.W() - gglm.DotVec3(qVec, qVec)
// rotatedVec.Add(v.Clone().Scale(t1))
rotatedVec.Add(gglm.Cross(qVec, v).Scale(2 * q.W()))
return rotatedVec
}
// rotatedVec.Add(gglm.Cross(qVec, v).Scale(2 * q.W()))
// return rotatedVec
// }
func (g *OurGame) Update() {