/* * CG_BuildProjectionOrigin * store the orientation_t closer to the tag_flash we can create, * or create one using an offset we consider acceptable. * NOTE: This tag will ignore weapon models animations. You'd have to * do it in realtime to use it with animations. Or be careful on not * moving the weapon too much */ static void CG_BuildProjectionOrigin( weaponinfo_t *weaponinfo ) { orientation_t tag, tag_barrel; static entity_t ent; if( !weaponinfo ) return; if( weaponinfo->model[WEAPON] ) { // assign the model to an entity_t, so we can build boneposes memset( &ent, 0, sizeof( ent ) ); ent.rtype = RT_MODEL; ent.scale = 1.0f; ent.model = weaponinfo->model[WEAPON]; CG_SetBoneposesForTemporaryEntity( &ent ); // assigns and builds the skeleton so we can use grabtag // try getting the tag_flash from the weapon model if( CG_GrabTag( &weaponinfo->tag_projectionsource, &ent, "tag_flash" ) ) return; // succesfully // if it didn't work, try getting it from the barrel model if( CG_GrabTag( &tag_barrel, &ent, "tag_barrel" ) && weaponinfo->model[BARREL] ) { // assign the model to an entity_t, so we can build boneposes memset( &ent, 0, sizeof( ent ) ); ent.rtype = RT_MODEL; ent.scale = 1.0f; ent.model = weaponinfo->model[BARREL]; CG_SetBoneposesForTemporaryEntity( &ent ); if( CG_GrabTag( &tag, &ent, "tag_flash" ) && weaponinfo->model[BARREL] ) { VectorCopy( vec3_origin, weaponinfo->tag_projectionsource.origin ); Matrix3_Identity( weaponinfo->tag_projectionsource.axis ); CG_MoveToTag( weaponinfo->tag_projectionsource.origin, weaponinfo->tag_projectionsource.axis, tag_barrel.origin, tag_barrel.axis, tag.origin, tag.axis ); return; // succesfully } } } // doesn't have a weapon model, or the weapon model doesn't have a tag VectorSet( weaponinfo->tag_projectionsource.origin, 16, 0, 8 ); Matrix3_Identity( weaponinfo->tag_projectionsource.axis ); }
/* * R_ClearScene */ void R_ClearScene( void ) { rsc.numDlights = 0; rsc.numPolys = 0; rsc.numEntities = 0; rsc.worldent = R_NUM2ENT(0); rsc.worldent->scale = 1.0f; rsc.worldent->model = rsh.worldModel; rsc.worldent->rtype = RT_MODEL; Matrix3_Identity( rsc.worldent->axis ); rsc.numEntities = 1; rsc.numBmodelEntities = 0; rsc.debugSurface = NULL; rsc.renderedShadowBits = 0; rsc.frameCount++; R_ClearDebugBounds(); R_ClearShadowGroups(); R_ClearSkeletalCache(); }
/* * RB_BeginFrame */ void RB_BeginFrame( void ) { Vector4Set( rb.nullEnt.shaderRGBA, 1, 1, 1, 1 ); rb.nullEnt.scale = 1; VectorClear( rb.nullEnt.origin ); Matrix3_Identity( rb.nullEnt.axis ); memset( &rb.stats, 0, sizeof( rb.stats ) ); // start fresh each frame RB_SetShaderStateMask( ~0, 0 ); RB_BindVBO( 0, 0 ); }
bool RF_LerpTag( orientation_t *orient, const model_t *mod, int oldframe, int frame, float lerpfrac, const char *name ) { if( !orient ) return false; VectorClear( orient->origin ); Matrix3_Identity( orient->axis ); if( !name ) return false; if( mod->type == mod_skeletal ) return R_SkeletalModelLerpTag( orient, (const mskmodel_t *)mod->extradata, oldframe, frame, lerpfrac, name ); if( mod->type == mod_alias ) return R_AliasModelLerpTag( orient, (const maliasmodel_t *)mod->extradata, oldframe, frame, lerpfrac, name ); return false; }
/* * CG_AllocSprite */ static lentity_t *CG_AllocSprite( letype_t type, const vec3_t origin, float radius, int frames, float r, float g, float b, float a, float light, float lr, float lg, float lb, struct shader_s *shader ) { lentity_t *le; le = CG_AllocLocalEntity( type, r, g, b, a ); le->frames = frames; le->light = light; le->lightcolor[0] = lr; le->lightcolor[1] = lg; le->lightcolor[2] = lb; le->ent.rtype = RT_SPRITE; le->ent.renderfx = RF_NOSHADOW; le->ent.radius = radius; le->ent.customShader = shader; le->ent.shaderTime = cg.time; le->ent.scale = 1.0f; Matrix3_Identity( le->ent.axis ); VectorCopy( origin, le->ent.origin ); return le; }