/****************************************************************************** libx42 - skinned vertex animation library Copyright (C) 2007 HermitWorks Entertainment Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #include "local.h" static void copy_tc( const vec2_t * RESTRICT iTc, uint numVerts, x42memStream_t *oTc ) { uint i; for( i = 0; i < numVerts; i++ ) { stream_emit2fv( oTc, iTc[i] ); } } static void copy_cl_bgra( const rgba_t * RESTRICT iCl, uint numVerts, x42memStream_t *oCl ) { uint i; for( i = 0; i < numVerts; i++ ) { const byte * RESTRICT cl = iCl[i]; stream_emit4ub( oCl, cl[2], cl[1], cl[0], cl[3] ); } } static void copy_cl_argb( const rgba_t * RESTRICT iCl, uint numVerts, x42memStream_t *oCl ) { uint i; for( i = 0; i < numVerts; i++ ) { const byte * RESTRICT cl = iCl[i]; stream_emit4ub( oCl, cl[3], cl[0], cl[1], cl[2] ); } } static void copy_cl_rgba( const rgba_t * RESTRICT iCl, uint numVerts, x42memStream_t *oCl ) { uint i; for( i = 0; i < numVerts; i++ ) { stream_emit4ubv( oCl, iCl[i] ); } } X42_EXPORT bool X42_CALL x42_CopyVertAttribs( x42memStream_t *oTc, x42memStream_t *oCl, uint color_type, const x42data_t *x42, uint groupNum, x42opts_t *opts ) { const x42group_t *g; REF_PARAM( opts ); #ifndef LIBX42_NO_PARAM_VALIDATION demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" ); demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" ); demand_rf( groupNum < x42->header.numGroups, X42_ERR_OUTOFRANGE, "group number out of range" ); #endif g = x42->groups + groupNum; if( !oTc && !oCl ) //nothing to do return true; if( oTc ) copy_tc( x42->vertTc + g->firstVert, g->numVerts, oTc ); if( oCl ) { switch( color_type ) { case X42_COLOR_BGRA: copy_cl_bgra( x42->vertCl + g->firstVert, g->numVerts, oCl ); break; case X42_COLOR_ARGB: copy_cl_argb( x42->vertCl + g->firstVert, g->numVerts, oCl ); break; case X42_COLOR_RGBA: copy_cl_rgba( x42->vertCl + g->firstVert, g->numVerts, oCl ); break; default: fail_rf( X42_ERR_BADPARAMS, "invalid color type" ); } } return true; } #pragma warning( disable : 4206 )