Sourcecode: Grappling Hook Collisions

In this zip-file is the sourcecode for the collision system of Grappling Hook:

http://ghook.speedrungames.com/download/GrapplingHook_src_physics.zip



Features:

  • entirely written in Java
  • optimized for the use in Grappling Hook
  • no allocations during updates
  • supports collisions between axis-aligned-bounding-boxes, rays, and points
  • supports both static and dynamic AABBs
  • depends only on com.jme.math.Vector3f, so it could be used without jme with only a bit work



    How to use it?

    The main-class is physics.PhysWorld. You have access to almost all functionality with this class. It is best to have a look at this class first, when you want to use the system.

    There are not many comments in this class, but the names of all functions and variables should give you a clue, what they do.



    This is not a library. It is optimized code of a released project. That means that there can be optimizations, which are not useful for other projects. I don't recommend to paste the code into other projects without reviewing it.

    I hope it will be helpful for some of you as a reference, when you try to implement your own collision-system.

    When it is useful, a credit would be great, but is not required.





    Edit: Please note, that this does not provide any physics simulation. This is only for collision-detection. You have to write the whole velocity/acceleration/force/torque… code by yourself.


hey this is a really cool contribution.



thanks!

Since you're collisions are only AABB and rays, which aren't triangle accurate, there's probably not any easy way of making this physics implementation work with TerrainPage's, correct?

SomethingNew said:

Since you're collisions are only AABB and rays, which aren't triangle accurate, there's probably not any easy way of making this physics implementation work with TerrainPage's, correct?

It's already easy enough, you can get the height at any point of the TerrainPage using getHeight(x,y) method, then place the player model at the height. You can also get the normal using getNormal(x,y) and implement sliding or prevent character from going up cliffs.

If you want general purpose triangle accuracy, check in a few days. I will submit the latest changes to jME3 which include a full blown triangle accurate collision detection and handling system, which you can use in your projects  :)

Major kudos on releasing this :smiley: