/// <summary> /// Draws the string txt as a 'floating text' positioned slightly above the GameObject. /// </summary> /// <param name="go"></param> /// <param name="font"></param> /// <param name="txt"></param> /// <param name="col"></param> public static void SetText(GameObject go, String fontResKey, String txt, Color col) { Vector3 p = go.WorldMatPos; if (go.ObjectModel != null) p += 1.05f * go.ObjectModel.Dimensions().Y * go.WorldMat.Up; //Monitor.AddMessage("in frustum: " + go.GetType() + " " + Collision.IsInsideFrustum(go.theScene.Frustum, p)); if (Collision.IsInsideFrustum(go.theScene.Frustum, p)) { if (!FontCollection.TryGetValue(fontResKey, out tempSF)) { tempSF = go.ResourceGetSpriteFont(fontResKey); FontCollection.Add(fontResKey, tempSF); } tempsize = tempSF.MeasureString(txt); // Aligns the string to be just a little over the top of the object tempv3 = go.theGame.Graphics.GraphicsDevice.Viewport.Project(p, go.theScene.CamProjection, go.theScene.CamView, Matrix.Identity); tempv2 = new Vector2(tempv3.X - tempsize.X / 2, tempv3.Y - tempsize.Y); FloatList.Add(new FloatEntry(tempSF, txt, tempv2, col)); } }