int GrUCircle (fix xc1, fix yc1, fix r1) { //dunno if this really works, radar doesn't seem to.. hm.. glDisable (GL_TEXTURE_2D); // glPointSize (X2F (rad); OglCanvasColor (&CCanvas::Current ()->Color ()); glPushMatrix (); glTranslatef ( (X2F (xc1) + CCanvas::Current ()->Left ()) / (float) ogl.m_states.nLastW, 1.0f - (X2F (yc1) + CCanvas::Current ()->Top ()) / (float) ogl.m_states.nLastH, 0); glScalef (X2F (r1), X2F (r1), X2F (r1)); if (r1<=I2X (5)) { if (!circleh5) circleh5 = CircleListInit (5, GL_LINE_LOOP, GL_COMPILE_AND_EXECUTE); else glCallList (circleh5); } else { if (!circleh10) circleh10 = CircleListInit (10, GL_LINE_LOOP, GL_COMPILE_AND_EXECUTE); else glCallList (circleh10); } glPopMatrix (); if (CCanvas::Current ()->Color ().rgb) glDisable (GL_BLEND); return 0; }
int G3DrawSphere3D (g3sPoint *p0, int nSides, int rad) { tCanvasColor c = CCanvas::Current ()->Color (); g3sPoint p = *p0; int i; float hx, hy, x, y, z, r; float ang; glDisable (GL_TEXTURE_2D); OglCanvasColor (&CCanvas::Current ()->Color ()); x = X2F (p.p3_vec[X]); y = X2F (p.p3_vec[Y]); z = X2F (p.p3_vec[Z]); r = X2F (rad); glBegin (GL_POLYGON); for (i = 0; i <= nSides; i++) { ang = 2.0f * (float) Pi * (i % nSides) / nSides; hx = x + (float) cos (ang) * r; hy = y + (float) sin (ang) * r; glVertex3f (hx, hy, z); } if (c.rgb) glDisable (GL_BLEND); glEnd (); return 1; }
int G3DrawCircle3D (g3sPoint *p0, int nSides, int rad) { g3sPoint p = *p0; int i, j; CFloatVector v; float x, y, r; float ang; glDisable (GL_TEXTURE_2D); OglCanvasColor (&CCanvas::Current ()->Color ()); x = X2F (p.p3_vec[X]); y = X2F (p.p3_vec[Y]); v[Z] = X2F (p.p3_vec[Z]); r = X2F (rad); glBegin (GL_LINES); for (i = 0; i <= nSides; i++) for (j = i; j <= i + 1; j++) { ang = 2.0f * (float) Pi * (j % nSides) / nSides; v[X] = x + (float) cos (ang) * r; v[Y] = y + (float) sin (ang) * r; glVertex3fv (reinterpret_cast<GLfloat*> (&v)); } if (CCanvas::Current ()->Color ().rgb) glDisable (GL_BLEND); glEnd (); return 1; }
void CShrapnel::Draw (void) { if ((m_info.xTTL > 0) && LoadExplBlast ()) { fix xSize = I2X (1) / 2 + d_rand () % (I2X (1) / 4); G3DrawSprite (m_info.vPos, xSize, xSize, bmpExplBlast, NULL, X2F (m_info.xTTL) / X2F (m_info.xLife) / 2, 0, 0); } }
void DrawDebrisCorona (CObject *objP) { static tRgbaColorf debrisGlow = {0.66f, 0, 0, 1}; static tRgbaColorf markerGlow = {0, 0.66f, 0, 1}; static time_t t0 = 0; if (objP->info.nType == OBJ_MARKER) RenderWeaponCorona (objP, &markerGlow, 0.75f, 0, 4, 1, 1, 0); #if DBG else if (objP->info.nType == OBJ_DEBRIS) { #else else if ((objP->info.nType == OBJ_DEBRIS) && gameOpts->render.nDebrisLife) { #endif float h = (float) nDebrisLife [gameOpts->render.nDebrisLife] - X2F (objP->info.xLifeLeft); if (h < 0) h = 0; if (h < 10) { h = (10 - h) / 20.0f; if (gameStates.app.nSDLTicks - t0 > 50) { t0 = gameStates.app.nSDLTicks; debrisGlow.red = 0.5f + X2F (d_rand () % (I2X (1) / 4)); debrisGlow.green = X2F (d_rand () % (I2X (1) / 4)); } RenderWeaponCorona (objP, &debrisGlow, h, 5 * objP->info.xSize, 1.5f, 1, LIGHTTRAIL_BLENDMODE, 0); } } }
int G3DrawSphere (g3sPoint *pnt, fix rad, int bBigSphere) { double r; glDisable (GL_TEXTURE_2D); OglCanvasColor (&CCanvas::Current ()->Color ()); glPushMatrix (); glTranslatef (X2F (pnt->p3_vec[X]), X2F (pnt->p3_vec[Y]), X2F (pnt->p3_vec[Z])); r = X2F (rad); glScaled (r, r, r); if (bBigSphere) { #if 1 OglDrawCircle (20, GL_POLYGON); #else if (hBigSphere) glCallList (hBigSphere); else hBigSphere = CircleListInit (20, GL_POLYGON, GL_COMPILE_AND_EXECUTE); #endif } else { if (hSmallSphere) glCallList (hSmallSphere); else hSmallSphere = CircleListInit (12, GL_POLYGON, GL_COMPILE_AND_EXECUTE); } glPopMatrix (); if (CCanvas::Current ()->Color ().rgb) glDisable (GL_BLEND); return 0; }
//------------------------------------------------------------------------------ //start the frame void G3StartFrame (int bFlat, int bResetColorBuf) { //set int w,h & fixed-point w,h/2 xCanvW2 = CCanvas::Current ()->Width () << 15; xCanvH2 = CCanvas::Current ()->Height () << 15; fxCanvW2 = X2F (xCanvW2); fxCanvH2 = X2F (xCanvH2); transformation.ComputeAspect (); InitFreePoints (); ogl.StartFrame (bFlat, bResetColorBuf); gameStates.render.bHeadlightOn = 1; if (RENDERPATH) gameOpts->render.bDepthSort = 1; }
float ComputeCoronaSprite (CFloatVector *sprite, CFloatVector *vCenter, short nSegment, short nSide) { CSide* sideP = SEGMENTS [nSegment].m_sides + nSide; short* corners; int i; float fLight = 0; CFloatVector v; corners = SEGMENTS [nSegment].Corners (nSide); for (i = 0; i < 4; i++) { fLight += X2F (sideP->m_uvls [i].l); if (RENDERPATH) transformation.Transform (sprite [i], gameData.segs.fVertices [corners [i]], 0); else sprite [i] = gameData.segs.fVertices [corners [i]]; //already transformed } v.Assign (SEGMENTS [nSegment].SideCenter (nSide)); transformation.Transform (*vCenter, v, 0); #if 0 if (gameStates.render.bQueryCoronas) { for (i = 0; i < 4; i++) { v = sprite [i] - *vCenter; VmVecScaleAdd (sprite + i, vCenter, &v, 0.5f); } } #endif return fLight; }
void DrawMonsterball (tObject *objP, float red, float green, float blue, float alpha) { #if !SIMPLE_SPHERE if (!gameData.render.monsterball.pSphere) { gameData.render.monsterball.nTessDepth = 3; gameData.render.monsterball.nFaces = CreateSphere (&gameData.render.monsterball); } if (gameData.render.monsterball.nFaces > 0) #endif { if ((gameOpts->render.bDepthSort > 0) || (RENDERPATH && !gameOpts->render.bDepthSort)) TIAddSphere (riMonsterball, red, green, blue, alpha, objP); else { static tOOF_vector p = {0,0,0}; float r = X2F (objP->info.xSize); gameStates.ogl.bUseTransform = 1; OglSetupTransform (0); G3StartInstanceMatrix(objP->info.position.vPos, objP->info.position.mOrient); RenderSphere (&gameData.render.monsterball, &p, r, r, r, red, green, blue, gameData.hoard.monsterball.bm.bmTexBuf ? 1.0f : alpha, &gameData.hoard.monsterball.bm, 4, 0); G3DoneInstance (); OglResetTransform (1); gameStates.ogl.bUseTransform = 0; } } }
void DrawShieldSphere (tObject *objP, float red, float green, float blue, float alpha) { if (!CreateShieldSphere ()) return; #if !SIMPLE_SPHERE if (gameData.render.shield.nFaces > 0) #endif { if ((gameOpts->render.bDepthSort > 0) || (RENDERPATH && !gameOpts->render.bDepthSort)) TIAddSphere (riSphereShield, red, green, blue, alpha, objP); else { tOOF_vector p = {0, 0, 0}; fix nSize = gameData.models.polyModels [objP->rType.polyObjInfo.nModel].rad; float fScale, r = X2F (nSize) /** 1.05f*/; tTransformation *posP = OBJPOS (objP); vmsVector vPos; //gameStates.ogl.bUseTransform = 1; glBlendFunc (GL_ONE, GL_ONE); G3StartInstanceMatrix (*PolyObjPos (objP, &vPos), posP->mOrient); RenderSphere (&gameData.render.shield, &p, r, r, r, red, green, blue, alpha, bmpShield, 1, 1); G3DoneInstance (); gameStates.ogl.bUseTransform = 0; fScale = gameData.render.shield.pPulse->fScale; G3StartInstanceMatrix (vPos, posP->mOrient); vPos.SetZero(); RenderObjectHalo (&vPos, 3 * nSize / 2, red * fScale, green * fScale, blue * fScale, alpha * fScale, 0); G3DoneInstance (); } } }
inline void CapTMapColor (tUVL *uvlList, int nVertices, CBitmap *bm) { #if 0 tFaceColor *color = tMapColor.index ? &tMapColor : lightColor.index ? &lightColor : NULL; if (! (bm->props.flags & BM_FLAG_NO_LIGHTING) && color) { double a, m = tMapColor.color.red; double h, l = 0; int i; for (i = 0; i < nVertices; i++, uvlList++) { h = (bm->props.flags & BM_FLAG_NO_LIGHTING) ? 1.0 : X2F (uvlList->l); if (l < h) l = h; } // scale brightness with the average color to avoid darkening bright areas with the color a = (color->color.red + color->color.green + color->color.blue) / 3; if (m < color->color.green) m = color->color.green; if (m < color->color.blue) m = color->color.blue; l = l / a; // prevent any color component getting over 1.0 if (l * m > 1.0) l = 1.0 / m; color->color.red *= l; color->color.green *= l; color->color.blue *= l; } #endif }
void RenderLaserCorona (CObject *objP, tRgbaColorf *colorP, float alpha, float fScale) { if (!SHOW_OBJ_FX) return; if (SHOW_SHADOWS && (gameStates.render.nShadowPass != 1)) return; if (gameOpts->render.coronas.bShots && LoadGlare ()) { tHitbox* phb = &gameData.models.hitboxes [objP->rType.polyObjInfo.nModel].hitboxes [0]; float fLength = X2F (phb->vMax [Z] - phb->vMin [Z]) / 2; tRgbaColorf color; static CFloatVector vEye = CFloatVector::ZERO; colorP->alpha = alpha; float fScale = coronaIntensities [gameOpts->render.coronas.nObjIntensity] / 2; color = *colorP; colorP = &color; color.red *= fScale; color.green *= fScale; color.blue *= fScale; bmpGlare->SetColor (colorP); ogl.RenderSprite (bmpGlare, objP->info.position.vPos + objP->info.position.mOrient.FVec () * (F2X (fLength - 0.5f)), I2X (1), I2X (1), alpha, LIGHTTRAIL_BLENDMODE, 1); bmpGlare->SetColor (NULL); } }
int ControlsCapSampleRate (void) { // DEFTIME if (gameStates.limitFPS.bControls) { // check elapsed time since last call to ControlsReadAll // if less than 25 ms (i.e. 40 fps) return if (gameOpts->legacy.bMouse) gameStates.input.kcPollTime = gameData.time.xFrame; else { if (gameData.app.bGamePaused) GetSlowTicks (); kcFrameCount++; gameStates.input.kcPollTime += gameData.time.xFrame; if (!gameStates.app.tick40fps.bTick) return 1; } } else gameStates.input.kcPollTime = gameData.time.xFrame; gameStates.input.kcFrameTime = (float) gameStates.input.kcPollTime / kcFrameCount; #if 1 nMaxTurnRate = (int) gameStates.input.kcFrameTime; #else nMaxTurnRate = (int) (gameStates.input.kcFrameTime * (1.0f - X2F (gameData.pig.ship.player->maxRotThrust))); #endif if (CheckGameConfig ()) SDL_Delay (gameData.app.nFrameCount % 100); return 0; }
int CShrapnelCloud::Create (CObject* parentObjP, CObject* objP) { int i, h = (int) (X2F (parentObjP->info.xSize) * fShrapnelScale [gameOpts->render.effects.nShrapnels] + 0.5); objP->info.xLifeLeft = 0; objP->cType.explInfo.nSpawnTime = -1; objP->cType.explInfo.nDeleteObj = -1; objP->cType.explInfo.nDeleteTime = -1; h += d_rand () % h; if (!CStack<CShrapnel>::Create (h)) return 0; if (!Grow (h)) return 0; #pragma omp parallel { #pragma omp for for (i = 0; i < h; i++) { m_data.buffer [i].Create (parentObjP, objP); } } objP->info.xLifeLeft *= 2; objP->cType.explInfo.nSpawnTime = -1; objP->cType.explInfo.nDeleteObj = -1; objP->cType.explInfo.nDeleteTime = -1; return 1; }
void CBitmap::OglVertices (int x, int y, int w, int h, int scale, int orient, CBitmap* destP) { if (!destP) destP = CCanvas::Current (); if (!w) w = Width (); else if (w < 0) w = destP->Width (); if (!h) h = Height (); else if (h < 0) h = destP->Height (); float dx = float (destP->Left ()) / float (ogl.m_states.nLastW); float dy = float (destP->Top ()) / float (ogl.m_states.nLastH); if (orient & 1) { ::Swap (w, h); ::Swap (dx, dy); } float fScale = X2F (scale); m_render.aspect = float (ogl.m_states.nLastW * fScale); m_render.x0 = dx + float (x) / m_render.aspect; m_render.x1 = dx + float (x + w) / m_render.aspect; m_render.aspect = float (ogl.m_states.nLastH * fScale); m_render.y0 = 1.0f - dy - float (y) / m_render.aspect; m_render.y1 = 1.0f - dy - float (y + h) / m_render.aspect; m_render.aspect = float (screen.Width ()) / float (screen.Height ()); }
void RenderSoftGlare (CFloatVector *sprite, CFloatVector *vCenter, int nTexture, float fIntensity, int bAdditive, int bColored) { tRgbaColorf color; tTexCoord2f tcGlare [4] = {{{0,0}},{{1,0}},{{1,1}},{{0,1}}}; int i; CBitmap* bmP = NULL; if (gameStates.render.bQueryCoronas) { glDisable (GL_TEXTURE_2D); glBlendFunc (GL_ONE, GL_ZERO); } else { glEnable (GL_TEXTURE_2D); glDepthFunc (GL_ALWAYS); if (bAdditive) glBlendFunc (GL_ONE, GL_ONE); if (!(bmP = bAdditive ? bmpGlare : bmpCorona)) return; } if (gameStates.render.bAmbientColor) color = gameData.render.color.textures [nTexture].color; else color.red = color.green = color.blue = X2F (IsLight (nTexture)) / 2; if (!bColored) color.red = color.green = color.blue = (color.red + color.green + color.blue) / 4; if (gameOptions [0].render.coronas.nStyle == 1) fIntensity = float (sqrt (fIntensity)); if (bAdditive) glColor4f (fIntensity * color.red, fIntensity * color.green, fIntensity * color.blue, 1); else glColor4f (color.red, color.green, color.blue, fIntensity); if (ogl.EnableClientStates (gameStates.render.bQueryCoronas == 0, 0, 0, GL_TEXTURE0)) { if (!gameStates.render.bQueryCoronas) { bmP->Bind (1); OglTexCoordPointer (2, GL_FLOAT, 0, tcGlare); } OglVertexPointer (3, GL_FLOAT, sizeof (CFloatVector), sprite); OglDrawArrays (GL_QUADS, 0, 4); ogl.DisableClientStates (gameStates.render.bQueryCoronas == 0, 0, 0, GL_TEXTURE0); } else { if (gameStates.render.bQueryCoronas == 0) bmP->Bind (1); glBegin (GL_QUADS); for (i = 0; i < 4; i++) { glTexCoord2fv (reinterpret_cast<GLfloat*> (tcGlare + i)); glVertex3fv (reinterpret_cast<GLfloat*> (sprite + i)); } glEnd (); } if (!gameStates.render.bQueryCoronas && bAdditive) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderCoronaOutline (sprite, vCenter); if (gameStates.render.bQueryCoronas != 2) { glEnable (GL_DEPTH_TEST); if (gameStates.render.bQueryCoronas == 1) glDepthFunc (GL_LEQUAL); } }
float MissileSpeedScale (CObject *objP) { int i = extraGameInfo [IsMultiGame].nMslStartSpeed; if (!i) return 1; return nMslSlowDown [i] * X2F (gameData.time.xGame - objP->CreationTime ()); }
g3sPoint *RotateVertex (int i) { g3sPoint *p = gameData.segs.points + i; if (gameData.render.mine.nRotatedLast [i] != gameStates.render.nFrameCount) { G3TransformAndEncodePoint (p, gameData.segs.vertices [i]); if (gameData.render.zMax < p->p3_vec [Z]) gameData.render.zMax = p->p3_vec [Z]; if (!ogl.m_states.bUseTransform) { gameData.segs.fVertices [i][X] = X2F (p->p3_vec [X]); gameData.segs.fVertices [i][Y] = X2F (p->p3_vec [Y]); gameData.segs.fVertices [i][Z] = X2F (p->p3_vec [Z]); } p->p3_index = i; gameData.render.mine.nRotatedLast [i] = gameStates.render.nFrameCount; } return p; }
CFloatMatrix& CFixMatrix::Transpose (CFloatMatrix& dest, CFixMatrix& src) { dest [0] = X2F (src [0]); dest [4] = X2F (src [1]); dest [8] = X2F (src [2]); dest [1] = X2F (src [3]); dest [5] = X2F (src [4]); dest [9] = X2F (src [5]); dest [2] = X2F (src [6]); dest [6] = X2F (src [7]); dest [10] = X2F (src [8]); dest [11] = dest [12] = dest [13] = dest [14] = 0; dest [15] = 1.0f; return dest; }
void SpeedtestFrame(void) { CFixVector view_dir, center_point; gameData.speedtest.nSide=gameData.speedtest.nSegment % MAX_SIDES_PER_SEGMENT; gameData.objs.viewerP->info.position.vPos = SEGMENTS [gameData.speedtest.nSegment].Center (); gameData.objs.viewerP->info.position.vPos[X] += 0x10; gameData.objs.viewerP->info.position.vPos[Y] -= 0x10; gameData.objs.viewerP->info.position.vPos[Z] += 0x17; gameData.objs.viewerP->RelinkToSeg (gameData.speedtest.nSegment); center_point = SEGMENTS [gameData.speedtest.nSegment].SideCenter (gameData.speedtest.nSide); CFixVector::NormalizedDir(view_dir, center_point, gameData.objs.viewerP->info.position.vPos); //gameData.objs.viewerP->info.position.mOrient = CFixMatrix::Create(view_dir, NULL, NULL); gameData.objs.viewerP->info.position.mOrient = CFixMatrix::CreateF(view_dir); if (((gameData.app.nFrameCount - gameData.speedtest.nFrameStart) % 10) == 0) { #if TRACE console.printf (CON_DBG, "."); #endif } gameData.speedtest.nSegment++; if (gameData.speedtest.nSegment > gameData.segs.nLastSegment) { char msg[128]; sprintf(msg, TXT_SPEEDTEST, gameData.app.nFrameCount-gameData.speedtest.nFrameStart, X2F(TimerGetFixedSeconds() - gameData.speedtest.nStartTime), (double) (gameData.app.nFrameCount-gameData.speedtest.nFrameStart) / X2F(TimerGetFixedSeconds() - gameData.speedtest.nStartTime)); #if TRACE console.printf (CON_DBG, "%s", msg); #endif HUDInitMessage(msg); gameData.speedtest.nCount--; if (gameData.speedtest.nCount == 0) gameData.speedtest.bOn = 0; else SpeedtestInit(); } }
void DoRobotSmoke (CObject *objP) { int h = -1, nObject, nSmoke, nShields = 0, nParts; float nScale; CFixVector pos; nObject = objP->Index (); if (!(SHOW_SMOKE && gameOpts->render.particles.bRobots)) { if (particleManager.GetObjectSystem (nObject) >= 0) KillObjectSmoke (nObject); return; } if ((objP->info.xShields < 0) || (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED))) nParts = 0; else { nShields = X2IR (RobotDefaultShields (objP)); h = X2IR (objP->info.xShields) * 100 / nShields; } if (h < 0) return; nParts = 10 - h / 5; if (nParts > 0) { if (nShields > 4000) nShields = 4000; else if (nShields < 1000) nShields = 1000; CreateDamageExplosion (nParts, nObject); //nParts *= nShields / 10; nParts = BOT_MAX_PARTS; nScale = (float) sqrt (8.0 / X2F (objP->info.xSize)); nScale *= 1.0f + h / 25.0f; if (!gameOpts->render.particles.bSyncSizes) { nParts = -MAX_PARTICLES (nParts, gameOpts->render.particles.nDens [2]); nScale = PARTICLE_SIZE (gameOpts->render.particles.nSize [2], nScale); } if (0 > (nSmoke = particleManager.GetObjectSystem (nObject))) { //PrintLog ("creating robot %d smoke\n", nObject); nSmoke = particleManager.Create (&objP->info.position.vPos, NULL, NULL, objP->info.nSegment, 1, nParts, nScale, gameOpts->render.particles.bSyncSizes ? -1 : gameOpts->render.particles.nSize [2], 1, BOT_PART_LIFE, BOT_PART_SPEED, SMOKE_PARTICLES, nObject, smokeColors, 1, -1); if (nSmoke < 0) return; particleManager.SetObjectSystem (nObject, nSmoke); } else { particleManager.SetScale (nSmoke, nScale); particleManager.SetDensity (nSmoke, nParts, gameOpts->render.particles.bSyncSizes ? -1 : gameOpts->render.particles.nSize [2]); particleManager.SetSpeed (nSmoke, !objP->mType.physInfo.velocity.IsZero () ? BOT_PART_SPEED : BOT_PART_SPEED * 2 / 3); } pos = objP->info.position.vPos + objP->info.position.mOrient.FVec () * (-objP->info.xSize / 2); particleManager.SetPos (nSmoke, &pos, NULL, objP->info.nSegment); } else KillObjectSmoke (nObject); }
inline void VmsRot(const vmsMatrix& pm) { glMatrixf m; memset (m, 0, sizeof (m)); m [0] = X2F (pm[RVEC][X]); m [1] = X2F (pm[RVEC][Y]); m [2] = X2F (pm[RVEC][Z]); m [4] = X2F (pm[UVEC][X]); m [5] = X2F (pm[UVEC][Y]); m [6] = X2F (pm[UVEC][Z]); m [8] = X2F (pm[FVEC][X]); m [9] = X2F (pm[FVEC][Y]); m [10] = X2F (pm[FVEC][Z]); m [15] = 1; OglRot (m); }
void DoRobotSmoke (tObject *objP) { int h = -1, i, nShields = 0, nParts; float nScale; vmsVector pos; i = OBJ_IDX (objP); if (!(SHOW_SMOKE && gameOpts->render.smoke.bRobots)) { if (gameData.smoke.objects [i] >= 0) KillObjectSmoke (i); return; } if ((objP->info.xShields < 0) || (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED))) nParts = 0; else { nShields = X2IR (RobotDefaultShields (objP)); h = X2IR (objP->info.xShields) * 100 / nShields; } if (h < 0) return; nParts = 10 - h / 5; if (nParts > 0) { if (nShields > 4000) nShields = 4000; else if (nShields < 1000) nShields = 1000; CreateDamageExplosion (nParts, i); //nParts *= nShields / 10; nParts = BOT_MAX_PARTS; nScale = (float) sqrt (8.0 / X2F (objP->info.xSize)); nScale *= 1.0f + h / 25.0f; if (!gameOpts->render.smoke.bSyncSizes) { nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [2]); nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [2], nScale); } if (gameData.smoke.objects [i] < 0) { //PrintLog ("creating robot %d smoke\n", i); SetSmokeObject (i, CreateSmoke (&objP->info.position.vPos, NULL, NULL, objP->info.nSegment, 1, nParts, nScale, gameOpts->render.smoke.bSyncSizes ? -1 : gameOpts->render.smoke.nSize [2], 1, BOT_PART_LIFE, BOT_PART_SPEED, SMOKE_PARTICLES, i, smokeColors, 1, -1)); } else { SetSmokePartScale (gameData.smoke.objects [i], nScale); SetSmokeDensity (gameData.smoke.objects [i], nParts, gameOpts->render.smoke.bSyncSizes ? -1 : gameOpts->render.smoke.nSize [2]); SetSmokeSpeed (gameData.smoke.objects [i], !objP->mType.physInfo.velocity.IsZero() ? BOT_PART_SPEED : BOT_PART_SPEED * 2 / 3); } pos = objP->info.position.vPos + objP->info.position.mOrient[FVEC] * (-objP->info.xSize / 2); SetSmokePos (gameData.smoke.objects [i], &pos, NULL, objP->info.nSegment); } else KillObjectSmoke (i); }
void RenderHardGlare (CFloatVector *sprite, CFloatVector *vCenter, int nTexture, float fLight, float fIntensity, tIntervalf *zRangeP, int bAdditive, int bColored) { tTexCoord2f tcGlare [4] = {{{0,0}},{{1,0}},{{1,1}},{{0,1}}}; tRgbaColorf color; CBitmap* bmP; int i; fLight /= 4; if (fLight < 0.01f) return; color.alpha = vCenter->Mag (); if (color.alpha < zRangeP->fRad) fIntensity *= color.alpha / zRangeP->fRad; if (gameStates.render.bAmbientColor) { color = gameData.render.color.textures [nTexture].color; color.alpha = (float) (color.red * 3 + color.green * 5 + color.blue * 2) / 30 * 2; } else { color.alpha = X2F (IsLight (nTexture)); color.red = color.green = color.blue = color.alpha / 2; color.alpha *= 2.0f / 3.0f; } if (!bColored) color.red = color.green = color.blue = (color.red + color.green + color.blue) / 4; color.alpha *= fIntensity * fIntensity; if (color.alpha < 0.01f) return; glEnable (GL_TEXTURE_2D); if (!(bmP = bAdditive ? bmpGlare : bmpCorona)) return; bmP->SetTranspType (-1); if (bmP->Bind (1)) return; bmP->Texture ()->Wrap (GL_CLAMP); glDisable (GL_CULL_FACE); if (bAdditive) { fLight *= color.alpha; glBlendFunc (GL_ONE, GL_ONE); } glColor4fv (reinterpret_cast<GLfloat*> (&color)); glBegin (GL_QUADS); for (i = 0; i < 4; i++) { glTexCoord2fv (reinterpret_cast<GLfloat*> (tcGlare + i)); glVertex3fv (reinterpret_cast<GLfloat*> (sprite + i)); } glEnd (); if (bAdditive) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_CULL_FACE); RenderCoronaOutline (sprite, vCenter); }
static void convertFixedIndirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,GLsizei count,GLenum indices_type,const GLvoid* indices,unsigned int strideOut,int attribSize) { for(int i = 0 ;i < count ;i++) { unsigned short index = indices_type == GL_UNSIGNED_BYTE? ((GLubyte *)indices)[i]: ((GLushort *)indices)[i]; const GLfixed* fixed_data = (GLfixed *)(dataIn + index*strideIn); GLfloat* float_data = reinterpret_cast<GLfloat*>(static_cast<unsigned char*>(dataOut) + index*strideOut); for(int j=0;j<attribSize;j++) { float_data[j] = X2F(fixed_data[j]); } } }
float CObject::Damage (void) { float fDmg; fix xMaxShields; if (info.nType == OBJ_PLAYER) fDmg = X2F (gameData.multiplayer.players [info.nId].shields) / 100; else if (info.nType == OBJ_ROBOT) { xMaxShields = RobotDefaultShields (this); fDmg = X2F (info.xShields) / X2F (xMaxShields); #if 0 if (gameData.bots.info [0][info.nId].companion) fDmg /= 2; #endif } else if (info.nType == OBJ_REACTOR) fDmg = X2F (info.xShields) / X2F (ReactorStrength ()); else if ((info.nType == 255) || (info.nFlags & (OF_EXPLODING | OF_SHOULD_BE_DEAD | OF_DESTROYED | OF_ARMAGEDDON))) fDmg = 0.0f; else fDmg = 1.0f; return (fDmg > 1.0f) ? 1.0f : (fDmg < 0.0f) ? 0.0f : fDmg; }
void G3VertexColor (CFloatVector3 *pvVertNorm, CFloatVector3 *pVertPos, int nVertex, tFaceColor *pVertColor, tFaceColor *pBaseColor, float fScale, int bSetColor, int nThread) { PROF_START CFloatVector3 colorSum = CFloatVector3::Create(0.0f, 0.0f, 0.0f); CFloatVector3 vertPos; tFaceColor* pc = NULL; int bVertexLights; CVertColorData vcd; InitVertColorData (vcd); #if DBG if (!gameStates.render.nState && (nVertex == nDbgVertex)) nVertex = nVertex; #endif #if 0 if (gameStates.render.nFlashScale) fScale *= X2F (gameStates.render.nFlashScale); #endif if (!FAST_SHADOWS && (gameStates.render.nShadowPass == 3)) ; //fScale = 1.0f; else if (FAST_SHADOWS || (gameStates.render.nShadowPass != 1)) ; //fScale = 1.0f; else fScale *= gameStates.render.bHeadlightOn ? 0.4f : 0.3f; if (fScale > 1) fScale = 1; #if 1//!DBG //cache light values per frame if (!(gameStates.render.nState || vcd.bExclusive || vcd.bMatEmissive) && (nVertex >= 0)) { pc = gameData.render.color.vertices + nVertex; if (pc->index == gameStates.render.nFrameFlipFlop + 1) { if (pVertColor) { pVertColor->index = gameStates.render.nFrameFlipFlop + 1; pVertColor->color.red = pc->color.red * fScale; pVertColor->color.green = pc->color.green * fScale; pVertColor->color.blue = pc->color.blue * fScale; pVertColor->color.alpha = 1; } if (bSetColor) OglColor4sf (pc->color.red * fScale, pc->color.green * fScale, pc->color.blue * fScale, 1.0); #if DBG if (!gameStates.render.nState && (nVertex == nDbgVertex)) nVertex = nVertex; #endif PROF_END(ptVertexColor) return; } }
void DoMissileSmoke (CObject *objP) { int nParts, nSpeed, nLife, nObject, nSmoke; float nScale = 1.75f; tThrusterInfo ti; nObject = objP->Index (); if (!(SHOW_SMOKE && gameOpts->render.particles.bMissiles)) { if (particleManager.GetObjectSystem (nObject) >= 0) KillObjectSmoke (nObject); return; } if ((objP->info.xShields < 0) || (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED))) nParts = 0; else { nSpeed = WI_speed (objP->info.nId, gameStates.app.nDifficultyLevel); nLife = gameOpts->render.particles.nLife [3] + 1; #if 1 nParts = int (MSL_MAX_PARTS * X2F (nSpeed) / (34.0f * (4 - nLife))); if ((objP->info.nId == EARTHSHAKER_MEGA_ID) || (objP->info.nId == ROBOT_SHAKER_MEGA_ID)) nParts /= 2; #else nParts = (objP->info.nId == EARTHSHAKER_ID) ? 1500 : (objP->info.nId == MEGAMSL_ID) ? 1400 : (objP->info.nId == SMARTMSL_ID) ? 1300 : 1200; #endif } if (nParts) { if (0 > (nSmoke = particleManager.GetObjectSystem (nObject))) { if (!gameOpts->render.particles.bSyncSizes) { nParts = -MAX_PARTICLES (nParts, gameOpts->render.particles.nDens [3]); nScale = PARTICLE_SIZE (gameOpts->render.particles.nSize [3], nScale); } nSmoke = particleManager.Create (&objP->info.position.vPos, NULL, NULL, objP->info.nSegment, 1, nParts, nScale, gameOpts->render.particles.bSyncSizes ? -1 : gameOpts->render.particles.nSize [3], 1, nLife * MSL_PART_LIFE, MSL_PART_SPEED, SMOKE_PARTICLES, nObject, smokeColors + 1, 1, -1); if (nSmoke < 0) return; particleManager.SetObjectSystem (nObject, nSmoke); } CalcThrusterPos (objP, &ti, 0); particleManager.SetPos (nSmoke, ti.vPos, NULL, objP->info.nSegment); } else KillObjectSmoke (nObject); }
void CPaletteManager::FadeEffect (void) { float nDecAmount = 0; bool bForce = false; // Diminish at FADE_RATE units/second. // For frame rates > FADE_RATE Hz, use randomness to achieve this. if (gameData.time.xFrame < I2X (1) / FADE_RATE) { if (d_rand () < gameData.time.xFrame * FADE_RATE / 2) nDecAmount = 1; } else { if (!(nDecAmount = X2F (gameData.time.xFrame * FADE_RATE))) // one second = FADE_RATE counts nDecAmount = 1; // make sure we decrement by something } nDecAmount /= 64.0f; if (m_data.xFlashDuration) { // Part of hack system to force update of palette after exiting a menu. if (m_data.xLastEffectTime) bForce = true; if ((m_data.xLastEffectTime + I2X (1)/8 < gameData.time.xGame) || (m_data.xLastEffectTime > gameData.time.xGame)) { audio.PlaySound (SOUND_CLOAK_OFF, SOUNDCLASS_GENERIC, m_data.xFlashDuration / 4); m_data.xLastEffectTime = gameData.time.xGame; } m_data.xFlashDuration -= gameData.time.xFrame; if (m_data.xFlashDuration < 0) m_data.xFlashDuration = 0; if (bForce || (d_rand () > 4096)) { if ((gameData.demo.nState == ND_STATE_RECORDING) && (m_data.effect.red || m_data.effect.green || m_data.effect.blue)) NDRecordPaletteEffect (short (m_data.effect.red * 64), short (m_data.effect.green * 64), short (m_data.effect.blue * 64)); paletteManager.SetEffect (); return; } } m_data.effect.red = UpdateEffect (m_data.effect.red, nDecAmount); m_data.effect.green = UpdateEffect (m_data.effect.green, nDecAmount); m_data.effect.blue = UpdateEffect (m_data.effect.blue, nDecAmount); if ((gameData.demo.nState == ND_STATE_RECORDING) && (m_data.effect.red || m_data.effect.green || m_data.effect.blue)) NDRecordPaletteEffect (short (m_data.effect.red * 64), short (m_data.effect.green * 64), short (m_data.effect.blue * 64)); SetEffect (bForce); }
void DoMissileSmoke (tObject *objP) { int nParts, nSpeed, nLife, i; float nScale = 1.5f; tThrusterInfo ti; i = OBJ_IDX (objP); if (!(SHOW_SMOKE && gameOpts->render.smoke.bMissiles)) { if (gameData.smoke.objects [i] >= 0) KillObjectSmoke (i); return; } if ((objP->info.xShields < 0) || (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED))) nParts = 0; else { nSpeed = WI_speed (objP->info.nId, gameStates.app.nDifficultyLevel); nLife = gameOpts->render.smoke.nLife [3] + 1; #if 1 nParts = (int) (MSL_MAX_PARTS * X2F (nSpeed) / (40.0f * (4 - nLife))); if ((objP->info.nId == EARTHSHAKER_MEGA_ID) || (objP->info.nId == ROBOT_SHAKER_MEGA_ID)) nParts /= 2; #else nParts = (objP->info.nId == EARTHSHAKER_ID) ? 1500 : (objP->info.nId == MEGAMSL_ID) ? 1400 : (objP->info.nId == SMARTMSL_ID) ? 1300 : 1200; #endif } if (nParts) { if (gameData.smoke.objects [i] < 0) { if (!gameOpts->render.smoke.bSyncSizes) { nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [3]); nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [3], nScale); } SetSmokeObject (i, CreateSmoke (&objP->info.position.vPos, NULL, NULL, objP->info.nSegment, 1, nParts, nScale, gameOpts->render.smoke.bSyncSizes ? -1 : gameOpts->render.smoke.nSize [3], 1, nLife * MSL_PART_LIFE, MSL_PART_SPEED, SMOKE_PARTICLES, i, smokeColors + 1, 1, -1)); } CalcThrusterPos (objP, &ti, 0); SetSmokePos (gameData.smoke.objects [i], ti.vPos, NULL, objP->info.nSegment); } else KillObjectSmoke (i); }