Result execute(Context & context) { std::string inout = context.getWord(); const PlatformDuration duration = PlatformDurationMsf(context.getFloat()); if(inout == "out") { Color3f color; color.r = context.getFloat(); color.g = context.getFloat(); color.b = context.getFloat(); fadeSetColor(color); fadeRequestStart(FadeType_Out, duration); DebugScript(" out " << toMs(duration) << ' ' << color.r << ' ' << color.g << ' ' << color.b); } else if(inout == "in") { fadeRequestStart(FadeType_In, duration); DebugScript(" in " << toMs(duration)); } else { ScriptWarning << "unexpected fade direction: " << inout; return Failed; } return Success; }
void ParticleSparkSpawnContinous(const Vec3f & pos, unsigned rate, SpawnSparkType type) { float amount = float(rate) * (g_platformTime.lastFrameDuration() / PlatformDurationMsf(66.666666f)); unsigned count = unsigned(amount); if(Random::getf() < (amount - float(count))) { count++; } ParticleSparkSpawn(pos, count, type); }
void ActiveSpellsGui::init() { m_texUnknown = TextureContainer::Load("graph/interface/icons/spell_unknown"); arx_assert(m_texUnknown); m_slotSize = Vec2f(24.f, 24.f); m_spacerSize = Vec2f(60.f, 50.f); m_slotSpacerSize = Vec2f(0.f, 9.f); m_flickNow = false; m_flickTime = 0; m_flickInterval = PlatformDurationMsf(1000.0f / 60.0f); }
void MenuWindow::update() { m_pos.x = m_initalOffsetX + (m_fadeDistance * glm::sin(glm::radians(fAngle))); fAngle = std::min(fAngle + g_platformTime.lastFrameDuration() / PlatformDurationMsf(12.5f), 90.f); if(m_currentPage) { m_currentPage->update(m_pos + Vec2f(RATIO_X(14.5f), RATIO_Y(12.f))); } }
void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos, Rectf rect, float scale) { RenderState baseState = render3D().depthTest(false).fog(false); Vec3f pos = Vec3f(0.f, 0.f, 2100.f); EERIE_LIGHT * light = lightHandleGet(torchLightHandle); EERIE_LIGHT tl = *light; light->pos = Vec3f(500.f, -1960.f, 1590.f); light->m_exists = true; light->rgb = Color3f(0.6f, 0.7f, 0.9f); light->intensity = 1.8f; light->fallstart = 4520.f; light->fallend = light->fallstart + 600.f; RecalcLight(light); Camera * oldcam = g_camera; g_culledDynamicLights[0] = light; g_culledDynamicLightsCount = 1; Vec2i tmpPos(0); GRenderer->SetAntialiasing(true); float wave = timeWaveSin(g_platformTime.frameStart(), PlatformDurationMsf(1256.6370614f)); float ptDelta = toMs(g_platformTime.lastFrameDuration()); Camera bookcam; bookcam.angle = Anglef(); bookcam.m_pos = Vec3f(0.f); bookcam.focal = 500.f; bookcam.cdepth = 2200.f; for(size_t i = 0; i < RUNE_COUNT; i++) { if(!gui::necklace.runes[i]) continue; EERIE_3DOBJ * rune = gui::necklace.runes[i]; Vec2i projectionCenter = Vec2i(rect.topLeft() + (Vec2f(285, 36) + Vec2f(tmpPos) * Vec2f(45, 64)) * scale); PrepareCamera(&bookcam, Rect(rect), projectionCenter); if(player.hasRune((Rune)i)) { Anglef angle; if(rune->angle.getYaw() != 0.f) { if(rune->angle.getYaw() > 300.f) { rune->angle.setYaw(300.f); } angle.setYaw(wave * rune->angle.getYaw() * (1.0f / 40)); } rune->angle.setYaw(rune->angle.getYaw() - ptDelta * 0.2f); if(rune->angle.getYaw() < 0.f) rune->angle.setYaw(0.f); // Now draw the rune TransformInfo t2(pos, glm::quat_cast(toRotationMatrix(angle))); DrawEERIEInter(rune, t2, NULL, false, 0.f); Rectf runeBox = UpdateBbox2d(*rune).toRect(); PopAllTriangleListOpaque(baseState); tmpPos.x++; if(tmpPos.x > 4) { tmpPos.x = 0; tmpPos.y++; } // TODO this is a workaround for vertexClipPositions being relative to viewport Vec2f mousePosInViewport = mousePos - rect.topLeft(); // Checks for Mouse floating over a rune... if(runeBox.contains(mousePosInViewport)) { bool r = false; for(size_t j = 0; j < rune->facelist.size(); j++) { float n = PtIn2DPolyProj(rune->vertexClipPositions, &rune->facelist[j], mousePosInViewport.x, mousePosInViewport.y); if(n != 0.f) { r = true; break; } } if(r) { TransformInfo t(pos, glm::quat_cast(toRotationMatrix(angle))); DrawEERIEInter(rune, t, NULL, false, 0.f); rune->angle.setYaw(rune->angle.getYaw() + ptDelta * 2.f); PopAllTriangleListOpaque(baseState.blendAdditive()); cursorSetInteraction(); if(eeMouseDown1()) { PlayerBookDrawRune((Rune)i); } } } TransformInfo t1(pos, quat_identity()); DrawEERIEInter(gui::necklace.lacet, t1, NULL, false, 0.f); PopAllTriangleListOpaque(baseState); } } *light = tl; PrepareCamera(oldcam, g_size); GRenderer->SetAntialiasing(false); }
void AddFlare(const Vec2f & pos, float sm, short typ, Entity * io, bool bookDraw) { size_t oldest = 0; size_t i; for(i = 0; i < g_magicFlaresMax; i++) { if(!g_magicFlares[i].exist) { break; } if(g_magicFlares[i].tolive < g_magicFlares[oldest].tolive) { oldest = i; } } if(i >= g_magicFlaresMax) { removeFlare(g_magicFlares[oldest]); i = oldest; } MagicFlare & flare = g_magicFlares[i]; flare.exist = 1; g_magicFlaresCount++; flare.bDrawBitmap = bookDraw; flare.io = io; if(io) { flare.flags = 1; io->flarecount++; } else { flare.flags = 0; } flare.pos.x = pos.x - Random::getf(0.f, 4.f); flare.pos.y = pos.y - Random::getf(0.f, 4.f); if(!bookDraw) { if(io) { float vx = -(flare.pos.x - g_size.center().x) * 0.2173913f; float vy = (flare.pos.y - g_size.center().y) * 0.1515151515151515f; flare.p = io->pos; flare.p += angleToVectorXZ(io->angle.getYaw() + vx) * 100.f; flare.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getPitch() + vy))) * 100.f - 150.f; } else { Vec3f screenPos(1.0f * (pos.x - float(g_size.width() / 2)) * 156.f / (640.f * g_sizeRatio.y), 0.75f * (pos.y - float(g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y), 75.f); flare.p = Vec3f(glm::inverse(g_preparedCamera.m_worldToView) * Vec4f(screenPos, 1.0f)); } } else { flare.p = Vec3f(flare.pos.x, flare.pos.y, 0.001f); } switch(g_magicFlareCurrentColor) { case 0: { flare.rgb = Color3f(0.4f, 0.f, 0.4f) + Color3f(2.f / 3, 2.f / 3, 2.f / 3) * randomColor3f(); break; } case 1: { flare.rgb = Color3f(0.5f, 0.5f, 0.f) + Color3f(0.625f, 0.625f, 0.55f) * randomColor3f(); break; } case 2: { flare.rgb = Color3f(0.4f, 0.f, 0.f) + Color3f(2.f / 3, 0.55f, 0.55f) * randomColor3f(); break; } default: arx_unreachable(); } static const float FLARE_MUL = 2.f; if(typ == -1) { float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? Random::getf() : 1.f); if(zz < 0.2f) { flare.type = 2; flare.size = Random::getf(42.f, 84.f); flare.tolive = PlatformDurationMsf(Random::getf(800.f, 1600.f) * FLARE_MUL); } else if(zz < 0.5f) { flare.type = 3; flare.size = Random::getf(16.f, 68.f); flare.tolive = PlatformDurationMsf(Random::getf(800.f, 1600.f) * FLARE_MUL); } else { flare.type = 1; flare.size = Random::getf(32.f, 56.f) * sm; flare.tolive = PlatformDurationMsf(Random::getf(1700.f, 2200.f) * FLARE_MUL); } } else { flare.type = (Random::getf() > 0.8f) ? 1 : 4; flare.size = Random::getf(64.f, 102.f) * sm; flare.tolive = PlatformDurationMsf(Random::getf(1700.f, 2200.f) * FLARE_MUL); } flare.dynlight = LightHandle(); for(unsigned int kk = 0; kk < 3; kk++) { if(Random::getf() < 0.5f) { continue; } PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } if(!bookDraw) { pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING; if(!io) { pd->m_flags |= PARTICLE_NOZBUFFER; } } else { pd->m_flags = FADE_IN_AND_OUT; } pd->ov = flare.p + arx::randomVec(-5.f, 5.f); pd->move = Vec3f(0.f, 5.f, 0.f); pd->scale = Vec3f(-2.f); pd->tolive = 1300 + kk * 100 + Random::getu(0, 800); pd->tc = fire2; if(kk == 1) { pd->move.y = 4.f; pd->siz = 1.5f; } else { pd->siz = Random::getf(1.f, 2.f); } pd->rgb = flare.rgb * (2.f / 3); pd->m_rotation = 1.2f; if(bookDraw) { pd->is2D = true; } } }