void primPointSize3Fade(vector *p1, real32 size, color c, real32 fade) { GLboolean blend = glIsEnabled(GL_BLEND); if (!blend) { glEnable(GL_BLEND); } glPointSize(size); glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f)); glBegin(GL_POINTS); glVertex3f(p1->x, p1->y, p1->z); //!!! no size glEnd(); glPointSize(1.0f); if (!blend) { glDisable(GL_BLEND); } }
//---------------------------------------------------------------------------------- void CVehicleMovementTank::DebugDrawMovement(const float deltaTime) { if (!IsProfilingMovement()) return; CVehicleMovementStdWheeled::DebugDrawMovement(deltaTime); IPhysicalEntity* pPhysics = GetPhysics(); IRenderer* pRenderer = gEnv->pRenderer; // float color[4] = {1,1,1,1}; // float green[4] = {0,1,0,1}; ColorB colRed(255,0,0,255); // float y = 50.f, step1 = 15.f, step2 = 20.f, size=1.3f, sizeL=1.5f; if (g_pGameCVars->v_dumpFriction) { if (m_avgLateralSlip > 0.01f) { CryLog("%4.2f, %4.2f, %4.2f", m_currSteer, m_avgLateralSlip, m_latFriction); } } }
/*----------------------------------------------------------------------------- Name : colMultiplyClamped Description : multiply a color by a floating-point factor clamping to prevent overflow Inputs : Outputs : Return : multiplied color ----------------------------------------------------------------------------*/ color colMultiplyClamped(color c, real32 factor) { udword red, green, blue; udword intFactor; if (factor < 0.0f) { intFactor = 0; } else if (factor > 1.0f) { intFactor = 255; } else { intFactor = (udword)(factor * 255.0f); } red = (colRed(c) * intFactor) >> 8; green = (colGreen(c) * intFactor) >> 8; blue = (colBlue(c) * intFactor) >> 8; return(colRGB(red, green, blue)); }
/*----------------------------------------------------------------------------- Name : primEllipseOutlineZ Description : Draw an axis-aligned ellipse centred about a specified point on the Z plane Inputs : centre - centre of the ellipse rx - x - axis radius ry - y - axis radius nSegments - number of segments c - color of ellipse Outputs : Return : ----------------------------------------------------------------------------*/ void primEllipseOutlineZ(vector *centre, real32 rx, real32 ry, sdword nSegments, color c) { GLfloat rim[3]; double theta, thetaDelta; real32 x, y; theta = 0.0f; thetaDelta = 2.0 * PI / (double)nSegments; glColor3ub(colRed(c), colGreen(c), colBlue(c)); x = centre->x; y = centre->y; rim[2] = centre->z; glBegin(GL_LINE_STRIP); for (; nSegments >= 0; nSegments--) { rim[0] = x + (real32)sin(theta) * rx; rim[1] = y + (real32)cos(theta) * ry; glVertex3fv(rim); theta += thetaDelta; } glEnd(); }
/*----------------------------------------------------------------------------- Name : primCircleSolid3 Description : Draw a solid circle on the z = centre->z plane Inputs : centre - centre point (in 3D coords) of the circle radius - radius of circle (actually, distance from centre to vertices) nSlices - number of polygons to draw c - color of circle Outputs : .. Return : void ----------------------------------------------------------------------------*/ void primCircleSolid3(vector *centre, real32 radius, sdword nSlices, color c) { sdword index; GLfloat v[3]; double theta; glColor3ub(colRed(c), colGreen(c), colBlue(c)); v[0] = centre->x; v[1] = centre->y; v[2] = centre->z; glBegin(GL_TRIANGLE_FAN); glVertex3fv(v); //centre vertex for (index = 0, theta = 0.0; index < nSlices; index++) { v[0] = centre->x + (real32)(sin(theta)) * radius; v[1] = centre->y + (real32)(cos(theta)) * radius; theta += 2.0 * PI / (double)nSlices; glVertex3fv(v); //vertex on outer rim } v[0] = centre->x; v[1] = centre->y + radius; glVertex3fv(v); //final vertex on outer rim glEnd(); }
/*----------------------------------------------------------------------------- Name : primLine3 Description : Draw a line in 3D using having a thickness of 1 pixel Inputs : p1, p2 - end points of line segment to draw c - color to draw it in. Outputs : Return : void ----------------------------------------------------------------------------*/ void primLine3(vector *p1, vector *p2, color c) { bool blendon; if (glCapFeatureExists(GL_LINE_SMOOTH)) { blendon = glIsEnabled(GL_BLEND); if (!blendon) glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); rndAdditiveBlends(FALSE); } glColor3ub(colRed(c), colGreen(c), colBlue(c)); glBegin(GL_LINES); glVertex3fv((const GLfloat *)p1); glVertex3fv((const GLfloat *)p2); glEnd(); if (glCapFeatureExists(GL_LINE_SMOOTH)) { if (!blendon) glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } }
void primCircleSolid3Fade(vector *centre, real32 radius, sdword nSlices, color c, real32 fade) { sdword index; GLfloat v[3]; double theta; GLboolean blend = glIsEnabled(GL_BLEND); if (!blend) { glEnable(GL_BLEND); rndAdditiveBlends(FALSE); } glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f)); v[0] = centre->x; v[1] = centre->y; v[2] = centre->z; glBegin(GL_TRIANGLE_FAN); glVertex3fv(v); //centre vertex for (index = 0, theta = 0.0; index < nSlices; index++) { v[0] = centre->x + (real32)(sin(theta)) * radius; v[1] = centre->y + (real32)(cos(theta)) * radius; theta += 2.0 * PI / (double)nSlices; glVertex3fv(v); //vertex on outer rim } v[0] = centre->x; v[1] = centre->y + radius; glVertex3fv(v); //final vertex on outer rim glEnd(); if (!blend) { glDisable(GL_BLEND); } }
/*----------------------------------------------------------------------------- Name : primMaskedRoundRectOutline Description : Draw an outline 2d rounded rectangle. Inputs : rect - pointer to rectangle structure containing coordinates. thickness - thickness of the lines, mask - OL_* mask for roundedness c - color to draw it in, xb - x offset, yb - y offset Outputs : .. Return : void ----------------------------------------------------------------------------*/ void primMaskedRoundRectOutline(rectangle *rect, sdword thickness, color c, uword xb, uword yb, uword mask) { oval o; sdword segs = SEGS; glColor3ub(colRed(c), colGreen(c), colBlue(c)); glPushAttrib(GL_LINE_BIT); glLineWidth((GLfloat)thickness); glBegin(GL_LINES); glVertex2f(SX(X0+xb), SY(Y0)); glVertex2f(SX(X1-xb), SY(Y0)); glVertex2f(SX(X1), SY(Y0+yb)); glVertex2f(SX(X1), SY(Y1-yb)); glVertex2f(SX(X1-xb), SY(Y1)); glVertex2f(SX(X0+xb), SY(Y1)); glVertex2f(SX(X0), SY(Y1-yb)); glVertex2f(SX(X0), SY(Y0+yb)); if (!(mask & OL_UL)) { glVertex2f(SX(X0), SY(Y0)); glVertex2f(SX(X0+xb), SY(Y0)); glVertex2f(SX(X0), SY(Y0)); glVertex2f(SX(X0), SY(Y0+yb)); } if (!(mask & OL_LL)) { glVertex2f(SX(X0), SY(Y1)); glVertex2f(SX(X0+xb), SY(Y1)); glVertex2f(SX(X0), SY(Y1)); glVertex2f(SX(X0), SY(Y1-yb)); } if (!(mask & OL_UR)) { glVertex2f(SX(X1-xb), SY(Y0)); glVertex2f(SX(X1), SY(Y0)); glVertex2f(SX(X1), SY(Y0)); glVertex2f(SX(X1), SY(Y0+yb)); } if (!(mask & OL_LR)) { glVertex2f(SX(X1), SY(Y1-yb)); glVertex2f(SX(X1), SY(Y1)); glVertex2f(SX(X1), SY(Y1)); glVertex2f(SX(X1-xb), SY(Y1)); } glEnd(); glPopAttrib(); if (xb > 4 || yb > 4) segs *= 2; // upper left o.centreX = X0+xb; o.centreY = Y0+yb; o.radiusX = xb; o.radiusY = yb; if (mask & OL_UL) primOvalArcOutline2(&o, 3*PI/2, TWOPI, 2, segs, c); // upper right o.centreX = X1-xb; if (mask & OL_UR) primOvalArcOutline2(&o, 0.0f, PI/2, 2, segs, c); // lower right o.centreY = Y1-yb; if (mask & OL_LR) primOvalArcOutline2(&o, PI/2, PI, 2, segs, c); // lower left o.centreX = X0+xb; if (mask & OL_LL) primOvalArcOutline2(&o, PI, 3*PI/2, 2, segs, c); }
/*----------------------------------------------------------------------------- Name : primOvalArcOutline2 Description : Draw an outline section of an oval. Inputs : o - oval structure describing location and size on-screen degStarts, degEnd - degree stations of start and end of line thickness - thickness of lines segments - number of line segments for a complete oval c - color to draw outline in Outputs : .. Return : void Note : The coordinate system used will be the engineering system where up (x = 0, y = -1) is 0 rad. ----------------------------------------------------------------------------*/ void primOvalArcOutline2(oval *o, real32 radStart, real32 radEnd, sdword thickness, sdword segments, color c) { sdword segment, endSegment; real32 angle, angleInc; real32 centreX, centreY, width, height; real32 x, y, lastX, lastY; if (glcActive()) { centreX = (real32)o->centreX; centreY = (real32)o->centreY; width = (real32)o->radiusX; height = (real32)o->radiusY; } else { centreX = primScreenToGLX(o->centreX); //get floating-point version of oval attributes centreY = primScreenToGLY(o->centreY); width = primScreenToGLScaleX(o->radiusX); height = primScreenToGLScaleY(o->radiusY); } segment = (sdword)(radStart * (real32)segments / (2.0f * PI));//get starting segment endSegment = (sdword)(radEnd * (real32)segments / (2.0f * PI) - 0.01f);//get ending segment glColor3ub(colRed(c), colGreen(c), colBlue(c)); glPushAttrib(GL_LINE_BIT); glLineWidth((GLfloat)thickness); glBegin(GL_LINE_STRIP); x = centreX + (real32)sin((double)radStart) * width; //first vertex y = centreY + (real32)cos((double)radStart) * height; if (glcActive()) { lastX = x; lastY = y; } else { glVertex2f(x, y); } segment++; angle = (real32)segment * (2.0f * PI / (real32)segments); angleInc = (2.0f * PI / (real32)segments); for (; segment <= endSegment; segment++) { //for start and all complete segments x = centreX + (real32)sin((double)angle) * width; y = centreY + (real32)cos((double)angle) * height; if (glcActive()) { glcLine2((sdword)lastX, (sdword)lastY, (sdword)x, (sdword)y, thickness, c); lastX = x; lastY = y; } else { glVertex2f(x, y); } angle += angleInc; //update angle } x = centreX + (real32)sin((double)radEnd) * width; y = centreY + (real32)cos((double)radEnd) * height; if (glcActive()) { glcLine2((sdword)lastX, (sdword)lastY, (sdword)x, (sdword)y, thickness, c); } else { glVertex2f(x, y); //draw last vertex } glEnd(); glPopAttrib(); }
void liBlendColorDodge(color *buffer, color *layer, real32 opacity, sdword nPixels) { real32 redSource, greenSource, blueSource, alpha; real32 redDest, greenDest, blueDest;//, alphaDest; real32 oneMinusAlpha; while (nPixels > 0) { alpha = colUbyteToReal(colAlpha(*layer)) * opacity; oneMinusAlpha = 1.0f - alpha; redSource = colUbyteToReal(colRed(*layer)); //read pixel to floating point greenSource = colUbyteToReal(colGreen(*layer)); blueSource = colUbyteToReal(colBlue(*layer)); redDest = colUbyteToReal(colRed(*buffer)); greenDest = colUbyteToReal(colGreen(*buffer)); blueDest = colUbyteToReal(colBlue(*buffer)); redDest = (redDest + redSource * redSource * redDest) * alpha + redDest * oneMinusAlpha; greenDest = (greenDest + greenSource * greenSource * greenDest) * alpha + greenDest * oneMinusAlpha; blueDest = (blueDest + blueSource * blueSource * blueDest) * alpha + blueDest * oneMinusAlpha; redDest = min(redDest, 1.0f); greenDest = min(greenDest, 1.0f); blueDest = min(blueDest, 1.0f); *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest), colRealToUbyte(blueDest)); buffer++; layer++; nPixels--; } /* real32 redSource, greenSource, blueSource, alpha; real32 redDest, greenDest, blueDest;//, alphaDest; real32 oneMinusAlpha; real32 hueS, satS, valS, hueD, satD, valD; // real32 cvalD, cvalS; while (nPixels > 0) { alpha = colUbyteToReal(colAlpha(*layer)) * opacity; oneMinusAlpha = 1.0f - alpha; redSource = colUbyteToReal(colRed(*layer)); //read pixel to floating point greenSource = colUbyteToReal(colGreen(*layer)); blueSource = colUbyteToReal(colBlue(*layer)); redDest = colUbyteToReal(colRed(*buffer)); greenDest = colUbyteToReal(colGreen(*buffer)); blueDest = colUbyteToReal(colBlue(*buffer)); // redDest = (redDest + redSource * redSource * redDest) * alpha + redDest * oneMinusAlpha; // greenDest = (greenDest + greenSource * greenSource * greenDest) * alpha + greenDest * oneMinusAlpha; // blueDest = (blueDest + blueSource * blueSource * blueDest) * alpha + blueDest * oneMinusAlpha; colRGBToHSV(&hueS, &satS, &valS, redSource * alpha, greenSource * alpha, blueSource * alpha); colRGBToHSV(&hueD, &satD, &valD, redDest, greenDest, blueDest); valD += valS; valD = min(valD, 1.0f); colHSVToRGB(&redDest, &greenDest, &blueDest, hueD, satD, valD); *buffer = colRGB(colRealToUbyte(redDest), colRealToUbyte(greenDest), colRealToUbyte(blueDest)); buffer++; layer++; nPixels--; } */ }
/*----------------------------------------------------------------------------- Name : primSolidTexture3 Description : Draw a 3D point with size Inputs : p1 - location of point size - physical size of point c - color of point Outputs : Return : void ----------------------------------------------------------------------------*/ void primSolidTexture3(vector *p1, real32 size, color c, trhandle tex) { real32 halfsize; real32 biasRed, biasGreen, biasBlue; texreg* reg; if (!glCapFeatureExists(RGL_COLOROP_ADD)) { //multi-pass render to approximate a missing feature primSolidTexture3_multi(p1, size, c, tex); return; } halfsize = 0.5f * size; rndTextureEnable(TRUE); // glDepthMask(GL_FALSE); trMakeCurrent(tex); reg = trStructureGet(tex); if (bitTest(reg->flags, TRF_Alpha)) { glEnable(GL_BLEND); glDisable(GL_ALPHA_TEST); rndAdditiveBlends(TRUE); } biasRed = colReal32(colRed(c)); biasGreen = colReal32(colGreen(c)); biasBlue = colReal32(colBlue(c)); if (RGL) { glPixelTransferf(GL_RED_BIAS, biasRed); glPixelTransferf(GL_GREEN_BIAS, biasGreen); glPixelTransferf(GL_BLUE_BIAS, biasBlue); } glColor3f(biasRed, biasGreen, biasBlue); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f); glEnd(); if (RGL) { glPixelTransferf(GL_RED_BIAS, 0.0f); glPixelTransferf(GL_GREEN_BIAS, 0.0f); glPixelTransferf(GL_BLUE_BIAS, 0.0f); } glDisable(GL_BLEND); // glDepthMask(GL_TRUE); rndAdditiveBlends(FALSE); }
/*----------------------------------------------------------------------------- Name : primCircleOutline3 Description : Draw a solid circle on the z = centre->z plane Inputs : centre - centre point (in 3D coords) of the circle radius - radius of circle (actually, distance from centre to vertices) nSlices - number of polygons to draw nSpokes - number of 'spokes' which actually get drawn. nSlices should integer divide by this with no remainder. color - color of circle axis - axis on which to draw the circle Outputs : .. Return : void ----------------------------------------------------------------------------*/ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices, sdword nSpokes, color color, uword axis) { Node *node; vertice_array *vertices; register vector *vec_ptr; sdword index; GLfloat c[3], rim[3]; // find the vertice list containing the unit circle that has the same // number of slices and is aligned along the same axis as the circle to be drawn node = CircleList.head; while (node != NULL) { vertices = (vertice_array *)listGetStructOfNode(node); if ((vertices->num_vertices == (nSlices + 1)) && (vertices->axis == axis)) { //found the correct unit circle break; } node = node->next; } //if the unit circle isn't found, generate a new one if (node == NULL) { vertices = primCreateNewCircleVerticeArray(nSlices, axis); } if (nSpokes != 0) { nSpokes = nSlices / nSpokes; } glColor3ub(colRed(color), colGreen(color), colBlue(color)); c[0] = centre->x; //compute centre point c[1] = centre->y; c[2] = centre->z; glShadeModel(GL_SMOOTH); if (glCapFeatureExists(GL_LINE_SMOOTH)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); rndAdditiveBlends(FALSE); } vec_ptr = &vertices->vertice[0]; switch (axis) { case X_AXIS: rim[0] = centre->x + vec_ptr->x * radius; //draw the circle glBegin(GL_LINE_LOOP); for (index = 0; index <= nSlices; index++, vec_ptr++) { rim[1] = centre->y + vec_ptr->y * radius; rim[2] = centre->z + vec_ptr->z * radius; glVertex3fv(rim); //vertex on rim } glEnd(); //now draw the spokes if (nSpokes) { vec_ptr = &vertices->vertice[0]; glBegin(GL_LINES); for (index = 0; index <= nSlices; index += nSpokes, vec_ptr += nSpokes) { rim[1] = centre->y + vec_ptr->y * radius; rim[2] = centre->z + vec_ptr->z * radius; glVertex3fv(c); glVertex3fv(rim); } glEnd(); } break; case Y_AXIS: rim[1] = centre->y + vec_ptr->y * radius; //draw the circle glBegin(GL_LINE_LOOP); for (index = 0; index <= nSlices; index++, vec_ptr++) { rim[0] = centre->x + vec_ptr->x * radius; rim[2] = centre->z + vec_ptr->z * radius; glVertex3fv(rim); //vertex on rim } glEnd(); //draw the spokes if (nSpokes) { vec_ptr = &vertices->vertice[0]; glBegin(GL_LINES); for (index = 0; index <= nSlices; index += nSpokes, vec_ptr += nSpokes) { rim[0] = centre->x + vec_ptr->x * radius; rim[2] = centre->z + vec_ptr->z * radius; glVertex3fv(c); glVertex3fv(rim); } glEnd(); } break; case Z_AXIS: rim[2] = centre->z + vec_ptr->z * radius; //draw the circle glBegin(GL_LINE_LOOP); for (index = 0; index <= nSlices; index++, vec_ptr++) { rim[0] = centre->x + vec_ptr->x * radius; rim[1] = centre->y + vec_ptr->y * radius; glVertex3fv(rim); //vertex on rim } glEnd(); //draw the spokes if (nSpokes) { vec_ptr = &vertices->vertice[0]; glBegin(GL_LINES); for (index = 0; index <= nSlices; index += nSpokes, vec_ptr += nSpokes) { rim[0] = centre->x + vec_ptr->x * radius; rim[1] = centre->y + vec_ptr->y * radius; glVertex3fv(c); glVertex3fv(rim); } glEnd(); } break; default: break; } if (glCapFeatureExists(GL_LINE_SMOOTH)) { glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } }
/*----------------------------------------------------------------------------- Name : pingListDraw Description : Draw all pings from farthest to nearest. Inputs : camera - the camera we're rendering from modelView, projection - current matrices viewPort - rectangle we're rending in, for the TO legend Outputs : Return : Note : The renderer should be in 2D mode at this point. ----------------------------------------------------------------------------*/ void pingListDraw(Camera *camera, hmatrix *modelView, hmatrix *projection, rectangle *viewPort) { real32 pingAge, pingCycle, pingMod, pingSize; real32 x, y, radius; Node *thisNode, *nextNode; ping *thisPing; vector distSquared; sdword nSegments, index, rowHeight, xScreen, yScreen; oval o; udword TOFlags = 0; fonthandle fhSave; toicon *icon; color col; real32 realMargin; ShipClass shipClass; static real32 lastProximityPing = REALlyBig; static real32 lastAnomolyPing = REALlyBig; static real32 lastBattlePing = REALlyBig; static real32 lastHyperspacePing = REALlyBig; static real32 lastNewshipPing = REALlyBig; bool pingset; //start by sorting the ping list from farthest to nearest thisNode = pingList.head; while (thisNode != NULL) { //scan all pings nextNode = thisNode->next; thisPing = listGetStructOfNode(thisNode); if (thisPing->owner != NULL) { thisPing->centre = thisPing->owner->posinfo.position; } vecSub(distSquared, camera->eyeposition, thisPing->centre); thisPing->cameraDistanceSquared = vecMagnitudeSquared(distSquared); TOFlags |= thisPing->TOMask; thisNode = nextNode; } listMergeSortGeneral(&pingList, pingListSortCallback); //now the list is sorted; proceed to draw all the pings thisNode = pingList.head; pingset = FALSE; while (thisNode != NULL) { //scan all pings nextNode = thisNode->next; thisPing = listGetStructOfNode(thisNode); pingCycle = thisPing->pingDuration + thisPing->interPingPause; pingAge = universe.totaltimeelapsed - thisPing->creationTime; pingMod = (real32)fmod((double)pingAge, (double)pingCycle); if (pingMod <= thisPing->pingDuration) { pingSize = (thisPing->size - thisPing->minSize) * pingMod / thisPing->pingDuration + thisPing->minSize; selCircleComputeGeneral(modelView, projection, &thisPing->centre, max(thisPing->size,thisPing->minSize), &x, &y, &radius); if (radius > 0.0f) { radius = max(radius, thisPing->minScreenSize); radius *= pingSize / max(thisPing->size,thisPing->minSize); o.centreX = primGLToScreenX(x); o.centreY = primGLToScreenY(y); o.radiusX = o.radiusY = primGLToScreenScaleX(radius); nSegments = pieCircleSegmentsCompute(radius); primOvalArcOutline2(&o, 0.0f, 2*PI, 1, nSegments, thisPing->c); /* starting to draw a new ping so play the sound */ if (!smZoomingIn && !smZoomingOut && !pingset) { switch (thisPing->TOMask) { case PTOM_Anomaly: if (pingSize <=lastAnomolyPing) { soundEvent(NULL, UI_SensorsPing); pingset = TRUE; lastAnomolyPing = pingSize; } break; case PTOM_Battle: if (pingSize <= lastBattlePing) { soundEvent(NULL, UI_PingBattle); pingset = TRUE; lastBattlePing = pingSize; } break; case PTOM_Hyperspace: if (pingSize <= lastHyperspacePing) { soundEvent(NULL, UI_PingHyperspace); pingset = TRUE; lastHyperspacePing = pingSize; } break; case PTOM_Proximity: if (pingSize <= lastProximityPing) { soundEvent(NULL, UI_PingProximity); pingset = TRUE; lastProximityPing = pingSize; } break; case PTOM_NewShips: if (pingSize <= lastNewshipPing) { soundEvent(NULL, UI_PingNewShips); pingset = TRUE; lastNewshipPing = pingSize; } break; default: break; } } } } thisNode = nextNode; } //draw the blip TO if (smTacticalOverlay) { realMargin = primScreenToGLScaleX(viewPort->x0); fhSave = fontCurrentGet(); //save the current font fontMakeCurrent(selGroupFont2); // use a common, fairly small font rowHeight = fontHeight("M"); // used to space the legend yScreen = viewPort->y0 + rowHeight; //leave some space at the top to start radius = primScreenToGLScaleX(rowHeight)/2; xScreen = viewPort->x0 + (sdword)(rowHeight * 2.5); for (index = 0; index < PTO_NumberTOs; index++) { if ((TOFlags & pingTOList[index].bitMask)) { // fontPrint(xScreen, yScreen, *pingTOList[index].c, "O"); pingTOList[index].lastTimeDrawn = universe.totaltimeelapsed; } if (universe.totaltimeelapsed - pingTOList[index].lastTimeDrawn <= pingTOLingerTime) { o.centreX = viewPort->x0 + rowHeight * 3 / 2; o.centreY = yScreen + rowHeight / 2; o.radiusX = o.radiusY = rowHeight / 2; primOvalArcOutline2(&o, 0.0f, TWOPI, 1, pingTONSegments, *pingTOList[index].c); fontPrint(xScreen, yScreen, TO_TextColor, strGetString(pingTOList[index].stringEnum)); yScreen += rowHeight + 1; } } for (shipClass = 0; shipClass < NUM_CLASSES; shipClass++) { if (!toClassUsed[shipClass][0]) { continue; } icon = toClassIcon[shipClass]; fontPrint(xScreen, yScreen + (rowHeight>>2), TO_TextColor, ShipClassToNiceStr(shipClass)); #if TO_STANDARD_COLORS col = teFriendlyColor; #else col = teColorSchemes[universe.curPlayerIndex].tacticalColor; #endif col = colRGB(colRed(col)/TO_IconColorFade, colGreen(col)/TO_IconColorFade, colBlue(col)/TO_IconColorFade); primLineLoopStart2(1, col); for (index = icon->nPoints - 1; index >= 0; index--) { primLineLoopPoint3F(realMargin + primScreenToGLX(rowHeight*1.5) + icon->loc[index].x * radius, primScreenToGLY(yScreen + rowHeight/2) + icon->loc[index].y * radius); } primLineLoopEnd2(); yScreen += rowHeight + 1; } fontMakeCurrent(fhSave); } }
/*----------------------------------------------------------------------------- Name : RenderNAVLights Description : TODO: render sorted by projected depth value so alpha sorts correctly Inputs : ship - the ship whose navlights we are to render Outputs : Return : ----------------------------------------------------------------------------*/ void RenderNAVLights(Ship *ship) { sdword i; NAVLight *navLight; NAVLightInfo *navLightInfo; ShipStaticInfo *shipStaticInfo; NAVLightStatic *navLightStatic; vector origin = {0.0f, 0.0f, 0.0f}; NAVLightStaticInfo *navLightStaticInfo; real32 fade; bool lightOn; extern bool bFade; extern real32 meshFadeAlpha; fade = bFade ? meshFadeAlpha : 1.0f; shipStaticInfo = (ShipStaticInfo *)ship->staticinfo; navLightInfo = ship->navLightInfo; if(shipStaticInfo->navlightStaticInfo && navLightInfo != NULL) { glDepthMask(GL_FALSE); rndAdditiveBlends(TRUE); lightOn = rndLightingEnable(FALSE); navLightStaticInfo = shipStaticInfo->navlightStaticInfo; navLightStatic = navLightStaticInfo->navlightstatics; navLight = navLightInfo->navLights; for( i=0 ; i<navLightStaticInfo->numNAVLights ; i++, navLight ++, navLightStatic ++) { // Account for the startdelay. if(navLight->lastTimeFlashed == navLightStatic->startdelay) { navLight->lastTimeFlashed = universe.totaltimeelapsed + navLightStatic->startdelay; } if(universe.totaltimeelapsed > navLight->lastTimeFlashed) { if(navLight->lightstate == 1) { navLight->lastTimeFlashed = universe.totaltimeelapsed + navLightStatic->flashrateoff; } else { navLight->lastTimeFlashed = universe.totaltimeelapsed + navLightStatic->flashrateon; } navLight->lightstate = 1 - navLight->lightstate; } if(navLight->lightstate) { if (ship->currentLOD <= (sdword)navLightStatic->minLOD) { navLightBillboardEnable(ship, navLightStatic); if(navLightStatic->texturehandle == TR_InvalidHandle) { primCircleSolid3Fade(&origin, navLightStatic->size, 10, navLightStatic->color, fade); } else { primSolidTexture3Fade(&origin, navLightStatic->size, navLightStatic->color, navLightStatic->texturehandle, fade); } navLightBillboardDisable(); } else { color tempColor; tempColor = colRGB(colRed(navLightStatic->color) * 2 / 3, colGreen(navLightStatic->color) * 2 / 3, colBlue(navLightStatic->color) * 2 / 3); rndTextureEnable(FALSE); if (RGL) { if (glCapFastFeature(GL_BLEND)) { rndAdditiveBlends(TRUE); primPointSize3(&navLightStatic->position, 2.0f, tempColor); } else { primPointSize3(&navLightStatic->position, 1.0f, tempColor); } } else { rndAdditiveBlends(TRUE); glEnable(GL_POINT_SMOOTH); primPointSize3Fade(&navLightStatic->position, 2.0f, tempColor, fade); glDisable(GL_POINT_SMOOTH); } } } } rndLightingEnable(lightOn); rndAdditiveBlends(FALSE); glDepthMask(GL_TRUE); } }
void CVehiclePartSuspensionPart::Update(const float frameTime) { inherited::Update(frameTime); const Matrix34& parentTm = m_pParentPart->GetLocalTM(false); const Matrix34& targetTm = m_targetPart->GetLocalTM(false); Vec3 pos = parentTm * m_pos0; Vec3 targetPos = (m_ikFlags&k_flagIgnoreTargetRotation) ? (targetTm.GetColumn3() + m_targetOffset) : (targetTm * m_targetOffset); Vec3 dir = targetPos - pos; float length = dir.GetLength(); if (length > 1e-2f) { Matrix33 rot = Matrix33::CreateRotationV0V1(m_direction0, dir*(1.f/length)); Matrix33 partRot = rot*Matrix33(m_initialRot); if (m_mode==k_modeRotate || m_mode==k_modeSnapToEF) { if (m_mode==k_modeSnapToEF) { pos = targetPos - rot * m_direction0; } Matrix34 tm(partRot, pos); SetLocalTM(tm); } else if (m_mode==k_modeStretch) { const float scale = length * m_invLength0; const Vec3 z = m_direction0; const Vec3 sz = m_direction0*(scale-1.f); Matrix33 scaleM; scaleM.m00 = 1.f+sz.x*z.x; scaleM.m01 = sz.y*z.x ; scaleM.m02 = sz.z*z.x; scaleM.m10 = sz.x*z.y ; scaleM.m11 = 1.f+sz.y*z.y; scaleM.m12 = sz.z*z.y; scaleM.m20 = sz.x*z.z ; scaleM.m21 = sz.y*z.z ; scaleM.m22 = 1.f+sz.z*z.z; Matrix34 tm(partRot * scaleM, pos); SetLocalTM(tm); } } #if !defined(_RELEASE) if (VehicleCVars().v_debugSuspensionIK) { IRenderAuxGeom* pAuxGeom = gEnv->pRenderer->GetIRenderAuxGeom(); SAuxGeomRenderFlags flags = pAuxGeom->GetRenderFlags(); SAuxGeomRenderFlags oldFlags = pAuxGeom->GetRenderFlags(); flags.SetDepthWriteFlag(e_DepthWriteOff); flags.SetDepthTestFlag(e_DepthTestOff); pAuxGeom->SetRenderFlags(flags); ColorB colRed(255,0,0,255); ColorB colBlue(0,0,255,255); ColorB colWhite(255,255,255,255); ColorB colGreen(0,255,0,255); pos = m_pVehicle->GetEntity()->GetWorldTM() * pos; targetPos = m_pVehicle->GetEntity()->GetWorldTM() * targetPos; pAuxGeom->DrawSphere(pos, 0.02f, colGreen); pAuxGeom->DrawSphere(targetPos, 0.02f, colBlue); pAuxGeom->DrawLine(pos, colWhite, targetPos, colWhite); } #endif }