Picking works with sphere but not with custom mesh

Hello,

my picking code works perfectly with standard sphere mesh. However, it does not work with my own mesh. The mesh is displayed correctly but the ray does not hit it. What exactly do I have to take care of when writing my mesh code?

Thanks.

Regards,

Equi

After setting the mesh data you have to update the collision info.

Hi,

nop. Does not work. I have added

[java]mesh.createCollisionData();[/java]

at the end of my data after the mesh has been created…

[java]



mesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(verticesArrayList.toArray(new Vector3f[]{})));

mesh.setBuffer(Type.Normal, 3, BufferUtils.createFloatBuffer(normalsArrayList.toArray(new Vector3f[]{})));

mesh.setBuffer(Type.Index, 1, BufferUtils.createIntBuffer(integerArray));



mesh.createCollisionData();

[/java]

but it still does not work.

The code

[java]

Ray ray = new Ray(origin, direction);

CollisionResults results = new CollisionResults();

try {

rootNode.collideWith(ray, results);

} catch (Exception e) {

}

[/java]

returns

[java]results.size()==0[/java]

Thanks for help.

Regards,

Equi

You have to call updateBound() after you change the mesh

perfact, it works.

Thanks a lot.



Regards,

Equi