/* ================== CG_BuildableHealthBar ================== */ static void CG_BuildableHealthBar( centity_t *cent ) { vec3_t origin, origin2, down, right, back, downLength, rightLength; float rimWidth = HEALTH_BAR_HEIGHT / 15.0f; float doneWidth, leftWidth, progress; int health; qhandle_t shader; entityState_t *es; vec3_t mins, maxs; es = ¢->currentState; health = es->generic1 & ~( B_POWERED_TOGGLEBIT | B_DCCED_TOGGLEBIT | B_SPAWNED_TOGGLEBIT ); progress = (float)health / B_HEALTH_SCALE; if( progress < 0.0f ) progress = 0.0f; else if( progress > 1.0f ) progress = 1.0f; if( progress < 0.33f ) shader = cgs.media.redBuildShader; else shader = cgs.media.greenBuildShader; doneWidth = ( HEALTH_BAR_WIDTH - 2 * rimWidth ) * progress; leftWidth = ( HEALTH_BAR_WIDTH - 2 * rimWidth ) - doneWidth; VectorCopy( cg.refdef.viewaxis[ 2 ], down ); VectorInverse( down ); VectorCopy( cg.refdef.viewaxis[ 1 ], right ); VectorInverse( right ); VectorSubtract( cg.refdef.vieworg, cent->lerpOrigin, back ); VectorNormalize( back ); VectorCopy( cent->lerpOrigin, origin ); BG_FindBBoxForBuildable( es->modelindex, mins, maxs ); VectorMA( origin, 48.0f, es->origin2, origin ); VectorMA( origin, -HEALTH_BAR_WIDTH / 2.0f, right, origin ); VectorMA( origin, maxs[ 0 ] + 8.0f, back, origin ); VectorCopy( origin, origin2 ); VectorScale( right, rimWidth + doneWidth, rightLength ); VectorScale( down, HEALTH_BAR_HEIGHT, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); VectorMA( origin, rimWidth + doneWidth, right, origin2 ); VectorScale( right, leftWidth, rightLength ); VectorScale( down, rimWidth, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); VectorMA( origin, rimWidth + doneWidth, right, origin2 ); VectorMA( origin2, HEALTH_BAR_HEIGHT - rimWidth, down, origin2 ); VectorScale( right, leftWidth, rightLength ); VectorScale( down, rimWidth, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); VectorMA( origin, HEALTH_BAR_WIDTH - rimWidth, right, origin2 ); VectorScale( right, rimWidth, rightLength ); VectorScale( down, HEALTH_BAR_HEIGHT, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); if( !( es->generic1 & B_POWERED_TOGGLEBIT ) && BG_FindTeamForBuildable( es->modelindex ) == BIT_HUMANS ) { VectorMA( origin, 15.0f, right, origin2 ); VectorMA( origin2, HEALTH_BAR_HEIGHT + 5.0f, down, origin2 ); VectorScale( right, HEALTH_BAR_WIDTH / 2.0f - 5.0f, rightLength ); VectorScale( down, HEALTH_BAR_WIDTH / 2.0f - 5.0f, downLength ); CG_DrawPlane( origin2, downLength, rightLength, cgs.media.noPowerShader ); } }
void ME_DrawVehicle( IGME_vehicle_t* veh ) { if( !veh ) return; if( veh->groundInstallation ) { DrawInfo_GI_t drawInfo; memset( &drawInfo, 0, sizeof(drawInfo) ); VectorCopy( veh->angles, drawInfo.basicInfo.angles ); VectorCopy( veh->origin, drawInfo.basicInfo.origin ); AnglesToAxis( veh->angles, drawInfo.basicInfo.axis ); drawInfo.basicInfo.vehicleIndex = veh->vehidx; drawInfo.basicInfo.entityNum = -1; drawInfo.turretAngle = 0; drawInfo.gunAngle = 10; drawInfo.upgrades = availableGroundInstallations[veh->vehidx].upgrades; CG_DrawGI(&drawInfo); } else { switch( availableVehicles[veh->vehidx].cat ) { case CAT_PLANE: { DrawInfo_Plane_t drawInfo; memset( &drawInfo, 0, sizeof(drawInfo) ); VectorCopy( veh->angles, drawInfo.basicInfo.angles ); VectorCopy( veh->origin, drawInfo.basicInfo.origin ); AnglesToAxis( veh->angles, drawInfo.basicInfo.axis ); drawInfo.basicInfo.vehicleIndex = veh->vehidx; drawInfo.basicInfo.entityNum = -1; drawInfo.basicInfo.usedLoadout = &availableLoadouts[veh->vehidx]; CG_DrawPlane(&drawInfo); } break; case CAT_GROUND: { DrawInfo_GV_t drawInfo; memset( &drawInfo, 0, sizeof(drawInfo) ); VectorCopy( veh->angles, drawInfo.basicInfo.angles ); VectorCopy( veh->origin, drawInfo.basicInfo.origin ); AnglesToAxis( veh->angles, drawInfo.basicInfo.axis ); drawInfo.basicInfo.vehicleIndex = veh->vehidx; drawInfo.basicInfo.entityNum = -1; drawInfo.basicInfo.usedLoadout = &availableLoadouts[veh->vehidx]; CG_DrawGV(&drawInfo); } break; case CAT_BOAT: { DrawInfo_Boat_t drawInfo; memset( &drawInfo, 0, sizeof(drawInfo) ); VectorCopy( veh->angles, drawInfo.basicInfo.angles ); VectorCopy( veh->origin, drawInfo.basicInfo.origin ); AnglesToAxis( veh->angles, drawInfo.basicInfo.axis ); drawInfo.basicInfo.vehicleIndex = veh->vehidx; drawInfo.basicInfo.entityNum = -1; drawInfo.basicInfo.usedLoadout = &availableLoadouts[veh->vehidx]; CG_DrawBoat(&drawInfo); } break; case CAT_HELO: break; case CAT_LQM: break; } } // draw selectors if( veh->selected ) { refEntity_t sel; int j; memset( &sel, 0, sizeof(sel) ); sel.hModel = cgs.media.IGME_selector; VectorCopy( veh->origin, sel.origin ); VectorCopy( veh->origin, sel.lightingOrigin ); VectorCopy( veh->origin, sel.oldorigin ); AnglesToAxis( veh->angles, sel.axis ); for( j = 0; j < 3; ++j ) { VectorScale( sel.axis[j], veh->selectorScale[j], sel.axis[j] ); } sel.nonNormalizedAxes = true; refExport.AddRefEntityToScene( &sel ); } // draw waypoints if( cgs.IGME.waypointmode && (veh->selected || cgs.IGME.showAllWaypoints) ) { int k; vec3_t lastpos, dir, ang; VectorCopy( veh->origin, lastpos ); for( k = 0; k < IGME_MAX_WAYPOINTS; ++k ) { refEntity_t wpt, lnk; int l; float dist; if( !veh->waypoints[k].active ) break;//as they are in a row memset( &wpt, 0, sizeof(wpt) ); wpt.hModel = cgs.media.IGME_selector; VectorCopy( veh->waypoints[k].origin, wpt.origin ); VectorCopy( wpt.origin, wpt.lightingOrigin ); VectorCopy( wpt.origin, wpt.oldorigin ); AxisCopy( axisDefault, wpt.axis ); for( l = 0; l < 3; ++l ) { VectorScale( wpt.axis[l], 0.25f, wpt.axis[l] ); } wpt.nonNormalizedAxes = true; if( veh->waypoints[k].selected ) { wpt.customShader = cgs.media.IGME_waypoint; } else { wpt.customShader = cgs.media.IGME_waypoint2; } refExport.AddRefEntityToScene( &wpt ); // draw link VectorSubtract( wpt.origin, lastpos, dir ); dist = VectorNormalize( dir ); dist *= 0.97f; vectoangles( dir, ang ); memset( &lnk, 0, sizeof(lnk) ); lnk.hModel = cgs.media.IGME_selector; VectorMA( lastpos, dist/2, dir, lnk.origin ); VectorCopy( lnk.origin, lnk.lightingOrigin ); VectorCopy( lnk.origin, lnk.oldorigin ); AnglesToAxis( ang, lnk.axis ); VectorScale( lnk.axis[0], dist/200.0f, lnk.axis[0] ); VectorScale( lnk.axis[1], 0.01f, lnk.axis[1] ); VectorScale( lnk.axis[2], 0.01f, lnk.axis[2] ); lnk.nonNormalizedAxes = true; lnk.customShader = cgs.media.IGME_waypoint2; refExport.AddRefEntityToScene( &lnk ); VectorCopy( veh->waypoints[k].origin, lastpos ); } } }