get all objects in scene in python

im working on a lod for my game but i need the script to make every thing
but the map and the main objects to be invisible unless its infront of the camera, i tryed to do this with a radar sensor but it murderd performace, im so lost please help


There is an example LOD script in the BGE docs:

Use that method.

o to compicated for me to understand, someone post a .blend please, i dont get what im soposed to do with all that