Results 1 to 4 of 4

Thread: Multiple glClipPlane to create object

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2009
    Location
    USA
    Posts
    3

    Multiple glClipPlane to create object

    I'm fairly new to OpenGL and haven't done anything with it in quite a while and never something this advanced. I need to be able to create an object essentially out of clip planes. The user will start off with a cube (or other simple starting shape) and be slicing off sections. I found a section on this site "Capping Clipped Solids with the Stencil Buffer" and that sounds just about exactly what I need but my end objects could end up having a couple of hundred planes (though more commonly 50-100). The scene itself will be very simple, this one object is it, no special textures or anything like that.

    So, is that likely to work as expected? Starting with a cube and using clip planes and capping to cut it down to what I need? Will having that many clip planes be any serious performance problem? This is going to be a 3D modeling program of sorts so while performance matters, I don't strictly need so many fps for a game.

    Thanks for any suggestions or advice.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649

    Re: Multiple glClipPlane to create object

    Quote Originally Posted by Ashley Perrien
    I need to be able to create an object essentially out of clip planes. The user will start off with a cube (or other simple starting shape) and be slicing off sections ... could end up having a couple of hundred planes (though more commonly 50-100).
    Sounds like CSG or at least Computational Geometry.

    Question: What do you want to see on the clip planes? A smooth surface? Or a voxelized step surface?

    I'm going to assume the former, in which case I'd suggest that while you'd likely use OpenGL to interactively render the resulting shape, you wouldn't use OpenGL to compute it. I mean, we're talking about a bunch of plane-plane intersections to come up with vertices, edges, and faces.

    Check out CGAL. I haven't used it -- only read some blog posts by folks that have. Hopefully others will chime in with other similar libraries.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2009
    Location
    USA
    Posts
    3

    Re: Multiple glClipPlane to create object

    Quote Originally Posted by Dark Photon
    Sounds like CSG or at least Computational Geometry.

    Question: What do you want to see on the clip planes? A smooth surface? Or a voxelized step surface?
    I haven't done much in the past so I'm not sure what a voxelized step surface even is yet. But plan flat surfaces are fine, no special effects required.

    Quote Originally Posted by Dark Photon
    I'm going to assume the former, in which case I'd suggest that while you'd likely use OpenGL to interactively render the resulting shape, you wouldn't use OpenGL to compute it. I mean, we're talking about a bunch of plane-plane intersections to come up with vertices, edges, and faces.
    And I assume with that you're assuming there would be significant performance problems?

    I'm currently working on a proof of concept application to see how it would do but since I only worked on open GL for a few weeks about a year ago, I've forgotten pretty much all of it so am starting over from scratch. I won't be able to see how or even if it's possible for probably a couple of weeks. That's why I'm hoping for a quick answer here that yes it most likely will or will not work.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649

    Re: Multiple glClipPlane to create object

    Quote Originally Posted by Ashley Perrien
    Quote Originally Posted by Dark Photon
    Question: What do you want to see on the clip planes? A smooth surface? Or a voxelized step surface?
    I haven't done much in the past so I'm not sure what a voxelized step surface even is yet. But plan flat surfaces are fine, no special effects required.
    Something like this:

    where you end up doing in/out tests per 3D cell (voxel) or point, yielding something like this:

    or possibly even smoothed out some by applying marching cubes/tetrahedra/etc. instead of just per voxel in/out tests. Pretty sure you didn't want this but wanted to be sure because this is something you can parallelize well on a GPU.

    Quote Originally Posted by Dark Photon
    I'm going to assume the former, in which case I'd suggest that while you'd likely use OpenGL to interactively render the resulting shape, you wouldn't use OpenGL to compute it. I mean, we're talking about a bunch of plane-plane intersections to come up with vertices, edges, and faces.
    And I assume with that you're assuming there would be significant performance problems?
    Sort of, yeah. It's just not one of those things that intuitively would seem to parallelize really well. Might as well find the mesh on the CPU and then render it with the GPU. But then again, I'm not a GPGPU guy and there might be some amazing OpenCL/CUDA algorithm for this that runs circles around a CPU on the GPU.

    The fact that you're cutting with infinite planes I think implies you will end up with a convex polyhedra, which may mean there's a pretty easy algorithm for coming up with the verts, edges, and faces. Maybe, for each plane, cull away any verts/edges/faces totally behind the plane, blast out all the intersections with all the existing edges, and retesselate affected faces.

    Then again, maybe this would parallelize well on the GPU: that is, brute-force parallel-compute all the 3-plane intersection points, parallel-merge to a common point list, then brute-force parallel-cull the entire pointset against each plane. The remaining points are the verts of the convex polyhedra. Snap on a mesh (build edges/faces) and you're done.


Similar Threads

  1. How to create multiple windows on multiple displays with GLFW
    By Wally Lee in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-30-2017, 09:52 AM
  2. Should I create multiple VBO's in this situation?
    By hashbrown in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 09-21-2016, 06:42 AM
  3. select object from multiple object and rotate
    By somnath in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-05-2011, 04:57 PM
  4. Can somebody help me to Create Multiple Viewports?
    By deviputhran in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-26-2006, 06:41 AM
  5. How to create Multiple windows
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-13-2002, 11:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean