picomodel: white default color of fm, md2 (was one white and rest black)

unified picoColor_white
This commit is contained in:
Garux 2018-06-10 01:27:49 +03:00
parent 47ef9a6ae2
commit b12ecc838b
12 changed files with 33 additions and 38 deletions

View File

@ -263,7 +263,7 @@ void PicoSetSurfaceShader( picoSurface_t *surface, picoSh
void PicoSetSurfaceXYZ( picoSurface_t *surface, int num, picoVec3_t xyz );
void PicoSetSurfaceNormal( picoSurface_t *surface, int num, picoVec3_t normal );
void PicoSetSurfaceST( picoSurface_t *surface, int array, int num, picoVec2_t st );
void PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, picoColor_t color );
void PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, const picoColor_t color );
void PicoSetSurfaceIndex( picoSurface_t *surface, int num, picoIndex_t index );
void PicoSetSurfaceIndexes( picoSurface_t *surface, int num, picoIndex_t *index, int count );
void PicoSetFaceNormal( picoSurface_t *surface, int num, picoVec3_t normal );
@ -336,12 +336,12 @@ picoVertexCombinationHash_t *PicoFindVertexCombinationInHashTable( picoVertexCom
picoVertexCombinationHash_t *PicoAddVertexCombinationToHashTable( picoVertexCombinationHash_t **hashTable, picoVec3_t xyz, picoVec3_t normal, picoVec3_t st, picoColor_t color, picoIndex_t index );
/* specialized functions */
int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, picoColor_t *color, picoIndex_t smoothingGroup );
int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, const picoColor_t *color, picoIndex_t smoothingGroup );
void PicoFixSurfaceNormals( picoSurface_t *surface );
int PicoRemapModel( picoModel_t *model, char *remapFile );
void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals, int numSTs, picoVec2_t **st, int numColors, picoColor_t **colors, picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup );
void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals, int numSTs, picoVec2_t **st, int numColors, const picoColor_t **colors, picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup );
/* end marker */
#ifdef __cplusplus

View File

@ -468,6 +468,8 @@ picoVec_t _pico_calc_plane( picoVec4_t plane, picoVec3_t a, picoVec3_t b, picoVe
return _pico_normalize_vec( plane );
}
const picoColor_t picoColor_white = { 255, 255, 255, 255 };
/* separate from _pico_set_vec4 */
void _pico_set_color( picoColor_t c, int r, int g, int b, int a ){
c[ 0 ] = r;
@ -476,7 +478,7 @@ void _pico_set_color( picoColor_t c, int r, int g, int b, int a ){
c[ 3 ] = a;
}
void _pico_copy_color( picoColor_t src, picoColor_t dest ){
void _pico_copy_color( const picoColor_t src, picoColor_t dest ){
dest[ 0 ] = src[ 0 ];
dest[ 1 ] = src[ 1 ];
dest[ 2 ] = src[ 2 ];

View File

@ -75,6 +75,8 @@ extern "C"
#define PICO_IOEOF 1
#define PICO_IOERR 2
const picoColor_t picoColor_white;
/* types */
typedef struct picoParser_s
{
@ -146,7 +148,7 @@ void _pico_zero_vec4( picoVec4_t vec );
void _pico_set_vec( picoVec3_t v, float a, float b, float c );
void _pico_set_vec4( picoVec4_t v, float a, float b, float c, float d );
void _pico_set_color( picoColor_t c, int r, int g, int b, int a );
void _pico_copy_color( picoColor_t src, picoColor_t dest );
void _pico_copy_color( const picoColor_t src, picoColor_t dest );
void _pico_copy_vec( picoVec3_t src, picoVec3_t dest );
void _pico_copy_vec2( picoVec2_t src, picoVec2_t dest );
picoVec_t _pico_normalize_vec( picoVec3_t vec );

View File

@ -998,7 +998,7 @@ void PicoSetSurfaceST( picoSurface_t *surface, int array, int num, picoVec2_t st
void PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, picoColor_t color ){
void PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, const picoColor_t color ){
if ( surface == NULL || num < 0 || color == NULL ) {
return;
}
@ -1610,7 +1610,7 @@ picoVertexCombinationHash_t *PicoAddVertexCombinationToHashTable( picoVertexComb
fixme: needs non-naive algorithm
*/
int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, picoColor_t *color, picoIndex_t smoothingGroup ){
int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, const picoColor_t *color, picoIndex_t smoothingGroup ){
int i, j;
@ -1654,7 +1654,7 @@ int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t
if ( numColors > 0 && color != NULL ) {
for ( j = 0; j < numSTs; j++ )
{
if ( *( (int*) surface->color[ j ] ) != *( (int*) color[ j ] ) ) {
if ( *( (const int*) surface->color[ j ] ) != *( (const int*) color[ j ] ) ) {
break;
}
}
@ -2255,7 +2255,7 @@ int PicoRemapModel( picoModel_t *model, char *remapFile ){
*/
void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals,
int numSTs, picoVec2_t **st, int numColors, picoColor_t **colors,
int numSTs, picoVec2_t **st, int numColors, const picoColor_t **colors,
picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup ){
int i,j;
int vertDataIndex;

View File

@ -40,9 +40,6 @@
/* dependencies */
#include "picointernal.h"
/* ydnar */
static picoColor_t white = { 255,255,255,255 };
/* remarks:
* - 3ds file version is stored in pico special field 0 on load (ydnar: removed)
* todo:
@ -299,7 +296,7 @@ static int GetMeshVertices( T3dsLoaderPers *pers ){
/* add current vertex */
PicoSetSurfaceXYZ( pers->surface,i,v );
PicoSetSurfaceColor( pers->surface,0,i,white ); /* ydnar */
PicoSetSurfaceColor( pers->surface, 0, i, picoColor_white );
#ifdef DEBUG_PM_3DS_EX
printf( "Vertex: x: %f y: %f z: %f\n",v[0],v[1],v[2] );

View File

@ -48,9 +48,6 @@
#include "time.h"
#endif
/* plain white */
static picoColor_t white = { 255, 255, 255, 255 };
/* jhefty - multi-subobject material support */
/* Material/SubMaterial management */
@ -406,7 +403,7 @@ static void _ase_submit_triangles_unshared( picoModel_t* model, aseMaterial_t* m
}
else
{
PicoSetSurfaceColor( surface, 0, numVertexes, white );
PicoSetSurfaceColor( surface, 0, numVertexes, picoColor_white );
}
PicoSetSurfaceSmoothingGroup( surface, numVertexes, ( vertices[( *i ).indices[j]].id * ( 1 << 16 ) ) + ( *i ).smoothingGroup );
@ -435,7 +432,7 @@ static void _ase_submit_triangles( picoModel_t* model, aseMaterial_t* materials,
picoVec3_t* xyz[3];
picoVec3_t* normal[3];
picoVec2_t* st[3];
picoColor_t* color[3];
const picoColor_t* color[3];
picoIndex_t smooth[3];
int j;
/* we pull the data from the vertex, color and texcoord arrays using the face index data */
@ -450,7 +447,7 @@ static void _ase_submit_triangles( picoModel_t* model, aseMaterial_t* materials,
}
else
{
color[j] = &white;
color[j] = &picoColor_white;
}
smooth[j] = ( vertices[( *i ).indices[j]].id * ( 1 << 16 ) ) + ( *i ).smoothingGroup; /* don't merge vertices */

View File

@ -215,7 +215,6 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
picoColor_t color;
bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
@ -590,6 +589,9 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
st[ 0 ] = ( ( texCoord[p_index_LUT[i].ST].s ) / ( (float)fm_head->skinWidth ) );
st[ 1 ] = ( texCoord[p_index_LUT[i].ST].t / ( (float)fm_head->skinHeight ) );
PicoSetSurfaceST( picoSurface, 0, i, st );
/* set color */
PicoSetSurfaceColor( picoSurface, 0, i, picoColor_white );
}
if ( dups ) {
@ -612,11 +614,11 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
st[ 0 ] = ( ( texCoord[p_index_LUT_DUPS[i].ST].s ) / ( (float)fm_head->skinWidth ) );
st[ 1 ] = ( texCoord[p_index_LUT_DUPS[i].ST].t / ( (float)fm_head->skinHeight ) );
PicoSetSurfaceST( picoSurface, 0, i + fm_head->numXYZ, st );
}
}
/* set color */
PicoSetSurfaceColor( picoSurface, 0, 0, color );
PicoSetSurfaceColor( picoSurface, 0, i + fm_head->numXYZ, picoColor_white );
}
}
// Free up malloc'ed LL entries
for ( i = 0; i < fm_head->numXYZ; i++ )

View File

@ -347,7 +347,6 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
picoColor_t color;
/* set as md2 */
@ -592,6 +591,9 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
st[ 0 ] = ( ( texCoord[p_index_LUT[i].ST].s ) / ( (float)md2->skinWidth ) );
st[ 1 ] = ( texCoord[p_index_LUT[i].ST].t / ( (float)md2->skinHeight ) );
PicoSetSurfaceST( picoSurface, 0, i, st );
/* set color */
PicoSetSurfaceColor( picoSurface, 0, i, picoColor_white );
}
if ( dups ) {
@ -614,11 +616,11 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
st[ 0 ] = ( ( texCoord[p_index_LUT_DUPS[i].ST].s ) / ( (float)md2->skinWidth ) );
st[ 1 ] = ( texCoord[p_index_LUT_DUPS[i].ST].t / ( (float)md2->skinHeight ) );
PicoSetSurfaceST( picoSurface, 0, i + md2->numXYZ, st );
}
}
/* set color */
PicoSetSurfaceColor( picoSurface, 0, 0, color );
PicoSetSurfaceColor( picoSurface, 0, i + md2->numXYZ, picoColor_white );
}
}
// Free up malloc'ed LL entries
for ( i = 0; i < md2->numXYZ; i++ )

View File

@ -193,7 +193,6 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
picoColor_t color;
/* -------------------------------------------------
@ -368,7 +367,6 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
/* copy vertexes */
texCoord = (md3TexCoord_t*) ( (picoByte_t *) surface + surface->ofsSt );
vertex = (md3Vertex_t*) ( (picoByte_t*) surface + surface->ofsVertexes + surface->numVerts * frameNum * sizeof( md3Vertex_t ) );
_pico_set_color( color, 255, 255, 255, 255 );
for ( j = 0; j < surface->numVerts; j++, texCoord++, vertex++ )
{
@ -394,7 +392,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
PicoSetSurfaceST( picoSurface, 0, j, st );
/* set color */
PicoSetSurfaceColor( picoSurface, 0, j, color );
PicoSetSurfaceColor( picoSurface, 0, j, picoColor_white );
}
/* get next surface */

View File

@ -467,7 +467,6 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
picoColor_t color;
/* -------------------------------------------------
@ -674,7 +673,6 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
vertexComp = (mdcXyzCompressed_t *) ( (picoByte_t *) surface + surface->ofsXyzCompressed ) + ( *mdcCompVert * surface->numVerts );
}
}
_pico_set_color( color, 255, 255, 255, 255 );
for ( j = 0; j < surface->numVerts; j++, texCoord++, mdcShort += 4 )
{
@ -718,7 +716,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
PicoSetSurfaceST( picoSurface, 0, j, st );
/* set color */
PicoSetSurfaceColor( picoSurface, 0, j, color );
PicoSetSurfaceColor( picoSurface, 0, j, picoColor_white );
}
/* get next surface */

View File

@ -55,9 +55,6 @@
#define DEBUG_PM_MS3D
#define DEBUG_PM_MS3D_EX
/* plain white */
static picoColor_t white = { 255,255,255,255 };
/* ms3d limits */
#define MS3D_MAX_VERTS 8192
#define MS3D_MAX_TRIS 16384
@ -355,7 +352,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
PicoSetSurfaceXYZ( surface,vertexIndex,vertex->xyz );
/* store vertex color */
PicoSetSurfaceColor( surface,0,vertexIndex,white );
PicoSetSurfaceColor( surface, 0, vertexIndex, picoColor_white );
/* store vertex normal */
PicoSetSurfaceNormal( surface,vertexIndex,triangle->vertexNormals[ m ] );

View File

@ -544,7 +544,7 @@ static picoModel_t *_terrain_load( PM_PARAMS_LOAD ){
_pico_set_color( color, colorPixel[ 0 ], colorPixel[ 1 ], colorPixel[ 2 ], colorPixel[ 3 ] );
}
else{
_pico_set_color( color, 255, 255, 255, 255 );
_pico_copy_color( picoColor_white, color );
}
PicoSetSurfaceColor( picoSurface, 0, v, color );