Thread: RE: [Plib-devel] ssgaSpheres?
Brought to you by:
sjbaker
From: McEVOY, N. <nic...@ba...> - 2005-02-02 04:41:40
|
Bram Stolk wrote: <...snip...> > bounds0: center=-0.124761,0.005011,0.317507 radius=1.860521 > bounds1: center=0.000000,0.000000,-0.000000 radius=0.947555 >...which looks wrong for three reasons: >1) radius of non latlong sphere is roughly twice as big >2) radii are not 1.0 >3) center of bounding sphere for non latlong sphere is not 0,0,0 I had a similar problem (and its still a problem nearly 3yrs later - I never had time to dig deeper into the PLIB code) - but in my case I was loading a sphere from AC3D (a 3D modelling tool) of radius 10 and centred at 0,0,0 - but when I check its bounding sphere ... getBSphere() I got bounding sphere radius return 17.9544 ??? And the centre of -1.27190,-0.726630,0.303701 ??? See http://sourceforge.net/mailarchive/message.php?msg_id=1153817 Sorry I don't yet have a solution. :( Cheers, Nick |
From: McEVOY, N. <nic...@ba...> - 2005-02-02 23:06:59
|
Steve wrote: >If you follow that tortured explanation then you'll see that the bounding >sphere for a sphere is not an exact fit for the sphere. Thanks for the explanation Steve - that clears my issue up. And sorry Bram, for me jumping in and confusing the issue - my problem was obviously not the same as yours. Cheers, Nick |
From: Wolfram K. <w_...@rz...> - 2005-02-03 13:46:19
|
Nick wrote: >Thanks for the explanation Steve - that clears my issue up. Indeed.=20 Taking the BBox of a sphere and then the BSphere of it will lead to a factor of sqrt( 3 ) which is quite accurately what you observe. Bye bye, Wolfram. |
From: Steve B. <sjb...@ai...> - 2005-02-02 06:33:04
|
McEVOY, Nick wrote: > Bram Stolk wrote: > <...snip...> > >> bounds0: center=-0.124761,0.005011,0.317507 radius=1.860521 >> bounds1: center=0.000000,0.000000,-0.000000 radius=0.947555 >>...which looks wrong for three reasons: >>1) radius of non latlong sphere is roughly twice as big >>2) radii are not 1.0 >>3) center of bounding sphere for non latlong sphere is not 0,0,0 > > > I had a similar problem (and its still a problem nearly 3yrs later - I never > had time to dig deeper into the PLIB code) - but in my case I was loading a > sphere from AC3D (a 3D modelling tool) of radius 10 and centred at 0,0,0 - > but when I check its bounding sphere ... getBSphere() I got bounding sphere > radius return 17.9544 ??? And the centre of -1.27190,-0.726630,0.303701 ??? The code for computing a really tight bounding sphere around an object is horribly, horribly expensive. Since PLIB's bounding sphere is only used for optimising rendering, it doesn't need to be perfect. What it does is to compute the maximum and minimum X, Y and Z coordinates - uses that to find the median X, Y and Z and makes that the center of the sphere - the radius is the smallest sphere to enclose an axially aligned box that extends from (minX, minY, minZ) to (maxX, maxY, maxZ). If you follow that tortured explanation then you'll see that the bounding sphere for a sphere is not an exact fit for the sphere. Now - to take this one step further - an ssgaSphere is more than one ssgLeaf node. The system has to compute the sphere around each of those and then the sphere around those spheres. Don't sweat it. It's not *supposed* to be a tight fit - and it isn't. You could try to look for a more intelligent bsphere calculating algorithm - but unless it's REALLY efficient, we won't want it no matter how accurate it might be. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |
From: Bram S. <br...@sa...> - 2005-02-02 13:21:13
Attachments:
balls.jpeg
|
On 02/02/05 09:30:56, Steve Baker wrote: > If you follow that tortured explanation then you'll see that the > bounding > sphere for a sphere is not an exact fit for the sphere. Steve, This is not the problem. As I said, the spheres are also visually wrong. If you render both styles, they have different sizes. And both sizes are also a mismatch against a sgSphere with radius 1, judging from the hits I get from sgIsect() (although this latter problem could be a bug in my isect program). Rendering this scenegraph: scene =3D new ssgRoot ; balltrf0 =3D new ssgTransform ; balltrf1 =3D new ssgTransform ; ball0 =3D new ssgaSphere(); ball1 =3D new ssgaSphere(); ball0->setLatLongStyle(FALSE); ball0->setSize(1.0); ball0->setColour(blu); ball1->setLatLongStyle(TRUE); ball1->setSize(1.0); ball1->setColour(red); scene->addKid(balltrf0); scene->addKid(balltrf1); balltrf0->addKid(ball0); balltrf1->addKid(ball1); sgVec3 pos0=3D{-1,0,0}; sgVec3 pos1=3D{ 1,0,0}; balltrf0->setTransform(pos0); balltrf1->setTransform(pos1); ssgSimpleState *state =3D new ssgSimpleState(); state->setShininess(8.0); ball0->setKidState(state); ball1->setKidState(state); sgCoord campos ; sgSetCoord ( & campos, 0.0f, -5.0f, 1.0f, 0.0, 0.0f, 0.0f ) ; ssgSetCamera ( & campos ) ; Will give you the output as can be seen in attached jpeg. This is clearly wrong. Changing topology of the sphere should not affect size. I also expect the mismatch against sgSphere. I have some isect test prog if you want that. Also, you have to make a decision on the definition of ssgaSphere of size 1: do you want its radius to be 1, or its diameter? From what I'm seeing: neither sphere style has neither radius 1 nor diameter 1, judging from isects with sgSphere radius 1. Bram |
From: Steve B. <sjb...@ai...> - 2005-02-02 15:50:57
|
Bram Stolk wrote: > As I said, the spheres are also visually wrong. > If you render both styles, they have different sizes. > And both sizes are also a mismatch against a sgSphere > with radius 1, judging from the hits I get from sgIsect() > (although this latter problem could be a bug in my isect program). Ah - OK. So it looks like there is a radius/diameter screwup somewhere in ssgaSphere. > This is clearly wrong. Changing topology of the sphere should > not affect size. I also expect the mismatch against sgSphere. Indeed. > Also, you have to make a decision on the definition of ssgaSphere > of size 1: do you want its radius to be 1, or its diameter? The size of all of the ssgaShape's is supposed to be the overall size - so it *should* be the diameter. I have committed a fix for the sphere (there was also a problem with the colour of the teapot that needed fixing). I've added an example program for the ssgaShapes in examples/src/ssg/shapes > From what I'm seeing: neither sphere style has neither radius 1 nor > diameter 1, judging from isects with sgSphere radius 1. I don't know about the isect results - I have not checked that. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |
From: Bram S. <br...@sa...> - 2005-02-02 16:35:20
|
On 02/02/05 18:48:47, Steve Baker wrote: > I've added an example program for the ssgaShapes in > examples/src/ssg/shapes Ok thanks. The ssgaSizes are now the same, as demonstrated by your test prog. BTW: For me, the lighting on the teapot is really messed up. There seems to be no shading. (only cyan ambient reflection, and a specular reflection that seems way off). No shading (neither gouraud nor flat). Is this the same for you? Additionally, the mismatch with sgSphere is still there. See my other post on the isects. Bram =20 |