3d model and collision

Hi All,



Belated merry x’mas.



This time I loaded a house model in 3ds format.When the game starts I am inside the model and when I walk, I need to enable collision detection,Now please advise me what is the best option for enabling collision.I am still using jme2.Thanks in advance.

Ray casting… https://wiki.jmonkeyengine.org/legacy/doku.php/starter:hello_intersection

I have gone through that.Also, I am just trying to understand object walking example. I think that is more ideal here.It makes use of ray casting and triangle mesh.when the ray hits on any triangle, it just draws a triangle on the obstacle mesh and adjusts the camera position on Y-axis.But in my case, I am trying to cast the ray on z-axis i.e when the camera moves forward.I am almost getting the triangles drawn on the wall and adjust the camera position so that the camera does not fall through the wall.But this is not happening on all the time.For example, there are some stairs. The ray just hits only on some of the steps,not all even though I adjust the first person camera height.How can I achieve ,in this case, almost 100% ray hit on all the obstacle mesh ? This is the following code.

[java]

TrianglePickResults camResults = new TrianglePickResults() {



public void processPick() {

//initialize selection triangles, this can go across multiple target

//meshes.

int total = 0;

System.out.println(getNumber());

for(int i = 0; i < getNumber(); i++) {

total += getPickData(i).getTargetTris().size();

//}

//if (getNumber() > 0) {

PickData pData = getPickData(i);

ArrayList<Integer> tris = pData.getTargetTris();

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

System.out.println("…tris…"+tris.size());

if(tris.size() > 0) {

int triIndex = ((Integer) tris.get(0)).intValue();

Vector3f[] vec = new Vector3f[3];

mesh.getTriangle(triIndex, vec);

for(int x = 0; x < vec.length; x++) {

vec[x].multLocal(mesh.getWorldScale());

mesh.getWorldRotation().mult(vec[x], vec[x]);

vec[x].addLocal(mesh.getWorldTranslation());

}



Vector3f loc = new Vector3f();

pData.getRay().intersectWhere(vec[0], vec[1], vec[2], loc);

System.out.println("…loc…"+loc.toString());

loc.z += 5;

// if((loc.y - oldCamLoc.y) > 5f) {

// logger.info("too big");

// cam.getLocation().set(oldCamLoc);

// cam.update();

// } else {

cam.getLocation().set(loc);

cam.update();

oldCamLoc.set(cam.getLocation());



BufferUtils.setInBuffer(loc, pointWalk.getVertexBuffer(), 0);



FloatBuffer buff = walkSelection.getVertexBuffer();

BufferUtils.setInBuffer(vec[0], buff, 0);

BufferUtils.setInBuffer(vec[1], buff, 1);

BufferUtils.setInBuffer(vec[2], buff, 2);

BufferUtils.setInBuffer(vec[0], buff, 3);

//}

} else {

logger.info("No triangles");

}

}

}

};



[/java]