Sign in to follow this  

Long beam sprites and clipping

This topic is 3862 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

Before I start, this is all theory and none of it is in practice yet, I'm just planning ahead. One of the things I would like in my isometric engine is the ability to cast long beams (often called billboard beams in 3D games) from one arbitrary point to another. The issue here is the drawing order of the tiles. Most objects in iso games are drawn on a per tile basis, and so they fit neatly in one or two tiles. A beam needs to span multiple tiles, without drawing "over" any walls/objects that are supposed to appear in front of the beam. I have devised two approaches to this: 1) Divide the beam into tiles. This is no simple task - I would have to plot the line from point A to B, treating each tile in the game world as 3D space, then plot the entry and exit points of the beam through each tile on its path, then devise the quad coordinates to draw the beam without spilling into other tiles, and also without overlaying two beam sections onto each other (or, for that matter, having small gaps in the beam). It would need some pretty decent maths to do all this without bogging down the game every time a beam is created. 2) Stencilling. I could, in theory, calculate the point closest to the screen (or furthest down the screen if you prefer) and draw from there. Then what I would do is plot each tile along the beam's path, and draw a stencil mask of anything in the tiles "in front" of each tile on the path. This has two major drawbacks - performance on older hardware (that's a lot of stencilling/drawing to perform each frame) and secondly, if a beam was to be directed so that it moves vertically up or down the screen, then I would be stencilling tiles along the beam that might end up obscuring the beam when it should be clear. So what I'm asking is, does anyone have any better ideas? Or a way to negate the drawbacks of my own ideas?

Share this post


Link to post
Share on other sites
Three ideas; two obvious and therefore might be unworkable in your existing design, and one maybe not obvious or unworkable.

1) Use 3D, and use the Z-Buffer. Problem solved.

2) Use a distinct layer system, rendering each layer bottom to top, and each layer back to front. Place your beams in an appropriate layer.

3) Divide the beam into tiles. Seriously, it actually isn't that hard so long as the beam is no more than 1 tile wide, and becomes just moderately more complex outside that range. For why it is not so complex, look at Xiaolin Wu's Line Algorithm. Be creative.

Share this post


Link to post
Share on other sites
...or do a check to see if the line crosses the view frustum, if so - render it.
Unless we´re talking about an obscene amount of beams speed won´t be an issue. :)

Share this post


Link to post
Share on other sites

This topic is 3862 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this