   Objects visibility for a camera
  I would like to know if there is an easy way to know if an object is visible from a specific camera?I thought i could use a modified z-buffer that would also include object ID along depth info, but i am no expert in opengl... Does someone know how i could implement this or if there is an easier way?   
  Would frustum culling help? Frustum culling tests polygons against the viewing frustum, which is the mesh which defines the region visible by the camera. This would test wether an object is visible or not...   ;  Yes it looks like it could help :)The thing is that it involves lots of maths, that's why i hoped there was a way to tell opengl to make a z-buffer..Is frustum culling the easiest way to do it?It doesn't need to be very fast or efficient. There are very few objects on display.Thanks!   ;Quote:Original post by deb123Yes it looks like it could help :)The thing is that it involves lots of maths, that's why i hoped there was a way to tell opengl to make a z-buffer..Is frustum culling the easiest way to do it?It doesn't need to be very fast or efficient. There are very few objects on display.Thanks!No Raw frustum culling is not very fast, especially with large scenes. But smart frustum culling is VERY fast and efficient.The idea is to have some way of sub-dividing your entire world, commong methods are BSPs or Octrees. You then only apply frustum culling onto your octree or BSP tree to determine visible sets of polygons. Consider if you had a gun model, you could test whether the outerbounding box of the gun model is inside the frustum and render accordingly. If the gun is 1000polys then testing each one is absurd.;Quote:Original post by deb123Yes it looks like it could help :)The thing is that it involves lots of maths, that's why i hoped there was a way to tell opengl to make a z-buffer..Is frustum culling the easiest way to do it?It doesn't need to be very fast or efficient. There are very few objects on display.Thanks!Overall, frustum culling is probably the best way to go; for references, just google 'frustum plane extraction', 'frustum culling' 'frustum AABB test', and similar phrases.There is a fair amount of math and base code required though, so if performance is not an issue and you just want to get something up and running, you might look into OpenGL feedback mode. Google 'opengl picking'; what you would want to do is basically 'pick' using feedback mode, except that the picking frustum will be the same as the view frustum.I might also ask what you need it for; is it an excercise? I ask because if you only have a few objects, frustum culling isn't important anyway, so I'm wondering why you need to know whether certain objects are visible from the camera (maybe there's a better solution for your particular needs).   ;Quote:Original post by jykGoogle 'opengl picking'; what you would want to do is basically 'pick' using feedback mode, except that the picking frustum will be the same as the view frustum.It looks like this is exactly what i need!From what i understand, it's ok if the view frustrum is the same as the picking frustrum, since i just need to get a list of the objects on the screen that are visible.Quote:Original post by jykI might also ask what you need it for; is it an excercise? I ask because if you only have a few objects, frustum culling isn't important anyway, so I'm wondering why you need to know whether certain objects are visible from the camera (maybe there's a better solution for your particular needs).Here's the background story :)I joined a small research team at university so i can work on my project (needed to get my diploma). They have a 3d program, and one of its functions should output a list of all the objects displayed on the screen. But this function isn't working properly.The guy that wrote the program left some time ago, and from what i've seen, most of the remaining programmers only know java. Since i know C/Cpp quite well, they asked me if i could fix this problem.I'd like to help them, but i need to keep in mind that i'm going to add code in a program that i never worked on, and  i don't want to spend weeks on the problem. The 3d part of the program is very simple, there are few objects, which almost never move. That's why i need a simple solution, not necessarily an optimal one.Something too complex would be playing with fire since i didn't develop any part of the software; the code I would add might conflict with some other part of the program, and i could spend my days bug-hunting.My knowledge of opengl is very basic. A few years ago, I worked in a company on a virtual reality program, but most of the opengl programming was done by someone else...So to sum it up, i just need something that will give me a list of all the visible 3D objects displayed on the screen. If possible, it would also be nice (though not required) if there was a way to tell which proportion of an object that is visible (i.e. if the object is partially obstructed by another, it would say "70% object ABC is 70% visible).But object picking with gluPickMatrix looks like the easiest way to implement this.Thanks a lot! :)(Sorry if my english is a bit strange; i don't speak it very often.)edit: i continued reading on the subject, and it seems another simple solution would be to use "color coding": give each object a different color, and render the view in a off-screen buffer.   