Re: [Plib-users] Identifying objects after loading an AC3D- modell
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2004-03-26 01:38:42
|
Michael Wessels wrote: > in my '.ac' file I have the comment field "Tribune1". How can I tell the > PLIB loaders to call a callback function in the application when they find > this comment field ? Write a function like this: ssgBranch *process_userdata ( char *data ) { if ( data == NULL || data [ 0 ] == '\0' ) return NULL ; if ( strncmp ( "Tribune1", data, strlen ( "Tribune1" ) ) == 0 ) { ssgBranch *b = new ssgBranch () ; /* ...or whatever you want this node to be */ /* whatever you need to do here */ return b ; } return NULL ; } Sometime after ssgInit() but before you load your model: ssgLoaderOptions *loader_opts = new ssgLoaderOptions () ; loader_opts -> setCreateBranchCallback ( process_userdata ) ; /* You may wish to set other loader options here */ ssgSetCurrentOptions ( loader_opts ) ; ...then just load your model in the usual way and whenever SSG needs to create a branch node, it'll call your 'process_userdata' function with the comment as the parameter. If this is a 'special' node, then you create the node and return it as the result. If it's not special then just return NULL and the loader will do something appropriate. ---------------------------- 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----- |