private void UpdatePropertiesInternal(MatrixD newViewMatrix) { ViewMatrix = newViewMatrix; MatrixD.Invert(ref ViewMatrix, out WorldMatrix); // Projection matrix according to zoom level ProjectionMatrix = MatrixD.CreatePerspectiveFieldOfView(FovWithZoom, AspectRatio, GetSafeNear(), FarPlaneDistance); ProjectionMatrixFar = MatrixD.CreatePerspectiveFieldOfView(FovWithZoom, AspectRatio, GetSafeNear(), 1000000); ViewProjectionMatrix = ViewMatrix * ProjectionMatrix; ViewProjectionMatrixFar = ViewMatrix * ProjectionMatrixFar; // Projection matrix according to zoom level // float near = System.Math.Min(NearPlaneDistance, NearForNearObjects); //minimum cockpit distance // ProjectionMatrixForNearObjects = MatrixD.CreatePerspectiveFieldOfView(FovWithZoomForNearObjects, ForwardAspectRatio, // near, // FarForNearObjects); UpdateBoundingFrustum(); }
/// <summary> /// Find the best reference orientation to use for jump drive coordinates. /// It will try one of several things: /// 1) Find a cockpit or RC block grouped to the FTL. If it find any, it will use the 'Main Cockpit', if set, otherwise random. /// 2) Search for a non-grouped cockpit or remote control block. If it finds only one, it uses that /// 3) If there are multiple, and one has 'FTL' in the name, it uses the first one found. /// 4) If there are multiple, and not named, it finds the first one with 'Main Cockpit' set /// 4) If there are multiple, and not named, it finds the first one with 'Control Thrusters' set /// 5) If there are no cockpits, it uses the original entity reference. /// </summary> /// <returns>Worldmatrix of entity to use for reference</returns> public static VRageMath.MatrixD GetShipReference(this IMyFunctionalBlock ftl) { VRageMath.MatrixD reference = ftl.GetTopMostParent().PositionComp.WorldMatrix; var controller = GetShipController(ftl); if (controller != null) { reference = controller.WorldMatrix; } return(reference); }
void IMyEntity.SetWorldMatrix(VRageMath.MatrixD worldMatrix, object source) { PositionComp.SetWorldMatrix(worldMatrix, source); }
public void SetViewMatrix(MatrixD newViewMatrix) { PreviousPosition = Position; UpdatePropertiesInternal(newViewMatrix); }