PDA

Click to See Complete Forum and Search --> : Looks like NO ONE knows how to draw a SIMPLE line!


Jotaf98
Feb 23rd, 2001, 05:31 PM
Hi!

I've tried many methods to draw NON-antialiased lines (it's for collision detection), but none of them work! I mean, they do, but only if "X > Y" or something...
and I can't figure out how to make it work under any conditions, like VB's function (look at my other post on the midpoint algorythm - that's a very fast algorythm so I would prefer it, but anything will have to do!).

Can someone please help me on this? Any piece of code will help!

Thanks!

Fox
Feb 23rd, 2001, 06:13 PM
Why do you need a line for collision detection?

kedaman
Feb 23rd, 2001, 06:57 PM
Yeah, that must be really weird, maybe the user is the one that has to detect the collision by looking at the line and see if it hits something...

*Super Sniper*
Feb 23rd, 2001, 07:38 PM
sounds like he wants the user to be able to see where the limit is, but I am not sure what he wants...

Jotaf98
Feb 24th, 2001, 07:02 AM
Well... if you really wanna know: I want it for a 2-d line of sight system. I need to cast rays from each of the lights and when it finds an obstacle it stops...

Does anyone know how to make a line?

I've seen Fox's example, it's cool but it only works under some conditions.
I looked at the midpoint algorythm, it has the same problem.
I tried to make on myself, and it STILL had the same problem!

Please help! I'm really desperate! :(

Xyanth
Feb 24th, 2001, 09:38 AM
How about you get a pencil, some paper, and a ruler, and you start from one end of the ruler, and draw aaaaaall the way to the ot-...What? Visual Basic? Oh! Nevermind! Heheh....eeeheheh.. <;)

HarryW
Feb 24th, 2001, 07:15 PM
http://www.sanctuary.org/~ashe/coding/breshanham.html

It's C but easily converted to VB. This is the best known line drawing algorithm. There are better ones for special circumstances, but I doubt they'd all be easily implemented in VB.

Jotaf98
Feb 26th, 2001, 04:40 PM
Thanks! The pice of code I had from Brensenham's algorythm was incomplete, this one works ;)

Do you think storing the brightness values of each tile surrounding each light in seperate variables would be good? Or should I store only the start and end points of each light?

schnarf283
Feb 27th, 2001, 06:58 PM
Dim slope as long
Dim startx as long
Dim starty as long
Dim xlen as long
xlen=500

Line1.x1=startx
Line1.y1=starty
Line1.x2=xlen
Line1.y2=(slope*xlen)+Line1.y1

Jotaf98
Mar 2nd, 2001, 09:02 AM
Thanks Schnarf, but I was trying to do it without controls. Thanks anyway!

kedaman
Mar 2nd, 2001, 09:13 AM
whats a starting point of a light? and what's a ending point then?

Jotaf98
Mar 4th, 2001, 04:15 PM
Well... here's the article:

http://www.gamedev.net/reference/articles/article729.asp

It has details on a new way to make lights.
It's in C++ but since it doesn't have any code, converting it to VB shouldn't be a problem!

My idea would be to, instead of storing the start and end points of each ray, to store the brightness values of each point of the light, like an image, to make it faster. What do you think?

Also, the original idea was to use this for Line of Sight. It can easily be changed to Lights... I don't think I have to explain too much on this ;)

kedaman
Mar 4th, 2001, 04:30 PM
ERROR: The requested URL could not be retrieved

on that link, well i have almost no idea what youre talking about, sorry

Jotaf98
Mar 4th, 2001, 04:58 PM
Heh, it's outdated :rolleyes:

Here it is as a TXT.