Collision Manager

if I was to use collision detection it would probably be easier to use the manager however there are 2 one in the src folder and another in the test directory. My question is I use StandardGame and as a result my rootNodes aren’t exactly attached to each other. (I use a singleton,which I can put the collisionManager in as well ,to get and store the current height of the terrain). I guess as far as I can think for now I would need a class that I can add everyNode created in a manager which can tell whether two nodes are contacting or not (WALL and player, player and bullet, player and player) so that I can perform custom animations…would either of these classes provide such use or you can’t tell really by looking at them…



thx in advance…

thx for the reply but how would i use charNode.hasCollision(wall(or charNode or bullet), false); for every wall or structure i implement would i be forced to but a for loop in the update method which scrolls cycles through every possible collisionNode or would i have to create a Node at the bottom of every charNode (say a rootWallNode which is attached to every active wallNode or a rootCharNode thats connected to every character object in the game)… thx for the assistance i jsut wanted to make sure (I use gameStates so would probably create a singleton to have every base collision Node)

Bonechilla said:

if I was to use collision detection it would probably be easier to use the manager however there are 2 one in the src folder and another in the test directory. My question is I use StandardGame and as a result my rootNodes aren't exactly attached to each other. (I use a singleton,which I can put the collisionManager in as well ,to get and store the current height of the terrain). I guess as far as I can think for now I would need a class that I can add everyNode created in a manager which can tell whether two nodes are contacting or not (WALL and player, player and bullet, player and player) so that I can perform custom animations...would either of these classes provide such use or you can't tell really by looking at them...

thx in advance...


If you don't need details, then it's easiest and fastest to just check for bounding volume collisions.  Presumably your Spatials all end up in a single super-graph, whether or not you ever reference them that way.  That's all that's needed for bounding volume collision detection, since it compares the world positions.  To find out if Spatials collide, run someSceneNode.hasCollision(s, false).  Use Spatial.setIsCollidable() liberally to eliminate unnecessary checks.
Bonechilla said:

thx for the reply but how would i use charNode.hasCollision(wall(or charNode or bullet), false); for every wall or structure i implement would i be forced to but a for loop in the update method which scrolls cycles through every possible collisionNode or would i have to create a Node at the bottom of every charNode (say a rootWallNode which is attached to every active wallNode or a rootCharNode thats connected to every character object in the game)... thx for the assistance i jsut wanted to make sure (I use gameStates so would probably create a singleton to have every base collision Node)


You invoke hasCollision() whenever you want to know if there is a collision.  For navigation, I invoke it in my update method only when the avatar has moved during that update, but coarse bounding volume collision detection is so efficient that there may be no noticable difference if you do it every frame.

There is no need to maintain anything else other than using setIsCollidable(), since the supplied update methods (incl. GameStates other than TextGameState) update world bounds via rootNode.updateGeometricState().  You certainly don't need to run any loop during updates, you just invoke hasCollision one time to get your boolean answer.

(Regardless of whether you have any collisions in your game at all, you always need to instantiate model volumes for your Geometries before they are rendered in your scene, and updateModelBound() when necessary, to allow for frustum culling.)