Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make a 3d editor in DX9/XNA for a project I'm working on. I'm just thinking through how I would go about certain tasks and I'm stuck on one particular thing, which is crucial to making the editor working.

The editor will allow 3d objects to be added to the scene. For example I would add a cube to the scene. Now I want to be able to select one edge of the cube. When this edge is selected it should change colour. The remaining edges should not change colour.

If my description is not clear enough then it would basically be the same as the edge tool in blender. If you look at the following image you will see the first double cube has its centre edge highlighted

I can't recall coming across anything in DX9 or XNA that allows edges to highlighted in this way. Would this be done in a shader perhaps?


Edit From OP: (Can't seem to post comments so editing the original.) I had considered drawing lines but wasn't sure if it would trace the exact same path as the edge. I guess I it would be best to try this first before dismissing it. The purpose of the post was to find out if xna or dx9 had something built into it to do this sort of thing. I'm currently just in the design phase so have not implemented anything.

I would accept the answer from Roy T but I can't find the option to do so! Thanks.

share|improve this question
Has the feature of selecting edges been already implemented? Edge highlighting can be a trivial problem if you have the that feature done. – ChrisC Aug 19 '12 at 20:30
Note: you can't accept the answer or post comments because you're not logged in. You registered under the name "Ray", so you should log in as that. – Nicol Bolas Aug 20 '12 at 14:29
up vote 4 down vote accepted

You might be over-thinking this ;).

The way you phrased your question seems to indicate that you already have the edge and the two vertices that represent this edge. If not you need to look at the Viewport.Unproject method to shoot a ray from the mouse pointer and then see if this (almost) intersects with an edge. Anyway once you have the two vertices that represent the edge all you have to do is this:

  1. First draw your model or trianglelist/trianglestrip
  2. Then draw a line between the two vertices. this will be drawn over the model and will look like highlighting, especially if you draw your line not totally opaque.

That's all there is to it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.