Sets the position and calculates rotation
| 276 | |
| 277 | // Sets the position and calculates rotation |
| 278 | void afxCamera::snapToPosition(const Point3F& tPos) |
| 279 | { |
| 280 | MatrixF transMat; |
| 281 | |
| 282 | if (mCam_subject) |
| 283 | { |
| 284 | // get the subject's transform |
| 285 | MatrixF objToWorld = mCam_subject->getRenderTransform(); |
| 286 | |
| 287 | // transform the center-of-interest to world-space |
| 288 | Point3F objPos; |
| 289 | objToWorld.mulP(mCoi_offset, &objPos); |
| 290 | |
| 291 | // find normalized direction vector looking from camera to coi |
| 292 | VectorF dirVec = objPos - tPos; |
| 293 | dirVec.normalize(); |
| 294 | |
| 295 | MathUtils::getAnglesFromVector(dirVec, mRot.z, mRot.x); |
| 296 | mRot.x = 0 - mRot.x; |
| 297 | |
| 298 | transMat = MathUtils::createOrientFromDir(dirVec); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | transMat.identity(); |
| 303 | } |
| 304 | |
| 305 | transMat.setColumn(3, tPos); |
| 306 | Parent::setTransform(transMat); |
| 307 | } |
| 308 | |
| 309 | void afxCamera::setCameraSubject(SceneObject* new_subject) |
| 310 | { |
nothing calls this directly
no test coverage detected