Recommended Posts

I am working on a 2D isometric game (my first isometric game!), but unfortunately I am stuck, so I hope some people here could enlighten me.

My main trouble is related to how I project the camera view area into my grids plane (defined in x-z plane). Currently I am doing it as follows:

1. I define my view area in the X-Y Plane (aka screen), I move the camera around using this view area.

2. To find the visible area on my grid, I project the 4 corners of my view area to isometric space (x-z plane) and compute a axis aligned bounding box from this 4 points.

3. This projected area (the AABB in x-z plane) is what I use to for intersections test against my entities / tiles rectangles (also in x-z plane).

This approach works fine ONLY if my objects have a height == 0 (on plane), if I test this area against a entity with a height of 64 (to say something), it miss it at some places, mostly at the corners.

I guess this trouble is related to how I manage my objects with a height > 0,I just sets its bounding box size to be the radius of the entity, much like

Share this post

Link to post

Share on other sites

This sounds simply like your frustrum-culling is looking only at the ground plane, and expecting your objects to exist at ground level.

If you have a fixed camera angle, then the workaround is simple; objects have to put their view-projected AABB into the view-spatial lookup structure (and probably while keeping their actual AABB in the now-separate world-spatial lookup structure). To avoid two separate spatial lookup structures, maybe you could create for each object a "solid" and "phantom" rectangle, the latter of which is used for view culling, and the former for collision checks.

If you don't have fixed camera angle, then all objects need to update their phantom hit rectangle whenever the camera rotates (around any of the three axes). Because you're using an orthographic projection (you are using an orthographic projection, not just an isometric-like perspective projection, right?), you don't need to update the phantom rectangles when moving the camera as well.

0

Share this post

Link to post

Share on other sites

Now, regarding your idea, I liked the "solid" and "phantom" rectangle method, it is elegant and simple to implement, and yes; I am using a fixed camera angle with orthographic projection so it will fit fine in my current code ;)