2
\$\begingroup\$

I've wondered how to get basic collision detection working in an isometric game. I'm using panda3d which has very comfortable support for bullet, ode and a small builtin physics framework. The problem is that these naturally don't work with flat images. I'm using dynamically generated quads as canvases in the 3d coordinate system. Every image or texture is mapped on one of these. The idea is to create tiles with images and place them in 3 dimensions to let panda3d do the rendering.

In order to place a tree on the screen I would generate one of the dynamic flat quads and map a texture with an image of the tree on it. Then I would move the quad to the desired position and everything's fine. Panda3d manages the correct rendering order.

Up to now the player object simply walks through the environment. I need to implement basic collision detection in order to solidify the trees. Browsing through previous questions I've found this one How do I handle Isometric collision detection? Unfortunately the question only targeted collisions to prevent the player from falling through the ground and allowing him to jump on platforms. This can be done comfortably with panda3d's builtin physics.

Here's a picture to show you what I want: enter image description here

The ground itself is composed of a 10x10 grid of tiles. I've used the same texture for all of them. The tree is not a sprite that's rendered in 2d. It's actually a flat rectangle with a partially transparent tree texture. The white rectangle is my player object. With the standard 3d physics I could prevent the player from walking through the quad but the tree would still be perfectly flat. I thought about adding a "dummy mesh" to have 3d collisions but that would surely come pricey in terms of performance and would spoil the neat implementation of my 3d canvases.

Is there a canonical way to get 3d collisions in an isometric game ?

How would you do this ? Please answer this second question on behalf of panda3d.

I know that this is probably rather complicated. A link to a good article would be perfect. If you want to have a look at my code, you might want to read this question: How do I use setFilmSize in panda3d to achieve the correct view?

UPDATE:

Here's another picture that might depict the problem better

enter image description here

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

First, see my answer here from a couple of weeks ago. That deals with the 2D aspect.

Then for 3D, assuming you're using bounding boxes (need not be 1:1:1 side ratios), it's as easy as checking for an additional collision in Z. The general idea is this:

if (collides in 2D (x OR y) OR collides in 3rd dimension (z))
   resolveCollision();

Since this is a simple OR operation, you could do collision testing in any order you like, since the result remains that if there is a collision in any of X, Y, or Z, then a collision has occurred.

Isometry really has nothing to do with collision detection, it is just a representation of the world. My answer linked to above explains this in full.

\$\endgroup\$
4
  • \$\begingroup\$ hmm I'll read the article you posted in the other question. You know that my tree is completely flat ? I've "exploited" the isometric perspective to be able to use images instead of 3d models. I don't quite get how you would implement a bounding box of a 2d image. \$\endgroup\$
    – lhk
    Commented Jan 20, 2012 at 14:52
  • 1
    \$\begingroup\$ @lhk You wouldn't. The point is that you need to envision your world from a top down perspective. Then you can see that every player has a bounding area around their feet in XY. It's that bounding area that is the basis for collision detection. Forget your images for now. My other answer explains clearly that it is best to start off with just lines, in order not to confuse yourself in regards to the collision logic. Or at least, implement 2 view modes: one that shows you 2D wireframes for collisions, and one to toggle your overlaid images on and off. \$\endgroup\$
    – Engineer
    Commented Jan 20, 2012 at 14:56
  • \$\begingroup\$ I'll post another image to show you how flat the tree is \$\endgroup\$
    – lhk
    Commented Jan 20, 2012 at 14:57
  • \$\begingroup\$ sorry missed your comment \$\endgroup\$
    – lhk
    Commented Jan 20, 2012 at 14:58
1
\$\begingroup\$

ThomasEgi on the panda3d irc channel gave me some good advice. It will be best to add an additional mesh for each solid model in the scene. The graphics are rendered by the flat rectangle and its texture. The collision detection works on the new mesh. ThomasEgi suggested a small sphere, with a diameter of the trees trunk. Spheres would work best with the physics system and would be cheap on performance.

Thank you very much ThomasEgi

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .