I know it's an old thread and probably the original poster isn't interested anymore but still i'd like to make a contribution.
I encountered the same problem and wrote this method:
/**
* Converts the given world coordinates into screen coordinates.
*
* @param p Point in world coordinates
* @return Position on the screen
*/
public static Point2f worldToScreen (Canvas3D canvas, Point3f p) {
// get the model-view and the projection matrix
Matrix4f mP = canvas.getView().calculatePerspective(canvas.getWidth(),
canvas.getHeight()).getMatrix4f();
Matrix4f mM = canvas.getView().getModelViewTransform().getMatrix4f();
// convert the point into a vector of length 4
Vector4f v = new Vector4f(p.getX(), p.getY(), p.getZ(), 1);
// compute the distance between the eye and the view plane
float vpd = 1.0f / FastMath.tan(canvas.getView().getFieldOfView());
// v' = P x M x v
v.mul(mM, v);
v.mul(mP, v);
// scale the resulting vector so that it lies in the view plane
float x = v.getX() * vpd / v.getZ();
float y = v.getY() * vpd / v.getZ();
// convert normalized view plane coordinates into screen coordinates
float xs = (float) canvas.getWidth() * (x + 1f) / 2f;
float ys = (float) canvas.getHeight() / 2f * (1f - y);
return new Point2f(xs, ys);
}
Marvin, can you please have a look at it and tell me if it makes sense? If it is indeed correct you could add it to Xith as a utility method.