Calculator Community > TI 68K

Best way to perform clipping with irregular shapes

<< < (2/2)

E37:
If you can reduce every shape down to a series of lines (or can get away with approximating them as such) then you could just take the lines that outline the shape you want to test and check it against every line that makes up the environment. There are pretty simple formulas that you can use to check if 2 line segments intersect. If the calc you are using has a built in multiplication instruction it would likely be faster than drawing lines and use less memory depending on how it is implemented. But if you use really complex shapes or need precision with curved surfaces drawing to a buffer is your best bet. Drawing to a buffer also lets you save the buffer if the area doesn't change which makes it really fast.

If you are having trouble drawing to the larger area, you could use the built in sprite routines to draw the whole thing to the 240x128 area, copy that much to the 256x256 buffer, shift everything over, draw again, copy that much to the larger buffer and repeat until all the area is filled. If you are redrawing that every frame, it could get pretty slow.

Additionally, if you only have one object you are testing for collision, you can simply shift the environment around that one object. Since the things it will collide with will be inside the size of the default sprite drawing box, you don't need to worry about using a larger buffer. This does assume that you redraw the clipping buffer each frame/update.

Since you said you are making an rpg, I assume the environment is pretty static and using my second suggestion of a collision buffer, drawing everything to the screen just copying it chunk by chunk to the buffer is probably the best since it is the simplest.

Michael0x18:
Well, thanks everyone for the suggestions. I think I'm going to stick with the clipping plane thing. I got some assistance from @Lionel Debroux over on Ti-planet (not my first choice, since my French is terrible) and I'm using a modified version of the SDK sprite routines to draw.

Navigation

[0] Message Index

[*] Previous page

Go to full version