Re: [Plib-users] Identifying objects after loading an AC3D- modell
Brought to you by:
sjbaker
From: Michael W. <mic...@ti...> - 2004-04-26 17:38:44
|
Hi Paolo, I understand what you mean and I agree. I have tried to walk through the tree but not successfull. Can you give me some lines of C/C++code how to do it ? Best regards Michael ----- Original Message -----=20 From: "Paolo Leoncini" <p.l...@ci...> To: <pli...@li...> Sent: Monday, April 26, 2004 9:59 AM Subject: R: [Plib-users] Identifying objects after loading an AC3D- model= l Michael, Is the problem setting custom properties for objects/materials? The approach based on inline comments doesn't meet my favour since a) it works only for ascii-text file (3D) formats such as AC3D, b) needs of manual editing as you update the file (risk to loose such addenda or to be enabled to do it only in its final version). I'm in favour of this alternative solution: A) manually write a simple text properties file - I use kinda .ini format: [property] Object-name Params ... [property] Material-name Params ... B) learn to parse your format, and, after having loaded the 3D data, walk the graph by first identifying nodes by name (either objects or materials, the getName() method works on both, and on non-states you have also the getByName() utility) - all 3D formats allow to identifiy objs/mats by a textual name - then setting node properties depending on the directive in the file. I use properties like envmap, mirror, no-lit (disable lighting), etc, some acting on leafs and others on states. This approach is not so heavy in the implementation, keeps 3D data and custom properties separate, and works for all 3D data formats. Greetings - Paolo > -----Messaggio originale----- > Da: pli...@li... > [mailto:pli...@li...] Per conto di > Michael Wessels > Inviato: venerd=EC 23 aprile 2004 18.47 > A: pli...@li... > Oggetto: Re: [Plib-users] Identifying objects after loading > an AC3D- modell > > > Dear Steve, > I have implemented what you said. > But when I debug the application the code never jumps in the > function ssgBranch *process_userdata ( char *data ) . My > ac-file looks folowing:. > > AC3Db > MATERIAL "ac3dmat1" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 > spec 0.5 0.5 0.5 shi 10 trans 0 MATERIAL "ac3dmat3" rgb 1 0 > 0 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 > trans 0 MATERIAL "ac3dmat7" rgb 0.270588 0.52549 0.454902 > amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans > 0 MATERIAL "ac3dmat9" rgb 0 0 1 amb 0.2 0.2 0.2 emis 0 0 0 > spec 0.5 0.5 0.5 shi 10 trans 0 MATERIAL "ac3dmat13" rgb > 0.533333 0.533333 0.533333 amb 0.2 0.2 0.2 emis 0 0 0 spec > 0.5 0.5 0.5 shi 10 trans 0 OBJECT world kids 2 OBJECT group > name "Race-Course" loc 0.560112 0.0001 0.361112 kids 4 OBJECT > poly name "poly" loc -0.240913 0 -0.282012 texture > "ASSPHALT.bmp" texrep 10 10 numvert 10 -0.1712 0 -0.1475 > -0.0751 0 -0.1577 0.0686 0 -0.1675 0.2239 0 -0.1789 0.3284 0 > -0.1871 0.3219 0 -0.2051 0.1242 0 -0.1854 -0.0899 0 -0.1724 > -0.1744 0 -0.1613 -0.1744 0 -0.1613 numsurf 10 > ............... ................ > > I attach the .ac-file to this mail. > My intention is to seperate for example the > > OBJECT group > name "Race-Course" > > as a single object from the rest. > What can I do ? > > Best regards > > ----- Original Message -----=20 > From: "Steve Baker" <sjb...@ai...> > To: <pli...@li...> > Sent: Friday, March 26, 2004 3:35 AM > Subject: Re: [Plib-users] Identifying objects after loading > an AC3D- modell > > > > 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 =3D=3D NULL || data [ 0 ] =3D=3D '\0' ) return NULL ; > > > > if ( strncmp ( "Tribune1", data, strlen ( "Tribune1" ) ) =3D=3D = 0 ) > > { > > ssgBranch *b =3D 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 =3D 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---=20 > > 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----- > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: IBM Linux Tutorials > > Free Linux tutorial presented by Daniel Robbins, President > and CEO of > > GenToo technologies. Learn everything from fundamentals to system > > > administration.http://ads.osdn.com/?ad_id=3D1470&alloc_id=3D3638&op=3Dc= lick > > _______________________________________________ > > plib-users mailing list > > pli...@li... > > https://lists.sourceforge.net/lists/listinfo/plib-users > > > > ------------------------------------------------------- > This SF.net email is sponsored by: The Robotic Monkeys at > ThinkGeek For a limited time only, get FREE Ground shipping > on all orders of $35 or more. Hurry up and shop folks, this > offer expires April 30th! > http://www.thinkgeek.com/freeshipping/?cpg=3D> 12297 > > _______________________________________________ > > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/p> lib-users > ------------------------------------------------------- This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th! http://www.thinkgeek.com/freeshipping/?cpg=12297 _______________________________________________ plib-users mailing list pli...@li... https://lists.sourceforge.net/lists/listinfo/plib-users |