开发者

Good 2D Collision Response References

Hey, I'm currently looking for various methods of implementing collision resp开发者_如何学JAVAonse in 2D video games, something similar to this tutorial Metanet has: N Tutorial I'm looking to implement something in XNA, but any language would be fine. I'm more interested in implementing programmatically than actual theory. I'd prefer more beginner friendly material, but I do welcome more advance topics.

So could someone suggest some good 2D collision response articles/books?

(PS: I'm more interested in response than detection)


The N tutorial that you mentioned already is a great resource to start with. I also recommend the very good article 2D Polygon Collision Detection. It comes with a great C# implementation and example for polygon collision detection using the Separating Axis Theorem and explains some of the concepts better.

As far as responding to a collision is concerned it depends on the scenario. For games you might want to check for a possible collision based on the current velocity and then simply adjust the actual velocity to prevent collision. You could also implement some sort of 'bounce' effect. In any case it will likely be adjusting both the velocity and direction of the object.

You can use the Separating Axis Theorem to do the collision detection and also use polygon projection to find the distance to the target on a specific axis. (most of the time the vector on which you move).


I really like this one, it just arrived a week ago and it's everything you could want short of doing relativistic effects:

http://www.amazon.com/Physics-Game-Programmers-Grant-Palmer/dp/159059472X


How much detail do you need? Answering some of these questions would help you eliminate packages that don't do what you need.

Do you have to worry about object rotation? Then you need to be concerned about lever arms, angular momentum, moments of inertia, and torques.

Do you have to worry about deformation? Then you need to get into finite element analysis, stress/strain, etc. -- something that describes how the objects respond internally to external forces.

What about frictional effects? Then you'll need coefficients of friction, or possibly velocity models for air resistance.

Gravitational effects? Electromagnetic effects? Other forces?


If you want a basic answer for collision response, here it is :

for each pair of objects that collide
    ask gently to the collision detection lib their interpenetration distance
    Apply an impulse (i.e. a force in the duration of the frame) to both objects :
        force proportional to penetration depth (you will have to tune the coef by hand)
        direction : perpendicular to the collision normal.
        application point : the collision point (approximately, since it s not a point anymore but a volume)
integrate (Euler, Verlet, )\


I was searching for same info too, The most usable thing i found so far was

http://www.myphysicslab.com/collision.html

the worse thing here for me is tahat this is withoout friction (tangent collision impulse only normal impulse) and I think the one with such friction impulse would be better but still not found a tutorial how to correctly implement that


Physics engines are very complicated. You would be much better off using an existing one.

  • Farseer (C#, derived from an older version of Box2D).
  • Box2d (C++, It has .NET bindings)
  • Chipmunk (C, I don't think it has a C# port, but you could make one).

If you want to use physics in your game, use Farseer, or a Box2D bindings. If you want to learn about physics, consider making C# port of Box2D, or Chipmunk. If you are just curious, all of their code is open source.


Have you looked at Cocos2d?

  • Intro to Cocos2D Tutorial

  • Intro to Box2D Tutorial

  • How to Create a Breakout Game with Box2D and Cocos2D Tutorial: Part 1/2

  • How to Create a Breakout Game with Box2D and Cocos2D Tutorial: Part 2/2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜