void CursorTrail::DrawLine2D(float _fSize, Color3f color) { if(iNbOldCoord < 2) { return; } float incSize = _fSize / iNbOldCoord; float currentSize = incSize; Color3f incColor = Color3f(color.r / iNbOldCoord, color.g / iNbOldCoord, color.b / iNbOldCoord); Color3f currentColor = incColor; GRenderer->SetBlendFunc(BlendDstColor, BlendInvDstColor); GRenderer->ResetTexture(0); GRenderer->SetRenderState(Renderer::AlphaBlending, true); TexturedVertex v[4]; v[0].p.z = v[1].p.z = v[2].p.z = v[3].p.z = 0.f; v[0].rhw = v[1].rhw = v[2].rhw = v[3].rhw = 1.f; v[0].color = v[2].color = currentColor.toRGB(); if(!ComputePer(iOldCoord[0], iOldCoord[1], &v[0], &v[2], currentSize)) { v[0].p.x = v[2].p.x = iOldCoord[0].x; v[0].p.y = v[2].p.y = iOldCoord[1].y; } for(int i = 1; i < iNbOldCoord - 1; i++) { currentSize += incSize; currentColor += incColor; if(ComputePer(iOldCoord[i], iOldCoord[i + 1], &v[1], &v[3], currentSize)) { v[1].color = v[3].color = currentColor.toRGB(); EERIEDRAWPRIM(Renderer::TriangleStrip, v, 4); v[0].p.x = v[1].p.x; v[0].p.y = v[1].p.y; v[0].color = v[1].color; v[2].p.x = v[3].p.x; v[2].p.y = v[3].p.y; v[2].color = v[3].color; } } GRenderer->SetRenderState(Renderer::AlphaBlending, false); }
void ARX_MAGICAL_FLARES_Update() { if(!flarenum) return; shinum++; if(shinum >= 10) { shinum = 1; } long TICKS = long(arxtime) - FRAMETICKS; FRAMETICKS = (unsigned long)(arxtime); if(TICKS < 0) { return; } bool key = !GInput->actionPressed(CONTROLS_CUST_MAGICMODE); RenderMaterial mat; mat.setBlendType(RenderMaterial::Additive); EERIE_LIGHT * light = lightHandleGet(torchLightHandle); for(long j = 1; j < 5; j++) { TextureContainer * surf; switch(j) { case 2: surf = flaretc.lumignon; break; case 3: surf = flaretc.lumignon2; break; case 4: surf = flaretc.plasm; break; default: surf = flaretc.shine[shinum]; break; } mat.setTexture(surf); for(size_t i = 0; i < MAX_FLARES; i++) { FLARES & flare = magicFlares[i]; if(!flare.exist || flare.type != j) { continue; } flare.tolive -= float(TICKS * 2); if(flare.flags & 1) { flare.tolive -= float(TICKS * 4); } else if (key) { flare.tolive -= float(TICKS * 6); } float z = (flare.tolive * 0.00025f); float s; if(flare.type == 1) { s = flare.size * 2 * z; } else if(flare.type == 4) { s = flare.size * 2.f * z + 10.f; } else { s = flare.size; } if(flare.tolive <= 0.f || flare.pos.y < -64.f || s < 3.f) { removeFlare(flare); continue; } if(flare.type == 1 && z < 0.6f) { z = 0.6f; } Color3f c = flare.rgb * z; flare.tv.color = c.toRGB(); flare.v.p = flare.tv.p; light->rgb = componentwise_max(light->rgb, c); if(lightHandleIsValid(flare.dynlight)) { EERIE_LIGHT * el = lightHandleGet(flare.dynlight); el->pos = flare.v.p; el->rgb = c; } mat.setDepthTest(flare.io != NULL); if(flare.bDrawBitmap) { s *= 2.f * minSizeRatio(); EERIEAddBitmap(mat, flare.v.p, s, s, surf, Color::fromRGBA(flare.tv.color)); } else { EERIEAddSprite(mat, flare.v.p, s * 0.025f + 1.f, Color::fromRGBA(flare.tv.color), 2.f); } } } light->rgb = componentwise_min(light->rgb, Color3f::white); }
void ARX_MAGICAL_FLARES_Update() { if(!g_magicFlaresCount) return; shinum++; if(shinum >= 10) { shinum = 1; } float diff = toMs(g_platformTime.lastFrameDuration()); bool key = !GInput->actionPressed(CONTROLS_CUST_MAGICMODE); RenderMaterial mat; mat.setBlendType(RenderMaterial::Additive); EERIE_LIGHT * light = lightHandleGet(torchLightHandle); for(long j = 1; j < 5; j++) { TextureContainer * surf; switch(j) { case 2: surf = g_magicFlareTextures.lumignon; break; case 3: surf = g_magicFlareTextures.lumignon2; break; case 4: surf = g_magicFlareTextures.plasm; break; default: surf = g_magicFlareTextures.shine[shinum]; break; } mat.setTexture(surf); for(size_t i = 0; i < g_magicFlaresMax; i++) { MagicFlare & flare = g_magicFlares[i]; if(!flare.exist || flare.type != j) { continue; } flare.tolive -= diff * 2.f; if(flare.flags & 1) { flare.tolive -= diff * 4.f; } else if (key) { flare.tolive -= diff * 6.f; } float z = (flare.tolive * 0.00025f); float size; if(flare.type == 1) { size = flare.size * 2 * z; } else if(flare.type == 4) { size = flare.size * 2.f * z + 10.f; } else { size = flare.size; } if(flare.tolive <= 0.f || flare.pos.y < -64.f || size < 3.f) { removeFlare(flare); continue; } if(flare.type == 1 && z < 0.6f) { z = 0.6f; } Color3f c = flare.rgb * z; flare.tv.color = c.toRGB(); flare.v.p = flare.tv.p; light->rgb = componentwise_max(light->rgb, c); EERIE_LIGHT * el = lightHandleGet(flare.dynlight); if(el) { el->pos = flare.v.p; el->rgb = c; } mat.setDepthTest(flare.io != NULL); if(flare.bDrawBitmap) { size *= 2.f * minSizeRatio(); EERIEAddBitmap(mat, flare.v.p, size, size, surf, Color::fromRGBA(flare.tv.color)); } else { EERIEAddSprite(mat, flare.v.p, size * 0.025f + 1.f, Color::fromRGBA(flare.tv.color), 2.f); } } } light->rgb = componentwise_min(light->rgb, Color3f::white); }