private void ActivateCommon() { BoundingSphereD globalSphere = new BoundingSphereD(Vector3D.Transform(m_detectorSphere.Center, CubeGrid.WorldMatrix), m_detectorSphere.Radius); if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { MyRenderProxy.DebugDrawSphere(globalSphere.Center, (float)globalSphere.Radius, Color.Red.ToVector3(), 1.0f, false); } m_isActivatedOnSomething = false; foreach (var entry in m_entitiesInContact) { MyCubeGrid grid = entry.Key as MyCubeGrid; MyCharacter character = entry.Key as MyCharacter; if (grid != null) { m_tempBlocksBuffer.Clear(); grid.GetBlocksInsideSphere(ref globalSphere, m_tempBlocksBuffer); m_blocksToActivateOn.UnionWith(m_tempBlocksBuffer); } if (character != null && Sync.IsServer) { MyStringHash damageType = MyDamageType.Drill; if (this is IMyShipGrinder) { damageType = MyDamageType.Grind; } else if (this is IMyShipWelder) { damageType = MyDamageType.Weld; } character.DoDamage(20, damageType, true, attackerId: EntityId); } } m_isActivatedOnSomething |= Activate(m_blocksToActivateOn); m_activateCounter++; m_lastTimeActivate = MySandboxGame.TotalGamePlayTimeInMilliseconds; PlayLoopSound(m_isActivatedOnSomething); m_blocksToActivateOn.Clear(); }
public void DebugDraw() { MatrixD viewMatrix = MySector.MainCamera.ViewMatrix; Vector3D?nullable = null; foreach (MyHighLevelPrimitive local1 in this.m_pathNodes) { Vector3D down = MyGravityProviderSystem.CalculateTotalGravityInPoint(local1.WorldPosition); if (Vector3D.IsZero(down, 0.001)) { down = Vector3D.Down; } down.Normalize(); MyHighLevelPrimitive local2 = local1; Vector3D position = local2.WorldPosition + (down * -10.0); MyRenderProxy.DebugDrawSphere(position, 1f, Color.IndianRed, 1f, false, false, true, false); MyRenderProxy.DebugDrawLine3D(local2.WorldPosition, position, Color.IndianRed, Color.IndianRed, false, false); if (nullable != null) { MyRenderProxy.DebugDrawLine3D(position, nullable.Value, Color.IndianRed, Color.IndianRed, false, false); } nullable = new Vector3D?(position); } MyRenderProxy.DebugDrawSphere(this.m_startPoint, 0.5f, Color.HotPink, 1f, false, false, true, false); if (this.m_goal != null) { this.m_goal.DebugDraw(); } if (MyFakes.DEBUG_DRAW_FOUND_PATH) { Vector3D?nullable2 = null; for (int i = 0; i < this.m_expandedPath.Count; i++) { Vector3D position = new Vector3D(this.m_expandedPath[i]); float w = (float)this.m_expandedPath[i].W; Color color = (i == (this.m_expandedPath.Count - 1)) ? Color.OrangeRed : Color.Orange; MyRenderProxy.DebugDrawPoint(position, color, false, false); MyRenderProxy.DebugDrawText3D(position + (viewMatrix.Right * 0.10000000149011612), w.ToString(), color, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); if (nullable2 != null) { MyRenderProxy.DebugDrawLine3D(nullable2.Value, position, Color.Pink, Color.Pink, false, false); } nullable2 = new Vector3D?(position); } } }
public void DebugDraw() { int index = 0; while (index < this.m_obbs.Length) { int num2 = 0; while (true) { if (num2 >= this.m_obbs[0].Length) { index++; break; } if (this.m_obbs[index][num2] != null) { MyRenderProxy.DebugDrawOBB(this.m_obbs[index][num2].Value, Color.Red, 0f, true, false, false); } num2++; } } MyRenderProxy.DebugDrawOBB(this.BaseOBB, Color.White, 0f, true, false, false); if (this.m_obbs[0][0] != null) { MyRenderProxy.DebugDrawSphere(this.m_obbs[0][0].Value.Center, 5f, Color.Yellow, 0f, true, false, true, false); } if (this.m_obbs[0][this.OBBsPerLine - 1] != null) { MyRenderProxy.DebugDrawSphere(this.m_obbs[0][this.OBBsPerLine - 1].Value.Center, 5f, Color.Green, 0f, true, false, true, false); } if (this.m_obbs[this.OBBsPerLine - 1][this.OBBsPerLine - 1] != null) { MyRenderProxy.DebugDrawSphere(this.m_obbs[this.OBBsPerLine - 1][this.OBBsPerLine - 1].Value.Center, 5f, Color.Blue, 0f, true, false, true, false); } if (this.m_obbs[this.OBBsPerLine - 1][0] != null) { MyRenderProxy.DebugDrawSphere(this.m_obbs[this.OBBsPerLine - 1][0].Value.Center, 5f, Color.White, 0f, true, false, true, false); } MyOrientedBoundingBoxD?nullable = this.m_obbs[0][0]; MyOrientedBoundingBoxD?nullable2 = this.m_obbs[this.OBBsPerLine - 1][0]; MyOrientedBoundingBoxD?nullable3 = this.m_obbs[this.OBBsPerLine - 1][this.OBBsPerLine - 1]; MyRenderProxy.DebugDrawSphere(GetOBBCorner(nullable.Value, OBBCorner.LowerBackLeft), 5f, Color.White, 0f, true, false, true, false); MyRenderProxy.DebugDrawSphere(GetOBBCorner(nullable2.Value, OBBCorner.LowerBackRight), 5f, Color.White, 0f, true, false, true, false); MyRenderProxy.DebugDrawSphere(GetOBBCorner(nullable3.Value, OBBCorner.LowerFrontRight), 5f, Color.White, 0f, true, false, true, false); }
public override void UpdateBeforeSimulation() { base.UpdateBeforeSimulation(); if (ResourceSink != null) { ResourceSink.Update(); } if (IsWorking) { foreach (IMyEntity entityInterface in m_containedEntities) { MyEntity entity = entityInterface as MyEntity; MyCharacter character = entity as MyCharacter; IMyVirtualMass mass = entity as IMyVirtualMass; var naturalGravityMultiplier = MyGravityProviderSystem.CalculateHighestNaturalGravityMultiplierInPoint(entity.WorldMatrix.Translation); var gravity = GetWorldGravity(entity.WorldMatrix.Translation) * MyGravityProviderSystem.CalculateArtificialGravityStrengthMultiplier(naturalGravityMultiplier); if (mass != null && entity.Physics.RigidBody.IsActive) { if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_MISCELLANEOUS) { MyRenderProxy.DebugDrawSphere(entity.WorldMatrix.Translation, 0.2f, mass.IsWorking ? Color.Blue : Color.Red, 1.0f, false); } if (mass.IsWorking && entity.Physics.RigidBody.IsActive) { ((IMyEntity)mass.CubeGrid).Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * mass.VirtualMass, entity.WorldMatrix.Translation, null); } } else if (!entity.Physics.IsKinematic && !entity.Physics.IsStatic && entity.Physics.RigidBody2 == null && //jn: TODO this is actualy check for large grid character == null) { if (entity.Physics.RigidBody != null && entity.Physics.RigidBody.IsActive) { entity.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * entity.Physics.RigidBody.Mass, null, null); } } } } }
public void DebugDraw(MatrixD posAndOri) { if (MyDebugDrawSettings.DEBUG_DRAW_BOT_AIMING) { Vector3 translation = (Vector3)posAndOri.Translation; MyRenderProxy.DebugDrawArrow3D(translation, translation + posAndOri.Right, Color.Red, new Color?(Color.Red), false, 0.1, "X", 0.5f, false); MyRenderProxy.DebugDrawArrow3D(translation, translation + posAndOri.Up, Color.Green, new Color?(Color.Green), false, 0.1, "Y", 0.5f, false); MyRenderProxy.DebugDrawArrow3D(translation, translation + posAndOri.Forward, Color.Blue, new Color?(Color.Blue), false, 0.1, "-Z", 0.5f, false); MyRenderProxy.DebugDrawArrow3D(translation, translation + this.m_dbgDesiredForward, Color.Yellow, new Color?(Color.Yellow), false, 0.1, "Des.-Z", 0.5f, false); Vector3 pointFrom = translation + posAndOri.Forward; MyRenderProxy.DebugDrawArrow3D(pointFrom, (translation + posAndOri.Forward) + ((this.m_rotationHint.X * 10f) * posAndOri.Right), Color.Salmon, new Color?(Color.Salmon), false, 0.1, "Rot.X", 0.5f, false); MyRenderProxy.DebugDrawArrow3D(pointFrom, pointFrom - ((this.m_rotationHint.Y * 10f) * posAndOri.Up), Color.LimeGreen, new Color?(Color.LimeGreen), false, 0.1, "Rot.Y", 0.5f, false); MyCharacter botEntity = this.m_parent.BotEntity as MyCharacter; if (botEntity != null) { MyRenderProxy.DebugDrawSphere(botEntity.AimedPoint, 0.2f, Color.Orange, 1f, false, false, true, false); } } }
public void DebugDraw() { if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW == false) { return; } foreach (var steering in m_steerings) { steering.DebugDraw(); } Vector3 pos = PositionAndOrientation.Translation;// + /*PositionAndOrientation.Up * 1.5f + */ForwardVector; Vector3 rightVector = Vector3.Cross(m_forwardVector, UpVector); if (Stuck) { MyRenderProxy.DebugDrawSphere(pos, 1.0f, Color.Red.ToVector3(), 1.0f, false); } //MyRenderProxy.DebugDrawLine3D(pos, pos + rightVector, Color.Red, Color.Red, false); //MyRenderProxy.DebugDrawSphere(pos + rightVector * m_aiming.RotationHint.X, 0.05f, Color.Red.ToVector3(), 1.0f, true); //MyRenderProxy.DebugDrawLine3D(pos, pos + UpVector, Color.Green, Color.Green, false); //MyRenderProxy.DebugDrawSphere(pos + UpVector * m_aiming.RotationHint.Y, 0.05f, Color.Green.ToVector3(), 1.0f, true); //MyRenderProxy.DebugDrawLine3D(pos, pos + ForwardVector, Color.Blue, Color.Blue, false); Vector3 pos2 = PositionAndOrientation.Translation + PositionAndOrientation.Up * 1.5f; MyRenderProxy.DebugDrawLine3D(pos2, pos2 + m_aimingPositionAndOrientation.Right, Color.Red, Color.Red, false); MyRenderProxy.DebugDrawLine3D(pos2, pos2 + m_aimingPositionAndOrientation.Up, Color.Green, Color.Green, false); MyRenderProxy.DebugDrawLine3D(pos2, pos2 + m_aimingPositionAndOrientation.Forward, Color.Blue, Color.Blue, false); //var normalizedCorrection = Vector3D.Normalize(m_correction); //var normalizedCorrectedDirXZ = normalizedCorrection + m_forwardVector; //normalizedCorrectedDirXZ = Vector3D.Normalize(Vector3D.Reject(normalizedCorrectedDirXZ, Vector3D.Up)); //MyRenderProxy.DebugDrawLine3D(pos, pos + normalizedCorrectedDirXZ * 3, Color.Lime, Color.Lime, false); //MyRenderProxy.DebugDrawSphere(pos + ForwardVector, 0.05f, Color.Blue.ToVector3(), 1.0f, true); //MyRenderProxy.DebugDrawLine3D(pos + ForwardVector, pos + ForwardVector + m_correction, Color.Yellow, Color.Yellow, false); //MyRenderProxy.DebugDrawSphere(pos + ForwardVector + m_correction, 0.05f, Color.Yellow.ToVector3(), 1.0f, true); }
public void DebugDraw() { if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { this.m_aiming.DebugDraw(this.m_aimingPositionAndOrientation); if (MyDebugDrawSettings.DEBUG_DRAW_BOT_STEERING) { foreach (MySteeringBase local1 in this.m_steerings) { } } if (MyDebugDrawSettings.DEBUG_DRAW_BOT_NAVIGATION) { Vector3 translation = (Vector3)this.PositionAndOrientation.Translation; Vector3.Cross(this.m_forwardVector, this.UpVector); if (this.Stuck) { MyRenderProxy.DebugDrawSphere(translation, 1f, Color.Red.ToVector3(), 1f, false, false, true, false); } MyRenderProxy.DebugDrawArrow3D(translation, translation + this.ForwardVector, Color.Blue, new Color?(Color.Blue), false, 0.1, "Nav. FW", 0.5f, false); MyRenderProxy.DebugDrawArrow3D(translation + this.ForwardVector, (translation + this.ForwardVector) + this.m_correction, Color.LightBlue, new Color?(Color.LightBlue), false, 0.1, "Correction", 0.5f, false); if (this.m_destinationSphere != null) { this.m_destinationSphere.DebugDraw(); } MyCharacter botEntity = this.BotEntity as MyCharacter; if (botEntity != null) { MatrixD matrix = MatrixD.Invert(botEntity.GetViewMatrix()); MatrixD xd3 = botEntity.GetHeadMatrix(true, true, false, false, false); MyRenderProxy.DebugDrawLine3D(matrix.Translation, Vector3D.Transform(Vector3D.Forward * 50.0, matrix), Color.Yellow, Color.White, false, false); MyRenderProxy.DebugDrawLine3D(xd3.Translation, Vector3D.Transform(Vector3D.Forward * 50.0, xd3), Color.Red, Color.Red, false, false); if (botEntity.CurrentWeapon != null) { Vector3 vector2 = botEntity.CurrentWeapon.DirectionToTarget(botEntity.AimedPoint); MyRenderProxy.DebugDrawSphere(botEntity.AimedPoint, 1f, Color.Yellow, 1f, false, false, true, false); Vector3D pointFrom = (botEntity.CurrentWeapon as MyEntity).WorldMatrix.Translation; MyRenderProxy.DebugDrawLine3D(pointFrom, (botEntity.CurrentWeapon as MyEntity).WorldMatrix.Translation + (vector2 * 20f), Color.Purple, Color.Purple, false, false); } } } } }
public override unsafe void DebugDraw() { if (MyDebugDrawSettings.DEBUG_DRAW_ROTORS) { Vector3 vector; Vector3D vectord; Quaternion quaternion; this.m_motor.ComputeTopQueryBox(out vectord, out vector, out quaternion); MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(vectord, vector, quaternion), Color.Green.ToVector3(), 1f, false, false, false); if (this.m_motor.Rotor != null) { MyRenderProxy.DebugDrawSphere(Vector3D.Transform(this.m_motor.DummyPosition, this.m_motor.CubeGrid.WorldMatrix) + (Vector3D.Transform((this.m_motor.Rotor as MyMotorRotor).WheelDummy, this.m_motor.RotorGrid.WorldMatrix) - this.m_motor.RotorGrid.WorldMatrix.Translation), 0.1f, Color.Green, 1f, false, false, true, false); BoundingSphere boundingSphere = this.m_motor.Rotor.Model.BoundingSphere; BoundingSphere *spherePtr1 = (BoundingSphere *)ref boundingSphere; spherePtr1->Center = (Vector3)Vector3D.Transform(boundingSphere.Center, this.m_motor.Rotor.WorldMatrix); MyRenderProxy.DebugDrawSphere(boundingSphere.Center, boundingSphere.Radius, Color.Red, 1f, false, false, true, false); } } }
public override void DebugDraw() { if (MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_MISC && (this.m_character.CurrentWeapon != null)) { MyRenderProxy.DebugDrawAxis(((MyEntity)this.m_character.CurrentWeapon).WorldMatrix, 1.4f, false, false, false); MyRenderProxy.DebugDrawText3D(((MyEntity)this.m_character.CurrentWeapon).WorldMatrix.Translation, "Weapon", Color.White, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, -1, false); MyRenderProxy.DebugDrawSphere((this.m_character.AnimationController.CharacterBones[this.m_character.WeaponBone].AbsoluteTransform * this.m_character.PositionComp.WorldMatrix).Translation, 0.02f, Color.White, 1f, false, false, true, false); MyRenderProxy.DebugDrawText3D((this.m_character.AnimationController.CharacterBones[this.m_character.WeaponBone].AbsoluteTransform * this.m_character.PositionComp.WorldMatrix).Translation, "Weapon Bone", Color.White, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } if (MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_MISC && (this.m_character.IsUsing != null)) { Matrix worldMatrix = (Matrix)this.m_character.IsUsing.WorldMatrix; worldMatrix.Translation = Vector3.Zero; worldMatrix *= Matrix.CreateFromAxisAngle(worldMatrix.Up, 3.141593f); worldMatrix.Translation = (((Vector3)(this.m_character.IsUsing.PositionComp.GetPosition() - ((this.m_character.IsUsing.WorldMatrix.Up * MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large)) / 2.0))) + (worldMatrix.Up * 0.28f)) - (worldMatrix.Forward * 0.22f); MyRenderProxy.DebugDrawAxis(worldMatrix, 1.4f, false, false, false); } if (MyDebugDrawSettings.DEBUG_DRAW_SUIT_BATTERY_CAPACITY) { MatrixD worldMatrix = this.m_character.PositionComp.WorldMatrix; MyRenderProxy.DebugDrawText3D(worldMatrix.Translation + (2.0 * worldMatrix.Up), $"{this.m_character.SuitBattery.ResourceSource.RemainingCapacity} MWh", Color.White, 1f, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, -1, false); } this.m_simulatedBonesDebugDraw.Clear(); this.m_simulatedBonesAbsoluteDebugDraw.Clear(); if (MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_BONES) { this.m_character.AnimationController.UpdateTransformations(); for (int i = 0; i < this.m_character.AnimationController.CharacterBones.Length; i++) { MyCharacterBone bone = this.m_character.AnimationController.CharacterBones[i]; if (bone.Parent != null) { MatrixD matrix = (Matrix.CreateScale((float)0.1f) * bone.AbsoluteTransform) * this.m_character.PositionComp.WorldMatrix; Vector3 translation = (Vector3)matrix.Translation; Vector3 pointFrom = (Vector3)(bone.Parent.AbsoluteTransform * this.m_character.PositionComp.WorldMatrix).Translation; MyRenderProxy.DebugDrawLine3D(pointFrom, translation, Color.White, Color.White, false, false); MyRenderProxy.DebugDrawText3D((pointFrom + translation) * 0.5f, bone.Name + " (" + i.ToString() + ")", Color.Red, 0.5f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); MyRenderProxy.DebugDrawAxis(matrix, 0.1f, false, false, false); } } } }
public override void DebugDraw() { Vector3 vector; Vector3 vector2; Vector3D vectord = base.Parent.PositionAndOrientation.Translation + (base.Parent.PositionAndOrientation.Up * this.m_capsuleOffset); Vector3D vectord2 = vectord + (base.Parent.PositionAndOrientation.Up * this.m_capsuleHeight); Vector3D pointFrom = (vectord + vectord2) * 0.5; this.GetMovements(out vector, out vector2); Vector3D?targetWorld = this.TargetWorld; if (targetWorld != null) { MyRenderProxy.DebugDrawLine3D(pointFrom, targetWorld.Value, Color.White, Color.White, true, false); MyRenderProxy.DebugDrawSphere(targetWorld.Value, 0.05f, Color.White.ToVector3(), 1f, false, false, true, false); MyRenderProxy.DebugDrawCapsule(vectord, vectord2, (float)Math.Sqrt((double)this.m_capsuleRadiusSq), Color.Yellow, false, false, false); } MyRenderProxy.DebugDrawLine3D(vectord2, vectord2 + vector2, Color.Red, Color.Red, false, false); MyRenderProxy.DebugDrawLine3D(vectord2, vectord2 + vector, Color.Green, Color.Green, false, false); }
private void UpdatePastePosition() { m_pastePositionPrevious = m_pastePosition; // Current position of the placed entity is either simple translation or // it can be calculated by raycast, if we want to snap to surfaces MatrixD pasteMatrix = GetPasteMatrix(); Vector3 dragVectorGlobal = pasteMatrix.Forward * m_dragDistance; m_pastePosition = pasteMatrix.Translation + dragVectorGlobal; Matrix firstGridOrientation = GetFirstGridOrientationMatrix(); m_pastePosition += Vector3.TransformNormal(m_dragPointToPositionLocal, firstGridOrientation); if (MyDebugDrawSettings.DEBUG_DRAW_COPY_PASTE) { MyRenderProxy.DebugDrawSphere(pasteMatrix.Translation + dragVectorGlobal, 0.15f, Color.Pink, 1.0f, false); MyRenderProxy.DebugDrawSphere(m_pastePosition, 0.15f, Color.Pink.ToVector3(), 1.0f, false); } }
public override void DebugDraw() { if (this.m_turretBase.Render.GetModel() != null) { BoundingSphere boundingSphere = this.m_turretBase.Render.GetModel().BoundingSphere; } Vector3 vector = new Vector3(); switch (this.m_turretBase.GetStatus()) { case MyLargeTurretBase.MyLargeShipGunStatus.MyWeaponStatus_Deactivated: vector = Color.Green.ToVector3(); break; case MyLargeTurretBase.MyLargeShipGunStatus.MyWeaponStatus_Searching: vector = Color.Red.ToVector3(); break; case MyLargeTurretBase.MyLargeShipGunStatus.MyWeaponStatus_Shooting: vector = Color.White.ToVector3(); break; default: break; } Color colorFrom = new Color(vector); Color colorTo = new Color(vector); if (this.m_turretBase.Target != null) { MyRenderProxy.DebugDrawLine3D(this.m_turretBase.Barrel.Entity.PositionComp.GetPosition(), this.m_turretBase.Target.PositionComp.GetPosition(), colorFrom, colorTo, false, false); MyRenderProxy.DebugDrawSphere(this.m_turretBase.Target.PositionComp.GetPosition(), this.m_turretBase.Target.PositionComp.LocalVolume.Radius, Color.White, 1f, false, false, true, false); } MyResourceSinkComponent component = this.m_turretBase.Components.Get <MyResourceSinkComponent>(); if (component != null) { component.DebugDraw((Matrix)this.m_turretBase.PositionComp.WorldMatrix); } base.DebugDraw(); }
public void DebugDraw() { int y = 0; MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, (y++) * 13.0f), "Cleanup in " + m_waitForClean.ToString(), Color.Red, 0.5f); MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, (y++) * 13.0f), "Planet infos:", Color.GreenYellow, 0.5f); foreach (var info in m_planets) { MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, (y++) * 13.0f), " Name: " + info.Value.Planet.Generator.FolderName + ", Id: " + info.Key + ", Bots: " + info.Value.BotNumber.ToString(), Color.LightYellow, 0.5f); } MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, (y++) * 13.0f), "Num. of spawn infos: " + m_allSpawnInfos.Count + "/" + m_timeoutInfoGrid.Count, Color.GreenYellow, 0.5f); int currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds; foreach (var spawnInfo in m_allSpawnInfos) { Vector3D position = spawnInfo.Position; Vector3 down = spawnInfo.Planet.PositionComp.GetPosition() - position; down.Normalize(); int secondsRemaining = Math.Max(0, (spawnInfo.SpawnTime - currentTime) / 1000); int abandonedIn = Math.Max(0, (spawnInfo.AbandonTime - currentTime) / 1000); if (secondsRemaining == 0 || abandonedIn == 0) { continue; } MyRenderProxy.DebugDrawSphere(position, SPHERE_SPAWN_DIST, Color.Yellow, 1.0f, false); MyRenderProxy.DebugDrawText3D(position, "Spawning in: " + secondsRemaining.ToString(), Color.Yellow, 0.5f, false); MyRenderProxy.DebugDrawText3D(position - down * 0.5f, "Abandoned in: " + abandonedIn.ToString(), Color.Yellow, 0.5f, false); } foreach (var timeoutInfo in m_allTimeoutInfos) { Vector3D position = timeoutInfo.Position; int secondsRemaining = Math.Max(0, (timeoutInfo.TimeoutTime - currentTime) / 1000); MyRenderProxy.DebugDrawSphere(position, TIMEOUT_DIST, Color.Blue, 1.0f, false); MyRenderProxy.DebugDrawText3D(position, "Timeout: " + secondsRemaining.ToString(), Color.Blue, 0.5f, false); } }
public override void UpdateBeforeSimulation() { base.UpdateBeforeSimulation(); PowerReceiver.Update(); if (IsWorking) { foreach (IMyEntity entityInterface in m_containedEntities) { MyEntity entity = entityInterface as MyEntity; MyCharacter character = entity as MyCharacter; IMyVirtualMass mass = entity as IMyVirtualMass; var gravity = GetWorldGravity(entity.WorldMatrix.Translation); if (mass != null && entity.Physics.RigidBody.IsActive) { if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_MISCELLANEOUS) { MyRenderProxy.DebugDrawSphere(entity.WorldMatrix.Translation, 0.2f, mass.IsWorking ? Color.Blue : Color.Red, 1.0f, false); } if (mass.IsWorking && entity.Physics.RigidBody.IsActive) { ((IMyEntity)mass.CubeGrid).Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * mass.VirtualMass, entity.WorldMatrix.Translation, null); } } else if (!entity.Physics.IsKinematic && !entity.Physics.IsStatic && entity.Physics.RigidBody2 == null && //jn: TODO this is actualy check for large grid (character == null || character.IsDead)) { if (entity.Physics.RigidBody != null && entity.Physics.RigidBody.IsActive) { entity.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * entity.Physics.RigidBody.Mass, null, null); } } } } }
private static void DebugDraw() { foreach (var antennaEntry in m_pirateAntennas) { MyRadioAntenna antenna = null; MyEntities.TryGetEntityById(antennaEntry.Key, out antenna); if (antenna != null) { var dt = Math.Max(0, antennaEntry.Value.AntennaDefinition.SpawnTimeMs - MySandboxGame.TotalGamePlayTimeInMilliseconds + antennaEntry.Value.LastGenerationGameTime); MyRenderProxy.DebugDrawText3D(antenna.WorldMatrix.Translation, "Time remaining: " + dt.ToString(), Color.Red, 1.0f, false); } } foreach (var value in m_pirateAntennas) { MyEntity entity; MyEntities.TryGetEntityById(value.Key, out entity); if (entity != null) { MyRenderProxy.DebugDrawSphere(entity.WorldMatrix.Translation, (float)entity.PositionComp.WorldVolume.Radius, Color.BlueViolet, 1.0f, false); } } foreach (var value in m_droneInfos) { MyEntity entity; MyEntities.TryGetEntityById(value.Key, out entity); if (entity != null) { MyCubeGrid grid = entity as MyCubeGrid; if (grid == null) { var remote = entity as MyRemoteControl; grid = remote.CubeGrid; } MyRenderProxy.DebugDrawSphere(grid.PositionComp.WorldVolume.Center, (float)grid.PositionComp.WorldVolume.Radius, Color.Cyan, 1.0f, false); MyRenderProxy.DebugDrawText3D(grid.PositionComp.WorldVolume.Center, ((value.Value.DespawnTime - MySandboxGame.TotalGamePlayTimeInMilliseconds) / 1000).ToString(), Color.Cyan, 0.7f, false); } } }
public override void DebugDraw() { if (!MyDebugDrawSettings.DEBUG_DRAW_NEUTRAL_SHIPS || ShipController == null) { return; } Vector3D cameraPos = MySector.MainCamera.Position; Vector3D origin = Vector3D.Normalize(ShipController.PositionComp.GetPosition() - cameraPos); Vector3D destination = Vector3D.Normalize(m_destination - cameraPos); Vector3D halfPoint = Vector3D.Normalize((origin + destination) * 0.5f) + cameraPos; // Prevent going through the camera origin += cameraPos; destination += cameraPos; Vector3D currentPoint = Vector3D.Normalize(ShipController.WorldMatrix.Translation - cameraPos) + cameraPos; MyRenderProxy.DebugDrawLine3D(origin, halfPoint, Color.Red, Color.Red, false); MyRenderProxy.DebugDrawLine3D(halfPoint, destination, Color.Red, Color.Red, false); MyRenderProxy.DebugDrawSphere(currentPoint, 0.01f, Color.Orange.ToVector3(), 1.0f, false); MyRenderProxy.DebugDrawSphere(currentPoint + m_direction * 0.015f, 0.005f, Color.Yellow.ToVector3(), 1.0f, false); }
public override void DebugDraw() { // Probably a base entity, render its dummy if (Entity.Render.RenderObjectIDs[0] == UInt32.MaxValue) { MyRenderProxy.DebugDrawSphere(Entity.PositionComp.WorldMatrix.Translation, 0.2f, Color.Orange, 0.5f, true); MyRenderProxy.DebugDrawAxis(Entity.PositionComp.WorldMatrix, 1, true); } if (MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES) { DebugDrawDummies(Entity.Render.GetModel()); } if (MyDebugDrawSettings.DEBUG_DRAW_ENTITY_IDS) { if (this.Entity.Parent == null || !MyDebugDrawSettings.DEBUG_DRAW_ENTITY_IDS_ONLY_ROOT) { MyRenderProxy.DebugDrawText3D(Entity.PositionComp.WorldMatrix.Translation, Entity.EntityId.ToString("X16"), Color.White, 0.6f, false); } } }
bool IMyTerrainHeightProvider.GetTerrainHeight(Vector3 bonePosition, out float terrainHeight, out Vector3 terrainNormal) { MatrixD worldMatrix = Entity.PositionComp.WorldMatrix; Vector3D downDirection = worldMatrix.Down; Vector3D bonePositionWorld = Vector3D.Transform(new Vector3(bonePosition.X, Entity.PositionComp.LocalAABB.Min.Y, bonePosition.Z), ref worldMatrix); m_raycastHits.Clear(); MyPhysics.CastRay(bonePositionWorld - downDirection, bonePositionWorld + downDirection, m_raycastHits, MyPhysics.CollisionLayers.CharacterCollisionLayer); if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { MyRenderProxy.DebugDrawLine3D(bonePositionWorld - downDirection, bonePositionWorld + downDirection, Color.Red, Color.Yellow, false); } foreach (var hit in m_raycastHits) { IMyEntity hitEntity = hit.HkHitInfo.GetHitEntity(); if (hitEntity != Entity && !(hitEntity is Entities.Character.MyCharacter)) { if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { MyRenderProxy.DebugDrawSphere(hit.Position, 0.05f, Color.Red, 1, false); } Vector3D localPosition = Vector3D.Transform(hit.Position, Entity.PositionComp.WorldMatrixInvScaled); terrainHeight = (float)localPosition.Y - Entity.PositionComp.LocalAABB.Min.Y; float convexRadius = hit.HkHitInfo.GetConvexRadius(); const float maxConvexRadius = 0.06f; // todo: this is a hard limit, but can we somehow determine why the convexradius is so big sometimes? terrainHeight -= convexRadius < maxConvexRadius ? convexRadius : maxConvexRadius; terrainNormal = Vector3D.Transform(hit.HkHitInfo.Normal, Entity.WorldMatrixNormalizedInv.GetOrientation()); return(true); } } terrainHeight = Entity.PositionComp.LocalAABB.Min.Y; terrainNormal = Vector3.Zero; return(false); }
public override void DebugDraw() { Vector3D positionLeftBottomCorner = this.m_planet.PositionLeftBottomCorner; if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB) { this.m_planet.Components.Get <MyPlanetEnvironmentComponent>().DebugDraw(); this.m_planet.DebugDrawPhysics(); MyRenderProxy.DebugDrawAABB(this.m_planet.PositionComp.WorldAABB, Color.White, 1f, 1f, true, false, false); MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(1f, 0f, 0f), Color.Red, Color.Red, true, false); MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(0f, 1f, 0f), Color.Green, Color.Green, true, false); MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(0f, 0f, 1f), Color.Blue, Color.Blue, true, false); MyRenderProxy.DebugDrawAxis(this.m_planet.PositionComp.WorldMatrix, 2f, false, false, false); MyRenderProxy.DebugDrawSphere(this.m_planet.PositionComp.GetPosition(), 1f, Color.OrangeRed, 1f, false, false, true, false); } if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_GEOMETRY_CELL) { MyIntersectionResultLineTriangleEx?nullable; MyCamera mainCamera = MySector.MainCamera; LineD line = new LineD(mainCamera.Position, mainCamera.Position + (25f * mainCamera.ForwardVector)); if (this.m_planet.GetIntersectionWithLine(ref line, out nullable, IntersectionFlags.ALL_TRIANGLES)) { Vector3I vectori; Vector3I vectori2; BoundingBoxD xd2; MyTriangle_Vertices inputTriangle = nullable.Value.Triangle.InputTriangle; MyRenderProxy.DebugDrawTriangle(inputTriangle.Vertex0 + positionLeftBottomCorner, inputTriangle.Vertex1 + positionLeftBottomCorner, inputTriangle.Vertex2 + positionLeftBottomCorner, Color.Red, true, false, false); Vector3D intersectionPointInWorldSpace = nullable.Value.IntersectionPointInWorldSpace; MyVoxelCoordSystems.WorldPositionToVoxelCoord(positionLeftBottomCorner, ref intersectionPointInWorldSpace, out vectori2); MyVoxelCoordSystems.VoxelCoordToWorldAABB(positionLeftBottomCorner, ref vectori2, out xd2); MyRenderProxy.DebugDrawAABB(xd2, Vector3.UnitY, 1f, 1f, true, false, false); MyVoxelCoordSystems.WorldPositionToGeometryCellCoord(positionLeftBottomCorner, ref intersectionPointInWorldSpace, out vectori); MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(positionLeftBottomCorner, ref vectori, out xd2); MyRenderProxy.DebugDrawAABB(xd2, Vector3.UnitZ, 1f, 1f, true, false, false); } } }
public override void DebugDraw() { base.DebugDraw(); if (HumanoidEntity == null) { return; } HumanoidActions.AiTargetBase.DebugDraw(); var headMatrix = HumanoidEntity.GetHeadMatrix(true, true, false, true); // VRageRender.MyRenderProxy.DebugDrawAxis(headMatrix, 1.0f, false); //VRageRender.MyRenderProxy.DebugDrawLine3D(headMatrix.Translation, headMatrix.Translation + headMatrix.Forward * 30, Color.HotPink, Color.HotPink, false); if (HumanoidActions.AiTargetBase.HasTarget()) { HumanoidActions.AiTargetBase.DrawLineToTarget(headMatrix.Translation); Vector3D targetPos; float radius; HumanoidActions.AiTargetBase.GetTargetPosition(headMatrix.Translation, out targetPos, out radius); if (targetPos != Vector3D.Zero) { MyRenderProxy.DebugDrawSphere(targetPos, 0.3f, Color.Red, 0.4f, false); VRageRender.MyRenderProxy.DebugDrawText3D(targetPos, "GetTargetPosition", Color.Red, 1, false); } } VRageRender.MyRenderProxy.DebugDrawAxis(HumanoidEntity.PositionComp.WorldMatrix, 1.0f, false); var invHeadMatrix = headMatrix; invHeadMatrix.Translation = Vector3.Zero; invHeadMatrix = Matrix.Transpose(invHeadMatrix); invHeadMatrix.Translation = headMatrix.Translation; }
public void DebugDraw() { var cubeRoom = (!m_isPressurizing || DEBUG_MODE) ? m_cubeRoom : m_prevCubeRoom; if (cubeRoom == null) { return; } ProfilerShort.Begin("Oxygen Debug Draw"); for (int i = 0; i < cubeRoom.GetLength(0); i++) { for (int j = 0; j < cubeRoom.GetLength(1); j++) { for (int k = 0; k < cubeRoom.GetLength(2); k++) { Vector3I current = new Vector3I(i, j, k) + GridMin(); var currentBlock = m_cubeGrid.GetCubeBlock(current); if (currentBlock != null && currentBlock.FatBlock == null && !DEBUG_MODE) { continue; } Vector3 worldPos = m_cubeGrid.GridIntegerToWorld(current); if (cubeRoom[i, j, k].Room == null) { continue; } int roomIndex = cubeRoom[i, j, k].Room.Index; if (roomIndex == int.MaxValue) { continue; } Color color = cubeRoom[i, j, k].Room.Color; double oxygenLevel = cubeRoom[i, j, k].OxygenLevel(m_cubeGrid.GridSize); if (oxygenLevel > 0.9999) { color = Color.Teal; } else { color = Color.Lerp(Color.Red, Color.Green, (float)oxygenLevel); } if (cubeRoom[i, j, k].Room.IsPressurized || DEBUG_MODE) { MyRenderProxy.DebugDrawSphere(worldPos, 0.15f, color.ToVector3(), 0.5f, false, true); } if (DEBUG_MODE) { MyRenderProxy.DebugDrawText3D(worldPos, roomIndex.ToString(), Color.White, 0.5f, false); } } } } ProfilerShort.End(); }
internal override void DebugDraw(ref MatrixD worldTranslation, Color color) { MyRenderProxy.DebugDrawSphere(Vector3D.Transform(this.m_translation, worldTranslation), this.m_radius, color.ToVector3(), 0.5f, true, false, true, false); }
/* * /// <summary> * /// Returns the coordinates of the OBB * /// </summary> * public bool GetCoords(MyOrientedBoundingBoxD obb, out int xCoord, out int yCoord) * { * xCoord = yCoord = -1; * * for (int i = 0; i < m_obbs.Length; i++) * for (int j = 0; j < m_obbs[0].Length; j++) * if (obb == m_obbs[i][j]) * { * // Coordinates are swapped * xCoord = i; * yCoord = j; * return true; * } * return false; * } */ /// <summary> /// Debug draws the OBBs /// </summary> public void DebugDraw() { for (int i = 0; i < m_obbs.Length; i++) { for (int j = 0; j < m_obbs[0].Length; j++) { if (m_obbs[i][j].HasValue) { MyRenderProxy.DebugDrawOBB(m_obbs[i][j].Value, Color.Red, 0, true, false); } } } MyRenderProxy.DebugDrawOBB(BaseOBB, Color.White, 0, true, false); if (m_obbs[0][0].HasValue) { MyRenderProxy.DebugDrawSphere(m_obbs[0][0].Value.Center, 5f, Color.Yellow, 0, true, false); } //if (m_obbs[m_middleCoord][0].HasValue) // MyRenderProxy.DebugDrawSphere(m_obbs[m_middleCoord][0].Value.Center, 5f, Color.Yellow, 0, true, false); /* * if (m_obbs[0][m_middleCoord].HasValue) * MyRenderProxy.DebugDrawSphere(m_obbs[0][m_middleCoord].Value.Center, 5f, Color.Green, 0, true, false); */ //if (m_obbs[m_middleCoord][OBBsPerLine - 1].HasValue) // MyRenderProxy.DebugDrawSphere(m_obbs[m_middleCoord][OBBsPerLine - 1].Value.Center, 5f, Color.White, 0, true, false); /* * if (m_obbs[OBBsPerLine - 1][m_middleCoord].HasValue) * MyRenderProxy.DebugDrawSphere(m_obbs[OBBsPerLine - 1][m_middleCoord].Value.Center, 5f, Color.Blue, 0, true, false); * * */ if (m_obbs[0][OBBsPerLine - 1].HasValue) { MyRenderProxy.DebugDrawSphere(m_obbs[0][OBBsPerLine - 1].Value.Center, 5f, Color.Green, 0, true, false); } if (m_obbs[OBBsPerLine - 1][OBBsPerLine - 1].HasValue) { MyRenderProxy.DebugDrawSphere(m_obbs[OBBsPerLine - 1][OBBsPerLine - 1].Value.Center, 5f, Color.Blue, 0, true, false); } if (m_obbs[OBBsPerLine - 1][0].HasValue) { MyRenderProxy.DebugDrawSphere(m_obbs[OBBsPerLine - 1][0].Value.Center, 5f, Color.White, 0, true, false); } /////////////////////// var backLeftOBB = m_obbs[0][0]; var backRightOBB = m_obbs[OBBsPerLine - 1][0]; var frontRightOBB = m_obbs[OBBsPerLine - 1][OBBsPerLine - 1]; var lowerBackLeftPoint = GetOBBCorner(backLeftOBB.Value, OBBCorner.LowerBackLeft); MyRenderProxy.DebugDrawSphere(lowerBackLeftPoint, 5f, Color.White, 0, true, false); var lowerBackRightPoint = GetOBBCorner(backRightOBB.Value, OBBCorner.LowerBackRight); MyRenderProxy.DebugDrawSphere(lowerBackRightPoint, 5f, Color.White, 0, true, false); var lowerFrontRightPoint = GetOBBCorner(frontRightOBB.Value, OBBCorner.LowerFrontRight); MyRenderProxy.DebugDrawSphere(lowerFrontRightPoint, 5f, Color.White, 0, true, false); /////////////////////// //MyRenderProxy.DebugDrawSphere(NeighboursCenters[0], 5f, Color.White, 0, true, false); /* * foreach (var point in NeighboursCenters) * { * MyRenderProxy.DebugDrawSphere(point, 5f, Color.Yellow, 0, true, false); * Vector3D g = -Vector3.Normalize(MyGravityProviderSystem.CalculateTotalGravityInPoint(point)); * MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(point, BaseOBB.HalfExtent, Quaternion.CreateFromForwardUp(CenterOBB.Orientation.Forward, g)), Color.White, 0, true, false); * } */ /* * var point = NeighboursCenters.Last(); * MyRenderProxy.DebugDrawSphere(point, 5f, Color.Yellow, 0, true, false); * Vector3D g = -Vector3.Normalize(MyGravityProviderSystem.CalculateTotalGravityInPoint(point)); * MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(point, BaseOBB.HalfExtent, Quaternion.CreateFromForwardUp(CenterOBB.Orientation.Forward, g)), Color.White, 0, true, false); */ }
// Draws the gizmo public override void Draw() { if (!Active) { return; } if (DEBUG) { MyRenderProxy.DebugDrawLine3D(m_lastRay.From, m_lastRay.To, Color.Green, Color.Green, true); } if (ControlledEntity == null) { return; } if (ControlledEntity.Parent != null) { // Draw line to parent MyRenderProxy.DebugDrawLine3D(ControlledEntity.Parent.PositionComp.GetPosition(), ControlledEntity.PositionComp.GetPosition(), Color.Orange, Color.Blue, false); } var textPosition = new Vector2(20, Session.Camera.ViewportSize.Y / 2); switch (Operation) { case OperationMode.Translation: MyRenderProxy.DebugDrawText2D(textPosition, "Translation", Color.Yellow, 1); break; case OperationMode.Rotation: MyRenderProxy.DebugDrawText2D(textPosition, "Rotation", Color.Yellow, 1); break; case OperationMode.HierarchyAssignment: MyRenderProxy.DebugDrawText2D(textPosition, "Hierarchy", Color.Yellow, 1); break; } if (Operation == OperationMode.Translation) { // Change the size of the control elements var camPosition = Session.Camera.Position; var distance = Vector3D.Distance(m_xBB.Center, camPosition); var f = Session.Camera.ProjectionMatrix.Up.LengthSquared(); m_xBB.HalfExtent = Vector3D.One * 0.008 * distance * f; m_yBB.HalfExtent = Vector3D.One * 0.008 * distance * f; m_zBB.HalfExtent = Vector3D.One * 0.008 * distance * f; DrawOBB(m_xBB, Color.Red, 0.5f, 0); DrawOBB(m_yBB, Color.Green, 0.5f, 1); DrawOBB(m_zBB, Color.Blue, 0.5f, 2); } if (Operation != OperationMode.HierarchyAssignment) { DrawOBB(m_xPlane, Color.Red, 0.2f, 3); DrawOBB(m_yPlane, Color.Green, 0.2f, 4); DrawOBB(m_zPlane, Color.Blue, 0.2f, 5); } else { var volumeCenter = ControlledEntity.PositionComp.WorldVolume.Center; var volumeRadius = ControlledEntity.PositionComp.WorldVolume.Radius; MyRenderProxy.DebugDrawSphere(volumeCenter, (float)volumeRadius, Color.Yellow, 0.2f, true); } }
public override unsafe void DebugDraw(ref Matrix drawMatrix) { if (MyFakes.DEBUG_DRAW_NAVMESH_PROCESSED_VOXEL_CELLS) { Vector3 vector = Vector3.TransformNormal(this.m_cellSize, (Matrix)drawMatrix); Vector3 vector2 = Vector3.Transform((Vector3)(this.m_voxelMap.PositionLeftBottomCorner - this.m_voxelMap.PositionComp.GetPosition()), (Matrix)drawMatrix); foreach (Vector3I vectori in this.m_processedCells) { BoundingBoxD xd; xd.Min = vector2 + (vector * (new Vector3(0.0625f) + vectori)); BoundingBoxD *xdPtr1 = (BoundingBoxD *)ref xd; xdPtr1->Max = xd.Min + vector; xd.Inflate((double)-0.20000000298023224); MyRenderProxy.DebugDrawAABB(xd, Color.Orange, 1f, 1f, false, false, false); MyRenderProxy.DebugDrawText3D(xd.Center, vectori.ToString(), Color.Orange, 0.5f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } } if (MyFakes.DEBUG_DRAW_NAVMESH_CELLS_ON_PATHS) { Vector3 vector3 = Vector3.TransformNormal(this.m_cellSize, (Matrix)drawMatrix); Vector3 vector4 = Vector3.Transform((Vector3)(this.m_voxelMap.PositionLeftBottomCorner - this.m_voxelMap.PositionComp.GetPosition()), (Matrix)drawMatrix); MyCellCoord coord = new MyCellCoord(); foreach (ulong num in this.m_cellsOnWayCoords) { BoundingBoxD xd2; coord.SetUnpack(num); Vector3I coordInLod = coord.CoordInLod; xd2.Min = vector4 + (vector3 * (new Vector3(0.0625f) + coordInLod)); BoundingBoxD *xdPtr2 = (BoundingBoxD *)ref xd2; xdPtr2->Max = xd2.Min + vector3; xd2.Inflate((double)-0.30000001192092896); MyRenderProxy.DebugDrawAABB(xd2, Color.Green, 1f, 1f, false, false, false); } } if (MyFakes.DEBUG_DRAW_NAVMESH_PREPARED_VOXEL_CELLS) { Vector3 vector5 = Vector3.TransformNormal(this.m_cellSize, (Matrix)drawMatrix); Vector3 vector6 = Vector3.Transform((Vector3)(this.m_voxelMap.PositionLeftBottomCorner - this.m_voxelMap.PositionComp.GetPosition()), (Matrix)drawMatrix); float negativeInfinity = float.NegativeInfinity; Vector3I zero = Vector3I.Zero; int index = 0; while (true) { if (index >= this.m_toAdd.Count) { for (int i = 0; i < this.m_toAdd.Count; i++) { BoundingBoxD xd3; CellToAddHeapItem local1 = this.m_toAdd.GetItem(i); float num6 = local1.HeapKey; Vector3I position = local1.Position; xd3.Min = vector6 + (vector5 * (new Vector3(0.0625f) + position)); BoundingBoxD *xdPtr3 = (BoundingBoxD *)ref xd3; xdPtr3->Max = xd3.Min + vector5; xd3.Inflate((double)-0.10000000149011612); Color aqua = Color.Aqua; if (position.Equals(zero)) { aqua = Color.Red; } MyRenderProxy.DebugDrawAABB(xd3, aqua, 1f, 1f, false, false, false); string text = $"{num6.ToString("n2")}"; MyRenderProxy.DebugDrawText3D(xd3.Center, text, aqua, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } break; } CellToAddHeapItem item = this.m_toAdd.GetItem(index); float heapKey = item.HeapKey; if (heapKey > negativeInfinity) { negativeInfinity = heapKey; zero = item.Position; } index++; } } MyRenderProxy.DebugDrawSphere(this.m_debugPos1, 0.2f, Color.Red, 1f, false, false, true, false); MyRenderProxy.DebugDrawSphere(this.m_debugPos2, 0.2f, Color.Green, 1f, false, false, true, false); MyRenderProxy.DebugDrawSphere(this.m_debugPos3, 0.1f, Color.Red, 1f, false, false, true, false); MyRenderProxy.DebugDrawSphere(this.m_debugPos4, 0.1f, Color.Green, 1f, false, false, true, false); if (MyFakes.DEBUG_DRAW_VOXEL_CONNECTION_HELPER) { this.m_connectionHelper.DebugDraw(ref drawMatrix, base.Mesh); } if (MyFakes.DEBUG_DRAW_NAVMESH_CELL_BORDERS) { foreach (KeyValuePair <ulong, List <DebugDrawEdge> > pair in this.m_debugCellEdges) { foreach (DebugDrawEdge edge in pair.Value) { MyRenderProxy.DebugDrawLine3D(edge.V1, edge.V2, Color.Orange, Color.Orange, false, false); } } } else { this.m_debugCellEdges.Clear(); } if (MyFakes.DEBUG_DRAW_NAVMESH_HIERARCHY) { if (MyFakes.DEBUG_DRAW_NAVMESH_HIERARCHY_LITE) { this.m_higherLevel.DebugDraw(true); } else { this.m_higherLevel.DebugDraw(false); this.m_higherLevelHelper.DebugDraw(); } } if ((MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES == MyWEMDebugDrawMode.LINES) && !(this.m_voxelMap is MyVoxelPhysics)) { int num7 = 0; MyWingedEdgeMesh.EdgeEnumerator edges = base.Mesh.GetEdges(null); Vector3D position = this.m_voxelMap.PositionComp.GetPosition(); while (edges.MoveNext()) { MyWingedEdgeMesh.Edge current = edges.Current; Vector3D vectord2 = base.Mesh.GetVertexPosition(current.Vertex2) + position; Vector3D point = ((base.Mesh.GetVertexPosition(edges.Current.Vertex1) + position) + vectord2) * 0.5; if (MyCestmirPathfindingShorts.Pathfinding.Obstacles.IsInObstacle(point)) { MyRenderProxy.DebugDrawSphere(point, 0.05f, Color.Red, 1f, false, false, true, false); } num7++; } } }
public override void Draw() { base.Draw(); if (MySector.MainCamera != null) { var pos = MySector.MainCamera.Position; var dir = MySector.MainCamera.ForwardVector; var hit = MyPhysics.CastRay(pos, pos + 500 * dir); if (hit.HasValue) { var entity = hit.Value.HkHitInfo.GetHitEntity(); if (entity != null) { var voxel = entity.GetTopMostParent() as MyVoxelPhysics; if (voxel != null) { var planet = voxel.Parent; var grav = planet as IMyGravityProvider; if (grav != null) { var gravity = grav.GetWorldGravity(hit.Value.Position); gravity.Normalize(); var point = planet.PositionComp.GetPosition() - gravity * 9503; MyRenderProxy.DebugDrawSphere(point, 0.5f, Color.Red, 1, false); MyRenderProxy.DebugDrawSphere(point, 5.5f, Color.Yellow, 1, false); hit = MyPhysics.CastRay(point, point + gravity * 500); if (hit.HasValue) { MyRenderProxy.DebugDrawText2D(new Vector2(10, 10), (hit.Value.HkHitInfo.HitFraction * 500).ToString(), Color.White, 0.8f); } } } } } } if (!MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { return; } if (MyCubeBuilder.Static == null) { return; } if (m_smartPath != null) { m_smartPath.DebugDraw(); VRageRender.MyRenderProxy.DebugDrawSphere(m_currentTarget, 2.0f, Color.HotPink, 1.0f, false); for (int i = 1; i < m_pastTargets.Count; ++i) { VRageRender.MyRenderProxy.DebugDrawLine3D(m_pastTargets[i], m_pastTargets[i - 1], Color.Blue, Color.Blue, false); } } var bb = MyCubeBuilder.Static.GetBuildBoundingBox(); VRageRender.MyRenderProxy.DebugDrawOBB(bb, Color.Red, 0.25f, false, false); var src = MyScreenManager.GetScreenWithFocus(); if (MyScreenManager.GetScreenWithFocus() == null || MyScreenManager.GetScreenWithFocus().DebugNamePath != "MyGuiScreenGamePlay") { return; } if (m_drawSphere) { VRageRender.MyRenderProxy.DebugDrawSphere(m_sphere.Center, m_sphere.Radius, Color.Red, 1.0f, false, cull: true); VRageRender.MyRenderProxy.DebugDrawAxis(m_sphereMatrix, 50.0f, false); VRageRender.MyRenderProxy.DebugDrawText2D(new Vector2(200.0f, 0.0f), m_string, Color.Red, 0.5f); } VRageRender.MyRenderProxy.DebugDrawSphere(m_point1, 0.5f, Color.Orange.ToVector3(), 1.0f, true); VRageRender.MyRenderProxy.DebugDrawSphere(m_point2, 0.5f, Color.Orange.ToVector3(), 1.0f, true); foreach (var point in DebugDrawPoints) { //VRageRender.MyRenderProxy.DebugDrawSphere(point.Position, 0.05f, point.Color.ToVector3(), 1.0f, false); VRageRender.MyRenderProxy.DebugDrawSphere(point.Position, 0.03f, point.Color, 1.0f, false); } foreach (var sphere in DebugDrawSpheres) { VRageRender.MyRenderProxy.DebugDrawSphere(sphere.Position, sphere.Radius, sphere.Color, 1.0f, false); } foreach (var box in DebugDrawBoxes) { VRageRender.MyRenderProxy.DebugDrawAABB(box.Box, box.Color, 1.0f, 1.0f, false); } if (DebugDrawMesh != null) { Matrix identity = Matrix.Identity; DebugDrawMesh.DebugDraw(ref identity, MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES); } foreach (var poly in DebugDrawPolys) { MatrixD identity = MatrixD.Identity; poly.DebugDraw(ref identity); } MyPolygonBoolOps.Static.DebugDraw(MatrixD.Identity); if (Boxes != null) { foreach (var box in Boxes) { VRageRender.MyRenderProxy.DebugDrawAABB(box, Color.Red, 1.0f, 1.0f, true); } } }
// ------------------------------------------------------------------------------------ /// <summary> /// Solve IK for chain of two bones + change rotation of end bone. /// </summary> /// <param name="characterBones">bone storage</param> /// <param name="ikChain">description of bone chain</param> /// <param name="finalPosition">desired position of end bone</param> /// <param name="finalNormal">desired normal of end bone - would be projected on plane first bone-second bone-third bone</param> /// <param name="fromBindPose">solve this starting from the bind pose</param> /// <returns>true on success</returns> public static bool SolveIkTwoBones(MyCharacterBone[] characterBones, MyAnimationIkChainExt ikChain, ref Vector3 finalPosition, ref Vector3 finalNormal, bool fromBindPose) { int boneIndex = ikChain.BoneIndex; float finalMinRot = MathHelper.ToRadians(ikChain.MinEndPointRotation); float finalMaxRot = MathHelper.ToRadians(ikChain.MaxEndPointRotation); Vector3 lastPoleVector = ikChain.LastPoleVector; int chainLength = ikChain.ChainLength; bool alignBoneWithTerrain = ikChain.AlignBoneWithTerrain; MyCharacterBone thirdBone = characterBones[boneIndex]; if (thirdBone == null) { return(false); } MyCharacterBone secondBone = thirdBone.Parent; for (int i = 2; i < chainLength; i++) { secondBone = secondBone.Parent; } if (secondBone == null) { return(false); } MyCharacterBone firstBone = secondBone.Parent; if (firstBone == null) { return(false); } if (fromBindPose) { firstBone.SetCompleteBindTransform(); secondBone.SetCompleteBindTransform(); thirdBone.SetCompleteBindTransform(); firstBone.ComputeAbsoluteTransform(true); } Matrix thirdBoneTransformBackup = thirdBone.AbsoluteTransform; //Vector3 firstBoneTransformRightDir = firstBone.AbsoluteTransform.Right; Vector3 firstBoneOrigin = firstBone.AbsoluteTransform.Translation; Vector3 secondBoneOrigin = secondBone.AbsoluteTransform.Translation; Vector3 thirdBoneOrigin = thirdBone.AbsoluteTransform.Translation; // Vector3D finalPosition comes from parameter Vector3 secondMinusFirst = secondBoneOrigin - firstBoneOrigin; Vector3 finalMinusFirst = finalPosition - firstBoneOrigin; //Vector3 finalMinusSecond = finalPosition - secondBoneOrigin; Vector3 poleVectorNormalized; Vector3 thirdMinusFirst = thirdBoneOrigin - firstBoneOrigin; Vector3.Cross(ref secondMinusFirst, ref thirdMinusFirst, out poleVectorNormalized); // project to 2D (only vectors) poleVectorNormalized.Normalize(); poleVectorNormalized = Vector3.Normalize(Vector3.Lerp(poleVectorNormalized, lastPoleVector, m_poleVectorChangeSmoothness)); Vector3 planeDirY = Vector3.Normalize(finalMinusFirst); // finalMinusFirst? thirdMinusFirst? Vector3 planeDirX = Vector3.Normalize(Vector3.Cross(planeDirY, poleVectorNormalized)); //Vector2 firstBoneOrigin2D = new Vector2(0, 0); Vector2 secondBoneOrigin2D = new Vector2(planeDirX.Dot(ref secondMinusFirst), planeDirY.Dot(ref secondMinusFirst)); Vector2 thirdBoneOrigin2D = new Vector2(planeDirX.Dot(ref thirdMinusFirst), planeDirY.Dot(ref thirdMinusFirst)); Vector2 finalPosition2D = new Vector2(planeDirX.Dot(ref finalMinusFirst), planeDirY.Dot(ref finalMinusFirst)); Vector2 terrainNormal2D = new Vector2(planeDirX.Dot(ref finalNormal), planeDirY.Dot(ref finalNormal)); float firstBoneLength = (secondBoneOrigin2D /* - 0*/).Length(); float secondBoneLength = (thirdBoneOrigin2D - secondBoneOrigin2D).Length(); float finalDistance = finalPosition2D.Length(); if (firstBoneLength + secondBoneLength <= finalDistance) { finalPosition2D = (firstBoneLength + secondBoneLength) * finalPosition2D / finalDistance; // too far //return false; } // mid-joint -> wanted position in 2D Vector2 newSecondBoneOrigin2D; { newSecondBoneOrigin2D.Y = (finalPosition2D.Y * finalPosition2D.Y - secondBoneLength * secondBoneLength + firstBoneLength * firstBoneLength) / (2.0f * finalPosition2D.Y); float srqtArg = firstBoneLength * firstBoneLength - newSecondBoneOrigin2D.Y * newSecondBoneOrigin2D.Y; newSecondBoneOrigin2D.X = (float)Math.Sqrt(srqtArg > 0 ? srqtArg : 0); } // project back Vector3 newSecondBoneOrigin = firstBoneOrigin + planeDirX * newSecondBoneOrigin2D.X + planeDirY * newSecondBoneOrigin2D.Y; Vector3 newSecondMinusFirst = newSecondBoneOrigin - firstBoneOrigin; Vector3 newThirdMinusSecond = finalPosition - newSecondBoneOrigin; Vector3 newTerrainNormal = planeDirX * terrainNormal2D.X + planeDirY * terrainNormal2D.Y; newTerrainNormal.Normalize(); // set the rotations in the bones // first bone --------------------------------- Matrix firstBoneAbsoluteFinal = firstBone.AbsoluteTransform; Quaternion rotFirstDelta = Quaternion.CreateFromTwoVectors(secondMinusFirst, newSecondMinusFirst); firstBoneAbsoluteFinal.Right = Vector3.Transform(firstBoneAbsoluteFinal.Right, rotFirstDelta); firstBoneAbsoluteFinal.Up = Vector3.Transform(firstBoneAbsoluteFinal.Up, rotFirstDelta); firstBoneAbsoluteFinal.Forward = Vector3.Transform(firstBoneAbsoluteFinal.Forward, rotFirstDelta); firstBone.SetCompleteTransformFromAbsoluteMatrix(ref firstBoneAbsoluteFinal, true); firstBone.ComputeAbsoluteTransform(); // second bone --------------------------------- Matrix secondBoneAbsoluteFinal = secondBone.AbsoluteTransform; Quaternion rotSecondDelta = Quaternion.CreateFromTwoVectors(thirdBone.AbsoluteTransform.Translation - secondBone.AbsoluteTransform.Translation, newThirdMinusSecond); secondBoneAbsoluteFinal.Right = Vector3.Transform(secondBoneAbsoluteFinal.Right, rotSecondDelta); secondBoneAbsoluteFinal.Up = Vector3.Transform(secondBoneAbsoluteFinal.Up, rotSecondDelta); secondBoneAbsoluteFinal.Forward = Vector3.Transform(secondBoneAbsoluteFinal.Forward, rotSecondDelta); secondBone.SetCompleteTransformFromAbsoluteMatrix(ref secondBoneAbsoluteFinal, true); secondBone.ComputeAbsoluteTransform(); //// third bone ---------------------------------- if (ikChain.EndBoneTransform.HasValue) { MatrixD localTransformRelated = ikChain.EndBoneTransform.Value * MatrixD.Invert((MatrixD)thirdBone.BindTransform * thirdBone.Parent.AbsoluteTransform); thirdBone.Rotation = Quaternion.CreateFromRotationMatrix(Matrix.Normalize((Matrix)localTransformRelated.GetOrientation())); thirdBone.Translation = (Vector3)localTransformRelated.Translation; thirdBone.ComputeAbsoluteTransform(); } else if (alignBoneWithTerrain) { Matrix footRotation; Vector3 finalRotPoleVec; Vector3.Cross(ref newTerrainNormal, ref Vector3.Up, out finalRotPoleVec); float deltaAngle = MyUtils.GetAngleBetweenVectors(newTerrainNormal, Vector3.Up); if (finalRotPoleVec.Dot(poleVectorNormalized) > 0) { deltaAngle = -deltaAngle; } deltaAngle = MathHelper.Clamp(deltaAngle, finalMinRot, finalMaxRot); Matrix.CreateFromAxisAngle(ref poleVectorNormalized, deltaAngle, out footRotation); ikChain.LastAligningRotationMatrix = Matrix.Lerp(ikChain.LastAligningRotationMatrix, footRotation, ikChain.AligningSmoothness); Matrix thirdBoneAbsoluteFinal = thirdBoneTransformBackup.GetOrientation() * ikChain.LastAligningRotationMatrix; thirdBoneAbsoluteFinal.Translation = thirdBone.AbsoluteTransform.Translation; thirdBone.SetCompleteTransformFromAbsoluteMatrix(ref thirdBoneAbsoluteFinal, true); thirdBone.ComputeAbsoluteTransform(); } // Debugging of the solver. if (m_showDebugDrawings) { MyRenderProxy.DebugDrawLine3D(Vector3D.Transform(firstBoneOrigin, ref DebugTransform), Vector3D.Transform(secondBoneOrigin, ref DebugTransform), Color.Yellow, Color.Red, false); MyRenderProxy.DebugDrawLine3D(Vector3D.Transform(secondBoneOrigin, ref DebugTransform), Vector3D.Transform(thirdBoneOrigin, ref DebugTransform), Color.Yellow, Color.Red, false); MyRenderProxy.DebugDrawSphere(Vector3D.Transform(finalPosition, ref DebugTransform), 0.05f, Color.Cyan, 1.0f, false); MyRenderProxy.DebugDrawLine3D(Vector3D.Transform(secondBoneOrigin, ref DebugTransform), Vector3D.Transform(secondBoneOrigin + poleVectorNormalized, ref DebugTransform), Color.PaleGreen, Color.PaleGreen, false); MyRenderProxy.DebugDrawLine3D(Vector3D.Transform(firstBoneOrigin, ref DebugTransform), Vector3D.Transform(firstBoneOrigin + planeDirX, ref DebugTransform), Color.White, Color.White, false); MyRenderProxy.DebugDrawLine3D(Vector3D.Transform(firstBoneOrigin, ref DebugTransform), Vector3D.Transform(firstBoneOrigin + planeDirY, ref DebugTransform), Color.White, Color.White, false); MyRenderProxy.DebugDrawSphere(Vector3D.Transform(newSecondBoneOrigin, ref DebugTransform), 0.05f, Color.Green, 1.0f, false); MyRenderProxy.DebugDrawAxis(firstBone.AbsoluteTransform * DebugTransform, 0.5f, false); MyRenderProxy.DebugDrawLine3D(Vector3D.Transform(finalPosition, ref DebugTransform), Vector3D.Transform(finalPosition + newTerrainNormal, ref DebugTransform), Color.Black, Color.LightBlue, false); MyRenderProxy.DebugDrawArrow3D(Vector3D.Transform(secondBoneOrigin, ref DebugTransform), Vector3D.Transform(newSecondBoneOrigin, ref DebugTransform), Color.Green, Color.White, false); } ikChain.LastPoleVector = poleVectorNormalized; return(true); }
public static void DebugDraw(this IMyConveyorEndpoint endpoint) { if (!MyDebugDrawSettings.DEBUG_DRAW_CONVEYORS) { return; } Vector3 centerPos = new Vector3(); for (int i = 0; i < endpoint.GetLineCount(); ++i) { var position = endpoint.GetPosition(i); Vector3 pos = new Vector3(position.LocalGridPosition) + 0.5f * new Vector3(position.VectorDirection); centerPos += pos; } centerPos = centerPos * endpoint.CubeBlock.CubeGrid.GridSize / (float)endpoint.GetLineCount(); centerPos = Vector3.Transform(centerPos, endpoint.CubeBlock.CubeGrid.WorldMatrix); for (int i = 0; i < endpoint.GetLineCount(); ++i) { var position = endpoint.GetPosition(i); MyConveyorLine line = endpoint.GetConveyorLine(i); Vector3 pos = (new Vector3(position.LocalGridPosition) + 0.5f * new Vector3(position.VectorDirection)) * endpoint.CubeBlock.CubeGrid.GridSize; Vector3 pos2 = (new Vector3(position.LocalGridPosition) + 0.4f * new Vector3(position.VectorDirection)) * endpoint.CubeBlock.CubeGrid.GridSize; pos = Vector3.Transform(pos, endpoint.CubeBlock.CubeGrid.WorldMatrix); pos2 = Vector3.Transform(pos2, endpoint.CubeBlock.CubeGrid.WorldMatrix); Vector3 dir = Vector3.TransformNormal(position.VectorDirection * endpoint.CubeBlock.CubeGrid.GridSize * 0.5f, endpoint.CubeBlock.CubeGrid.WorldMatrix); Color color = line.IsFunctional ? Color.Orange : Color.DarkRed; color = line.IsWorking ? Color.GreenYellow : color; EndpointDebugShape shape = EndpointDebugShape.SHAPE_SPHERE; float dirMultiplier = 1.0f; float radius = 0.05f; if (line.GetEndpoint(0) == null || line.GetEndpoint(1) == null) { if (line.Type == Common.ObjectBuilders.MyObjectBuilder_ConveyorLine.LineType.SMALL_LINE) { dirMultiplier = 0.2f; radius = 0.015f; shape = EndpointDebugShape.SHAPE_SPHERE; } else { dirMultiplier = 0.1f; radius = 0.015f; shape = EndpointDebugShape.SHAPE_CAPSULE; } } else { if (line.Type == Common.ObjectBuilders.MyObjectBuilder_ConveyorLine.LineType.SMALL_LINE) { dirMultiplier = 1.0f; radius = 0.05f; shape = EndpointDebugShape.SHAPE_SPHERE; } else { dirMultiplier = 0.2f; radius = 0.05f; shape = EndpointDebugShape.SHAPE_CAPSULE; } } MyRenderProxy.DebugDrawLine3D(pos, pos + dir * dirMultiplier, color, color, true); if (shape == EndpointDebugShape.SHAPE_SPHERE) { MyRenderProxy.DebugDrawSphere(pos, radius * endpoint.CubeBlock.CubeGrid.GridSize, color.ToVector3(), 1.0f, false); } else if (shape == EndpointDebugShape.SHAPE_CAPSULE) { MyRenderProxy.DebugDrawCapsule(pos - dir * dirMultiplier, pos + dir * dirMultiplier, radius * endpoint.CubeBlock.CubeGrid.GridSize, color, false); } if (MyDebugDrawSettings.DEBUG_DRAW_CONVEYORS_LINE_IDS) { MyRenderProxy.DebugDrawText3D(pos2, line.GetHashCode().ToString(), color, 0.6f, false); } MyRenderProxy.DebugDrawLine3D(pos, centerPos, color, color, false); } }
private static void DrawMountPointsAxisHelpers(MyCubeBlockDefinition def, ref MatrixD drawMatrix, float cubeSize) { Vector3I centerGrid = def.Center; Vector3 centerOffset = def.Size * 0.5f; MatrixD drawTransf = MatrixD.CreateTranslation(centerGrid - centerOffset) * MatrixD.CreateScale(cubeSize) * drawMatrix; // Draw axis helpers for the six mount point walls for (int i = 0; i < 6; ++i) { Base6Directions.Direction dir = (Base6Directions.Direction)i; Vector3D position = Vector3D.Zero; position.Z = -0.2f; Vector3D normal = Vector3.Forward; Vector3D right = Vector3.Right; Vector3D up = Vector3.Up; position = def.MountPointLocalToBlockLocal(position, dir); position = Vector3D.Transform(position, drawTransf); normal = def.MountPointLocalNormalToBlockLocal(normal, dir); normal = Vector3D.TransformNormal(normal, drawTransf); up = def.MountPointLocalNormalToBlockLocal(up, dir); up = Vector3D.TransformNormal(up, drawTransf); right = def.MountPointLocalNormalToBlockLocal(right, dir); right = Vector3D.TransformNormal(right, drawTransf); MatrixD rightMat = MatrixD.CreateWorld(position + right * 0.25f, normal, right); MatrixD upMat = MatrixD.CreateWorld(position + up * 0.25f, normal, up); Vector4 rc = Color.Red.ToVector4(); Vector4 uc = Color.Green.ToVector4(); MyRenderProxy.DebugDrawSphere(position, 0.03f * cubeSize, Color.Red.ToVector3(), 1.0f, true); MySimpleObjectDraw.DrawTransparentCylinder(ref rightMat, 0.0f, 0.03f * cubeSize, 0.5f * cubeSize, ref rc, false, 16, 0.01f * cubeSize); MySimpleObjectDraw.DrawTransparentCylinder(ref upMat, 0.0f, 0.03f * cubeSize, 0.5f * cubeSize, ref uc, false, 16, 0.01f * cubeSize); MyRenderProxy.DebugDrawLine3D(position, position - normal * 0.2f, Color.Red, Color.Red, true); float textSizeX = 0.5f * cubeSize; float textSizeY = 0.5f * cubeSize; float textSizeDesc = 0.5f * cubeSize; if (MySector.MainCamera != null) { float distX = (float)(position + right * 0.55f - MySector.MainCamera.Position).Length(); float distY = (float)(position + up * 0.55f - MySector.MainCamera.Position).Length(); float distDesc = (float)(position + normal * 0.1f - MySector.MainCamera.Position).Length(); textSizeX = textSizeX * 6 / distX; textSizeY = textSizeY * 6 / distY; textSizeDesc = textSizeDesc * 6 / distDesc; } MyRenderProxy.DebugDrawText3D(position + right * 0.55f, "X", Color.Red, textSizeX, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyRenderProxy.DebugDrawText3D(position + up * 0.55f, "Y", Color.Green, textSizeY, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyRenderProxy.DebugDrawText3D(position + normal * 0.1f, m_mountPointSideNames[i], Color.White, textSizeDesc, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // If close enough, draw a black grid spaced by tenths of a mount point unit float dist = (float)(drawTransf.Translation - MySector.MainCamera.Position).Length(); BoundingBoxD bb = new BoundingBoxD(-def.Size * cubeSize * 0.5f, def.Size * cubeSize * 0.5f); dist -= (float)bb.Size.Max() * 0.866f; // sqrt(3) * 0.5 - half of the solid diagonal of a cube Color black = Color.Black; if (dist < cubeSize * 3.0f) { MySimpleObjectDraw.DrawTransparentBox(ref drawMatrix, ref bb, ref black, MySimpleObjectRasterizer.Wireframe, def.Size * 10, 0.005f / (float)bb.Size.Max() * cubeSize, onlyFrontFaces: true); } }
public void DebugDraw() { var matrix = Sandbox.Game.World.MySector.MainCamera.ViewMatrix; Vector3D?prevPosition = null; foreach (var node in m_pathNodes) { Vector3D down = Sandbox.Game.GameSystems.MyGravityProviderSystem.CalculateTotalGravityInPoint(node.WorldPosition); if (Vector3D.IsZero(down, 0.001)) { down = Vector3D.Down; } down.Normalize(); Vector3D position = node.WorldPosition + down * -10.0; MyRenderProxy.DebugDrawSphere(position, 1.0f, Color.IndianRed, 1.0f, false); MyRenderProxy.DebugDrawLine3D(node.WorldPosition, position, Color.IndianRed, Color.IndianRed, false); if (prevPosition.HasValue) { MyRenderProxy.DebugDrawLine3D(position, prevPosition.Value, Color.IndianRed, Color.IndianRed, false); } prevPosition = position; } /*if (m_hlEnd != null) * { * Vector3D position = m_hlEnd.WorldPosition + new Vector3D(0.0f, 10.0f, 0.0f); * MyRenderProxy.DebugDrawSphere(position, 1.0f, Color.Crimson, 1.0f, false); * MyRenderProxy.DebugDrawLine3D(m_hlEnd.WorldPosition, position, Color.Crimson, Color.Crimson, false); * }*/ MyRenderProxy.DebugDrawSphere(m_startPoint, 0.5f, Color.HotPink, 1.0f, false); /*MyRenderProxy.DebugDrawSphere(m_endPoint, 0.5f, Color.HotPink, 1.0f, false); * MyRenderProxy.DebugDrawLine3D(m_startPoint, m_endPoint, Color.HotPink, Color.HotPink, false);*/ if (m_goal != null) { m_goal.DebugDraw(); } if (MyFakes.DEBUG_DRAW_FOUND_PATH) { Vector3D?prevPoint = null; for (int i = 0; i < m_expandedPath.Count; ++i) { Vector3D point = new Vector3D(m_expandedPath[i]); float radius = (float)m_expandedPath[i].W; Color col = i == m_expandedPath.Count - 1 ? Color.OrangeRed : Color.Orange; //VRageRender.MyRenderProxy.DebugDrawSphere(point, radius, col, 1.0f, false); VRageRender.MyRenderProxy.DebugDrawPoint(point, col, false); VRageRender.MyRenderProxy.DebugDrawText3D(point + matrix.Right * 0.1f, radius.ToString(), col, 0.7f, false); if (prevPoint.HasValue) { VRageRender.MyRenderProxy.DebugDrawLine3D(prevPoint.Value, point, Color.Pink, Color.Pink, false); } prevPoint = point; } } }