Creating in-game interfaces?

nikhilhs

Member
Joined
Feb 22, 2004
Messages
22
I have a game where ships fly around, input and everything working... Now I need to figure out how to draw the user interface. Is there a way to draw it without manually finding where the vertices need to be so that theyre right in front of the camera?

Im going to include things such as radar, other ships, messages, etc.

Ive attached an example of what Im trying to do. Ive taken this from Freelancer screen shots.

Im talking about things like the health bars in the center, #weapons left, options at the top right, etc.

One idea would be somehow switching to ortho view, and then drawing the gui, but Im not sure if its possible to draw the main game in perspective view, switch to ortho, give it some new vertices, and then have it draw both.

Any ideas?

Thanks.

-Nick
 

Attachments

What you need is to use transformed vertices. Or just use Sprite class as it does that for you in the background.
 
nikhilhs said:
One idea would be somehow switching to ortho view, and then drawing the gui, but Im not sure if its possible to draw the main game in perspective view, switch to ortho, give it some new vertices, and then have it draw both.

Yes, this works fine and is a good way to go.
 
Unfortunately, it doesnt seem to be working. Ive added this code between begin scene and end scene. All the 3d graphics still work fine. Its just not drawing anything that I specify after I switch to ortho.

Code:
device.SetTransform(TransformType.Projection, Matrix.OrthoLH(1.0f, 1.0f, 0.0f, 1.0f));
device.VertexFormat = CustomVertex.PositionNormalColored.Format;

CustomVertex.PositionNormalColored[] radarB = new CustomVertex.PositionNormalColored[2];
radarB[0].SetPosition(new Vector3(0.25f, 0.25f, 0.01f));
radarB[0].Color = System.Drawing.Color.Black.ToArgb();
radarB[0].SetNormal(new Vector3(0.0f, 0.0f, -1.0f));
radarB[1].SetPosition(new Vector3(0.40f, 0.25f, 0.01f));
radarB[1].Color = System.Drawing.Color.Black.ToArgb();
radarB[1].SetNormal(new Vector3(0.0f, 0.0f, -1.0f));
device.DrawUserPrimitives(PrimitiveType.LineStrip, 1, radarB);
 
Back
Top