# Collision detection on cubes.

This topic is 4880 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everyone! I'm working on a 3-dimensional tetris, but I've got some problem with how to check if two cubes have collided. The reason is that I want to check if they collide even when they're rotated. I could probably write some function to check two normal cubes, but when you rotate one or both of the cubes I'm completely lost. I've tried googling around a bit, but I can't seem to find anything relevant. So if anyone could push, kick or throw me in the right direction I'd be really grateful.

##### Share on other sites
For tetris you want your cubes to either hit or miss, rather than rotate through 45 degrees, just touch the corner, and roll off, yes? So there isn't actually a great deal of physics involved. Can I also assume that by "rotated" you dont mean the cube is rotated, you mean there is a set of cubes which form a piece and the piece has been rotated? And that this rotation is always a multiple of 90 degrees around some axis?

I would be inclined to have a 3D array of on/off flags for the entire volume the piece can fill, and another such for the play area, and just check to see if two corresponding ones are set - one for each cube.

##### Share on other sites
No, by rotated I actually mean a 3D-cube that has been freely rotated. I'm trying to make a somewhat different tetris than the usual, so I want the player to freely rotate the cubes. But thanks for your reply anyways.

##### Share on other sites
Try googling 'OBB separating axis test'. You might also take a look at this.

##### Share on other sites
Sounds interesting actually. Anyway, have you taken a look at http://www.tokamakphysics.com/? One of the demos is actually collapsible cubes (kind-of what you're talking about I think). I'll be honest though, I haven't actually tried this physics engine, but I heard some good things about it...

##### Share on other sites
jyk, thanks for the suggestion. I'll take a look at that, seems like it's what I need. Thanks for your suggestion also AP, but I'm not really interested in a physics engine. Seems like a bit of overkill [smile]. A bit offtopic though, how come an AP has a user rating? I've never noticed that before.

##### Share on other sites
Regarding physics engines, I'm just testing a few (Novodex, Newton, Tokamak, ODE) and I found Tokamak to be the most straightforward to use. A physics based Tetris-style game actually sounds like an interesting idea.

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633329
• Total Posts
3011381
• ### Who's Online (See full list)

There are no registered users currently online

×