Hello all
I have been idle for a while cause my wife and I had a daughter. But I am back and as a result I have questions
I have been trying todo pr vertex intersection but I cant seem to get it working. if (A.getWorldBound().intersects(B.getWorldBound())) this evaluates to true but no vertexes intersect??
First a little background. Each of my ships is a node containing another node with the actual model.
I hope someone can spot an error.
/*
* Created on 19-03-2004
* Created by Oliver Billing
*/
package com.extorris.physics;
import java.util.ArrayList;
import java.util.Iterator;
import com.extorris.node.spaceship.Shuttle;
import com.extorris.physics.strategies.BounceStrategy;
import com.extorris.physics.strategies.CollisionResponseSpheres;
import com.jme.intersection.TriangleCollisionResults;
import com.jme.scene.Controller;
import com.jme.scene.Node;
/**
* This singleton simulator handles all flight and intersection of objects in
* space
*
* @author oliver billing
*
*/
public class PhysicalObjectsController extends Controller {
/** Calculating bounce for intersection */
private BounceStrategy bounce = new CollisionResponseSpheres();
/**List of physical objects*/
private ArrayList physicalObjects;
/**Super node for all physical objects*/
//ArrayList pnode;
/**Result set*/
private TriangleCollisionResults results = new TriangleCollisionResults();
public PhysicalObjectsController() {
super();
physicalObjects = new ArrayList();
//this.pnode =pnode;
}
public void removePhysicalobj(PhysicalObject obj){
physicalObjects.remove(obj);
}
public void addPhysicalobj(PhysicalObject obj){
physicalObjects.add(obj);
}
public void update(float time) {
//OPTMIZEME:
//n * n operation can be optimized to n log n by only checking A versus B
// and not B versus A
Iterator I = physicalObjects.listIterator();
while (I.hasNext()) {
Iterator II = physicalObjects.listIterator();
Node A = (Node) I.next();
while (II.hasNext()) {
Node B = (Node) II.next();
if (!A.equals(B)) {
//System.out.println("comparing "+ A.getName() + A.getWorldBound()+ " with " + B.getName() + B.getWorldBound());
A.updateWorldBound();
B.updateWorldBound();
if (A.getWorldBound().intersects(B.getWorldBound())){
//get the models and calculate their collisions
Shuttle As= (Shuttle)A;
Shuttle Bs= (Shuttle)B;
results.clear();
As.getModel().calculateCollisions(As.getModel(), results);
if (results.getNumber() > 0) {
System.out.println("numbe rof results??" + results.getNumber());
for (int i = 0; i < results.getCollisionData(0).getSourceTris()
.size(); i++) {
System.out.println("Resuuults");
}
}
System.out.println("HIIIT");
//if intersection call the respective objects
//PhysicalObject objA = (PhysicalObject)A;
//PhysicalObject objB = (PhysicalObject)B;
//bounce.calcbounce(objA,objB);
// objA.showHitEffect();
}
}
}
}
}
}