Coding error

this a part in a method that keeps giving an error and i cant see whats wrong with it, i have the most up to date JME, can anyone see whats wrong with the code,



Thanx





private void checkEllipseSpaceCollision(Spatial collisionSpatial, Vector3f ellipseSpaceCenter, Vector3f ellipseSpaceVelocity, Vector3f ellipseSpaceScale, BoundingVolume worldSpaceBounds) {

if ((collisionSpatial.getType() & Spatial.TRIMESH) != 0) {

TriMesh triMesh = (TriMesh)collisionSpatial;

    OBBTree collisionTree = triMesh.getCollisionTree();



ERROR MESSAGE/////////////////////

Cannot find symbol method getCollisionTree()

appearantly your IDE doesnt show you the "updated jME". collision trees are now handled through the CollisionTreeManager. checkout that class, TestCollisionTree or TestObjectWalking.

Cool, thanx, im tryna think how to detect collision with for example a tree, but there is hundreds of trees on my terrain, im using the methods findCollisions and hasCollisions etc. but how can i detect a collision with one tree, i have been stuck on this issue for a good while now, and there is nothing in CVS really to help, can you give me an idea or anything to help me on my way??



Thanx…

i have created this simple collision detection here, but it detects a collision of all the trees even if im not near an object because all my trees are close together and propably all there bounding spheres are touch, if that makes sence, how could i make it more accurate?



public boolean checkForCollisions(Spatial scene, Node Player) {

        results.clear();

        Player.calculateCollisions(scene, results);

       

        int i = results.getNumber();

        if(i >0)

        {

       

        return true;

        }

        else

        {

        return false;

        }

       

        }

I was looking through the forums and i came across this code, but my player still goes through all the trees  :(, does anyone know what the proplem is.



P.S. Sorry bou putting up so many posts, just im new at this and i have very lil time to get it done, thanx for ur help



import com.jme.math.Vector3f;

import com.jme.intersection.BoundingCollisionResults;

import com.jme.intersection.TriangleCollisionResults;

import com.jme.intersection.CollisionData;

import com.jme.scene.TriMesh;

import com.jme.scene.Node;

import com.jme.math.Triangle;

import java.util.ArrayList;

import com.jme.scene.Spatial;







class TestCollision2

{

public Spatial scene;

public Node player;



Vector3f temp = new Vector3f();

Vector3f delta = new Vector3f();

Vector3f prevLoc = new Vector3f();



BoundingCollisionResults results = new BoundingCollisionResults();

TriangleCollisionResults triResults = new TriangleCollisionResults();



public void checkForCollision(Node player, Spatial scene, Vector3f prevLoc, Vector3f delta) {



results.clear();

player.calculateCollisions(scene, results);



// check for bounding collision

if(results.getNumber() > 0) {



triResults.clear();

player.calculateCollisions(scene, triResults);



// check for actual triangle collision (always true if bounds collision)

if(triResults.getNumber() > 0) {



temp.zero();



for(int index = 0; index < triResults.getNumber(); index++)

temp.addLocal(getCollisionNormal(reCalcCollision(triResults.getCollisionData(index))));



if(temp != Vector3f.ZERO)

System.out.println("Collision Surface Normal: " + temp.normalize());



temp.normalizeLocal();

temp.multLocal(delta.length()).multLocal(1.1f);; // try this instead if you still have probs : temp.multLocal(delta.length()).multLocal(1.05f);

temp.addLocal(delta);



player.setLocalTranslation(prevLoc.add(temp));

}

}

}



private Vector3f getCollisionNormal(CollisionData triData) {



Vector3f normal = new Vector3f();



if(triData.getTargetTris().size() > 0) {



TriMesh mesh = (TriMesh) triData.getTargetMesh();

Triangle[] triangles = mesh.getMeshAsTriangles(triData.getTargetBatchId(), null);

ArrayList<Integer> triIndex = triData.getTargetTris();



for(Integer i : triIndex) {



Triangle t = triangles;

t.calculateNormal();

normal.addLocal(triData.getTargetMesh().getLocalRotation().mult(t.getNormal()));

}

}



return normal.normalizeLocal();

}



private CollisionData reCalcCollision(CollisionData data) {



TriangleCollisionResults tcr = new TriangleCollisionResults();

data.getSourceMesh().calculateCollisions(data.getTargetMesh(), tcr);



return (tcr.getNumber() > 0 ? tcr.getCollisionData(0) : null);

}

}

protected void update(float interpolation) {

        // update the time to get the framerate

        timer.update();

        interpolation = timer.getTimePerFrame();

       

        prevLoc.set(player.getLocalTranslation());

       

        //update the keyboard input (move the player around)

        input.update(interpolation);

        //update the chase camera to handle the player moving around.

        chaser.update(interpolation);



        f.update(interpolation);

       

        delta.set(player.getLocalTranslation().subtract(prevLoc));

       

       

        test.checkForCollision(player, scene, prevLoc,delta);

       

       

The temp Vector which is always printed out remains zero



temp.zero();



for(int index = 0; index < triResults.getNumber(); index++)

temp.addLocal(getCollisionNormal(reCalcCollision(triResults.getCollisionData(index))));



if(temp != Vector3f.ZERO)

System.out.println("Collision Surface Normal: " + temp.normalize());



temp.normalizeLocal();

temp.multLocal(delta.length()).multLocal(1.1f);; // try this instead if you still have probs : temp.multLocal(delta.length()).multLocal(1.05f);

temp.addLocal(delta);



player.setLocalTranslation(prevLoc.add(temp));

}

If i have my world node scene as i have above as my spatial, will that mean that the collision detector will see the whole world as an object and constantly say there is a collision, what would be the best way to get around this problem???