BoundingVolume Questions

  1. Whats the difference between spatial.getWorldBound() and ((Geometry)spatial).getModelBound()?

  2. The following code throws an unsupported exception when using BoundingSphere, but works with BoundingBox. Why?


    CollisionResults results = new CollisionResults();

    getRootNode().collideWith(boundingVolume, results);


  3. Im trying to detect if there are any geometries infront of my character (in order to detect melee/punch range). Using BoundingBox could be problematic as i can not modify the rotation of the box. Thus sometimes the punch range will be furfilled, sometimes not, depending on the current character rotation. How to solve this?
  1. worldBound is a computed bound for the spatial and all children modelBound is the actual bounding volume of the geometry (which is used to compute the worldbound of the ancestors)
  2. Uh, I dont know… You can look inside the collideWith code to see which collision types are supported. For anything else use rays or bullet
  3. Ray or logic (is my model there? how big is it?) tests. Or again more flexible collision detection via physics…
1 Like


I can maybe help with number 3.

Say you’ve got your character, and he has a sphere around him that is his ‘reach’ we’ll say. This is a BoundingSphere. Whenever a target baddie gets close enough, by checking every frame to see if something is in your character’s reach sphere, you can then check if they are in front of the character by taking the facing direction of the character and dot producting it with a vector of the baddie to the player. The dot product will be a value between -1 and 1. I can’t recall off the top of my head, but I think -1 would mean you are facing the baddie, and anything greater than 0 would mean you’re facing perpendicular or away.

After checking if both of these conditions are met, then you can punch them or whatever you had planned.

I forget the technical term for it, but you’re basically taking the front half of a sphere in front of the player and figuring out if there’s anything in it. Half space? Maybe that’s what they call it. I dunno XD



1 Like

Thx normen

Im trying to detect all geometries in the near frontal vicinity of my character. It works with BoundingBox, im just worried if the rotation of the BoundingBox (that is always fixed and thus NOT in sync with the rotation of the character) will affect which geometries will be in the collision and which not. Thats why i wanted to use BoundingSphere, but oddly enough it just works with rays!

How would i do ray tests to detect geometries in the frontal vicinity of my character? That would be like hundreds of raytests!?

As this bounding checks will be performed many times, i wanted to increase performance, as suggested by the docs, thats why i am afraid of attaching too many ghostcontrols to the physicsspace.

Thx teflah

Thanks for pointing that out, i was already wondering how to detect if something is in front of my character or behind my character.

But again, checking for collision between geometries and BoundingSpheres does not work :frowning:

nego said:
How would i do ray tests to detect geometries in the frontal vicinity of my character? That would be like hundreds of raytests!?

You can save some of these due to the data you already have, think of your worst enemy and how you could kill him with only four spears ;) Frankly don't have the exact idea for your problem atm.. But maybe something like a ray on each edge of the would already be enough. You'll really have to see how well it works in your game.
1 Like

Thx, i have done some research, it seems that intersection between BoundingSpheres and Triangles (-> comes from Mesh) is not supported yet.

It sounds to me that you want to perform the same sort of logic as frustrum culling, which is used for determining what a camera can see?

1 Like

Hmm i wouldnt know what frustrum culling does. I bet that it uses rays for checking what it can see and what not :slight_smile:

I switched to ghost controls attached to the character for now and im using the method described by teflah (btw excellent idea) to determine front / rear / sides.

Hello Again!

nego said:
But again, checking for collision between geometries and BoundingSpheres does not work :(

Correct. However, when your geometries are loaded from a file I think they're automatically given a collision shape of some sort. If they're not, you could always plop your own around it. I guess it depends on how much flexibility you would like between the characters as far as what shape to use. I only needed quick n' dirty collisions so it's spheres and boxes smacking into one another. You can get the bounding volume of the geometry with a .getWorldBounds() call I think. If you're wondering what kind of bounding volume it used, you can tack a .getType() on that and output it.

Another thing, if you need a specific "cone" in front of the player, instead of checking whether the dot product is less than 0. You could check if the value is like -0.5 to -1. That would mean that an object would have to be in the front 45 degrees of view in front of the player.

I'm halfway wondering if you can just do invisible collisions with actual geometries, or if that would even be a solution. Though using bounding volumes would be a less effort required solution. I have no experience with GhostControls, so I can't say anything there. But hey, if it works. It works :D

1 Like

Thx for clarification!

Yeah, didnt think of getWorldBound() - smashes head

But now i have a cool feature with GhostControls: its easy to determine the distance from the collision object, and since my game is all about physics, i am now punching the opponents, based how close they are :slight_smile:

I have spent some time figuring out the dot product, if your interested, see

and ofc there was an even easier solution with just CharacterDirection.angleBetween(CollisionObjectPosition.subtract(CharacterLocation))