void CCreateField::Render() { if(!VisibleSphere(Sphere(eSrc - Vec3f(0.f, 120.f, 0.f), 400.f))) return; //------------------------------------------------------------------------- // rendu if(youp) { fglow += 0.5f; if(fglow >= 50) { youp = false; } } else { fglow -= 0.5f; if(fglow <= 0) { youp = true; } } float ysize = std::min(1.0f, m_elapsed / GameDurationMs(1000)); if(ysize >= 1.0f) { size = std::min(1.0f, (m_elapsed - GameDurationMs(1000)) / GameDurationMs(1000)); size = std::max(size, 0.1f); } // ondulation ft += 0.01f; if(ft > 360.0f) { ft = 0.0f; } falpha = glm::sin(glm::radians(fglow)) + Random::getf(0.f, 0.2f); falpha = glm::clamp(falpha, 0.f, 1.f); float smul = 100 * size; // bottom points Vec3f b[4] = { eSrc + Vec3f(-smul, 0.f, -smul), eSrc + Vec3f(smul, 0.f, -smul), eSrc + Vec3f(smul, 0.f, smul), eSrc + Vec3f(-smul, 0.f, smul) }; // top points Vec3f t[4] = { b[0] + Vec3f(0.f, -250 * ysize, 0.f), b[1] + Vec3f(0.f, -250 * ysize, 0.f), b[2] + Vec3f(0.f, -250 * ysize, 0.f), b[3] + Vec3f(0.f, -250 * ysize, 0.f) }; fwrap -= 5.0f; // TODO ignores the frame delay while(fwrap < 0) { fwrap += 360; } RenderMaterial mat; mat.setTexture(tex_jelly); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); RenderSubDivFace(b, b, 0, 1, 2, 3, mat); RenderSubDivFace(t, t, 0, 3, 2, 1, mat); RenderSubDivFace(b, t, 1, 0, 0, 1, mat); RenderSubDivFace(b, t, 3, 2, 2, 3, mat); RenderSubDivFace(b, t, 0, 3, 3, 0, mat); RenderSubDivFace(b, t, 2, 1, 1, 2, mat); EERIE_LIGHT * light = lightHandleGet(lLightId); if(light) { light->intensity = 0.7f + 2.3f * falpha; light->fallend = 500.f; light->fallstart = 400.f; light->rgb = Color3f(0.8f, 0.0f, 1.0f); light->pos = eSrc + Vec3f(0.f, -150.f, 0.f); light->duration = GameDurationMs(800); } }
void CCreateField::Render() { if(!VisibleSphere(eSrc - Vec3f(0.f, 120.f, 0.f), 400.f)) return; if(ulCurrentTime >= ulDuration) return; float fOneOnDuration = 1.f / (float)(ulDuration); falpha = 1.f - (((float)(ulCurrentTime)) * fOneOnDuration); if (falpha > 1.f) falpha = 1.f; //------------------------------------------------------------------------- // rendu if(youp) { fglow += 0.5f; if(fglow >= 50) { youp = false; } } else { fglow -= 0.5f; if(fglow <= 0) { youp = true; } } ysize = std::min(1.0f, ulCurrentTime * 0.001f); if(ysize >= 1.0f) { size = std::min(1.0f, (ulCurrentTime - 1000) * 0.001f); size = std::max(size, 0.1f); } // ondulation ft += 0.01f; if(ft > 360.0f) { ft = 0.0f; } falpha = glm::sin(glm::radians(fglow)) + rnd() * 0.2f; falpha = glm::clamp(falpha, 0.f, 1.f); float x = eSrc.x; float y = eSrc.y; float z = eSrc.z; float smul = 100 * size; // bottom points b[0].x = x - smul; b[0].y = y; b[0].z = z - smul; b[1].x = x + smul; b[1].y = y; b[1].z = z - smul; b[2].x = x + smul; b[2].y = y; b[2].z = z + smul; b[3].x = x - smul; b[3].y = y; b[3].z = z + smul; // top points t[0].x = x - smul; t[0].y = y - 250 * ysize; t[0].z = z - smul; t[1].x = x + smul; t[1].y = y - 250 * ysize; t[1].z = z - smul; t[2].x = x + smul; t[2].y = y - 250 * ysize; t[2].z = z + smul; t[3].x = x - smul; t[3].y = y - 250 * ysize; t[3].z = z + smul; fwrap -= 5.0f; // TODO ignores the frame delay while(fwrap < 0) { fwrap += 360; } RenderMaterial mat = RenderMaterial::getCurrent(); mat.setTexture(tex_jelly); mat.setWrapMode(TextureStage::WrapRepeat); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); RenderSubDivFace(b, b, 0, 1, 2, 3, mat); RenderSubDivFace(t, t, 0, 3, 2, 1, mat); RenderSubDivFace(b, t, 1, 0, 0, 1, mat); RenderSubDivFace(b, t, 3, 2, 2, 3, mat); RenderSubDivFace(b, t, 0, 3, 3, 0, mat); RenderSubDivFace(b, t, 2, 1, 1, 2, mat); if(lightHandleIsValid(lLightId)) { EERIE_LIGHT * light = lightHandleGet(lLightId); light->intensity = 0.7f + 2.3f * falpha; light->fallend = 500.f; light->fallstart = 400.f; light->rgb.r = 0.8f; light->rgb.g = 0.0f; light->rgb.b = 1.0f; light->pos.x = eSrc.x; light->pos.y = eSrc.y - 150; light->pos.z = eSrc.z; light->duration = 800; } //return falpha; }