Torus, Sphere, Cone clipping

This is a discussion on Torus, Sphere, Cone clipping within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I'm working on a project involving rendering of the Acis file format (sat). Rendering a torus, sphere or cone is ...

  1. #1
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297

    Torus, Sphere, Cone clipping

    I'm working on a project involving rendering of the Acis file format (sat). Rendering a torus, sphere or cone is simple enough. I had most of that working the first couple days. but Acis has a concept of "edges" that serve as bounding areas fot these surfaces. edges are basically curves in 3d space that as you can imagine must land on the surface itself.

    So here's the question to anyone who works in 3d often... Is there a nice algorithm for dealing with clipping on any of these surface types. I've got one semi developed but I'm not completely confident in it.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    There's a game programming board, you know.

    You know, I've noticed you constantly post programming-related questons here that are better suited to another board.

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    that's nice ken. this isn't a game question. it's a rendering/3d graphics question.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Whatever. Game/Graphics...they all deal with the same principal.

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    so let me get this straight. if a guy from industrial light and magic came on here looking to do add an effect to the character model generation code for the next movie you would send him to the game board? I see.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Yeah, sure, why not?

    You're not going to win in an argument here with me...I have this kind've shield...I think my doctor calls it "Gross stupidity" or something along those lines.

  7. #7
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > if a guy from industrial light and magic came on here looking to do add an effect to the character model generation code for the next movie you would send him to the game board?

    I'd ask him to dinner...

    This may be a stupid question, but have you STFW? I'm sure there're plenty of clipping algorithms out there.

  8. #8
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    this may or may not seem obvious but I wasn't looking for an argument here. ken, I'm deeply sorry that I soiled your precious GD board. I didn't realized how narrow general discussion could be. but then I expect that from you ken.

    Cheez however confuses me as someone I believe to be a professional. I'm familiar with your answer as one that anyone who asks a tough question gets consistently. Clipping a polygon to a plane is a common and easy problem that is easy to find on the web, yes. That is not what I'm asking. Edges, in Acis are 3d lines that represent the edge of the bounded area. It's not simple clipping.

    If you aren't interested in answering the question it would have been just as easy to let the thread slip down to oblivion. I withdraw the question.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #9
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Sorry, my fault, I misread the question. Besides, I wasn't trying to blow you off. Sometimes when I have a question I ask on the board before looking myself... I was wondering if this was the case here.

    I'll look around when I get home from work... I've got no experience with this, though.

  10. #10
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Originally posted by FillYourBrain
    this may or may not seem obvious but I wasn't looking for an argument here. ken, I'm deeply sorry that I soiled your precious GD board. I didn't realized how narrow general discussion could be. but then I expect that from you ken.

    Cheez however confuses me as someone I believe to be a professional. I'm familiar with your answer as one that anyone who asks a tough question gets consistently. Clipping a polygon to a plane is a common and easy problem that is easy to find on the web, yes. That is not what I'm asking. Edges, in Acis are 3d lines that represent the edge of the bounded area. It's not simple clipping.

    If you aren't interested in answering the question it would have been just as easy to let the thread slip down to oblivion. I withdraw the question.


    (Oh man, it got TWO rolleyes...now THAT'S sarcasticeriffic, folks!)

    Plus, you can't soil my GD board - it resides at FD, and it's already been heavily soiled.

  11. #11
    Shadow12345
    Guest
    I don't exactly know what you are doing but i do know how to clip out parts of a scene using any shape object in opengl. I dunno if you are using opengl so ill just post the algorithm hoping that this may help you. It involves using the stencil buffer, and again i don't know how much you know so I may just be wasting my breath. I only know the algorithm, I haven't used the stencil buffer myself except to make simple reflections

    1) enable the stencil buffer by calling glEnable(GL_STENCIL_TEST)
    2) disable the depth and color buffers, I think it's something like:
    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE) (turns off red, green, blue and alpha color components) turn off depth by calling glDepthMask(GL_FALSE)
    3) draw into the stencil buffer replacing the current values. If you wanted to draw a scene with the torus taken out of the middle (the shape of a torus would be left completely black) you would set up the stencil buffer, and then draw the torus into it, something like:
    glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF) this tells opengl's stencil function to always to the selected operation (doesn't even look at the values stored in the stencil buffer, my opengl super bible book uses a 1 instead of 0xFFFFFFFF (8 fs) but im currently looking at opengl game programming and that's what it uses, they both should work)
    after the glStencilFunc you call the stenciling operation that tells opengl what to do with the stencil buffer
    glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE)
    DrawTorus()
    4) The code above tells opengl to put the reference value of 1 at all of the pixels taken up by the torus object. but this doesn't help you, you want to actually be able to clip out objects. You turn the color and depth buffers back on (turned them off in step 2)
    In this example with the torus clipped out of the middle you want opengl to only draw where the reference value is not equal to 1 (where opengl didn't draw that torus). You do this by the following:
    glStencilFunc(GL_NOTEQUAL, 1, 0xFFFFFFFF)
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)

    DrawRestofScene();

    Ok I thought that would be simpler to explain. Again I don't know if that was helpful, but that is the way objects are usually clipped out of the scene with the single most widely used graphics api. I don't know if you have opengl books, I assume you do, now that I think about it. Ok well ta ta

    EDIT: I just realized that's not really an algorithm either

  12. #12
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    thanks shadow, but opengl is not an option. I need to do it. Don't worry about it. I've got a method in the works.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  13. #13
    Shadow12345
    Guest
    thanks shadow, but opengl is not an option. I need to do it. Don't worry about it. I've got a method in the works.
    Okey dokey I am curious to know how you are doing it, maybe you could give a general description of your process? Talk to you later.

    EDIT:
    Is there a nice algorithm for dealing with clipping on any of these surface types. I've got one semi developed but I'm not completely confident in it.
    Could you describe what exactly you meant by the 'clipping' of these 'surface types' ? I.e did you mean taking that shape of of these scene? Taking out the rest of the scene around the object? Etc. Are you working with actual models, or are you working with bezier curve type objects meaning your toruses and spheres and cones are described using equations? I think your project sounds really really cool fyb. You should get your company to hire me, too!
    Last edited by Shadow12345; 01-07-2003 at 07:54 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Volume of a Cone Equation always equals 0
    By Devolution in forum C Programming
    Replies: 11
    Last Post: 01-28-2009, 02:13 AM
  2. Lighting a Direct3D 9 mesh sphere
    By bennyandthejets in forum Game Programming
    Replies: 12
    Last Post: 02-14-2005, 12:19 AM
  3. Sphere code not working
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 10-03-2004, 07:29 AM
  4. Sphere backdrop problems
    By VirtualAce in forum Game Programming
    Replies: 26
    Last Post: 10-01-2004, 05:10 PM
  5. What am I doing wrong? Help please...
    By SprinterSteve in forum C Programming
    Replies: 9
    Last Post: 04-17-2003, 09:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21