| 950 | } |
| 951 | |
| 952 | void 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(); |
nothing calls this directly
no test coverage detected