Lines of width other than 1 in dx8
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
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
ByteMe95::~ByteMe95()
My S(h)ite
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
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
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
ByteMe95::~ByteMe95()
My S(h)ite
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...
Not the most elegant solution, but easy to implement quickly...
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
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
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
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
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
"it''s kinda long so I wont for no reason"
Anyway, thank''s for the info - it could be very useful.
John B
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement