Troubles in isometric space...

Started by
1 comment, last by ogracian 13 years, 7 months ago
Hello,

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

vector max = new vector(entity_width, entity_height, entity_length);
float radius = max.length() * 0.5;

entity_box.setFromCenterExtents(entityPos.x, entityPos.y, entityPos.z, radius, radius);

Thanks in advance,
Oscar


Advertisement
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.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
Hey Wyrframe! Thanks for your help, I really appreciate it.

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 ;)

Best Regards,
Oscar

This topic is closed to new replies.

Advertisement