# Populate camera background

Hello

I want populate the view of my camera. The background object are only point (like stars), but i've got 2 relate problem(solving one will solve the other)

1. how can I translate all the point inside the camera view?
2. when a point goes outside the camera view (tempCamera.contains(point.getModelBound())) i want move the point at the border of the camera view (resetting only the axis that make the point outside, if possible)

i'm using jme2.

Please gods of mathematics show yourself

I dont know why you would do that but here it is

``` // Utility methods   /**    * Computes the available height for the reels at a distance from the camera    */   public static float getFrustumHeightAtDistance(float fovY, float z) {     return FastMath.tan(fovY / 2 * FastMath.DEG_TO_RAD) * z * 2;   } // getFrustumHeightAtDistance   /**    * Computes the available width for the reels at a distance from the camera    */   public static float getFrustumWidthAtDistance(float fovY, float z, float aspectRatio) {     return getFrustumHeightAtDistance(fovY, z) * aspectRatio;   } // getFrustumWidthAtDistances // a camera plane for calculating z distance Plane tmpPlane = new Plane(camera.getDirection(), camera.getLocation()); // for every star do: float zDistanceFromCamera = tmpPlane.pseudoDistance(starIWantInside.getWorldBound().center); // now you can calculate the width and the height of the frustum at the z-distance of the star you want to move inside the camera with the methods given above and you can set the localTranslation in the X and Y axis of the star by checking it against half the width and height with FastMath.min() and FastMath.max() ```

ok, thank you for the code but i've got some problemâ€¦ the class Plase dosn't have a constructori like your(it's Plane(Vector3f normal, float constant)  )

Now i do:

``` Plane tmpPlane = new Plane(tempCamera.getDirection(), 0/*tempCamera.getLocation()*/); // for every star do: for (int i=0; i < starSize; i++){            float zDistanceFromCamera = tmpPlane.pseudoDistance(star[i].getWorldBound().getCenter());            float yCam=getFrustumHeightAtDistance(tempCamera.getLocation().x, zDistanceFromCamera);            float xCam=getFrustumWidthAtDistance(tempCamera.getLocation().y, zDistanceFromCamera, 1);            Vec2 camMin=tempCamera.getLocation().sub(xCam/2, yCam/2);            Vec2 camMax=tempCamera.getLocation().add(xCam/2, yCam/2);                 if ( camMin.x>star[i].getWorldBound().getCenter().x )                        star[i].setLocalTranslation(camMax,x, star[i].getWorldBound().getCenter().y, star[i].getWorldBound().getCenter().z);                 //ecc...... } ```

is it right?

p.s. sorry for the late answer, i've tested today your code :D

right, but that should work:

``` Plane tmpPlane = new Plane(camera.getDirection(), camera.getDirection().dot(camera.getLocation())); ```