| 925 | //---------------------------------------------------------------------------- |
| 926 | |
| 927 | void RigidShape::getCameraTransform(F32* pos,MatrixF* mat) |
| 928 | { |
| 929 | // Returns camera to world space transform |
| 930 | // Handles first person / third person camera position |
| 931 | if (isServerObject() && mShapeInstance) |
| 932 | mShapeInstance->animateNodeSubtrees(true); |
| 933 | |
| 934 | if (*pos == 0) |
| 935 | { |
| 936 | getRenderEyeTransform(mat); |
| 937 | return; |
| 938 | } |
| 939 | |
| 940 | // Get the shape's camera parameters. |
| 941 | F32 min,max; |
| 942 | MatrixF rot; |
| 943 | Point3F offset; |
| 944 | getCameraParameters(&min,&max,&offset,&rot); |
| 945 | |
| 946 | // Start with the current eye position |
| 947 | MatrixF eye; |
| 948 | getRenderEyeTransform(&eye); |
| 949 | |
| 950 | // Build a transform that points along the eye axis |
| 951 | // but where the Z axis is always up. |
| 952 | if (mDataBlock->cameraRoll) |
| 953 | mat->mul(eye,rot); |
| 954 | else |
| 955 | { |
| 956 | MatrixF cam(1); |
| 957 | VectorF x,y,z(0,0,1); |
| 958 | eye.getColumn(1, &y); |
| 959 | |
| 960 | mCross(y, z, &x); |
| 961 | x.normalize(); |
| 962 | mCross(x, y, &z); |
| 963 | z.normalize(); |
| 964 | |
| 965 | cam.setColumn(0,x); |
| 966 | cam.setColumn(1,y); |
| 967 | cam.setColumn(2,z); |
| 968 | mat->mul(cam,rot); |
| 969 | } |
| 970 | |
| 971 | // Camera is positioned straight back along the eye's -Y axis. |
| 972 | // A ray is cast to make sure the camera doesn't go through |
| 973 | // anything solid. |
| 974 | VectorF vp,vec; |
| 975 | vp.x = vp.z = 0; |
| 976 | vp.y = -(max - min) * *pos; |
| 977 | eye.mulV(vp,&vec); |
| 978 | |
| 979 | // Use the camera node as the starting position if it exists. |
| 980 | Point3F osp,sp; |
| 981 | if (mDataBlock->cameraNode != -1) |
| 982 | { |
| 983 | mShapeInstance->mNodeTransforms[mDataBlock->cameraNode].getColumn(3,&osp); |
| 984 | getRenderTransform().mulP(osp,&sp); |
nothing calls this directly
no test coverage detected