MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / snapToPosition

Method snapToPosition

Engine/source/afx/afxCamera.cpp:278–307  ·  view source on GitHub ↗

Sets the position and calculates rotation

Source from the content-addressed store, hash-verified

276
277// Sets the position and calculates rotation
278void 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
309void afxCamera::setCameraSubject(SceneObject* new_subject)
310{

Callers

nothing calls this directly

Calls 7

getAnglesFromVectorFunction · 0.85
createOrientFromDirFunction · 0.85
mulPMethod · 0.80
setColumnMethod · 0.80
getRenderTransformMethod · 0.45
normalizeMethod · 0.45
identityMethod · 0.45

Tested by

no test coverage detected