Re: [Plib-users] triangles from branches
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2004-10-26 00:35:21
|
Paolo Sacconier wrote: > Hi, > I'm new to this mailing list. I'm trying to use plib together with ode > (www.ode.org) dynamics engine, did anyone have some experience with it? Take a look at the TORCS project - it uses PLIB and ODE. > My main problem is that I need to access the triangle data for a given > object (ie a branch entity, which contains data loaded from a model in > .ac format) to create the geometric rapresentation for the ode's > collision detection system. Is there a simple way to reach these > informations using plib api? I couldn't figure out from the docs. Well, you need to walk the tree structure of the model using things like getNumKids() and getKid(n) at each node and using isAKindOf to recognise whether you have a leaf node or a branch node...for example: void processObj ( ssgEntity *n ) { if ( n == NULL ) return ; if ( n -> isAKindOf ( ssgTypeLeaf() ) ) { ssgLeaf *l = (ssgLeaf *) n ; ....DO SOMETHING WITH THE TRIANGLES... return ; } ssgBranch *b = (ssgBranch *) n ; for ( int i = 0 ; i < b -> getNumKids () ; i++ ) processObj ( b -> getKid ( i ) ) ; } ssgLeaf nodes contain the triangles - there are member functions to get the indices of the three vertices of the N'th triangle (getTriangle) and to retrieve the vertex, colour, normal and texture coordinate given a vertex index: getVertex()/getColour()/ getNormal()/getTexCoord(). ---------------------------- 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----- |