Re: [Plib-users] Newbie question
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2002-10-11 12:01:38
|
David Megginson wrote: > Marco Bancale writes: > > > Sure, changing the far plane was my first idea, but in that way > > all the objects would not be culled (by the far plane) anymore! > > Isn't it? So, if I have 100 spaceships around the solar system, > > I should see all of them... always. I think this is not much > > optimized :). > > You can put the planets in a separate scene graph: > > ssgSetNearFar(1, 100000); > ssgCullAndDraw(ships_root); > ssgSetNearFar(1000, 100000000000000); > ssgCullAndDraw(planets_root); > > The problem is that when the ships get close to planets or the sun, > they might not be drawn properly (i.e. the planet will block the ship > when it shouldn't). That won't work...the values written into the Z buffer when rendering the ships would be meaningless after you'd changed the near/far planes for drawing the planets - so it would be quite possible for a planet that's a million miles away to occlude a ship that's just one mile away. There are some Z tricks you can play to avoid that (in principle) - but this way isn't one of them. You could draw the planets first, then clear the Z buffer, then draw the ships...but then a ship would never be occluded by a planet - no matter what. > As long as you have only 100 ships, you can just put each one under an > ssgRangeSelector to make sure it's not draw when it's too far away. > With ssgRangeSelector, you can use the same near/far plane for > everything and avoid the z-buffer strangeness. Yes - that's the 'right' answer. ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |