Spatial contains Point?

Hi!

I’m currently trying to find out, how to find out (lol), if a spatial contains another spatial.



The code:

[java]spatial.getWorldBound().contains(otherSpatial.getWorldBound().getCenter())[/java]

Is there any mistake in it?

I Can’t find out why it doesn’ work when the second spatial moves straight into the first one.



Or is that not the way I should do it?

It looks fine.It should work.



how do you move the other spatial?

How you create the geometry? What are the meshes? If you create/modify the meshes manually you have to update its collision data as well.

How you create the geometry? What are the meshes?

The spatials I create with assetManager.load("Model.j3o");

If you create/modify the meshes manually you have to update its collision data as well.

There is no collision between these two spatials (that's how I wanted it), one of them doesn't have a RigidBodyControl, because it sould not collide with anything.

how do you move the other spatial?

setLocalTranslation
and (for that one that has a RigidBodyControl)
setPhysicsLocation

It might not be your problem, but just to keep in mind the difference between ‘contains’ and ‘intersects’:



javadoc:

“Contains determines if a given point is contained within this bounding volume. If the point is on the edge of the bounding volume, this method will return false. Use intersects(Vector3f) to check for edge intersection.”

No, tried that out, too.

ok, haven’t found the mistake itself but I know that is has nothing to do with the JME, it’s a logical mistake in my code :smiley:

Thanks for the answers.