• Advertisement

Archived

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

Lines of width other than 1 in dx8

This topic is 5785 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
I forgot to mention I only need this for 2d lines on a 2D ortho projection, so that should be easier

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

Share this post


Link to post
Share on other sites
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
Strange, I was expecting something longer give your:
"it''s kinda long so I wont for no reason"

Anyway, thank''s for the info - it could be very useful.

John B

Share this post


Link to post
Share on other sites
cool i like taht! I''m actually working on the exact same typ eof issue but in 3d!! I want to add trails to my missles like in this image. I think i''ll try somethign similar but be constructing 3 sided tubes basically



SkullOne - Hero Interactive

Share this post


Link to post
Share on other sites
quote:
Original post by ByteMe95
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



What IRC server and channel did you get the answers from, by the way?



E-mail: i8degrees@cox-internet.com
AIM: i8 degrees

Share this post


Link to post
Share on other sites
Isn''t that the first method you mentioned in your first post? I thought that''s what you meant when you said "draw a quad".

Share this post


Link to post
Share on other sites
JohnB: I guess the explanation was shorter than I thought

i8degrees: EnterTheGame server (irc.enterthegame.com) room #flipcode

CrazedGenious: Yes I mentioned it as a possibility but didn''t know how to go about it


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

Share this post


Link to post
Share on other sites

  • Advertisement