Hi,
in my program I implemented a firstpersonhandler with a crosshair. With this crosshair I want to control things in my world, e.g. when I "touch" the lamp on the table with the crosshair it should change its color and when I click with mouse it starts to light.
Up to now it works. When I look from a greater distance than 25f the crosshair is white, when I come closer to the lamp the crosshair is red and becomes white again when I turn around, but when I am very close to the lamp the crosshair stays red instead of becoming white when I turn left, right or another direction. :?
Maybe someone can help me to fix the problem. Thanks in advance.
private void activateLamp(Vector3f origin, Vector3f direction, boolean activate){
Sounds to me like you're just hitting the bounding box of the lamp when you are close and thus from the point of view of your code you are still on the lamp.
You'll need to start triangle accurate picking on the lamp model once you've hit the bounding box.
For pick able items I employ this method.
private final TrianglePickResults pickResults = new TrianglePickResults();
/**
* Takes a ray and returns the outcome of the intersection using that ray at triangle
* precision.
*
* @param ray
* @return the truth of the matter, ie if it is picked then return true.
*/
public boolean pick( final Ray ray ) {
pickResults.clear(); //new pick means we want new results!
calculatePick(ray, pickResults);
if (pickResults.getNumber() > 0) //have we intersected the bounding box?
return pickResults.getPickData(0).getTargetTris().size() > 0; //have we hit gold(triangles)?
else
return false;
}
Hi,
I solved my problem, I put the "crossHair.setTextColor(ColorRGBA.white);" close to the end of the function and deleted the others. Sometimes it's so stupid…but also so simple 
But thanks for your replies.