void drawEntityCam( int player ) { if( player < 0 || player > MAX_CLIENTS ) return; if ( !eth.entities[player].isValid ) return; ethEntity_t *ent = ð.entities[player]; //set camera view refdef_t camRefDef; memcpy(&camRefDef, ð.cg_refdef, sizeof(refdef_t)); camRefDef.fov_x = 90; camRefDef.fov_y = 90; //set origin and translate a bit forward vec3_t origin; VectorCopy( ent->head, origin ); VectorMA( origin, 5, ent->headAxis[0], origin ); VectorCopy( origin, camRefDef.vieworg ); //set angles //FIXME: find lerped angles somewhere for smoother view memcpy(ent->headAxis, camRefDef.viewaxis, sizeof(vec3_t) * 3); AnglesToAxis( eth.cg_entities[player].currentState->apos.trBase, camRefDef.viewaxis ); //memcpy( eth.cg_entities[player].pe_bodyRefEnt.axis, camRefDef.viewaxis, sizeof(vec3_t) * 3); /* vec3_t camangle; AxisToAngles( camRefDef.viewaxis, camangle ); printf("{%.1f,%.1f,%.1f}\n", camangle[0], camangle[1], camangle[2]); */ // Draw the spycam refdef_t *refDef = &camRefDef; float x = 10; float y = 10; float width = 240; float height = 240; // fool engine/mod into drawing ourselves :D int oldflags = eth.cg_entities[eth.cg_snap->ps.clientNum].currentState->eFlags; int *flags = ð.cg_entities[eth.cg_snap->ps.clientNum].currentState->eFlags; *flags &= ~EF_NODRAW; // Add all backuped refEntities to the scene int count = 0; for (; count < eth.refEntitiesCount; count++) { refEntity_t* refEnt = ð.refEntities[count]; int entityNum = refEnt->entityNum ; // set special flag for entcam subject if( entityNum == player ) refEnt->renderfx &= RF_FIRST_PERSON; // make sure we draw ourselves :D if( entityNum == eth.cg_snap->ps.clientNum ) refEnt->renderfx &= ~RF_THIRD_PERSON; orig_syscall(CG_R_ADDREFENTITYTOSCENE, refEnt); } // Adjust refDef from 640 refDef->x = x * eth.cgs_screenXScale; refDef->y = y * eth.cgs_screenYScale; refDef->width = width * eth.cgs_screenXScale; refDef->height = height * eth.cgs_screenYScale; // Draw the entcam scene drawFillRect(x, y, width, height, colorBlack); orig_syscall(CG_R_RENDERSCENE, refDef); // Draw border drawRect(x, y, width, height, colorBlack, 1); if(colorCam[3] != 0.0f) drawFillRect(x,y,width,height,colorCam); // Draw the crosshair #define CROSSHAIR_SIZE 4 drawRect(x + (width / 2) - (CROSSHAIR_SIZE / 2), y + (height / 2) - (CROSSHAIR_SIZE / 2) , CROSSHAIR_SIZE, CROSSHAIR_SIZE, colorRed, 1); // back us up please *flags = oldflags; }