| 209 | } |
| 210 | |
| 211 | bool Camera::playAnimation() { |
| 212 | SHARED::CANPT animPosition = cameraAnimPoints[animationPosition++]; |
| 213 | // TODO: This should really be relative to the players car |
| 214 | position = (glm::normalize(glm::quat(glm::vec3(-SIMD_PI/2,0,0))) * glm::vec3((animPosition.x/ 65536.0f) / 10.f, ((animPosition.y/ 65536.0f) / 10.f), (animPosition.z/ 65536.0f) / 10.f)) + initialPosition; |
| 215 | glm::quat RotationMatrix = glm::normalize(glm::quat(glm::vec3(glm::radians(0.f), glm::radians(-90.f), 0))) * glm::normalize(glm::quat(1.0f - (animPosition.od1/ 65536.0f), 1.0f - (animPosition.od2/ 65536.0f), 1.0f - (animPosition.od3/ 65536.0f), 1.0f - (animPosition.od4/ 65536.0f))); |
| 216 | glm::vec3 direction = glm::normalize(position * RotationMatrix); |
| 217 | |
| 218 | |
| 219 | // Camera matrix |
| 220 | ViewMatrix = glm::lookAt( |
| 221 | position, // Camera is here |
| 222 | position + direction, // and looks here : at the same position, plus "direction" |
| 223 | glm::vec3(0,1,0) |
| 224 | ); |
| 225 | |
| 226 | // TODO: At conclusion of animation routine, Hermite to rear of car |
| 227 | return animationPosition == cameraAnimPoints.size(); |
| 228 | } |