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

Method getCameraTransform

Engine/source/T3D/shapeBase.cpp:2053–2126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2051}
2052
2053void 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);

Callers

nothing calls this directly

Calls 13

getMaxFunction · 0.85
animateNodeSubtreesMethod · 0.80
mulVMethod · 0.80
getColumnMethod · 0.80
mulPMethod · 0.80
setColumnMethod · 0.80
mDotFunction · 0.50
mulMethod · 0.45
convolveMethod · 0.45
disableCollisionMethod · 0.45
castRayMethod · 0.45
lenSquaredMethod · 0.45

Tested by

no test coverage detected