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

Method getCameraTransform

Engine/source/T3D/shapeBase.cpp:1914–1987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1912}
1913
1914void ShapeBase::getCameraTransform(F32* pos,MatrixF* mat)
1915{
1916 // Returns camera to world space transform
1917 // Handles first person / third person camera position
1918
1919 if (isServerObject() && mShapeInstance)
1920 mShapeInstance->animateNodeSubtrees(true);
1921
1922 if (*pos != 0)
1923 {
1924 F32 min,max;
1925 Point3F offset;
1926 MatrixF eye,rot;
1927 getCameraParameters(&min,&max,&offset,&rot);
1928 getRenderEyeTransform(&eye);
1929 mat->mul(eye,rot);
1930
1931 // Use the eye transform to orient the camera
1932 VectorF vp,vec;
1933 vp.x = vp.z = 0;
1934 vp.y = -(max - min) * *pos;
1935 eye.mulV(vp,&vec);
1936
1937 VectorF minVec;
1938 vp.y = -min;
1939 eye.mulV( vp, &minVec );
1940
1941 // Use the camera node's pos.
1942 Point3F osp,sp;
1943 if (mDataBlock->cameraNode != -1) {
1944 mShapeInstance->mNodeTransforms[mDataBlock->cameraNode].getColumn(3,&osp);
1945
1946 // Scale the camera position before applying the transform
1947 const Point3F& scale = getScale();
1948 osp.convolve( scale );
1949
1950 getRenderTransform().mulP(osp,&sp);
1951 }
1952 else
1953 getRenderTransform().getColumn(3,&sp);
1954
1955 // Make sure we don't extend the camera into anything solid
1956 Point3F ep = sp + minVec + vec + offset;
1957 disableCollision();
1958 if (isMounted())
1959 getObjectMount()->disableCollision();
1960 RayInfo collision;
1961 if( mContainer && mContainer->castRay(sp, ep,
1962 (0xFFFFFFFF & ~(WaterObjectType |
1963 GameBaseObjectType |
1964 TriggerObjectType |
1965 DefaultObjectType)),
1966 &collision) == true) {
1967 F32 vecLenSq = vec.lenSquared();
1968 F32 adj = (-mDot(vec, collision.normal) / vecLenSq) * 0.1;
1969 F32 newPos = getMax(0.0f, collision.t - adj);
1970 if (newPos == 0.0f)
1971 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