Spodi
Warrior
USA
142 Posts |
Posted - Apr 28 2004 : 5:47:06 PM
|
"using pythagoras' good old theorem"
Just wondering, how would "A^2 + B^2 = C^2" help? Isn't this to calculate the hypotineus (or slanty-thingy) of a triangle?
|
vbGORE |
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Apr 28 2004 : 5:55:24 PM
|
You can use it to calculate the distance between two points by using the x,y coordinates as two of the sides of the triangle and the "hypotineus" (if it's spelled that way) for the distance. |
Whatever. Who knows... |
|
|
Spodi
Warrior
USA
142 Posts |
Posted - Apr 28 2004 : 8:55:41 PM
|
OOooooooooooohhhh, okay, that makes sense, thanks. And yeah, I dont think it's "hypotineus", wouldn't trust my spelling. :) |
vbGORE |
|
|
cjb0087
Knave
Australia
76 Posts |
Posted - Apr 29 2004 : 04:58:33 AM
|
but that would require the deadly square root function, because a=sqr(b*b+c*c) (a*a is faster than a^2), if the light is stationary maybe you could calculate the verticies at load time? |
www.bugsplat.tk |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Apr 29 2004 : 09:08:41 AM
|
Are there going to be shadows in the game? |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 29 2004 : 12:26:03 PM
|
Shadows? Sure, that would be a cinch...if I make them look kind of cheap. I would simply loop through that box from the inside out and stop when I get to a barrier (that is, stop for that direction only). It would work, kind of...I'll have to develop it tho, so far this is all theoretical.
Aw, the square root function isn't THAT slow, is it? For the example I gave a while ago, that would be, hmmm, let's see here...area = 7x7 = 49, so 49 tiles to possibly go through, then 49x4 since there are 4 vertices in each tile...that's 196 Sqr operations for one, kinda small light. Ok, so maybe I should try optimizing it somehow. Perhaps in my level editor I could make certain lights be precalculated. Then for the moving ones (i'll have enough of those), i'll do it during run-time.
|
|
|
cjb0087
Knave
Australia
76 Posts |
Posted - May 01 2004 : 12:10:30 AM
|
you could probably check the inline asm thingo at persistant realities, i *think* there is a squareroot function there |
www.bugsplat.tk |
|
|
EACam
Warrior
154 Posts |
Posted - May 01 2004 : 6:36:34 PM
|
I did some testing; lighting in 2D [using my method, anyway] works like a charm, with a little optimization it'll be working like Sampson at the treadmill. And Spodi, I don't get the slightest hint of a triangle. It's PERFECTLY attenuated and circular. |
|
|
Spodi
Warrior
USA
142 Posts |
Posted - May 02 2004 : 1:59:27 PM
|
Hmm, well I'll try doing it again. Do you think you can send me what you got though for reference? |
vbGORE |
|
|
SuperC
Squire
11 Posts |
Posted - May 02 2004 : 2:07:59 PM
|
This might help
http://www.eastcoastgames.com/articles/2dlight.htm |
|
|
EACam
Warrior
154 Posts |
Posted - May 02 2004 : 8:37:42 PM
|
Spodi, this example will work ONLY with how it's set up. I've tried changing the range and things get messed up, but the principle is the same...kind of.
I basically did this:
Range = 200
TileGeom(0).Color = D3DColorRGBA(Range - DistanceBetweenLightAndThisVertex, Range - Distance...., ...., 255) ' Notice, the 255 is the alpha value, so it's opaque. This doesn't work with colored lights or anything. It doesn't have customizable attenuation, but it works. TileGeom(1).Color = ... ...for all four vertices.
This is a bad example here, because you have to do something else. You have to have a variable that holds the color because you need to check if it's negative. If it is, just make it 0.
Now, my tiles are 32x32. They were all rotating CC in my test app, and everything looked fine. When I increased the range, I got dark splotches in the middle of the light area. When I decreased the light range, the whole thing got dimmer. I'll work on this and pop a post when its fixed up.
Note, this is TOTALLY UNOPTIMIZED. I did this calculation to ALL of the tiles on the screen, not just those within range like I should have. This only works with ONE light. So basically, this is a pretty lame example, but it was perfectly circular.
Sorry this is so confusing...I'll try to fix it up and post my results. |
Edited by - EACam on May 02 2004 8:39:53 PM |
|
|