Determine camera width in world coordinates /or/ detect if reached screen edge

Probably easy one, how can I find out in actual world coordinates how wide the camera is?

Or another solution for me would be to detect when a node reaches the left or right screen edge (or how ever that is called).

I pretty much want to prevent that something leaves the visible area seen by the camera.


// 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





Awesome, works!