Hi,
I need to compute the intersection between a TriMesh and a Box. This computation needs to be performed when the Box is visible, but the TriMesh is not. Is such a use case possible at all using the jMonkeyEngine?
Thanks,
Dan
Sure, bounding intersection is a math check and does not care about rendering
Thanks for the reply! It seems to work, indeed. but not as I expected.
Please see the screenshot below. The colored thing is a TriMesh, the textured thing is a Box. The green line is the collision that the findCollision returns to me. Do you have an idea of what I do wrong?
The following methods are called on both nodes:
setModelBound(new OrientedBoundingBox());
updateModelBound();
CollisionTreeManager.getInstance().updateCollisionTree(node);
The collision code is something like this:
CollisionResults results = new TriangleCollisionResults();
results.clear();
node.calculateCollisions(_inlineBox, results);
int nr = results.getNumber();
if (nr > 0) {
for (int i = 0; i < nr; i++) {
CollisionData data = results.getCollisionData(i);
...
for (int j = 0; j < data.getTargetTris().size(); j++) {
int triIndex = data.getTargetTris().get(j);
_inlineBox.getTriangle(triIndex, tempVertices);
for (Vector3f tempVertex : tempVertices) {
...
}
...
}
Line intLine = new Line("Intersection " + nrInt, vertices.toArray(new Vector3f[0]), normals.toArray(new Vector3f[0]), colors.toArray(new ColorRGBA[0]), textureCoords
.toArray(new Vector2f[0]));
intLine.setSolidColor(new ColorRGBA(0, 1, 0, 1));
intLine.setLineWidth(5);
intLine.setAntialiased(true);
intLine.setMode(Line.CONNECTED);
...
}
http://wush.net/svn/geocraft/geocraft/trunk/wiki/demo/intersection.png
Thanks a lot,
Dan
The screenshot:
Sorry, my mistake!
I was reusing the tempVertices instance in the call below:
((TriMesh) node).getTriangle(triIndex, tempVertices);
Dan