Re: [Plib-users] Scaling loaded models - clipping problems
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2001-01-17 05:43:49
|
Sam Stickland wrote: > > Hi, > > I'm having some difficultly scaling loaded models in SSG. I have an model > in AC3D format that I wish to draw in various sizes about the scene. So my > first thought is to load the model, and then stick relevant scaling > transforms above it. > > a 0 0 0 > 0 a 0 0 > 0 0 a 0 > 0 0 0 1 > > to scale by a in all three axis. But I get clipping problems when I do > this. It appears that SSG isn't updating the bounding sphere? (I've tried > calling recalcBSphere() on the returned entity from ssgLoadAC). Am I doing > anything obviously wrong here? Yeah - scaling is kinda *broken* in SSG. It turns out to be a real pain to implement because there isn't an easy way to maintain the bounding spheres during scaling without clobbering the performance of non-scaled models. I suggest running the ssgFlatten command which multiplies out transforms... or better still, just write a little tree walk that visits all the leaf nodes and multiplies all the vertices by 'a'. Scaling is generally a bad idea in OpenGL anyway because your vertex normals are scaled by the matrix too - that screws up your lighting. You can glEnable the renormalize flag (I forget the token name) - but that incurs an extra sqrt per vertex - which is pretty serious in itself - and in many OpenGL implementations, this throws you off the 'optimised path' and your program runs 50x slower or something awful. We should really remove scaling from the SSG API - but then you wouldn't be able to pass us an arbitary matrix - and that's too useful. This needs to be mentioned in the manual. -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net http://freeglut.sourceforge.net |