How to manually check colision [SOLVED]

So, if I have an GhostControl A that had trigged the getOverlappingObjects with the spatial B.
I want to check this control with an array of geometries that are only in memory, it has the right position in relation with the collide object B.
There is any function for that ?

1 Like

http://lmgtfy.com/?q=jme3+collision

:wink:

Nope, it didnt help me.
All info I found detect colision betewen object and scene :
http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:collision_and_intersection
I want to detect colision in memory betewen geometrys, the very basic type of colision detection.
There is nothing built in in Jm3 to do it ?

When you say a collision between an object and a scene do you mean between a geometry and a node, right?, why don’t you make a collision detection between the geometry and the node containing the “geometries in memory”?.

You can also iterate through that memory geometries (if your graph is a mess) and detect a collilsion between each of them and your object.

Another way, would be to merge all that geometries on a single one and do the collision.

You can also use bounds if you don’t really need accuracy perfection…
…
…

There are a lot of ways to do it, but the one I suggest is to have a scenegraph that allows you to just use a node that contains all the geometries you want to collide with.

By the way, when you say all the geometries in memory, where are these geometries in terms of code?

I not sure what you mean with geometry and node.
I have an colision. What I want is to check the collided object with an array of memory geometries.
The colision beteween each of them and my object is what I need, just dont know how to do it.
I am looking for something like bollean xy = spatial.checkCollideWith(geometry x) or PhysicsRigidBody.checkCollideWith(geometry x) or anything I could use inside the loop.

I highly recommend you to read the beginner tutorials. Once you have done all of them (there is one for collisions) you’ll probably know what I was talking about. You seem to don’t understand what is the scene graph.

To check the collision between two objects you can use the system in the link you looked before. If what you want is to check a collision using rigid bodies (bullets system), you can use a bullet’s physic collision listener.

Friend, its not what you are thinking.
I am doing an fracture system in the jm3.
For this, I have an object with small peaces inside, the object is rendered, but the peaces are not rendered in the scene for performance reasons, those peaces are just in memory.
When an colision happens on the master object, I translate the position of the object to all peaces. I want to check witch peace of the object ( including internal parts ) the collision happens, for this I need an manual collision check betewen geometries.
I have no idea why you are thinking I dont know scene or physics, I know my english is not good but I thought I was clear in the topic.
Also, in bullet there is an funcion called checkCollideWith , I could not find the wrapper for it anywhere, but maybe its somewhere in the jm3 code I didnt check it, or maybe it was implemented diferently, if anyone knows it will help, otherwise I will need to build it myself.

What you need in this case isn’t the collision of each object. In the initial collision you get a collision location and vector as well as the force applied. You just need to put your “fragment objects” in place and apply the same impulse.

I see. For that I need to create ghost objects for the fragments or there is another way ?

Just normal RigidBodies, I suppose you want your fragments to fly around, no?

Not exactly, a bit of they will, but mostly will stay just in memory.
I was in hope I dont need to input any of this objects in the scene or in the physical world, since they are many. I just need a very fast way to do it, will it be the way ?

I’m afraid I don’t get what you want to do then. Why do you want pieces at all if they are neither rendered nor physically interact? If at all you get more overhead from the physics if you check them all separately instead of letting the physics space do that. You could also make a separate physics space if you don’t want the pieces to interact with the other physics space.

Simulate fracture. I will keep the original object that must probally will not fracture completly, some part of ( some peaces) it will fly, but not all of they.
I was planning to do in the collide event :

  1. create an explosion sphere and check all peace memory objects it collide.
  2. create some peace objects and apply to the scene.
  3. change the mesh of the original object ( removing the parts ).
  4. remove the flying peaces from the memory array.
    I saw another post here in the forum about one guy that did something close to it, I will look on that too, but also what I want is to use the fracture models I have made in blender, it has good fracture generators and it imports fine in Jm3.

I just don’t get why you want pieces that you won’t use in the end in the first place.

I will use, all peaces that get hit by the explosion will be used in the scene.
But not all of they will be used.
Found the topic : Destruction of walls - #24 by tonihele
He was doing something similar, if you look at some pictures you will see a house, there is peaces on all walls, but you will not trow peaces from all walls in the air if the cannon hits only one wall right ?

?? All will be used but not all will be used?

What the guy was doing is separating the wall that was hit into pieces (and only that one) in the moment it was hit (and only in that moment). He didn’t keep all pieces in memory before the wall was hit, he added them in that moment.

I am doing exactly the same.
I think you may confused me on how I am keeping it in memory.
I am just keeping the geoms in one array, its not linked in the scene, I think its the best way dont ?
I could store in the array just the vertices maybe…
I guess he was also doing the same technique, since he needs to load the peaces somewhere.
Its a shame its an old topic, do you know if he posted the source anywhere ?

But he knows where to put the pieces when one bigger part disintegrates. Simply because theres basically two versions of each object, one geometry of the whole object and one Node with all the single pieces as Geometries in the right location. He didn’t try and solve a puzzle of “how can I make this big object from all the small pieces I have”.

I also have the big object version and the peaces all toguether version, preaty much the same, actually that is the way blender generates this.
But, I dont know if he create the objects and put physics on all these objects in the scene, in my case I am not doing that because I figure out it has much more performance if I just get it into one memory array and keep it there to use only in one colision event.
In one performance test, I was getting arround 60 fps with all objects and peaces added to the scene and physics, even if I just add this objects to ghosts I was getting arround 90 fps.
With out those peace objects, I am getting 300 fps, so the diference is big.
I dont know about this colision computation I am planning to do thought… I maybe inviable, maybe not, just need to test it.

Again, you put the pieces and physics for them in the scene in the moment the wall explodes. Not before.