]> icculus.org git repositories - divverent/nexuiz.git/blob - misc/gtkradiant/singlepatches/both-obj.diff
update the patches: fix unnecessary whitespace at line ends, and update line numbers
[divverent/nexuiz.git] / misc / gtkradiant / singlepatches / both-obj.diff
1 Index: libs/picomodel/pm_obj.c
2 ===================================================================
3 --- libs/picomodel/pm_obj.c.orig        2008-09-06 15:32:05.000000000 +0200
4 +++ libs/picomodel/pm_obj.c     2008-09-06 15:32:09.000000000 +0200
5 @@ -215,10 +215,9 @@
6         }
7  }
8  
9 -#if 0
10  static int _obj_mtl_load( picoModel_t *model )
11  {
12 -       //picoShader_t *curShader = NULL;
13 +       picoShader_t *curShader = NULL;
14         picoParser_t *p;
15         picoByte_t   *mtlBuffer;
16         int                       mtlBufSize;
17 @@ -266,7 +265,7 @@
18                 /* get next token in material file */
19                 if (_pico_parse( p,1 ) == NULL)
20                         break;
21 -#if 0
22 +#if 1
23  
24                 /* skip empty lines */
25                 if (p->token == NULL || !strlen( p->token ))
26 @@ -308,6 +307,7 @@
27                 else if (!_pico_stricmp(p->token,"map_kd"))
28                 {
29                         char *mapName;
30 +                       picoShader_t *shader;
31  
32                         /* pointer to current shader must be valid */
33                         if (curShader == NULL)
34 @@ -322,6 +322,10 @@
35                                 _pico_printf( PICO_ERROR,"Missing material map name in MTL, line %d.",p->curLine);
36                                 _obj_mtl_error_return;
37                         }
38 +                       /* create a new pico shader */
39 +                       shader = PicoNewShader( model );
40 +                       if (shader == NULL)
41 +                               _obj_mtl_error_return;
42                         /* set shader map name */
43                         PicoSetShaderMapName( shader,mapName );
44                 }
45 @@ -478,7 +482,6 @@
46         /* return with success */
47         return 1;
48  }
49 -#endif
50  
51  /* _obj_load:
52   *  loads a wavefront obj model file.
53 @@ -523,7 +526,7 @@
54         PicoSetModelFileName( model,fileName );
55  
56         /* try loading the materials; we don't handle the result */
57 -#if 0
58 +#if 1
59         _obj_mtl_load( model );
60  #endif
61  
62 @@ -832,6 +835,41 @@
63                                 curVertex += max;
64                         }
65                 }
66 +               else if (!_pico_stricmp(p->token,"usemtl"))
67 +               {
68 +                       picoShader_t *shader;
69 +                       char *name;
70 +
71 +                       /* get material name */
72 +                       name = _pico_parse( p,0 );
73 +
74 +                       /* validate material name */
75 +                       if (name == NULL || !strlen(name))
76 +                       {
77 +                               _pico_printf( PICO_ERROR,"Missing material name in OBJ, line %d.",p->curLine);
78 +                       }
79 +                       else
80 +                       {
81 +                               shader = PicoFindShader( model, name, 1 );
82 +                               if (shader == NULL)
83 +                               {
84 +                                       _pico_printf( PICO_ERROR,"Undefined material name in OBJ, line %d. Making a default shader.",p->curLine);
85 +
86 +                                       /* create a new pico shader */
87 +                                       shader = PicoNewShader( model );
88 +                                       if (shader != NULL)
89 +                                       {
90 +                                               PicoSetShaderName( shader,name );
91 +                                               PicoSetShaderMapName( shader,name );
92 +                                               PicoSetSurfaceShader( curSurface, shader );
93 +                                       }
94 +                               }
95 +                               else
96 +                               {
97 +                                       PicoSetSurfaceShader( curSurface, shader );
98 +                               }
99 +                       }
100 +               }
101                 /* skip unparsed rest of line and continue */
102                 _pico_parse_skip_rest( p );
103         }