/* * public static void UpdateTerminal(this MyCubeBlock block) * { * MyOwnershipShareModeEnum shareMode; * long ownerId; * if (block.IDModule != null) * { * ownerId = block.IDModule.Owner; * shareMode = block.IDModule.ShareMode; * } * else * { * var sorter = block as IMyTerminalBlock; * if (sorter != null) * { * sorter.ShowOnHUD = !sorter.ShowOnHUD; * sorter.ShowOnHUD = !sorter.ShowOnHUD; * } * return; * } * block.ChangeOwner(ownerId, shareMode == MyOwnershipShareModeEnum.None ? MyOwnershipShareModeEnum.Faction : MyOwnershipShareModeEnum.None); * block.ChangeOwner(ownerId, shareMode); * } */ public static void SphereCloud(int pointLimit, Vector3D[] physicsArray, MyEntity shieldEnt, bool transformAndScale, bool debug, Random rnd = null) { if (pointLimit > 10000) { pointLimit = 10000; } if (rnd == null) { rnd = new Random(0); } var sPosComp = shieldEnt.PositionComp; var unscaledPosWorldMatrix = MatrixD.Rescale(MatrixD.CreateTranslation(sPosComp.WorldAABB.Center), sPosComp.WorldVolume.Radius); var radius = sPosComp.WorldVolume.Radius; for (int i = 0; i < pointLimit; i++) { var value = rnd.Next(0, physicsArray.Length - 1); var phi = 2 * Math.PI * i / pointLimit; var x = (float)(radius * Math.Sin(phi) * Math.Cos(value)); var z = (float)(radius * Math.Sin(phi) * Math.Sin(value)); var y = (float)(radius * Math.Cos(phi)); var v = new Vector3D(x, y, z); if (transformAndScale) { v = Vector3D.Transform(Vector3D.Normalize(v), unscaledPosWorldMatrix); } if (debug) { DsDebugDraw.DrawX(v, sPosComp.LocalMatrix, 0.5); } physicsArray[i] = v; } }
public static void UnitSphereTranslateScale(int pointLimit, ref Vector3D[] physicsArray, ref Vector3D[] scaledCloudArray, MyEntity shieldEnt, bool debug) { var sPosComp = shieldEnt.PositionComp; var radius = sPosComp.WorldVolume.Radius; var center = sPosComp.WorldAABB.Center; for (int i = 0; i < pointLimit; i++) { var v = physicsArray[i]; scaledCloudArray[i] = v = center + (radius * v); if (debug) { DsDebugDraw.DrawX(v, sPosComp.LocalMatrix, 0.5); } } }
public static void UnitSphereCloudQuick(int pointLimit, ref Vector3D[] physicsArray, MyEntity shieldEnt, bool translateAndScale, bool debug, Random rnd = null) { if (pointLimit > 10000) { pointLimit = 10000; } if (rnd == null) { rnd = new Random(0); } var sPosComp = shieldEnt.PositionComp; var radius = sPosComp.WorldVolume.Radius; var center = sPosComp.WorldAABB.Center; var v = Vector3D.Zero; for (int i = 0; i < pointLimit; i++) { while (true) { v.X = (rnd.NextDouble() * 2) - 1; v.Y = (rnd.NextDouble() * 2) - 1; v.Z = (rnd.NextDouble() * 2) - 1; var len2 = v.LengthSquared(); if (len2 < .0001) { continue; } v *= radius / Math.Sqrt(len2); break; } if (translateAndScale) { physicsArray[i] = v += center; } else { physicsArray[i] = v; } if (debug) { DsDebugDraw.DrawX(v, sPosComp.LocalMatrix, 0.5); } } }
public static void UnitSphereTranslateScaleList(int pointLimit, ref Vector3D[] physicsArray, ref List <Vector3D> scaledCloudList, MyEntity shieldEnt, bool debug, MyEntity grid, bool rotate = true) { var sPosComp = shieldEnt.PositionComp; var radius = sPosComp.WorldVolume.Radius; var center = sPosComp.WorldAABB.Center; var gMatrix = grid.WorldMatrix; for (int i = 0; i < pointLimit; i++) { var v = physicsArray[i]; if (rotate) { Vector3D.Rotate(ref v, ref gMatrix, out v); } v = center + (radius * v); scaledCloudList.Add(v); if (debug) { DsDebugDraw.DrawX(v, sPosComp.LocalMatrix, 0.5); } } }
internal void DebugDraw() { DsDebugDraw.DrawSphere(HitSphere, Color.Red); }