Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jumpman

Trubble with drawing a hole..

This topic is 5275 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All. I am trying to draw a hole model over my playfield (which is just a heap of tris in a big rectangle) but the playfield is drawing over the hole as obviously the z-buffer is closer to that set by the hole (the hole is drawn first) I''ve attached a picture of what I want to achieve and the model I am using.. I guess I need to set the z-buffer so it has the same flat z over the entire hole so when the playfield is drawn is will miss out the already set z-buffer.. I thought of drawning a transparent sphere over the hole but ofcouse drawing anything transparent actually don''t make it that far down the rendering pipeline so it won''t set the z. any ideas about how I can do what I want to do.. many thanks... Chris Jumpman - Under Construction - Future Pinball

Share this post


Link to post
Share on other sites
Advertisement
quote:
I guess I need to set the z-buffer so it has the same flat z over the entire hole so when the playfield is drawn is will miss out the already set z-buffer.

I''m assuming the top of your "hole" model is in fact a hole, ie. it has no geometry. That''s a problem; If you draw nothing on something, you get something, not nothing. In such a case the only thing a z-buffer adjustment will do is draw the entire hole model on top of your playfield (including sides and all, which will look silly)

quote:
I thought of drawing a transparent sphere over the hole

Same problem as above; Drawing an invisible sphere over a visible playfield gives you a visible playfield, not an invisible one.

I''m primarily a Direct3D programmer and there may be something OGL specific I''m missing here but the most sensible solution to me would be to cut holes in the actual geometry of the playfield.

Share this post


Link to post
Share on other sites
i''ve been thinking that I first draw a mask of the top of the hole (the hole can be of a few different shapes) which would set the zbuffer to the top of the hole.. then force draw (by turning off the z-buffer) the hole graphics (will will draw over the mask) and then the playfield (or what ever surface the hole is on). that should work except that the ball (if sitting in the hole) whould get half cut off.. hmm..

Share this post


Link to post
Share on other sites
Have you considered alpha blending; that is, making the "hole" in the texture of the board? If that''s not suitable for some reason, I''d also recommend making an actual hole in the board geometry.

-Nik

Share this post


Link to post
Share on other sites
the main problem I have is that the editor i''m creating to create these tables has to be simple for everyday people to understand..

the hole (can be any shape (well as least one of a few) aswell as it might have stuff in the hole (like a pinball kicker which has a seat for the ball to sit on aswell as a metal arm to hit the ball)..

the playfield is generated to match the sizes the user puts in.. its not a model i can cut geometry outof without doing a lot of maths.. also since I can have multiple surfaces (at different heights), these also may have sunken objects..

I was wondering if I could use the stencil buffer in anyway ?.. draw my top mask onto the stencil and use that as a mask when rendering the hole model.. this would then only draw what would be visible from the top lip.

this would mean that I wouldn''t be able to use the stencil buffer for shadows late on though ...

although I have used the stencil buffer before on my last project it did slow things down a bit (though this time I would only need to enable it when I go to draw objects of this type..)



Share this post


Link to post
Share on other sites
You don''t need to use the stencil buffer. Create your alpha mask of the playfield as a texture, switch on alpha blending and modulate your colour map with your texture mask. Areas on the mask with the value of 0 will not be drawn and the hole geometry underneath will be visible. Areas on the mask with the value of 1 will be drawn.

Share this post


Link to post
Share on other sites
i agree thats how ''I'' would do it.. but my program is basically a construction set.. ie.. somebody plays with the editor and goes "I would like a hole object here" they shound;t need to worry about setting alphas and that.. my main need is to keep it simple.. so far I''ve had no problems with other objects only this sunken one due to obvious reasons.

i''m guess the stencil buffer is probably my only option..



Share this post


Link to post
Share on other sites
how about this one:

first you draw your whole playfield

next for each hole do

do some fancy maths to make your hole it''s own height over the playfield and positioned the propertional value in the direction of the camera position

draw the hole with the modified properties with depth_testing disabled and culling backfaces

Share this post


Link to post
Share on other sites
quote:
somebody plays with the editor and goes "I would like a hole object here" they shound;t need to worry about setting alphas and that


Just recalculate the alpha map every time an object is moved/added/removed. The calculation of the alpha map is fairly simple: Start with an opaque map. For each hole, draw a black circle on the map with the center position and radius of the hole model. The users themselves don''t have to worry about it.

Share this post


Link to post
Share on other sites
the only downside to that is that I have no control of what texture (even if any) is used for any surface (as it might just be a transparent plastic for raised surfaces)..

ofcourse setting the alpha of any texture is easy enough but getting the right positions depending on the textmap size (a low res texture would be a low res hole) so it perfectly lines up with the world 3d cords might be tricky though do able..

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!