@Override
public void collision(PhysicsCollisionEvent event) {
Object a = event.getNodeA();
Object b = event.getNodeB();
if (a == null) {
System.out.println("Object A is null");
return;
}
if (b == null) {
System.out.println("Object B is null");
return;
}
System.out.println(event.getNodeA().getName() + " colides with "
+ event.getNodeB().getName());
}
I put this inside my collision function because of NPE’s, the output is:
Floor colides with Mob
Object B is null
Floor colides with Mob
Object B is null
Floor colides with Mob
Floor colides with Marine
Floor colides with Marine
There is 1 floor, 1 green cube marine, 1 red randomly moving sphere mob
the only objects not named which are probably the null referance are bullets
Sphere bul = new Sphere(16,16,0.3f);
Geometry bullet = new Geometry("Bullet", bul);
bullet.addControl(new GhostControl(new SphereCollisionShape(0.3f)));
They do get removed from the physics space, but it happens long after the collision (when they reach the world bounds) and even when they do get removed from physics space, the pointer to them inside the collision should stop the GC from collecting them??
So if u attach a RigidBodyControl (which contains the collision mesh) to a Spatial and that Spatial is involved in a collision, it returns the Spatial and not the Control
But if u attach a GhostControl (which contains the collision mesh) to a Spatial that is involved in a collision, it returns the Control and not the Spatial
why is that???
and if this is the standard, desired behavior why doesnt event.getNode() account for Controls tooo?
I believe that non-null collision objects (which might also be controls) should be always returned (via the getObjectA() and getObjectB() methods) in any case .
If getNodeA() or getNodeB() is returning null, that might indicate that the control isn’t added to any Spatial.
Or the collision object might be something other than a GhostControl or a RigidBodyControl.
Or somehow the collision object’s user object got set to something other than a Spatial.
Yes. Soon as you pointed out that it was the function returning null and not the event containing null I used getObjectB() and confirmed that it is a GhostControl.
Using: jme3-jbullet-3.2.1-stable.jar
As can be seen from physics debug mode in the image the Collision meshes are all there and all in the correct position and all moving correctly
However:
Marine and Mob collide with Floor (expected and correct)
The projectile (with ghost control) does collide with Marine (the green square) when spawned at marine getLocalTranslate() (expected and correct) and doesnt collide with Marine when i spawn it outside the mesh (correct)
The projectile does collide with Floor (incorrect, it is parallel at y=1.0f with radius 0.3f) but its inconsistent (not every projectile, random) probably has to do with cloning the spacial, even though it gets translated before being attached (and ghost control automatically fetches spatial.localTranslation() onEnable())
However, the projectile NEVER collides with Mob and it is clearly intersecting (even when slowed down so there’s more ticks for collision
Marine and Mob are both RigidBodyControl(1.0f) and both move (though Marine much less) and both are colliding with the same object (at different times) yet one registers and the other doesnt.
Projectile also collides with Floor which is RigidBodyControl(0.0f) (which it shouldnt) meaning that its the SphereCollisionShape that is broken ??? (Sphere + Sphere not registering)
As for the GhostControl (for whatever reason it doesnt return the spacial instead) I just need to extend it to add public getSpatial() and i can manually change objects
jme3-bullet is part of jMonkeyEngine and is included in the SDK. To switch, you’d replace the jme3-jbullet library with 2 libraries: jme3-bullet and jme3-bullet-native.
Minie isn’t part of jMonkeyEngine and doesn’t have a wiki yet.
that kind of thing should be included in install instructions
and the SDK should probably be defaulted to one with the other in a separate folder for swapping
which should i use?
(all mentions of bullet in my jmonkey library (downloaded directly from here)
so i have 6, and i should have 2 (i guess android can stay?)
i’m guessing that jbullet.jar, jbullet-0.0.1.jar and jme3-jbullet-3.2.1-stable.jar needs to disappear?
i tried using maven to generate the library, it kept making a library and then following boot intelliJ marked it as invalid … shrug
my other maven libraries work great
it also couldnt pull the sources and javadocs with the library so something was obviously wrong