+ else if (!_pico_stricmp(p->token,"usemtl"))
+ {
+ picoShader_t *shader;
+ char *name;
+
+ /* get material name */
+ name = _pico_parse( p,0 );
+
+ if(curFace != 0 || curSurface == NULL)
+ {
+ _pico_printf( PICO_ERROR,"No group defined for usemtl, so creating an autoSurface in OBJ, line %d.",p->curLine);
+ AUTO_GROUPNAME(autoGroupNameBuf);
+ NEW_SURFACE(autoGroupNameBuf);
+ }
+
+ /* validate material name */
+ if (name == NULL || !strlen(name))
+ {
+ _pico_printf( PICO_ERROR,"Missing material name in OBJ, line %d.",p->curLine);
+ }
+ else
+ {
+ shader = PicoFindShader( model, name, 1 );
+ if (shader == NULL)
+ {
+ _pico_printf( PICO_ERROR,"Undefined material name in OBJ, line %d. Making a default shader.",p->curLine);
+
+ /* create a new pico shader */
+ shader = PicoNewShader( model );
+ if (shader != NULL)
+ {
+ PicoSetShaderName( shader,name );
+ PicoSetShaderMapName( shader,name );
+ PicoSetSurfaceShader( curSurface, shader );
+ }
+ }
+ else
+ {
+ PicoSetSurfaceShader( curSurface, shader );
+ }
+ }
+ }