Bug 856 : Implement u,v parameters for sphereDetail()
Last modified: 2008-08-10 12:48



Assigned To:

Attachment Type Created Size Actions
diff patch 2008-08-01 12:28 3.08 KB
sample of results image/pjpeg 2008-08-01 12:29 8.94 KB
sample sketch text/plain 2008-08-01 12:30 912 bytes
zipped source application/x-zip-compressed 2008-08-04 07:22 58.65 KB

Description:   Opened: 2008-07-24 10:10
Just a very low priority thought i had while working with some spheres of my own...

It might be nice to have different sphereDetail values for the u and v portions of the
sphere. If "u" is top-to-bottom and "v" is around, then v traverses twice the range of
u, producing slices that are more rectangular than square. If the number of u steps
were halved, or v doubled, then you might get a "nicer" sphere approximation at a
given detail level. (granted the word "nicer" is subjective, poor choice, just meaning
more even vertex spacing)

For both backwards compatibility and forwards flexibility, perhaps adding a
sphereDetail(float,float) to the api to separately set the values, leaving the existing
sphereDetail(float) to set both values identically. As a bonus, you'd get some nice
rhomboids and platonics at low levels of detail like 2,4 or 3,6 that aren't possible
Additional Comment #1 From fry 2008-07-31 14:55
Noted, patches welcome in the meantime.
Additional Comment #2 From davbol 2008-08-01 12:28

diff to 4147 implementing sphereDetail(U,V)
Additional Comment #3 From davbol 2008-08-01 12:29
sample of results
Additional Comment #4 From davbol 2008-08-01 12:30
sample sketch

sample sketch to test/compare/demo
Additional Comment #5 From davbol 2008-08-01 12:33
one possible implementation attached above
i changed the original sphereDetail variable to sphereDetailU and added
sphereDetailV -- i was torn about leaving the original as is, and just
adding "sphereDetail2" instead, as i wasn't sure if any other code would be affected
by the name change of the original... but figured it better to name things
appropriately (particularly in case someone ever checks if a texture is active and
emits uv coords inside sphere() then it should make sense for cylindrical mapping)
change/modify as appropriate, the diffs are relatively minor, cheers
Additional Comment #6 From fry 2008-08-02 10:15
oh cool, thanks.. can you post a zip of the three files you changed, or a
patch in actual patch format? i can't apply changes from the multi-file diff.
Additional Comment #7 From davbol 2008-08-04 07:22
zipped source

oops, zipped source attached. note that only PGraphics and PGraphics3D
"really" changed -- the only change in PApplet was the auto-stub for the api,
so not included here (and i shouldn't have diff'd it anyway!)

notes to amend reference: the minimum for U is still 3, but V will allow 2.
ie, sphereDetail(3,2) is lowest valid res.
Additional Comment #8 From fry 2008-08-10 12:48
Now patched in for 0145. Thanks a ton.