Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Determining whether a point will be drawn.

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2008
    Posts
    2

    Determining whether a point will be drawn.

    Before asking a question, I ask you to excuse me
    about using POOR English.
    I learned English, but I'm not good at English.


    I learned that computer determines whether a point will
    be drawn or not.(By using z buffer)
    But, I want to know a information about it.


    I'm making a simulator, and to make it, I should
    know whether a point is located inside
    3d-objects(with arbitrary shapes) , or not.
    To know it, I decided to use OpenGL. I thought that
    if I draw a object and a point, then I can know the information
    about position relationship between a objects, and a point.

    But, after I succeed to draw it, I realize that there is no
    function that give the information that I want to know.

    Is there a algorithm, or method to know it?

    Thanks for any advice.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    166

    Re: Determining whether a point will be drawn.

    I assume that you represent your 3D objects in some kind of piecewise linear fashion, e.g. a triangle or quad mesh. If for this mesh your normals are consistent (they all point outwards) you could run a plane-distance test for all the triangles/quads in your mesh.

    You know that for your point to be inside the object, the distance to all the planes has to have the same sign (positive or negative depending on convention). This test would not require opengl and would be quite slow if your 3D objects are detailed.

    A way of doing it in hardware might be to render into two separate depth buffers. The first is for the closest triangles that are facing you, the second for the closest back facing triangles. Once you have these two textures (depth buffers), you just have to render your point and figure out which pixel/pixels it maps to and check that it is inside the interval spanned by your two textures.

    Please let me know if this is unclear!

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2007
    Posts
    107

    Re: Determining whether a point will be drawn.

    A very simple and effective approach, is to use the extension http://www.opengl.org/registry/specs...sion_query.txt if it's available to you.
    kind regards,
    Nicolai de Haan

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    999

    Re: Determining whether a point will be drawn.

    Quote Originally Posted by thinks
    You know that for your point to be inside the object, the distance to all the planes has to have the same sign (positive or negative depending on convention).
    This is only true for convex 3D models, not concave ones...

    N.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    166

    Re: Determining whether a point will be drawn.

    Nicolai: Will the occlusion_query not just let you know whether the point gets rendered or not? I.e. if the point is behind the 3D object the answer is false, otherwise true. This does not answer the question of whether it is inside or not?

    Nico: Well, the only requirement I can think of is that the primitives of the 3D object do not intersect. In this case there is a clear distinction between inside and outside. Is this what you meant?

    For really fast lookup one can also generate a signed distance field of the 3D object (google: level sets), but this is quite involved.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    999

    Re: Determining whether a point will be drawn.

    Not really...

    For convex 3D objects the distances to all primitives have the same sign:

    Code :
    _____________
    |           |
    |           |
    |    x      |
    |           |
    |___________|

    For concave 3D objects this is not the case:

    Code :
    _____________
    |        _  |
    |       | |_|
    |    x  | __
    |       |_| |
    |___________|

    N.

  7. #7
    Junior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    166

    Re: Determining whether a point will be drawn.

    Nico: You are right, thanks for the illustration.

    I will stick with recommending the signed distance field approach which works without exceptions for water-tight meshes.

    I also realized that the approach of using two depth buffers doesn't work either because of the concavity issues that Nico pointed out.

  8. #8
    Junior Member Newbie
    Join Date
    Feb 2008
    Posts
    2

    Re: Determining whether a point will be drawn.

    Thanks for your advice.

    I think that I should think more about it.
    I also should care about "Inner empty spaces"
    like a core-shell.
    (or more complex concave inner empty spaces).

    If you have a good idea,

    Please tell me by replying , or by sending E-mail to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •