From 47ef9a6ae213b5a1e195d55b485da17e0581b589 Mon Sep 17 00:00:00 2001 From: Garux Date: Sun, 10 Jun 2018 01:27:49 +0300 Subject: [PATCH] * picomodel::obj: fix black default vertex color, also use one from .mtl --- libs/picomodel/picomodel.c | 2 +- libs/picomodel/pm_obj.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/picomodel/picomodel.c b/libs/picomodel/picomodel.c index 4526745c..94de0787 100644 --- a/libs/picomodel/picomodel.c +++ b/libs/picomodel/picomodel.c @@ -447,7 +447,7 @@ picoShader_t *PicoNewShader( picoModel_t *model ){ /* setup default shader colors */ _pico_set_color( shader->ambientColor,0,0,0,0 ); - _pico_set_color( shader->diffuseColor,255,255,255,1 ); + _pico_set_color( shader->diffuseColor,255,255,255,255 ); _pico_set_color( shader->specularColor,0,0,0,0 ); /* no need to do this, but i do it anyway */ diff --git a/libs/picomodel/pm_obj.c b/libs/picomodel/pm_obj.c index 4549c3c3..16e2a416 100644 --- a/libs/picomodel/pm_obj.c +++ b/libs/picomodel/pm_obj.c @@ -85,7 +85,7 @@ static int _obj_canload( PM_PARAMS_CANLOAD ){ /* few lines in file and look for common keywords often */ /* appearing at the beginning of wavefront objects */ - /* alllocate a new pico parser */ + /* allocate a new pico parser */ p = _pico_new_parser( (const picoByte_t *)buffer,bufSize ); if ( p == NULL ) { return PICO_PMV_ERROR_MEMORY; @@ -550,7 +550,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){ PicoFreeModel( model ); \ return NULL; \ } - /* alllocate a new pico parser */ + /* allocate a new pico parser */ p = _pico_new_parser( (const picoByte_t *)buffer,bufSize ); if ( p == NULL ) { return NULL; @@ -866,6 +866,8 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){ /*if( has_v )*/ PicoSetSurfaceXYZ( curSurface, ( curVertex + i ), verts [ i ] ); /*if( has_vt )*/ PicoSetSurfaceST( curSurface,0,( curVertex + i ), coords [ i ] ); /*if( has_vn )*/ PicoSetSurfaceNormal( curSurface, ( curVertex + i ), normals[ i ] ); + if( curSurface && curSurface->shader ) + PicoSetSurfaceColor( curSurface, 0, ( curVertex + i ), curSurface->shader->diffuseColor ); } /* add our triangle (A B C) */ PicoSetSurfaceIndex( curSurface,( curFace * 3 + 2 ),(picoIndex_t)( curVertex + 0 ) );