| 2051 | } |
| 2052 | |
| 2053 | void ShapeBase::getCameraTransform(F32* pos,MatrixF* mat) |
| 2054 | { |
| 2055 | // Returns camera to world space transform |
| 2056 | // Handles first person / third person camera position |
| 2057 | |
| 2058 | if (isServerObject() && mShapeInstance) |
| 2059 | mShapeInstance->animateNodeSubtrees(true); |
| 2060 | |
| 2061 | if (*pos != 0) |
| 2062 | { |
| 2063 | F32 min,max; |
| 2064 | Point3F offset; |
| 2065 | MatrixF eye,rot; |
| 2066 | getCameraParameters(&min,&max,&offset,&rot); |
| 2067 | getRenderEyeTransform(&eye); |
| 2068 | mat->mul(eye,rot); |
| 2069 | |
| 2070 | // Use the eye transform to orient the camera |
| 2071 | VectorF vp,vec; |
| 2072 | vp.x = vp.z = 0; |
| 2073 | vp.y = -(max - min) * *pos; |
| 2074 | eye.mulV(vp,&vec); |
| 2075 | |
| 2076 | VectorF minVec; |
| 2077 | vp.y = -min; |
| 2078 | eye.mulV( vp, &minVec ); |
| 2079 | |
| 2080 | // Use the camera node's pos. |
| 2081 | Point3F osp,sp; |
| 2082 | if (mDataBlock->cameraNode != -1) { |
| 2083 | mShapeInstance->mNodeTransforms[mDataBlock->cameraNode].getColumn(3,&osp); |
| 2084 | |
| 2085 | // Scale the camera position before applying the transform |
| 2086 | const Point3F& scale = getScale(); |
| 2087 | osp.convolve( scale ); |
| 2088 | |
| 2089 | getRenderTransform().mulP(osp,&sp); |
| 2090 | } |
| 2091 | else |
| 2092 | getRenderTransform().getColumn(3,&sp); |
| 2093 | |
| 2094 | // Make sure we don't extend the camera into anything solid |
| 2095 | Point3F ep = sp + minVec + vec + offset; |
| 2096 | disableCollision(); |
| 2097 | if (isMounted()) |
| 2098 | getObjectMount()->disableCollision(); |
| 2099 | RayInfo collision; |
| 2100 | if( mContainer && mContainer->castRay(sp, ep, |
| 2101 | (0xFFFFFFFF & ~(WaterObjectType | |
| 2102 | GameBaseObjectType | |
| 2103 | TriggerObjectType | |
| 2104 | DefaultObjectType)), |
| 2105 | &collision) == true) { |
| 2106 | F32 vecLenSq = vec.lenSquared(); |
| 2107 | F32 adj = (-mDot(vec, collision.normal) / vecLenSq) * 0.1; |
| 2108 | F32 newPos = getMax(0.0f, collision.t - adj); |
| 2109 | if (newPos == 0.0f) |
| 2110 | eye.getColumn(3,&ep); |
nothing calls this directly
no test coverage detected