[java]
// particles[p] is an array of nodes I believe
// .coords is the Vector3f (location in space)
// width and height are the size of the ViewPort… can remember the call off the top of my head… but easy to find
if (cam.getDirection().dot(particles[p].coords.subtract(cam.getLocation())) > 0) { // is in front of the camera, bypass all others
screenCoords = cam.getScreenCoordinates(particles[p].coords); // get obj x, y coords in pixels
int sX1 = (int)Math.floor(screenCoords.getX()); // float to int (pixel)
int sY1 = (int)Math.floor(screenCoords.getY()); // float to int (pixel)
if (sX1 >= 0 && sX1 <= width && sY1 >= 0 && sY1 <= height) { // Is inside the viewport
// Now… do something with it
}
}
[/java]
3 Likes