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 );
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
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;
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 ];
#define PICO_IOEOF 1
#define PICO_IOERR 2
+const picoColor_t picoColor_white;
+
/* types */
typedef struct picoParser_s
{
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 );
-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;
}
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;
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;
}
}
*/
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;
/* 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:
/* 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] );
#include "time.h"
#endif
-/* plain white */
-static picoColor_t white = { 255, 255, 255, 255 };
-
/* jhefty - multi-subobject material support */
/* Material/SubMaterial management */
}
else
{
- PicoSetSurfaceColor( surface, 0, numVertexes, white );
+ PicoSetSurfaceColor( surface, 0, numVertexes, picoColor_white );
}
PicoSetSurfaceSmoothingGroup( surface, numVertexes, ( vertices[( *i ).indices[j]].id * ( 1 << 16 ) ) + ( *i ).smoothingGroup );
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 */
}
else
{
- color[j] = &white;
+ color[j] = &picoColor_white;
}
smooth[j] = ( vertices[( *i ).indices[j]].id * ( 1 << 16 ) ) + ( *i ).smoothingGroup; /* don't merge vertices */
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
- picoColor_t color;
bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
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 ) {
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, i + fm_head->numXYZ, picoColor_white );
}
}
- /* set color */
- PicoSetSurfaceColor( picoSurface, 0, 0, color );
-
// Free up malloc'ed LL entries
for ( i = 0; i < fm_head->numXYZ; i++ )
{
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
- picoColor_t color;
/* set as md2 */
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 ) {
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, i + md2->numXYZ, picoColor_white );
}
}
- /* set color */
- PicoSetSurfaceColor( picoSurface, 0, 0, color );
-
// Free up malloc'ed LL entries
for ( i = 0; i < md2->numXYZ; i++ )
{
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
- picoColor_t color;
/* -------------------------------------------------
/* 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++ )
{
PicoSetSurfaceST( picoSurface, 0, j, st );
/* set color */
- PicoSetSurfaceColor( picoSurface, 0, j, color );
+ PicoSetSurfaceColor( picoSurface, 0, j, picoColor_white );
}
/* get next surface */
picoShader_t *picoShader;
picoVec3_t xyz, normal;
picoVec2_t st;
- picoColor_t color;
/* -------------------------------------------------
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 )
{
PicoSetSurfaceST( picoSurface, 0, j, st );
/* set color */
- PicoSetSurfaceColor( picoSurface, 0, j, color );
+ PicoSetSurfaceColor( picoSurface, 0, j, picoColor_white );
}
/* get next surface */
#define DEBUG_PM_MS3D
#define DEBUG_PM_MS3D_EX
-/* plain white */
-static picoColor_t white = { 255,255,255,255 };
-
/* ms3d limits */
const int MS3D_MAX_VERTS = 8192;
const int MS3D_MAX_TRIS = 16384;
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 ] );
_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 );