First thing, I am not a seasoned game developer. I am using game development as a conduit to learn programming.
I am attempting to put the player names above the player's head's. I am using a variation of Shawn Hargreaves solution;
basicEffect.World = Matrix.CreateConstrainedBillboard(textPosition, textPosition - cameraFront, Vector3.Down, null, null);
basicEffect.View = view;
basicEffect.Projection = projection;
const string message = "hello, world!";
Vector2 textOrigin = spriteFont.MeasureString(message) / 2;
const float textSize = 0.25f;
spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);
spriteBatch.DrawString(spriteFont, message, Vector2.Zero, Color.White, 0, textOrigin, textSize, 0, 0);
spriteBatch.End();
My game is space based, so I needed the text to rotate on all 3 axes, so I implemented the following;
foreach (PlayerShip objPlayerShip in objPlayers)
{
Vector3 objTextPosition = objPlayerShip.objShipVector + new Vector3(0, 3, 0);
Vector3 objCameraFront = objManager.objCamera.objCameraPostion;
objBasicEffect.World = Matrix.CreateBillboard(objTextPosition, objCameraFront, objManager.objCamera.objCameraUp, null);
objBasicEffect.View = objManager.objCamera.objViewMatrix;
objBasicEffect.Projection = objManager.objCamera.objProjectionMatrix;
string strText = objPlayerShip.strGUID.ToString();
Vector2 objTextOrgin = objCourierNew.MeasureString(strText) / 2;
spriteBatch.Begin(0, null, null, DepthStencilState.Default, RasterizerState.CullNone, objBasicEffect);
spriteBatch.DrawString(objCourierNew, strText, Vector2.Zero, Color.Green, 0, objTextOrgin, 0.09f, SpriteEffects.None, 0.0f);
spriteBatch.End();
}
It seems to be working, but the text is upside down. How would I flip the text right side up? I know I have to change something in objBasicEffect.World. I try to tweak it, but I just make things worse...
Any help would be appreciated. Linuxx