Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 they're right in front of the camera?

 

I'm going to include things such as radar, other ships, messages, etc.

 

I've attached an example of what I'm trying to do. I've taken this from Freelancer screen shots.

 

I'm 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 I'm not sure if it's 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

Posted
One idea would be somehow switching to ortho view, and then drawing the gui, but I'm not sure if it's 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.

Posted

Unfortunately, it doesn't seem to be working. I've added this code between begin scene and end scene. All the 3d graphics still work fine. It's just not drawing anything that I specify after I switch to ortho.

 

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);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...