/* =============== Main_MenuDraw =============== */ static void Main_MenuDraw( void ) { refdef_t refdef; refEntity_t ent; vec3_t origin; vec3_t angles; float adjust; float x, y, w, h; vec4_t color = {0.5, 0, 0, 1}; // setup the refdef memset( &refdef, 0, sizeof( refdef ) ); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear( refdef.viewaxis ); x = 0; y = 0; w = 640; h = 120; UI_AdjustFrom640( &x, &y, &w, &h ); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; adjust = 0; // JDC: Kenneth asked me to stop this 1.0 * sin( (float)uis.realtime / 1000 ); refdef.fov_x = 70 + adjust; refdef.fov_y = 19.6875 + adjust; refdef.time = uis.realtime; origin[0] = 300; origin[1] = 0; origin[2] = -32; trap_R_ClearScene(); // add the model memset( &ent, 0, sizeof(ent) ); adjust = 20.0 * sin( (float)uis.realtime / 3000 ); VectorSet( angles, 0, 180 + adjust, 0 ); AnglesToAxis( angles, ent.axis ); ent.hModel = s_main.bannerModel; VectorCopy( origin, ent.origin ); VectorCopy( origin, ent.lightingOrigin ); ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; VectorCopy( ent.origin, ent.oldorigin ); trap_R_AddRefEntityToScene( &ent ); // standard menu drawing Menu_Draw( &s_main.menu ); trap_R_RenderScene( &refdef ); /* if (uis.demoversion) { UI_DrawProportionalString( 320, 372, "DEMO FOR MATURE AUDIENCES DEMO", UI_CENTER|UI_SMALLFONT, color ); UI_DrawString( 320, 400, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color ); } else { UI_DrawString( 320, 450, "Quake III Arena(c) 1999-2000, Id Software, Inc. All Rights Reserved", UI_CENTER|UI_SMALLFONT, color ); }*/ }
/* =============== UI_DrawPlayer =============== */ void UI_DrawPlayer(float x, float y, float w, float h, playerInfo_t *pi, int time) { refdef_t refdef; refEntity_t legs; refEntity_t torso; refEntity_t head; refEntity_t gun; refEntity_t barrel; refEntity_t flash; vec3_t origin; int renderfx; vec3_t mins = {-16, -16, -24}; vec3_t maxs = {16, 16, 32}; float len; float xx; if (!pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames) { return; } // this allows the ui to cache the player model on the main menu if (w == 0 || h == 0) { return; } dp_realtime = time; if (pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer) { pi->weapon = pi->pendingWeapon; pi->lastWeapon = pi->pendingWeapon; pi->pendingWeapon = -1; pi->weaponTimer = 0; if (pi->currentWeapon != pi->weapon) { trap_S_StartLocalSound(weaponChangeSound, CHAN_LOCAL); } } UI_AdjustFrom640(&x, &y, &w, &h); y -= jumpHeight; memset(&refdef, 0, sizeof(refdef)); memset(&legs, 0, sizeof(legs)); memset(&torso, 0, sizeof(torso)); memset(&head, 0, sizeof(head)); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear(refdef.viewaxis); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f); xx = refdef.width / tan(refdef.fov_x / 360 * M_PI); refdef.fov_y = atan2(refdef.height, xx); refdef.fov_y *= (360 / M_PI); // calculate distance so the player nearly fills the box len = 0.7 * (maxs[2] - mins[2]); origin[0] = len / tan(DEG2RAD(refdef.fov_x) * 0.5); origin[1] = 0.5 * (mins[1] + maxs[1]); origin[2] = -0.5 * (mins[2] + maxs[2]); refdef.time = dp_realtime; trap_R_ClearScene(); // get the rotation information UI_PlayerAngles(pi, legs.axis, torso.axis, head.axis); // get the animation state (after rotation, to allow feet shuffle) UI_PlayerAnimation(pi, &legs.oldframe, &legs.frame, &legs.backlerp, &torso.oldframe, &torso.frame, &torso.backlerp); renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; // // add the legs // legs.hModel = pi->legsModel; legs.customSkin = pi->legsSkin; VectorCopy(origin, legs.origin); VectorCopy(origin, legs.lightingOrigin); legs.renderfx = renderfx; VectorCopy (legs.origin, legs.oldorigin); trap_R_AddRefEntityToScene(&legs); if (!legs.hModel) { return; } // // add the torso // torso.hModel = pi->torsoModel; if (!torso.hModel) { return; } torso.customSkin = pi->torsoSkin; VectorCopy(origin, torso.lightingOrigin); UI_PositionRotatedEntityOnTag(&torso, &legs, pi->legsModel, "tag_torso"); torso.renderfx = renderfx; trap_R_AddRefEntityToScene(&torso); // // add the head // head.hModel = pi->headModel; if (!head.hModel) { return; } head.customSkin = pi->headSkin; VectorCopy(origin, head.lightingOrigin); UI_PositionRotatedEntityOnTag(&head, &torso, pi->torsoModel, "tag_head"); head.renderfx = renderfx; trap_R_AddRefEntityToScene(&head); // // add the gun // if (pi->currentWeapon != WP_NONE) { memset(&gun, 0, sizeof(gun)); gun.hModel = pi->weaponModel; VectorCopy(origin, gun.lightingOrigin); UI_PositionEntityOnTag(&gun, &torso, pi->torsoModel, "tag_weapon"); gun.renderfx = renderfx; trap_R_AddRefEntityToScene(&gun); } // // add the spinning barrel // if (pi->realWeapon == WP_MACHINEGUN || pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG) { vec3_t angles; memset(&barrel, 0, sizeof(barrel)); VectorCopy(origin, barrel.lightingOrigin); barrel.renderfx = renderfx; barrel.hModel = pi->barrelModel; angles[YAW] = 0; angles[PITCH] = 0; angles[ROLL] = UI_MachinegunSpinAngle(pi); if (pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG) { angles[PITCH] = angles[ROLL]; angles[ROLL] = 0; } AnglesToAxis(angles, barrel.axis); UI_PositionRotatedEntityOnTag(&barrel, &gun, pi->weaponModel, "tag_barrel"); trap_R_AddRefEntityToScene(&barrel); } // // add muzzle flash // if (dp_realtime <= pi->muzzleFlashTime) { if (pi->flashModel) { memset(&flash, 0, sizeof(flash)); flash.hModel = pi->flashModel; VectorCopy(origin, flash.lightingOrigin); UI_PositionEntityOnTag(&flash, &gun, pi->weaponModel, "tag_flash"); flash.renderfx = renderfx; trap_R_AddRefEntityToScene(&flash); } // make a dlight for the flash if (pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2]) { trap_R_AddLightToScene(flash.origin, 200 + (rand()&31), pi->flashDlightColor[0], pi->flashDlightColor[1], pi->flashDlightColor[2]); } } // // add the chat icon // if (pi->chat) { UI_PlayerFloatSprite(pi, origin, trap_R_RegisterShaderNoMip("sprites/balloon3")); } // // add an accent light // origin[0] -= 100; // + = behind, - = in front origin[1] += 100; // + = left, - = right origin[2] += 100; // + = above, - = below trap_R_AddLightToScene(origin, 500, 1.0, 1.0, 1.0); origin[0] -= 100; origin[1] -= 100; origin[2] -= 100; trap_R_AddLightToScene(origin, 500, 1.0, 0.0, 0.0); trap_R_RenderScene(&refdef); }
void UI_DrawSides(float x, float y, float w, float h) { UI_AdjustFrom640( &x, &y, &w, &h ); trap_R_DrawStretchPic( x, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); trap_R_DrawStretchPic( x + w - 1, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); }
void UI_DrawTopBottom(float x, float y, float w, float h) { UI_AdjustFrom640( &x, &y, &w, &h ); trap_R_DrawStretchPic( x, y, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); trap_R_DrawStretchPic( x, y + h - 1, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); }
void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) { refdef_t refdef; refEntity_t legs = {0}; refEntity_t torso = {0}; refEntity_t head = {0}; refEntity_t gun = {0}; refEntity_t barrel = {0}; refEntity_t backpack = {0}; refEntity_t helmet = {0}; refEntity_t flash = {0}; vec3_t origin; int renderfx; vec3_t mins = {-16, -16, -24}; vec3_t maxs = {16, 16, 32}; float len; float xx; vec4_t hcolor = { 1, 0, 0, 0.5 }; const char *torso_anim = NULL, *legs_anim = NULL; if ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) { return; } dp_realtime = time; if ( pi->pendingWeapon != WP_NUM_WEAPONS && dp_realtime > pi->weaponTimer ) { pi->weapon = pi->pendingWeapon; pi->lastWeapon = pi->pendingWeapon; pi->pendingWeapon = WP_NUM_WEAPONS; pi->weaponTimer = 0; if ( pi->currentWeapon != pi->weapon ) { trap_S_StartLocalSound( trap_S_RegisterSound( "sound/weapons/change.wav" ), CHAN_LOCAL ); } } UI_AdjustFrom640( &x, &y, &w, &h ); y -= jumpHeight; memset( &refdef, 0, sizeof( refdef ) ); memset( &legs, 0, sizeof( legs ) ); memset( &torso, 0, sizeof( torso ) ); memset( &head, 0, sizeof( head ) ); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear( refdef.viewaxis ); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; refdef.fov_x = (int)((float)refdef.width / uiInfo.uiDC.xscale / 640.0f * 90.0f); xx = refdef.width / uiInfo.uiDC.xscale / tan( refdef.fov_x / 360 * M_PI ); refdef.fov_y = atan2( refdef.height / uiInfo.uiDC.yscale, xx ); refdef.fov_y *= ( 360 / M_PI ); // calculate distance so the player nearly fills the box len = 1.01 * ( maxs[2] - mins[2] ); // NERVE - SMF - changed from 0.7 origin[0] = len / tan( DEG2RAD( refdef.fov_x ) * 0.5 ); origin[1] = 0.5 * ( mins[1] + maxs[1] ); origin[2] = -0.5 * ( mins[2] + maxs[2] ); refdef.time = dp_realtime; trap_R_SetColor( hcolor ); trap_R_ClearScene(); trap_R_SetColor( NULL ); // get the rotation information UI_PlayerAngles( pi, legs.axis, torso.axis, head.axis ); // get the animation state (after rotation, to allow feet shuffle) // UI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp, // &torso.oldframe, &torso.frame, &torso.backlerp ); renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; // // add the body // legs.hModel = pi->legsModel; legs.customSkin = pi->legsSkin; legs.renderfx = renderfx; VectorCopy( origin, legs.origin ); VectorCopy( origin, legs.lightingOrigin ); VectorCopy( legs.origin, legs.oldorigin ); WM_getWeaponAnim( &torso_anim, &legs_anim ); if ( torso_anim ) { legs.torsoFrame = UI_GetAnimation( pi, torso_anim ); legs.oldTorsoFrame = UI_GetAnimation( pi, torso_anim ); } legs.torsoBacklerp = 0; //torso.backlerp; if ( legs_anim ) { legs.frame = UI_GetAnimation( pi, legs_anim ); legs.oldframe = UI_GetAnimation( pi, legs_anim ); } legs.backlerp = 0; memcpy( legs.torsoAxis, torso.axis, sizeof( torso.axis ) ); torso = legs; trap_R_AddRefEntityToScene( &torso ); // // add the head // head.hModel = pi->headModel; if ( !head.hModel ) { return; } head.customSkin = pi->headSkin; VectorCopy( origin, head.lightingOrigin ); UI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, "tag_head" ); head.renderfx = renderfx; trap_R_AddRefEntityToScene( &head ); // // add the gun // if ( pi->currentWeapon != WP_NONE ) { memset( &gun, 0, sizeof( gun ) ); gun.hModel = pi->weaponModel; VectorCopy( origin, gun.lightingOrigin ); UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon" ); gun.renderfx = renderfx; trap_R_AddRefEntityToScene( &gun ); } // // add the gun barrel // if ( pi->currentWeapon != WP_NONE && pi->barrelModel ) { memset( &barrel, 0, sizeof( barrel ) ); barrel.hModel = pi->barrelModel; VectorCopy( origin, barrel.lightingOrigin ); UI_PositionEntityOnTag( &barrel, &gun, pi->weaponModel, "tag_barrel" ); barrel.renderfx = renderfx; trap_R_AddRefEntityToScene( &barrel ); } // // add muzzle flash // if ( dp_realtime <= pi->muzzleFlashTime ) { if ( pi->flashModel ) { memset( &flash, 0, sizeof( flash ) ); flash.hModel = pi->flashModel; VectorCopy( origin, flash.lightingOrigin ); UI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, "tag_flash" ); flash.renderfx = renderfx; trap_R_AddRefEntityToScene( &flash ); } // make a dlight for the flash if ( pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2] ) { trap_R_AddLightToScene( flash.origin, 200 + ( rand() & 31 ), pi->flashDlightColor[0], pi->flashDlightColor[1], pi->flashDlightColor[2], 0 ); } } // // add the backpack // if ( pi->backpackModel ) { memset( &backpack, 0, sizeof( backpack ) ); backpack.hModel = pi->backpackModel; VectorCopy( origin, backpack.lightingOrigin ); UI_PositionEntityOnTag( &backpack, &torso, pi->torsoModel, "tag_back" ); backpack.renderfx = renderfx; trap_R_AddRefEntityToScene( &backpack ); } // // add the helmet // if ( pi->helmetModel ) { memset( &helmet, 0, sizeof( helmet ) ); helmet.hModel = pi->helmetModel; VectorCopy( origin, helmet.lightingOrigin ); UI_PositionEntityOnTag( &helmet, &head, pi->headModel, "tag_mouth" ); helmet.renderfx = renderfx; trap_R_AddRefEntityToScene( &helmet ); } // // add the chat icon // if ( pi->chat ) { UI_PlayerFloatSprite( pi, origin, trap_R_RegisterShaderNoMip( "sprites/balloon3" ) ); } // // add an accent light // origin[0] -= 100; // + = behind, - = in front origin[1] += 100; // + = left, - = right origin[2] += 100; // + = above, - = below trap_R_AddLightToScene( origin, 1000, 1.0, 1.0, 1.0, 0 ); origin[0] -= 100; origin[1] -= 100; origin[2] -= 100; trap_R_AddLightToScene( origin, 1000, 1.0, 1.0, 1.0, 0 ); trap_R_RenderScene( &refdef ); }
/* * UI_DrawPlayer */ void UI_DrawPlayer(float x, float y, float w, float h, Playerinfo *pi, int time) { Refdef refdef; Refent legs; Refent torso; Refent head; Refent gun; Refent barrel; Refent flash; Vec3 origin; int renderfx; Vec3 mins = {-16, -16, -24}; Vec3 maxs = {16, 16, 32}; float len; float xx; if(!pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames) return; dp_realtime = time; if(pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer){ pi->weapon = pi->pendingWeapon; pi->lastWeapon = pi->pendingWeapon; pi->pendingWeapon = -1; pi->weaponTimer = 0; if(pi->currentWeapon != pi->weapon) trap_sndstartlocalsound(weaponChangeSound, CHAN_LOCAL); } UI_AdjustFrom640(&x, &y, &w, &h); y -= jumpHeight; memset(&refdef, 0, sizeof(refdef)); memset(&legs, 0, sizeof(legs)); memset(&torso, 0, sizeof(torso)); memset(&head, 0, sizeof(head)); refdef.rdflags = RDF_NOWORLDMODEL; clearaxis(refdef.viewaxis); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f); xx = refdef.width / tan(refdef.fov_x / 360 * M_PI); refdef.fov_y = atan2(refdef.height, xx); refdef.fov_y *= (360 / M_PI); /* calculate distance so the player nearly fills the box */ len = 0.7 * (maxs[2] - mins[2]); origin[0] = len / tan(DEG2RAD(refdef.fov_x) * 0.5); origin[1] = 0.5 * (mins[1] + maxs[1]); origin[2] = -0.5 * (mins[2] + maxs[2]); refdef.time = dp_realtime; trap_R_ClearScene(); /* get the rotation information */ UI_PlayerAngles(pi, legs.axis, torso.axis, head.axis); /* get the animation state (after rotation, to allow feet shuffle) */ UI_PlayerAnimation(pi, &legs.oldframe, &legs.frame, &legs.backlerp, &torso.oldframe, &torso.frame, &torso.backlerp); renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; /* * add the legs * */ legs.hModel = pi->legsModel; legs.customSkin = pi->legsSkin; copyv3(origin, legs.origin); copyv3(origin, legs.lightingOrigin); legs.renderfx = renderfx; copyv3 (legs.origin, legs.oldorigin); trap_R_AddRefEntityToScene(&legs); if(!legs.hModel) return; /* * add the torso * */ torso.hModel = pi->torsoModel; if(!torso.hModel) return; torso.customSkin = pi->torsoSkin; copyv3(origin, torso.lightingOrigin); UI_PositionRotatedEntityOnTag(&torso, &legs, pi->legsModel, "tag_torso"); torso.renderfx = renderfx; trap_R_AddRefEntityToScene(&torso); /* * add the head * */ head.hModel = pi->headModel; if(!head.hModel) return; head.customSkin = pi->headSkin; copyv3(origin, head.lightingOrigin); UI_PositionRotatedEntityOnTag(&head, &torso, pi->torsoModel, "tag_head"); head.renderfx = renderfx; trap_R_AddRefEntityToScene(&head); /* * add the gun * */ if(pi->currentWeapon != Wnone){ memset(&gun, 0, sizeof(gun)); gun.hModel = pi->weaponModel; if(pi->currentWeapon == Wrailgun) byte4copy(pi->c1RGBA, gun.shaderRGBA); else byte4copy(colorWhite, gun.shaderRGBA); copyv3(origin, gun.lightingOrigin); UI_PositionEntityOnTag(&gun, &torso, pi->torsoModel, "tag_weapon"); gun.renderfx = renderfx; trap_R_AddRefEntityToScene(&gun); } /* * add the spinning barrel * */ if(pi->realWeapon == Wmachinegun || pi->realWeapon == Wmelee){ Vec3 angles; memset(&barrel, 0, sizeof(barrel)); copyv3(origin, barrel.lightingOrigin); barrel.renderfx = renderfx; barrel.hModel = pi->barrelModel; angles[YAW] = 0; angles[PITCH] = 0; angles[ROLL] = UI_MachinegunSpinAngle(pi); if(pi->realWeapon == Wmelee){ angles[PITCH] = angles[ROLL]; angles[ROLL] = 0; } eulertoaxis(angles, barrel.axis); UI_PositionRotatedEntityOnTag(&barrel, &gun, pi->weaponModel, "tag_barrel"); trap_R_AddRefEntityToScene(&barrel); } /* * add muzzle flash * */ if(dp_realtime <= pi->muzzleFlashTime){ if(pi->flashModel){ memset(&flash, 0, sizeof(flash)); flash.hModel = pi->flashModel; if(pi->currentWeapon == Wrailgun) byte4copy(pi->c1RGBA, flash.shaderRGBA); else byte4copy(colorWhite, flash.shaderRGBA); copyv3(origin, flash.lightingOrigin); UI_PositionEntityOnTag(&flash, &gun, pi->weaponModel, "tag_flash"); flash.renderfx = renderfx; trap_R_AddRefEntityToScene(&flash); } /* make a dlight for the flash */ if(pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2]) trap_R_AddLightToScene(flash.origin, 200 + (rand()&31), pi->flashDlightColor[0], pi->flashDlightColor[1], pi->flashDlightColor[2]); } /* * add the chat icon * */ if(pi->chat) UI_PlayerFloatSprite(pi, origin, trap_R_RegisterShaderNoMip("sprites/balloon4")); /* * add an accent light * */ origin[0] -= 100; /* + = behind, - = in front */ origin[1] += 100; /* + = left, - = right */ origin[2] += 100; /* + = above, - = below */ trap_R_AddLightToScene(origin, 500, 1.0, 1.0, 1.0); origin[0] -= 100; origin[1] -= 100; origin[2] -= 100; trap_R_AddLightToScene(origin, 500, 1.0, 0.0, 0.0); trap_R_RenderScene(&refdef); }
static void Main_MenuDraw( void ) { refdef_t refdef; refEntity_t ent; vec3_t origin; vec3_t angles; float adjust; float x, y, w, h; vec4_t color = {0.2, 0.2, 1.0, 1}; // setup the refdef memset( &refdef, 0, sizeof( refdef ) ); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear( refdef.viewaxis ); x = 0; y = 0; w = 640; h = 120; UI_AdjustFrom640( &x, &y, &w, &h ); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; adjust = 0; // JDC: Kenneth asked me to stop this 1.0 * sin( (float)uis.realtime / 1000 ); refdef.fov_x = 60 + adjust; refdef.fov_y = 19.6875 + adjust; refdef.time = uis.realtime; origin[0] = 300; origin[1] = 0; origin[2] = -32; trap_R_ClearScene(); // add the model memset( &ent, 0, sizeof(ent) ); adjust = 5.0 * sin( (float)uis.realtime / 5000 ); VectorSet( angles, 0, 180 + adjust, 0 ); AnglesToAxis( angles, ent.axis ); ent.hModel = s_main.bannerModel; VectorCopy( origin, ent.origin ); VectorCopy( origin, ent.lightingOrigin ); ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; VectorCopy( ent.origin, ent.oldorigin ); trap_R_AddRefEntityToScene( &ent ); trap_R_RenderScene( &refdef ); if (strlen(s_errorMessage.errorMessage)) { UI_DrawProportionalString_AutoWrapped( 320, 192, 600, 20, s_errorMessage.errorMessage, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color ); } else { // standard menu drawing Menu_Draw( &s_main.menu ); } UI_DrawProportionalString( 320, 372, "", UI_CENTER|UI_SMALLFONT, color ); UI_DrawString( 320, 400, "OpenArena(c) 2005-2018 OpenArena Team", UI_CENTER|UI_SMALLFONT, color ); UI_DrawString( 320, 414, "OpenArena comes with ABSOLUTELY NO WARRANTY; this is free software", UI_CENTER|UI_SMALLFONT, color ); UI_DrawString( 320, 428, "and you are welcome to redistribute it under certain conditions;", UI_CENTER|UI_SMALLFONT, color ); UI_DrawString( 320, 444, "read COPYING for details.", UI_CENTER|UI_SMALLFONT, color ); //Draw version. UI_DrawString( 640-40, 480-14, "^7" OA_VERSION, UI_SMALLFONT, color ); if ((int)trap_Cvar_VariableValue("protocol")!=OA_STD_PROTOCOL) { UI_DrawString( 0, 480-14, va("^7Protocol: %i",(int)trap_Cvar_VariableValue("protocol")), UI_SMALLFONT, color); } }
void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) { refdef_t refdef; refEntity_t legs; refEntity_t torso; refEntity_t head; refEntity_t gun; refEntity_t barrel; refEntity_t flash; vector3 origin; int renderfx; vector3 mins = {-16, -16, -24}; vector3 maxs = {16, 16, 32}; float len; float xx; if ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) { return; } // this allows the ui to cache the player model on the main menu if (w == 0 || h == 0) { return; } dp_realtime = time; if ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) { pi->weapon = pi->pendingWeapon; pi->lastWeapon = pi->pendingWeapon; pi->pendingWeapon = -1; pi->weaponTimer = 0; if( pi->currentWeapon != pi->weapon ) { trap->S_StartLocalSound( weaponChangeSound, CHAN_LOCAL ); } } UI_AdjustFrom640( &x, &y, &w, &h ); y -= jumpHeight; memset( &refdef, 0, sizeof( refdef ) ); memset( &legs, 0, sizeof(legs) ); memset( &torso, 0, sizeof(torso) ); memset( &head, 0, sizeof(head) ); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear( refdef.viewaxis ); refdef.x = (int)x; refdef.y = (int)y; refdef.width = (int)w; refdef.height = (int)h; refdef.fov_x = (float)refdef.width / uiInfo.uiDC.xscale / SCREEN_WIDTH * 90.0f; xx = refdef.width / uiInfo.uiDC.xscale / tanf( refdef.fov_x / 360 * M_PI ); refdef.fov_y = atan2f( refdef.height / uiInfo.uiDC.yscale, xx ); refdef.fov_y *= ( 360 / (float)M_PI ); // calculate distance so the player nearly fills the box len = 0.7f * ( maxs.z - mins.z ); origin.x = len / tanf( DEG2RAD(refdef.fov_x) * 0.5f ); origin.y = 0.5f * ( mins.y + maxs.y ); origin.z = -0.5f * ( mins.z + maxs.z ); refdef.time = dp_realtime; trap->R_ClearScene(); // get the rotation information UI_PlayerAngles( pi, legs.axis, torso.axis, head.axis ); // get the animation state (after rotation, to allow feet shuffle) UI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp, &torso.oldframe, &torso.frame, &torso.backlerp ); renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; // // add the legs // legs.hModel = pi->legsModel; legs.customSkin = pi->legsSkin; VectorCopy( &origin, &legs.origin ); VectorCopy( &origin, &legs.lightingOrigin ); legs.renderfx = renderfx; VectorCopy (&legs.origin, &legs.oldorigin); trap->R_AddRefEntityToScene( &legs ); if (!legs.hModel) { return; } // // add the torso // torso.hModel = pi->torsoModel; if (!torso.hModel) { return; } torso.customSkin = pi->torsoSkin; VectorCopy( &origin, &torso.lightingOrigin ); UI_PositionRotatedEntityOnTag( &torso, &legs, pi->legsModel, "tag_torso"); torso.renderfx = renderfx; trap->R_AddRefEntityToScene( &torso ); // // add the head // head.hModel = pi->headModel; if (!head.hModel) { return; } head.customSkin = pi->headSkin; VectorCopy( &origin, &head.lightingOrigin ); UI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, "tag_head"); head.renderfx = renderfx; trap->R_AddRefEntityToScene( &head ); // // add the gun // if ( pi->currentWeapon != WP_NONE ) { memset( &gun, 0, sizeof(gun) ); gun.hModel = pi->weaponModel; VectorCopy( &origin, &gun.lightingOrigin ); UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon"); gun.renderfx = renderfx; trap->R_AddRefEntityToScene( &gun ); } // // add the spinning barrel // if ( pi->barrelModel ) { vector3 angles; memset( &barrel, 0, sizeof(barrel) ); VectorCopy( &origin, &barrel.lightingOrigin ); barrel.renderfx = renderfx; barrel.hModel = pi->barrelModel; angles.yaw = 0; angles.pitch = 0; angles.roll = UI_MachinegunSpinAngle( pi ); AnglesToAxis( &angles, barrel.axis ); UI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, "tag_barrel"); trap->R_AddRefEntityToScene( &barrel ); } // // add muzzle flash // if ( dp_realtime <= pi->muzzleFlashTime ) { // make a dlight for the flash if ( pi->flashDlightColor.r || pi->flashDlightColor.g || pi->flashDlightColor.b ) { trap->R_AddLightToScene( &flash.origin, (float)(200 + (rand()&31)), pi->flashDlightColor.r, pi->flashDlightColor.g, pi->flashDlightColor.b ); } } // // add the chat icon // if ( pi->chat ) { UI_PlayerFloatSprite( pi, &origin, trap->R_RegisterShader( "sprites/balloon3" ) ); } // // add an accent light // origin.x -= 100; // + = behind, - = in front origin.y += 100; // + = left, - = right origin.z += 100; // + = above, - = below trap->R_AddLightToScene( &origin, 500, 1.0f, 1.0f, 1.0f ); origin.x -= 100; origin.y -= 100; origin.z -= 100; trap->R_AddLightToScene( &origin, 500, 1.0f, 0.0f, 0.0f ); trap->R_RenderScene( &refdef ); }
static void Main_MenuDraw(void) { refdef_t refdef; refEntity_t ent; vec3_t origin; vec3_t angles; float adjust; float x, y, w, h; vec4_t color; qboolean connected = qtrue; vec4_t oldColor = {0.8, 0.8, 0.8, 1}; // FIXME dont call on every update... s_main.servers = (int) trap_Cvar_VariableValue("ma_servers"); s_main.players = (int) trap_Cvar_VariableValue("ma_players"); s_main.motd = UI_Cvar_VariableString("ma_motd"); if (!s_main.motd || !Q_stricmp(s_main.motd, "")) { s_main.motd = "Failed to connect to master server"; connected = qfalse; } // options the refdef memset(&refdef, 0, sizeof ( refdef)); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear(refdef.viewaxis); x = 0; y = 0; w = 640; h = 120; UI_AdjustFrom640(&x, &y, &w, &h); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; adjust = 0; // JDC: Kenneth asked me to stop this 1.0 * sin( (float)uis.realtime / 1000 ); refdef.fov_x = 60 + adjust; refdef.fov_y = 19.6875 + adjust; refdef.time = uis.realtime; origin[0] = 300; origin[1] = 0; origin[2] = -32; trap_R_ClearScene(); // add the model memset(&ent, 0, sizeof (ent)); /*adjust = 5.0 * sin((float) uis.realtime / 5000); VectorSet(angles, 0, 180 + adjust, 0); AnglesToAxis(angles, ent.axis); ent.hModel = s_main.bannerModel; VectorCopy(origin, ent.origin); VectorCopy(origin, ent.lightingOrigin); ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; VectorCopy(ent.origin, ent.oldorigin);*/ x = 0; y = 0; w = 640; h = 64; UI_FillRect(x, y, w, h, color_black); x = 16; y = 16; UI_DrawString(x, y, "Hazewood", UI_LEFT, color_green); x = 196; y = 28; if (connected) { UI_DrawString(x, y, va("%s", s_main.motd), UI_LEFT | UI_SMALLERFONT, color_white); } else { UI_DrawString(x, y, va("%s", s_main.motd), UI_LEFT | UI_SMALLERFONT, color_red); } x = 640 - 196 + 48; y = 12; if (s_main.servers > 0) { UI_DrawString(x, y, va("%i Servers", s_main.servers), UI_LEFT | UI_SMALLFONT, color_blue); } else { UI_DrawString(x, y, va("%i Servers", s_main.servers), UI_LEFT | UI_SMALLFONT, color_red); } y = 36; if (s_main.players > 0) { UI_DrawString(x, y, va("%i Players", s_main.players), UI_LEFT | UI_SMALLFONT, color_blue); } else { UI_DrawString(x, y, va("%i Players", s_main.players), UI_LEFT | UI_SMALLFONT, color_red); } x = 0; y = 480 - 64; w = 640; h = 64; UI_FillRect(x, y, w, h, color_black); x = 0; y = 64; w = 640; h = 480 - 128; if (!s_main.up) { s_main.fade -= ((float) uis.frametime) / 10.0f; } else { s_main.fade += ((float) uis.frametime) / 10.0f; } if (s_main.fade >= 1200.0f) { s_main.up = qfalse; s_main.currentScene++; if (s_main.currentScene >= MAX_MENU_SCENES) { s_main.currentScene = 0; } } if (s_main.fade <= -100.0f) { s_main.up = qtrue; } Vector4Copy(oldColor, color); UI_DrawHandlePic(x, y, w, h, trap_R_RegisterShaderNoMip(va("gfx/scenes/%i", s_main.currentScene))); color[3] = s_main.fade / 1000.0f; if (color[3] > 1) { color[3] = 1; } if (color[3] < 0) { color[3] = 0; } trap_R_SetColor(color); UI_DrawNamedPic(x, y, w, h, "gfx/colors/blue.jpg"); trap_R_SetColor(oldColor); trap_R_AddRefEntityToScene(&ent); trap_R_RenderScene(&refdef); if (strlen(s_errorMessage.errorMessage)) { UI_DrawProportionalString_AutoWrapped(320, 192, 600, 20, s_errorMessage.errorMessage, UI_CENTER | UI_SMALLFONT | UI_DROPSHADOW, menu_text_color); } else { Menu_Draw(&s_main.menu); } }