Static Collisions

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
megizin
Halfling
Posts: 88
Joined: Fri Jun 24, 2005 4:30 pm
Contact:

Static Collisions

Post by megizin »

I have OgreODE working, and I am starting on my first game using Ogre. It is a game like tetris, and I am trying to wrap my head around how the game objects will be physically represented.

Some questions I had:

[Available demos]
First, has anyone done something similar with Ogre/OgreODE that could show me their demo (and code?)?

[Does OgreODE support static collisions? How?]
Second, if I rotate a block and that rotation causes a collision, would it be a static collision (since the rotation would be instantaneous.)? How would I find out about this collision immediately after rotating so I can catch my mistake (is there a query I can use?)? btw, I am thinking about keeping a singular cube mesh and joining 4 cubes with sliding joints (is there a better choice). Same question about static collisions for if I move the Block by setting position instead of setting velocity.

[What is correct game model I should follow?]
Finally, a lot of the game will be hacks (the blocks that have already fallen and are now part of the floor will not be affected by gravity. I will force their position to drop if a row below them is completed and deleted.) I will be keeping a list of the blocks in the game only so I can delete them later (I am not sure if this is a hack but it sounds like a hack). Is this an acceptable approach to program this game? Or is there a better model using fewer/no hacks that I am missing?

Thanks
User avatar
baxissimo
Greenskin
Posts: 135
Joined: Wed Feb 23, 2005 1:28 pm
Location: Tokyo, JAPAN

Do you need ODE?

Post by baxissimo »

This is probably obvious, but I'll go ahead and say it anyway. If you just want the action to be more or less like good ole Tetris, then you don't really need ODE, and in fact it'll probably do more harm than good. For collision detection in tetris all you need is a simple loop like

for (i=pieceLeftColumn; i<=pieceRightColumn; i++) {
Is debris in column i, higher than lower edge of piece in column i?
If yes: return collision
}
return noCollision;

What are you hoping to gain by using a full rigid body simulator like ODE?
User avatar
megizin
Halfling
Posts: 88
Joined: Fri Jun 24, 2005 4:30 pm
Contact:

Good point

Post by megizin »

thx for the reply baxissimo.

I was looking for a silver bullet, I guess.

I was going for a reusable algorithm: code that can be used with few changes to get any kind of objects interacting and some behavior code to limit what is possible (behavior code in Tetris being that the blocs only move left/right/down, and rows disappear when full, etc.).

I have made a tetris clone using the same algorithm you posted earlier so I know that I can fall back on that, but I was hoping to get tetris to work using physics/ODE. Should I just abandon that and do the physics-less? Is it too costly to try to go for physics based tetris?
caecus
Gnoblar
Posts: 16
Joined: Sun Mar 06, 2005 11:29 am

Post by caecus »

If you want to do it as a learning excercise I'd say go for it, but don't think your doing something efficient :) Also you should be aware that ODE isnt phenomonal accurate when it comes to stacking objects.

That said you may just want to use it for collision detection and not for the dynamics. You can do what you called "static collisions" by rotating a scenennode/geometry into the desired position and then calling one of the world.collide() methods. This should allow you to see if your move was ok.

Hope this helps.

-Charles
Post Reply