public override void Draw() { base.Draw(); Vector3 transformedPoint = Vector3.Transform(Container.Entity.PositionComp.GetPosition(), MySector.MainCamera.ViewMatrix); Vector4 projectedPoint = Vector4.Transform(transformedPoint, MySector.MainCamera.ProjectionMatrix); if (transformedPoint.Z > 0) { projectedPoint.X *= -1; projectedPoint.Y *= -1; } if (projectedPoint.W <= 0) { return; } Vector2 projectedPoint2D = new Vector2(projectedPoint.X / projectedPoint.W / 2.0f + 0.5f, -projectedPoint.Y / projectedPoint.W / 2.0f + 0.5f); projectedPoint2D = MyGuiManager.GetHudPixelCoordFromNormalizedCoord(projectedPoint2D); for (int i = 0; i < m_invetoryItem.IconTextures.Length; i++) { MyGuiManager.DrawSprite(m_invetoryItem.IconTextures[i], projectedPoint2D, new Rectangle(0, 0, 128, 128), Color.White, 0, new Vector2(64, 64), new Vector2(0.5f), SpriteEffects.None, 0); } }
public static void AddText(Vector3 worldCoord, StringBuilder text, Color color, float scale) { Vector4 screenCoord = Vector4.Transform(worldCoord, MyCamera.ViewProjectionMatrix); if (screenCoord.Z > 0) { Vector2 projectedPoint2D = new Vector2(screenCoord.X / screenCoord.W / 2.0f + 0.5f, -screenCoord.Y / screenCoord.W / 2.0f + 0.5f); projectedPoint2D = MyGuiManager.GetHudPixelCoordFromNormalizedCoord(projectedPoint2D); AddText(projectedPoint2D, text, color, scale); } }
internal unsafe void DebugDrawBots() { if (MyDebugDrawSettings.DEBUG_DRAW_BOTS) { Vector2 normalizedCoord = new Vector2(0.01f, 0.4f); for (int i = 0; i < this.m_botsQueue.Count; i++) { IMyBot bot = this.m_allBots[this.m_botsQueue[i]]; if (bot is IMyEntityBot) { IMyEntityBot bot2 = bot as IMyEntityBot; Color green = Color.Green; if ((this.m_botIndex == -1) || (i != this.m_botIndex)) { green = Color.Red; } string text = $"Bot[{i}]: {bot2.BehaviorSubtypeName}"; if (bot is MyAgentBot) { text = text + (bot as MyAgentBot).LastActions.GetLastActionsString(); } MyRenderProxy.DebugDrawText2D(MyGuiManager.GetHudPixelCoordFromNormalizedCoord(normalizedCoord), text, green, 0.5f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, false); MyCharacter botEntity = bot2.BotEntity as MyCharacter; IMyFaction faction = null; if (botEntity != null) { long identityId = botEntity.ControllerInfo.Controller.Player.Identity.IdentityId; faction = MySession.Static.Factions.TryGetPlayerFaction(identityId); } if (bot2.BotEntity != null) { Vector3D center = bot2.BotEntity.PositionComp.WorldAABB.Center; double * numPtr1 = (double *)ref center.Y; numPtr1[0] += bot2.BotEntity.PositionComp.WorldAABB.HalfExtents.Y; MyRenderProxy.DebugDrawText3D(center, $"Bot:{i}", green, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, -1, false); MyRenderProxy.DebugDrawText3D(center - new Vector3(0f, -0.5f, 0f), (faction == null) ? "NO_FACTION" : faction.Tag, green, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, -1, false); } float *singlePtr1 = (float *)ref normalizedCoord.Y; singlePtr1[0] += 0.02f; } } } }
public override unsafe void Draw() { base.Draw(); Vector3 position = (Vector3)Vector3.Transform((Vector3)base.Container.Entity.PositionComp.GetPosition(), MySector.MainCamera.ViewMatrix); Vector4 vector = Vector4.Transform(position, (Matrix)MySector.MainCamera.ProjectionMatrix); if (position.Z > 0f) { float *singlePtr1 = (float *)ref vector.X; singlePtr1[0] *= -1f; float *singlePtr2 = (float *)ref vector.Y; singlePtr2[0] *= -1f; } if (vector.W > 0f) { Vector2 normalizedCoord = new Vector2(((vector.X / vector.W) / 2f) + 0.5f, ((-vector.Y / vector.W) / 2f) + 0.5f); normalizedCoord = MyGuiManager.GetHudPixelCoordFromNormalizedCoord(normalizedCoord); for (int i = 0; i < this.m_invetoryItem.IconTextures.Length; i++) { MyGuiManager.DrawSprite(this.m_invetoryItem.IconTextures[i], normalizedCoord, new Rectangle(0, 0, 0x80, 0x80), Color.White, 0f, new Vector2(64f, 64f), new Vector2(0.5f), SpriteEffects.None, 0f, true); } } }