🔒 Locked
Creating user interfaces?
Advertisement
Original Post
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.
Thanks.
-Nick
[edited by - nickwinters on May 2, 2004 7:16:55 PM]
Imagine something similar like this. I took it off freelancer, since it's similar to what I want.

I'm talking about things like the health bars in the center, #weapons left, options at the top right, etc.
If it is just switching to ortho mode, would you please provide some sample code? MDX code is prefered, but I can kinda read DX code. In the past, switching from perspective to ortho generally results in crashes or blank screens.
Thanks.
-Nick
[edited by - nickwinters on May 2, 2004 7:36:17 PM]

I'm talking about things like the health bars in the center, #weapons left, options at the top right, etc.
If it is just switching to ortho mode, would you please provide some sample code? MDX code is prefered, but I can kinda read DX code. In the past, switching from perspective to ortho generally results in crashes or blank screens.
Thanks.
-Nick
[edited by - nickwinters on May 2, 2004 7:36:17 PM]
Use ID3DXSprite and ID3DXFont.
quote:
Original post by Deinonychus
Use ID3DXSprite and ID3DXFont.
Yup, that''s going to be good for most of the time.
To switch to ortho mode:
using Microsoft.DirectX;
device.SetTransform(Direct3D.TransformType.Projection, Matrix.OrthoLH(1.0f, 1.0f, 0.0f, 1.0f));
It should be something like that. I''m not a C# programmer so I don''t really know.
The end result should be - if you set your world and view matrices to identity - that vertex coordinates become fractions of the screen: a vertex at (0.5f, 0.5f) is dead-center, and so on.
By switching, I never realized there''s a nice way to do it. I just kinda added the ortho initialization into the rendering code.
Thanks for your help. Since we already have some of our gui in vertices, we're going to try ortho. However, I can't get anything to display. Below is my rendering code, that's between begin scene and end scence.
The 3D stuff that was there before is still there. Just no new ortho vertices.
[edited by - nickwinters on May 3, 2004 1:45:13 PM]
device.SetTransform(TransformType.Projection, Matrix.OrthoLH(1.0f, 1.0f, 0.0f, 1.0f));
device.VertexFormat = CustomVertex.PositionColored.Format;
CustomVertex.PositionColored[] radarB = new CustomVertex.PositionColored[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);
The 3D stuff that was there before is still there. Just no new ortho vertices.
[edited by - nickwinters on May 3, 2004 1:45:13 PM]
if it goes from 0 to 1, shouldn''t the distance between .25 and .4 be 15% of the screen?
quote:
Original post by nickwinters
if it goes from 0 to 1, shouldn''t the distance between .25 and .4 be 15% of the screen?
Are you remembering to set your World Matrix? If your vertices have the required position already, make sure you''re setting the World matrix to Identity.
Also, ditch the normal and turn off lighting.
Stay Casual,
Ken
Drunken Hyena
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement