Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ByteMe95

Lines of width other than 1 in dx8

This topic is 6053 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

Anyone know a good way to draw a line of various width? I''ve been tryign to figure this out on my own, still pondering how DX8 does not handle that for you. I figure one of 2 possible methods: 1)Draw a quad, not a line, and figure out the points based on the x/y and the width 2) from -width/2 to width/2, draw a line the problem is for 1), how should i figure out the points to use based on x1, y1, x2, y2 and the width and for 2) how do i calc the start/end points of every drawn line?? I ALMOST got it working using 1), but it''s a little off for some lines, works great for diagnoal lines and the endpoints are a bit off for everything else Anyone know which way is better or if there is a better/standard way? ByteMe95::~ByteMe95() My S(h)ite

Share this post


Link to post
Share on other sites
Advertisement
G''day!

I haven''t tried this code out, but it looks good. It''s from flipcode by Pierre Terdiman:

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-TexturedLinesInD3D&forum=cotd&id=-1

Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
haha, i got that link from someone else but I dont understand it at all, and that might not usually be a problem but I cant even figure out what function to call with what parameters out of that!

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites
You could do textured quads, or you could also try drawing the lines repeatedly at slight offsets (possibly as a bulk operation by tweaking the matrices), adjusting the alpha channel as you go.

Not the most elegant solution, but easy to implement quickly...

Share this post


Link to post
Share on other sites
I had a long hard chat with some irc people and got the MOST elegant and perfect solution im shocked and amazed, so thanks for the help but I got it

If anyone wants to know what the solution is just ask and I''ll post, it''s kinda long so I wont for no reason, but I enjoy spreading knowledge so dont be afraid to ask
- Rob

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites
well basically given 2 endpoints, A and B, u get a vector B-A.
Now bear in mind that a line is really just a rectangle (might not be axis aligned, but the angles are perpendicular = rectangle).
So using vector B-A, lets call it C, get the perpendicular vector to C, which is just (-C.y, C.x)

Now normalize the perpendicular vector since we just want direction. Multiply the normalized perpendicular vector by width*.5. (Call this new vector D)
Now, the 4 ponits of the rectangle are just:
1) A + D
2) A - D
3) B - D
4) B + D

And that''s it! Short, sweet, works perfectly and is simple (noce its pointed out to you, I was amazed that it worked)

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites

  • 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!