Re: [Plib-devel] searching scenegraphs
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2005-03-27 16:22:07
|
Bram Stolk wrote: > Hi there, > > I believe that plib's search functionality is currently limited to > searching a direct child in a branch, by ssgEntity pointer. There > does not seem to be a recursive search function, neither a search > on different criteria. (I checked docs, and ssg includes, but could > not find this). > > I would like to be able to search by name, in a hierarchy. > > What would be the proper thing to do? > > - Do this in application space, and let plib be as is? That's my current theory. The problem with a more generalised search function is to find a way to describe to SSG what the terminating conditions are. Doing the search yourself is a matter of a dozen lines of programming - it would be very easy for a generalised searching mechanism to consume a dozen lines of code just in telling it the precise conditions it's searching for. > - Do this in plib, as a non-member func in ssg, e.g. > ssgEntity *ssgFind(const char *name, ssgEntity *tree); That might be appropriate as an ssgAux function. > - Do this in a more generic way, so that: > * different criteria can be used, other than name-base. > * multiple hits can be returned. To be at all useful, I think it needs that degree of generality. If you are just trying to do something to each node with a particular name, it's easier to do it as the model loads using the various node creation callbacks. > - Model it after SGI's OpenGL|Performer pfLookupNode, which is: > pfNode* pfLookupNode(const char *name, pfType* type); I never found that to be very useful back when I last used Performer. I'd always want either more generality (eg: Find all the leaf nodes that contain purple polygons - or find all the transform nodes with rotation components) - or I'd be frustrated because the 'type' match might need to be 'isAKindOf' or 'isExactType' and Perfomer only does one of those (I forget which). If you really think you can come up with something good - make it an ssgAux function - that way we don't add weight to the core SSG nodes. ---------------------------- 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----- |