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

Method getCameraTransform

Engine/source/T3D/rigidShape.cpp:869–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

867//----------------------------------------------------------------------------
868
869void RigidShape::getCameraTransform(F32* pos,MatrixF* mat)
870{
871 // Returns camera to world space transform
872 // Handles first person / third person camera position
873 if (isServerObject() && mShapeInstance)
874 mShapeInstance->animateNodeSubtrees(true);
875
876 if (*pos == 0)
877 {
878 getRenderEyeTransform(mat);
879 return;
880 }
881
882 // Get the shape's camera parameters.
883 F32 min,max;
884 MatrixF rot;
885 Point3F offset;
886 getCameraParameters(&min,&max,&offset,&rot);
887
888 // Start with the current eye position
889 MatrixF eye;
890 getRenderEyeTransform(&eye);
891
892 // Build a transform that points along the eye axis
893 // but where the Z axis is always up.
894 if (mDataBlock->cameraRoll)
895 mat->mul(eye,rot);
896 else
897 {
898 MatrixF cam(1);
899 VectorF x,y,z(0,0,1);
900 eye.getColumn(1, &y);
901
902 mCross(y, z, &x);
903 x.normalize();
904 mCross(x, y, &z);
905 z.normalize();
906
907 cam.setColumn(0,x);
908 cam.setColumn(1,y);
909 cam.setColumn(2,z);
910 mat->mul(cam,rot);
911 }
912
913 // Camera is positioned straight back along the eye's -Y axis.
914 // A ray is cast to make sure the camera doesn't go through
915 // anything solid.
916 VectorF vp,vec;
917 vp.x = vp.z = 0;
918 vp.y = -(max - min) * *pos;
919 eye.mulV(vp,&vec);
920
921 // Use the camera node as the starting position if it exists.
922 Point3F osp,sp;
923 if (mDataBlock->cameraNode != -1)
924 {
925 mShapeInstance->mNodeTransforms[mDataBlock->cameraNode].getColumn(3,&osp);
926 getRenderTransform().mulP(osp,&sp);

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
mulMethod · 0.45
normalizeMethod · 0.45
disableCollisionMethod · 0.45
castRayMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected