[Plib-users] How to determine surface material by ssgState texture filena me ?
Brought to you by:
sjbaker
From: McEvoy, N. <nic...@ds...> - 2002-12-05 05:45:42
|
What is the best way to determine what type of 'surface' is under my players feet ? My setup is follows: - I load a terrain (an AC3D model) with different textures, eg. grass, rock, ice. - I get the hits: iNumHits = ssgIsect(reGetWorld(), &Sphere, InvMat, pHits) - I get the SimpleState of the hit leaf, eg. ssgHit* h = &pHits[i]; ssgState* pState = h->leaf->getState(); if (pState->isA(ssgTypeSimpleState())) { char* sTexture = ((ssgSimpleState*)pState)->getTextureFilename(); // then depending on texture filename set different surface properties // - this would be a bunch of strcmp() ... too slow !!! } But doing a bunch of string compares on the texture filename is going to be slow ... is it not !? Is there a better way to do this ? Note: I had a quick look at the way TuxKart does it ... with a Material structure (ie. ssgState) ... but I don't quite follow how to apply these states when reading the AC3D model. I have the vague idea that I should load the AC3D model using ssgLoaderOptions ... to handle ssgState ... and as each texture is read create my own ssgState (which I can then get in the hit leaf) ... but I'm still trying to work out how the loader options are supposed to work ... or am I barking up the wrong tree here. Sorry if I sound a bit confused ... cause I am ! :) Any suggestions ? Nick |