CharacterControl entities can walk through each other

so to get the intersection point , the getHitFraction will return the fraction of the ray that is traced to another physical entity

and give : the intersection point



tada !!!

Code:
public Spatial doRayTest(Spatial entity, float length, Vector3f storeLocation) { MovementControl control = entity.getControl(MovementControl.class); Vector3f startLocation = control.getLocation(); Vector3f endLocation = startLocation.add(control.getAimDirection().normalize().multLocal(length)); List<PhysicsRayTestResult> results = getPhysicsSpace().rayTest(startLocation, endLocation); Spatial found = null; float dist = Float.MAX_VALUE; for (Iterator<PhysicsRayTestResult> it = results.iterator(); it.hasNext();) { PhysicsRayTestResult physicsRayTestResult = it.next(); Spatial object = getEntity(physicsRayTestResult.getCollisionObject()); if (object == entity) { continue; } if (physicsRayTestResult.getHitFraction() < dist) { dist = physicsRayTestResult.getHitFraction(); if (storeLocation != null) { FastMath.interpolateLinear(physicsRayTestResult.getHitFraction(), startLocation, endLocation, storeLocation); } found = object; } } return found; }

tada !!! :)

[edit] i find it silly somehow, ghostcontrol can tell if two entities overlap, but dont return any intersection point, so to me, using a raytest afterward is doing the job twice and loading the cpu twice ...

No, its not doing anything twice. The data doesn’t exist, you create it when you do the ray test. Its checking overlaps (hence the name) and not collisions with normal etc.

@normen said:
No, its not doing anything twice. The data doesn't exist, you create it when you do the ray test. Its checking overlaps (hence the name) and not collisions with normal etc.


ok

but i thought checking intersection was mesh based
like each triangle of a mesh is checked against each triangle of another mesh
like between the player and the ground

so with the ray test, i'll not get the "real" intersection, but some sort of estimation
anyway that should do it
i guess if i add/remove dynamicaly joints on the fly, it should keep meshes from interpenetrating

:) yipeee
lol

@rompelstilchen: Are you willing to make a sample/test program for this if you got it all working. It can then included in the test or added to the wiki. I think it would be very useful for a lot of people.



Thanks in advance.

i don’t know, if i got it to work i’ll post my code, but i stardet with jme like 1 or 2 week ago so…