static int SetupText(PSEngine *psEngine) { int opq; int h= gistA.t.alignH, v= gistA.t.alignV; GtGetAlignment(&gistA.t, &h, &v); if (SetupColor(psEngine, gistA.t.color)) return 1; if (psEngine->curAlignH!=h || psEngine->curAlignV!=v) { sprintf(line, "%s %s JUS", psHCommands[h-1], psVCommands[v-1]); if (Append(psEngine, line)) return 1; psEngine->curAlignH= h; psEngine->curAlignV= v; } opq= gistA.t.opaque; /* if (gistA.t.orient!=TX_RIGHT) opq= 1; let this be X only limitation */ if (psEngine->curOpaque != (opq!=0)) { if (opq) Append(psEngine, "1 OPQ"); else if (Append(psEngine, "0 OPQ")) return 1; psEngine->curOpaque= (opq!=0); } if (psEngine->curFont!=gistA.t.font || psEngine->curHeight!=gistA.t.height) { if (SetupFont(psEngine, gistA.t.height)) return 1; } return 0; }
static int SetupLine(PSEngine *psEngine, GpLineAttribs *gistAl) { int changeLW= (psEngine->curWidth!=gistAl->width); if (SetupColor(psEngine, gistAl->color)) return 1; if (changeLW) { int lwidth; lwidth= (int)(DEFAULT_PS_WIDTH*gistAl->width); sprintf(line, "%d LW", lwidth); if (Append(psEngine, line)) return 1; psEngine->curWidth= gistAl->width; } /* WARNING-- the dash pattern is a function of the line width (see pscom.ps) */ if (psEngine->curType!=gistAl->type || (changeLW && gistAl->type!=L_SOLID)) { int ltype= gistAl->type; if (ltype==L_NONE) return 1; if (ltype<0 || ltype>N_PSDASHES) ltype= L_SOLID; sprintf(line, "%d DSH", ltype-1); if (Append(psEngine, line)) return 1; psEngine->curType= gistAl->type; } return 0; }
static int DrawMarkers(Engine *engine, long n, const GpReal *px, const GpReal *py) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &engine->map; long maxPoints= 4050, nPoints; int type, markEnd= 0; GpPoint *points; int size; char typeString[8]; if (n<1 || gistA.m.type<=0) return 0; if (CheckClip(psEngine)) return 1; if (SetupColor(psEngine, gistA.m.color) || SetupFont(psEngine, gistA.m.size*DEFAULT_MARKER_SIZE)) return 1; if (psEngine->curClip) size= 0; else size= (int)(psEngine->curHeight*NDC_TO_PS); if (gistA.m.type>32 && gistA.m.type<127) { char *now= typeString; *now++= '('; if (gistA.m.type=='(' || gistA.m.type==')' || gistA.m.type=='\\') *now++= '\\'; *now++= type= gistA.m.type; *now++= ')'; *now++= '\0'; } else { if (gistA.m.type<0 || gistA.m.type>M_CROSS) type= M_ASTERISK; else type= gistA.m.type; sprintf(typeString, "%d", type-1); } if (n>90) { long nLines= (n-1)/9 + 1; /* 9 points is 72 characters */ if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } if (Append(psEngine, typeString)) return 1; /* "(A)" or "1", e.g. */ sprintf(line, type<32? "%ld MS" : "%ld M", n); if (Append(psEngine, line) || PutLine(psEngine)) return 1; while ((nPoints= GpIntPoints(map, maxPoints, n, px, py, &points))) { if (PutPoints(psEngine, points, nPoints, size)) return 1; if (n==nPoints) break; n-= nPoints; px+= nPoints; py+= nPoints; } if (markEnd) { if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1; } return 0; }
MyColorButton::MyColorButton(QWidget *parent) : QPushButton(parent) { actionResetToDefault = NULL; actionAddToFlightAnimation = NULL; actionAddToKeyframeAnimation = NULL; parameterContainer = NULL; gotDefault = false; defaultValue = sRGB(); currentValue = sRGB(); setText(""); w = 40; h = 15; SetupColor(); }
void CParticle::UpdateColor (float fBrightness, int nThread) { if (m_nType <= SMOKE_PARTICLES) { if (m_nFadeState > 0) { if (m_color [0].green < m_color [1].green) { #if SMOKE_SLOWMO m_color [0].green += 1.0f / 20.0f / (float) gameStates.gameplay.slowmo [0].fSpeed; #else m_color [0].green += 1.0f / 20.0f; #endif if (m_color [0].green > m_color [1].green) { m_color [0].green = m_color [1].green; m_nFadeState--; } } if (m_color [0].blue < m_color [1].blue) { #if SMOKE_SLOWMO m_color [0].blue += 1.0f / 10.0f / (float) gameStates.gameplay.slowmo [0].fSpeed; #else m_color [0].blue += 1.0f / 10.0f; #endif if (m_color [0].blue > m_color [1].blue) { m_color [0].blue = m_color [1].blue; m_nFadeState--; } } } else if (m_nFadeState == 0) { m_color [0].red = m_color [1].red * RANDOM_FADE; m_color [0].green = m_color [1].green * RANDOM_FADE; m_color [0].blue = m_color [1].blue * RANDOM_FADE; m_nFadeState = -1; } #if SMOKE_LIGHTING //> 1 if (gameOpts->render.particles.nQuality == 3) { if (0 <= (m_nSegment = FindSegByPos (m_vPos, m_nSegment, 0, 0, 0, nThread))) { tFaceColor* colorP = lightManager.AvgSgmColor (m_nSegment, NULL, nThread); m_color [0].red *= colorP->color.red; m_color [0].green *= colorP->color.green; m_color [0].blue *= colorP->color.blue; } } #endif } SetupColor (fBrightness); }
static int DrawFill(Engine *engine, long n, const GpReal *px, const GpReal *py) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &engine->map; long maxPoints= 4050, nPoints; int markEnd= 0; GpPoint *points; int value= 0; /* For now, only FillSolid style supported */ if (n<1) return 0; if (CheckClip(psEngine) || SetupColor(psEngine, gistA.f.color)) return 1; if (n>90) { long nLines= (n-1)/9 + 1; /* 9 points is 72 characters */ if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } if (gistA.e.type==L_NONE) sprintf(line, "%ld F", n); else sprintf(line, "%ld E", n); if (Append(psEngine, line) || PutLine(psEngine)) return 1; while ((nPoints= GpIntPoints(map, maxPoints, n, px, py, &points))) { if (PutPoints(psEngine, points, nPoints, 0)) return 1; if (n==nPoints) break; n-= nPoints; px+= nPoints; py+= nPoints; value= 1; /* Polygons with >4050 sides won't be filled correctly */ } if (gistA.e.type!=L_NONE) { /* setup for edge (usually different color than fill), then draw it */ if (SetupLine(psEngine, &gistA.e)) return 1; if (Append(psEngine, "0 E") || PutLine(psEngine)) return 1; } if (markEnd) { if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1; } return value; }
int CParticle::Create (CFixVector *vPos, CFixVector *vDir, CFixMatrix *mOrient, short nSegment, int nLife, int nSpeed, char nParticleSystemType, char nClass, float nScale, tRgbaColorf *colorP, int nCurTime, int bBlowUp, char nFadeType, float fBrightness, CFixVector *vEmittingFace) { tRgbaColorf color; int nType = particleImageManager.GetType (nParticleSystemType); m_bChecked = 0; m_bBlowUp = bBlowUp && gameOpts->render.particles.bDisperse; if (nScale < 0) m_nRad = float (-nScale); else if (gameOpts->render.particles.bSyncSizes) m_nRad = float (PARTICLE_SIZE (gameOpts->render.particles.nSize [0], nScale, m_bBlowUp)); else m_nRad = float (nScale); if (!m_nRad) m_nRad = 1.0f; m_nType = nType; m_bEmissive = (nParticleSystemType == LIGHT_PARTICLES) ? 1 : (nParticleSystemType == FIRE_PARTICLES) ? 2 : 0; m_nClass = nClass; m_nFadeType = nFadeType; m_nSegment = nSegment; m_nBounce = ((m_nType == BUBBLE_PARTICLES) || (m_nType == WATERFALL_PARTICLES)) ? 1 : 2; m_bReversed = 0; m_nMoved = nCurTime; if (nLife < 0) nLife = -nLife; m_nLife = nLife; m_nDelay = 0; //bStart ? randN (nLife) : 0; m_color [0] = m_color [1] = color = (colorP && (m_bEmissive < 2)) ? *colorP : defaultParticleColor; if ((nType == BULLET_PARTICLES) || (nType == BUBBLE_PARTICLES)) { m_bBright = 0; m_nFadeState = -1; } else { m_bBright = (nType <= SMOKE_PARTICLES) ? (rand () % 50) == 0 : 0; if (colorP) { if (!m_bEmissive) { m_color [0].red *= RANDOM_FADE; m_color [0].green *= RANDOM_FADE; m_color [0].blue *= RANDOM_FADE; } m_nFadeState = 0; } else { m_color [0].red = 1.0f; m_color [0].green = 0.5f; m_color [0].blue = 0.0f; m_nFadeState = 2; } if (m_bEmissive) m_color [0].alpha = float (SMOKE_START_ALPHA + 64) / 255.0f; else if (nParticleSystemType != GATLING_PARTICLES) { if (!colorP) m_color [0].alpha = float (3 * SMOKE_START_ALPHA / 4 + randN (SMOKE_START_ALPHA / 2)) / 255.0f; else { if (colorP->alpha < 0) { ubyte a = ubyte (-colorP->alpha * 255.0f * 0.25f + 0.5f); m_color [0].alpha = float (3 * a + randN (2 * a)) / 255.0f; } else { if (2 == (m_nFadeState = char (colorP->alpha))) { m_color [0].red = 1.0f; m_color [0].green = 0.5f; m_color [0].blue = 0.0f; } m_color [0].alpha = float (3 * SMOKE_START_ALPHA / 4 + randN (SMOKE_START_ALPHA / 2)) / 255.0f; } } if (m_bBlowUp && !m_bBright) { fBrightness = 1.0f - fBrightness; m_color [0].alpha += fBrightness * fBrightness / 8.0f; } } } #if 0 if (nType == FIRE_PARTICLES) nSpeed = int (sqrt (double (nSpeed)) * float (I2X (1))); else #endif nSpeed *= I2X (1); if (!vDir) { m_vDrift [X] = nSpeed - randN (2 * nSpeed); m_vDrift [Y] = nSpeed - randN (2 * nSpeed); m_vDrift [Z] = nSpeed - randN (2 * nSpeed); m_vDir.SetZero (); m_bHaveDir = 1; } else { m_vDir = *vDir; CAngleVector a; CFixMatrix m; a [PA] = randN (I2X (1) / 4) - I2X (1) / 8; a [BA] = randN (I2X (1) / 4) - I2X (1) / 8; a [HA] = randN (I2X (1) / 4) - I2X (1) / 8; m = CFixMatrix::Create (a); if (nType == WATERFALL_PARTICLES) CFixVector::Normalize (m_vDir); m_vDrift = m * m_vDir; CFixVector::Normalize (m_vDrift); if (nType == WATERFALL_PARTICLES) { fix dot = CFixVector::Dot (m_vDir, m_vDrift); if (dot < I2X (1) / 2) return 0; } float d = float (CFixVector::DeltaAngle (m_vDrift, m_vDir, NULL)); if (d) { d = (float) exp ((I2X (1) / 8) / d); nSpeed = (fix) ((float) nSpeed / d); } m_vDrift *= nSpeed; if (nType <= FIRE_PARTICLES) m_vDir *= (I2X (3) / 4 + I2X (randN (16)) / 64); #if DBG if (CFixVector::Dot (m_vDrift, m_vDir) < 0) d = 0; #endif m_bHaveDir = 1; } if (vEmittingFace) m_vPos = *RandomPointOnQuad (vEmittingFace, vPos); else if (nType != BUBBLE_PARTICLES) m_vPos = *vPos + m_vDrift * (I2X (1) / 64); else { //m_vPos = *vPos + vDrift * (I2X (1) / 32); nSpeed = m_vDrift.Mag () / 16; CFixVector v = CFixVector::Avg ((*mOrient).RVec () * (nSpeed - randN (2 * nSpeed)), (*mOrient).UVec () * (nSpeed - randN (2 * nSpeed))); m_vPos = *vPos + v + (*mOrient).FVec () * (I2X (1) / 2 - randN (I2X (1))); } if ((nType != BUBBLE_PARTICLES) && mOrient) { CAngleVector vRot; CFixMatrix mRot; vRot [BA] = 0; vRot [PA] = 2048 - ((d_rand () % 9) * 512); vRot [HA] = 2048 - ((d_rand () % 9) * 512); mRot = CFixMatrix::Create (vRot); m_mOrient = *mOrient * mRot; } if (nType <= SMOKE_PARTICLES) { if (m_bBlowUp) m_nLife = 2 * m_nLife / 3; m_nLife = 4 * m_nLife / 5 + randN (2 * m_nLife / 5); m_nRad += float (randN (int (m_nRad))); } else if (nType == FIRE_PARTICLES) { m_nLife = 3 * m_nLife / 4 + randN (m_nLife / 4); m_nRad += float (randN (int (m_nRad))); } else if (nType == BUBBLE_PARTICLES) m_nRad = m_nRad / 10 + float (randN (int (9 * m_nRad / 10))); else m_nRad *= 2; //m_nRad *= 0.5f; m_vStartPos = m_vPos; if (m_bBlowUp) { m_nWidth = (nType == WATERFALL_PARTICLES) ? m_nRad * 0.6666667f : m_nRad; m_nHeight = m_nRad; } else { m_nWidth = (nType == WATERFALL_PARTICLES) ? m_nRad * 0.3333333f : m_nRad * 2; m_nHeight = m_nRad * 2; } m_nWidth /= 65536.0f; m_nHeight /= 65536.0f; m_nRad /= 65536.0f; m_nFrames = ParticleImageInfo (nType).nFrames; m_deltaUV = 1.0f / float (m_nFrames); if (nType == BULLET_PARTICLES) { m_iFrame = 0; m_nRotFrame = 0; m_nOrient = 3; } else if (nType == BUBBLE_PARTICLES) { m_iFrame = rand () % (m_nFrames * m_nFrames); m_nRotFrame = 0; m_nOrient = 0; } else if ((nType == LIGHT_PARTICLES) /*|| (nType == WATERFALL_PARTICLES)*/) { m_iFrame = 0; m_nRotFrame = 0; m_nOrient = 0; } else if (nType == FIRE_PARTICLES) { m_iFrame = (rand () % 10 < 6) ? 0 : 2; // more fire than smoke (60:40) if (m_iFrame < 2) m_nLife = 9 * m_nLife / 10; else m_nLife = 10 * m_nLife / 9; m_nRotFrame = rand () % PARTICLE_POSITIONS; m_nOrient = rand () % 4; } else { m_iFrame = rand () % (m_nFrames * m_nFrames); m_nRotFrame = rand () % PARTICLE_POSITIONS; m_nOrient = rand () % 4; #if 1 #endif } m_nTTL = m_nLife; m_nRenderType = RenderType (); m_bAnimate = (nType != FIRE_PARTICLES) && (gameOpts->render.particles.nQuality > 1) && (m_nFrames > 1); m_bRotate = (m_nRenderType <= SMOKE_PARTICLES) ? 1 : (m_nRenderType == FIRE_PARTICLES + PARTICLE_TYPES) ? -1 : 0; UpdateDecay (); UpdateTexCoord (); #if 0 if (colorP && (colorP->alpha < 0)) m_color [0].alpha /= 2.0f; else #endif { if (m_bEmissive) m_color [0].alpha = 1.0f; else if (nParticleSystemType == SIMPLE_SMOKE_PARTICLES) m_color [0].alpha /= 3.5f - float (gameOpts->render.particles.nQuality) / 2.0f; //colorP ? 2.0f + (color.red + color.green + color.blue) / 3.0f : 2.0f; else if (nParticleSystemType == SMOKE_PARTICLES) m_color [0].alpha /= colorP ? 3.0f - (color.red + color.green + color.blue) / 3.0f : 2.5f; else if (nParticleSystemType == BUBBLE_PARTICLES) m_color [0].alpha /= 2.0f; else if (nParticleSystemType == GATLING_PARTICLES) m_color [0].alpha /= 4.0f; # if 0 else if (nParticleSystemType == GATLING_PARTICLES) ;//m_color [0].alpha /= 6; # endif } SetupColor (fBrightness); return 1; }