/* ==================== AngleQuaternion ==================== */ void AngleQuaternion( float *angles, vec4_t quaternion ) { float sr, sp, sy, cr, cp, cy; #ifdef VECTORIZE_SINCOS SinCosFastVector( angles[2] * 0.5, angles[1] * 0.5, angles[0] * 0.5, 0, &sy, &sp, &sr, NULL, &cy, &cp, &cr, NULL); #else float angle; // FIXME: rescale the inputs to 1/2 angle angle = angles[2] * 0.5; sy = sin(angle); cy = cos(angle); angle = angles[1] * 0.5; sp = sin(angle); cp = cos(angle); angle = angles[0] * 0.5; sr = sin(angle); cr = cos(angle); #endif quaternion[0] = sr*cp*cy-cr*sp*sy; // X quaternion[1] = cr*sp*cy+sr*cp*sy; // Y quaternion[2] = cr*cp*sy-sr*sp*cy; // Z quaternion[3] = cr*cp*cy+sr*sp*sy; // W }
/* ==================== AngleMatrix ==================== */ void AngleMatrix (const float *angles, float (*matrix)[4] ) { float sr, sp, sy, cr, cp, cy; #ifdef VECTORIZE_SINCOS SinCosFastVector( DEG2RAD(angles[YAW]), DEG2RAD(angles[PITCH]), DEG2RAD(angles[ROLL]), 0, &sy, &sp, &sr, NULL, &cy, &cp, &cr, NULL); #else float angle; angle = angles[YAW] * (M_PI*2 / 360); sy = sin(angle); cy = cos(angle); angle = angles[PITCH] * (M_PI*2 / 360); sp = sin(angle); cp = cos(angle); angle = angles[ROLL] * (M_PI*2 / 360); sr = sin(angle); cr = cos(angle); #endif // matrix = (YAW * PITCH) * ROLL matrix[0][0] = cp*cy; matrix[1][0] = cp*sy; matrix[2][0] = -sp; matrix[0][1] = sr*sp*cy+cr*-sy; matrix[1][1] = sr*sp*sy+cr*cy; matrix[2][1] = sr*cp; matrix[0][2] = (cr*sp*cy+-sr*-sy); matrix[1][2] = (cr*sp*sy+-sr*cy); matrix[2][2] = cr*cp; matrix[0][3] = 0.0; matrix[1][3] = 0.0; matrix[2][3] = 0.0; }
/* =============== CL_EntityParticles set EF_BRIGHTFIELD effect =============== */ void CL_EntityParticles( cl_entity_t *ent ) { float angle; float sr, sp, sy, cr, cp, cy; vec3_t forward; particle_t *p; int i; for( i = 0; i < NUMVERTEXNORMALS; i++ ) { p = CL_AllocParticle( NULL ); if( !p ) return; #ifdef VECTORIZE_SINCOS SinCosFastVector( cl.time * cl_avelocities[i][0], cl.time * cl_avelocities[i][1], cl.time * cl_avelocities[i][2], 0, &sy, &sp, &sr, NULL, &cy, &cp, &cr, NULL); #else angle = cl.time * cl_avelocities[i][0]; SinCos( angle, &sy, &cy ); angle = cl.time * cl_avelocities[i][1]; SinCos( angle, &sp, &cp ); angle = cl.time * cl_avelocities[i][2]; SinCos( angle, &sr, &cr ); #endif VectorSet( forward, cp * cy, cp * sy, -sp ); p->die += 0.01f; p->color = 111; // yellow p->type = pt_explode; p->org[0] = ent->origin[0] + cl_avertexnormals[i][0] * 64.0f + forward[0] * 16.0f; p->org[1] = ent->origin[1] + cl_avertexnormals[i][1] * 64.0f + forward[1] * 16.0f; p->org[2] = ent->origin[2] + cl_avertexnormals[i][2] * 64.0f + forward[2] * 16.0f; } }