Jump to content
  • Advertisement
Sign in to follow this  
unikron

Drawing lines in a 3d environment

This topic is 4920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am pretty new to dx and am having a bit of a problem with 3d lines. I am seeing in many places that using primitives is not really a great idea because many video cards do not support them. So I was thinking that using the Direct3d.Line would do the job but am having some problems with it. Here is what I am trying to accomplish: I am creating a 3d solar system. I have created several planets orbiting a point. What I want to do is create a circular line to represent each planets orbit around that point. Right now, I am just trying to draw a straight line. From there I can then make it curved but for now, all I want to do it get this 3d line in my 3d space. What happens is that the line appears on the screen but it seems to be top level. I mean it appears above all meshes on my screen. Here is the code I used to create the line. Dim testline As New Direct3D.Line(device) Dim testvec(1) As Vector3 testvec(0).X = 0 testvec(0).Y = 0 testvec(0).Z = 0 testvec(1).X = 500 testvec(1).Y = 0 testvec(1).Z = 500 testline.Antialias = True testline.GlLines = True testline.DrawTransform(testvec, Matrix.Multiply(device.Transform.View, device.Transform.Projection), Color.White) Like I said the line appears on the screen but show above everything else. It seems like it is just mimicing 3d behavior but not actually placing itself into the 3d world.

Share this post


Link to post
Share on other sites
Advertisement
Problem is that those lines aren't being Z-tested. I haven't worked with that line method though so I'm not sure if you can do so or not. I'm sure you could program it in manually, but I couldn't say if there is a function to let it do it automatically. I would recommend just using polygon-based "lines". It's simple enough to generate a vertex buffer with what you need (no index buffer needed if you use TRIANGLESTRIP). The circles wont be perfectly curved, but you can add as many segments as you like and the more you have the curvier it will look.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!