# Billboards offset for character names + rotation

I am successfully using Matrix.CreateBillboard in my XNA game to print the characters name above the models. The problem I have is with the offset (to appear above the models). Currently, I am creating the location of the text using;

Vector3 objTextPosition = objPlayerShip.objShipVector + new Vector3(0, 3, 0);


This works fine if I stay within the same general lateral location. If I rotate above or below the model the text either appears on top of, or is covered by (or even below) the model. To compensate for this, I would need to create a rotation around the model (should I use a quaternion?) with the top always pointing up (with a Vector3(0, 3, 0) offset).

Am I over thinking this? Is there a simple way to achieve this?

Thanks in advance!

Here is the correct way (above the model)

Here is looking from top, down

## 1 Answer

A Vector that you can use to always cause the text to be slightly above the ship on the screen regardless of camera angle would be:

Vector3 objTextPosition = objPlayerShip.objShipVector + (Matrix.Invert(view).Up * 3);


essentially, it does what you were thinking of (transforming global UP by "some" rotation). But since the camera already using that "some" rotation , it just borrows a vector from it. (although it needs to be inverted to world space first).

• P.S. I found your blog last night while attempting to figure this out. It's going to me mandatory lunchtime reading for me for the next few day's! :-) People like you make this such a fun hobby to have! I cant thank you enough. – Linuxx Jan 9 '13 at 3:42
• Since you are setting the world space position of the text, you need world space vectors. The view matrix gets inverted to cause it's basis vectors to represent world space vectors instead of camera space vectors. – Steve H Jan 9 '13 at 13:54
• Thanks, I'm a hobbyist too. I agree, 3D programming is very fun. – Steve H Jan 9 '13 at 13:56