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

Method getCameraTransform

Engine/source/T3D/turret/turretShape.cpp:952–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

950}
951
952void TurretShape::getCameraTransform(F32* pos,MatrixF* mat)
953{
954 // Returns camera to world space transform
955 // Handles first person / third person camera position
956 if (isServerObject() && mShapeInstance)
957 mShapeInstance->animateNodeSubtrees(true);
958
959 if (*pos == 0) {
960 getRenderEyeTransform(mat);
961 return;
962 }
963
964 // Get the shape's camera parameters.
965 F32 min,max;
966 MatrixF rot;
967 Point3F offset;
968 getCameraParameters(&min,&max,&offset,&rot);
969
970 // Start with the current eye position
971 MatrixF eye;
972 getRenderEyeTransform(&eye);
973
974 // Build a transform that points along the eye axis
975 // but where the Z axis is always up.
976 {
977 MatrixF cam(1);
978 VectorF x,y,z(0,0,1);
979 eye.getColumn(1, &y);
980 mCross(y, z, &x);
981 x.normalize();
982 mCross(x, y, &z);
983 z.normalize();
984 cam.setColumn(0,x);
985 cam.setColumn(1,y);
986 cam.setColumn(2,z);
987 mat->mul(cam,rot);
988 }
989
990 // Camera is positioned straight back along the eye's -Y axis.
991 // A ray is cast to make sure the camera doesn't go through
992 // anything solid.
993 VectorF vp,vec;
994 vp.x = vp.z = 0;
995 vp.y = -(max - min) * *pos;
996 eye.mulV(vp,&vec);
997
998 // Use the camera node as the starting position if it exists.
999 Point3F osp,sp;
1000 if (mDataBlock->cameraNode != -1)
1001 {
1002 mShapeInstance->mNodeTransforms[mDataBlock->cameraNode].getColumn(3,&osp);
1003 getRenderTransform().mulP(osp,&sp);
1004 }
1005 else
1006 eye.getColumn(3,&sp);
1007
1008 // Make sure we don't hit ourself...
1009 disableCollision();

Callers

nothing calls this directly

Calls 13

animateNodeSubtreesMethod · 0.80
getColumnMethod · 0.80
setColumnMethod · 0.80
mulVMethod · 0.80
mulPMethod · 0.80
mCrossFunction · 0.50
mDotFunction · 0.50
normalizeMethod · 0.45
mulMethod · 0.45
disableCollisionMethod · 0.45
castRayMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected