Trigger With null Collisions

Hello!
I am a bit new to jMonkey so if this is really nooby please pardon me. I am having a bit of an issue with a trigger I am making using the
.collidesWith method and simple bounding boxes attached to spatials, the issue itself being that the CollisionResults I allocate (see code) return an
accurate number of results but have either null or default properties. I really don’t know enough of the A.P.I to figure what is going wrong, and I
have been sifting through the jMonkey code for a while and still can not figure it out. Here is the relevant code:
Object A (Cursor Initialization Method):
[java]public Spatial[] Initialize( Game game )
{
collisionMesh = new BoundingBox( new Vector3f( 0.f, 0.f, 0.f ), .2f, .2f, .2f );
spatial[ 0 ] = new Geometry//…
spatial[ 0 ].setModelBound( collisionMesh );
spatial[ 0 ].updateModelBound();
spatial[ 0 ].setMaterial( ObtainMaterial( “Wood3” ) );
//…
}[/java]
Object B (Trigger, Initialize, and “Refresh” Code):
[java]public Spatial[] Initialize( Game game )
{
Spatial[] newMesh = new Spatial[ 1 ];
boundingBox = new BoundingBox( new Vector3f( .5f, 0.f, 0.f ), 0.45f, .3f, 1.15f );
newMesh[ 0 ] = new Geometry//…
newMesh[ 0 ].setMaterial( ObtainMaterial( “Transparent” ) );
newMesh[ 0 ].setModelBound( boundingBox );
newMesh[ 0 ].updateModelBound();
//…
}
//!!!Problem!!!//
public Spatial[] Refresh( Game game )
{
CollisionResults collisionResults = new CollisionResults();
//test.mesh = instance of object A.//
mesh.collideWith( test.mesh.getWorldBound(), collisionResults );
int i = 0;
for( CollisionResult result : collisionResults )
{
//!!!Shows null.!!!//
System.out.println( "Looking at: " + result.getContactPoint() );
//!!!Shows 0 then 1 (two objects colliding).!!!//
System.out.println( i );
++i;
}
//…
}[/java]
Anyone here know what could cause this or something I am missing?

Thought experiment…

Point to the contact point in this picture:

@pspeed said: Thought experiment...

Point to the contact point in this picture:

Where the lower left hand corner of the blue box is. Also, this is not just with the contact point, it is with all the other attributes as well when the collision occurs (the results are only generated upon collision, so I know that it is being detected I just don’t know why the results are null).

Because there are no results that would be sensible. If you point to one contact point in that picture then I then defy you to find a decent normal… not only that, but I would point to three other potential “contact points” all with their own variations on what an accurate normal would be.

The type of collisions that are being done in the bounding shape → bounding shape collisions can’t deal with this. They can tell you things intersect but they can’t pick one of the many need-dependent variations on what a contact point might be.

@pspeed said: Because there are no results that would be sensible. If you point to one contact point in that picture then I then defy you to find a decent normal... not only that, but I would point to three other potential "contact points" all with their own variations on what an accurate normal would be.

The type of collisions that are being done in the bounding shape -> bounding shape collisions can’t deal with this. They can tell you things intersect but they can’t pick one of the many need-dependent variations on what a contact point might be.


I understand what you are saying, what in the jmonkeyengine can deal with this sort of thing that does not need physics/won’t react to physics automatically?

@The-Floating-Brain said: I understand what you are saying, what in the jmonkeyengine can deal with this sort of thing that does not need physics/won't react to physics automatically?

Nothing. You may have to take a step back and explain what you are actually trying to achieve, though. Maybe we can offer viable and simple alternatives… or at least understand why you want the contact point of two bounding boxes colliding. Maybe there is a way to calculate it that you can implement yourself easily.

Since I don’t know what you will use the contact point for then I can’t comment really.

@pspeed said: Nothing. You may have to take a step back and explain what you are actually trying to achieve, though. Maybe we can offer viable and simple alternatives... or at least understand why you want the contact point of two bounding boxes colliding. Maybe there is a way to calculate it that you can implement yourself easily.

Since I don’t know what you will use the contact point for then I can’t comment really.

It is not the contact point that I need, it is the name of the object, the contact point was just an example of a null property. I’m trying to make a trigger to detect if the cursor is colliding with it, or if and how many of a particular type of game object are colliding with it.

http://hub.jmonkeyengine.org/javadoc/com/jme3/collision/CollisionResult.html#getGeometry()
Then:
http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/Spatial.html#getName()

…or whatever else you want to get about the geometry.

Your loop only checked for the “impossible to find” contact point and so I thought that’s what you were complaining about missing. The colliding Geometry is the one thing that you will get.

@pspeed said: http://hub.jmonkeyengine.org/javadoc/com/jme3/collision/CollisionResult.html#getGeometry() Then: http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/Spatial.html#getName()

…or whatever else you want to get about the geometry.

Your loop only checked for the “impossible to find” contact point and so I thought that’s what you were complaining about missing. The colliding Geometry is the one thing that you will get.


Sorry it took me so long to get back to you.
That is the problem, most of the attributes are set to default values, it always just returns the name of the object that is invoking the .collidesWith method, never the other object, looking at the other values I am getting back, they look like defaults.

@The-Floating-Brain said: Sorry it took me so long to get back to you. That is the problem, most of the attributes are set to default values, it always just returns the name of the object that is invoking the .collidesWith method, never the other object, looking at the other values I am getting back, they look like defaults.

It is returning the Geometry objects that are in your scene. Those Geometry objects will have whatever names they were given. If they weren’t given any names then I’m not sure what you expect to find there.

Are you looking for their parent’s instead? getParent() is also available.

These aren’t magic fake geometry objects that you are intersecting with. They are the actual geometry of your scene.