StraightEdge, some questions on use...

Hi, I 'm hoping CommanderKeith is still around and can answer some questions on his awesome StraightEdge project? (or anyone really if they are familiar with it). The other thread was to old to respond to @ http://www.java-gaming.org/topics/straightedge-2d-path-finding-and-lighting/23427/view.html

Anyhoo. I’ve been hacking away at another community project (MapTool) and saw that another of our members jfrazierjr even asked some questions a few years ago so must be on the right track! :slight_smile:

So, here we go:

  1. Do you have any convenience methods to handle java.awt.geom.Area? Our current VBL (vision blocking layer) or “occulders” are stored as Area’s. I currentyl use PathIterator to pull back out individual polygons but having some issues (specifically on non rectangle poly’s, some points seem to be skipped or drawn out of order?). I was looking at JTP to see if there was a way to convert Area to Polygon(s) but didn’t see one. In fact, didn’t see any good methods out there other than PathIterator (and not sure how expensive that is to invoke?)

  2. Did you ever crack Soft Shadows? (Not required but they sure would look cool!)

  3. What’s the proper way to invoke multiple light sources? Each one should have it’s own KPoint eye of course, and I assume it’s own VisionData and then a single call to VisionFinder?

  4. How do you clear/reset a given eye (to turn it off or change it’s range or numPoints?) Do you just call reset() then recreate the boundaryPolygon with updated KPoint? Wanted to make sure I’m doing things the most efficient for performance.

  5. Is there a way (or rather an easy way) to utilize OpenGL or the video card in some way to improve performance? I’m new to this whole side of things and just trying to add some nicer affects and speed things up to get MapTool updated to 2015. You know, spice it up some!

  6. I’m having trouble on translating the KPolygon’s in regards to scaling. When our map zooms/scales, I can scale the KPolygon to the proper size ok, but the x,y locations are off, I can’t seem to scale those coords properly… Any suggestions?

Anyway, awesome job on StraightEdge! I was looking for something simple to plug into MapTool to do a Proof of Concept without having to dive into the full libraries like LWJGL or Box2dLights. Within a few hours I had your code up and running! (took me longer to get it to paint in the correct frame of our tool and even longer to covert our VBL to occluders…)

Hi Jamz,
Nice to hear from you, thanks for your kind words.
I haven’t worked on straightedge polygon library for a while, but I still use it in my projects.
Recently Google code announced that it will shut down so I plan to migrate to GitHub where I hope others might be able to help and get involved with fulfilling feature requests since I haven’t enough time for now.

  1. I haven’t integrated Area class but I agree that it would be nice to have. I should add it as a feature request.

  2. I never got soft shadows working, but there are some cheating methods you could use to make it appear as so. Paint the shadow edge as feint grey line. Or use multiple light sources or ‘eyes’ to cast multiple shadows and paint them on top of one another in a translucent colour so they appear as soft shadows.

  3. Yes that’s absolutely right.

  4. Vision is actually very quick, so the way you propose is fine. It’s path finding which is expensive.

  5. OpenGL would be great, I did make a LWJGL port once but I was more interested in java2D at the time since it was more reliable. There were a lot of openGL driver problems in the past. I have been meaning to make an openGL version. By the way, in the comments page on google code you can see that some people have ported the library to android and I think they’re using openGL to render. The drawing code should be quite easy to switch to openGL from java2d. It’s the number one thing I’ve been planning on doing in my next holiday.

  6. The default scale method scales relative to the ‘centroid’ of the polygon. There is another method which scales relative to an X,Y location, which you can make the origin of the map and then scaling should work as you want. Perhaps I should change this to abide by the ‘principal of least surprise’.

I haven’t looked into box2DLights (https://github.com/libgdx/box2dlights) very deeply but it certainly looks fantastic and is popular here. It has the benefit of built-in libgdx and openGL rendering, and I notice that the author has achieved soft shadows. I will try to learn how he does that.

Cheers,
Keith

Thanks for the replies!

Come over to GitHub, the water is fine! (We moved to GitHub as well for our project, so incorporating and forking StraightEdge would be even easier. If we find any issues or add any functionality we can push it back to you.

Re #1 Would be nice. I did end up just using a pathIterator and breaking them up into KPolygons. (Should I use KMultiPolygons instead?)

Re #2, no biggy, again just icing on the cake for us. (I also assume you’ve seen this link or not apply/help but just in case, http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/dynamic-2d-soft-shadows-r3065)

Re #5, not a big deal yet (unless we do find performance issues).

Re $6, I just ended up scaling the Area first, then converting to polgons, durr, that was easier anyway :slight_smile:

BTW, here’s a video of it at work in MapTool. If you want me to post a link or anything to StraightEdge in the comments, let me know.