internal IntPtr GetRecalculatedViewMatrix() { lock (InstanceMutationLock) { if (isDisposed) { return(IntPtr.Zero); } Vector3 u = _UpDirection * _Orientation; Vector3 v = _Orientation * u; // ReSharper disable once ImpureMethodCallOnReadonlyValueField Resharper bug, Write is not impure viewMatrix.Write(new Matrix( r0C0: u.X, r1C0: u.Y, r2C0: u.Z, r0C1: v.X, r1C1: v.Y, r2C1: v.Z, r0C2: _Orientation.X, r1C2: _Orientation.Y, r2C2: _Orientation.Z, r3C0: Vector3.Dot(_Position, -u), r3C1: Vector3.Dot(_Position, -v), r3C2: Vector3.Dot(_Position, -_Orientation), r3C3: 1f )); return(viewMatrix.AlignedPointer); } }
internal IntPtr GetRecalculatedProjectionMatrix(Camera camera) { Assure.NotNull(camera); lock (TargetWindow.WindowMutationLock) { if (isDisposed) { return(IntPtr.Zero); } if (camera.OrthographicDimensions != null) { projectionMatrix.Write(new Matrix( r0C0: 2f / camera.OrthographicDimensions.Value.X, r1C1: 2f / camera.OrthographicDimensions.Value.Y, r2C2: 1f / (camera.OrthographicDimensions.Value.Z - NearPlaneDist), r2C3: -NearPlaneDist / (camera.OrthographicDimensions.Value.Z - NearPlaneDist), r3C3: 1f ).Transpose); } else { float verticalFOV = camera.GetVerticalFOV(AspectRatio); projectionMatrix.Write(new Matrix( r0C0: 1f / (AspectRatio * (float)Math.Tan(verticalFOV / 2f)), r1C1: 1f / (float)Math.Tan(verticalFOV / 2f), r2C2: FarPlaneDist / (FarPlaneDist - NearPlaneDist), r2C3: 1f, r3C2: (-NearPlaneDist * FarPlaneDist) / (FarPlaneDist - NearPlaneDist) )); } return(projectionMatrix.AlignedPointer); } }
protected Entity() { EntityModule.AddActiveEntity(this); transform.Write(Transform.DEFAULT_TRANSFORM); }