Visit Our Project Home Page

Posts Tagged ‘physics’

Development Diary: Collision Detection

Sunday, April 13th, 2008

We’ve been pushing off most of the “play mode” game logic for a very long time, so I’m not entirely sure I believe myself when I say we’ve put in a class called PhysicsSystem.

Our current plan for physics calls for collision detection to be handled server-side. To do this, we need n things:

1) A way for the PhysicsSystem to keep track of all the player avatars in the game, as well as all the non-player things into which players can crash. Currently, PhysicsSystem has a field that stores a NetworkBetterServer, enabling us to look at a sceneNode. Should knowledge of a sceneNode ever be refactored out of NetworkBetterServer, we will need to change this. We also need some way to put player avatars into some collection when players log on. Can we use a connection listener for this, or will the avatar have been created yet when the connection listener fires?

2) A separate thread for the PhysicsSystem.

3) Actual game logic to make the PhysicsSystem, well, do stuff. Some JME commenters have laid out examples for a simple collision detection system using bounding boxes. To run server-side, such a system would have to check each player against every other Node in the scene. (I’m assuming, based on this example, that checking collision with a given Spatial will check for collision with its children as well.) A heuristic for checking only “close” Spatials will be helpful, especially if we intend to use TriangleCollisionTests instead of bounding boxes (and delve into the magical world of vector algebra.)