float Overlay::getGlowLevel() { if (_glowLevelPulse == 0.0f) { return _glowLevel; } float pulseLevel = updatePulse(); return (_glowLevelPulse >= 0.0f) ? _glowLevel * pulseLevel : _glowLevel * (1.0f - pulseLevel); }
float Overlay::getAlpha() { if (_alphaPulse == 0.0f) { return _alpha; } float pulseLevel = updatePulse(); return (_alphaPulse >= 0.0f) ? _alpha * pulseLevel : _alpha * (1.0f - pulseLevel); }
void StairvilleLEDParSpot::update(){ if(fading){ updateFade(); } if(pulsing){ updatePulse(); } // TODO: Checken, ob das mit dem sizeof funktioniert for(int i=0; i<sizeof(channels); i++) { dmx->setLevel(i + startAddress, channels[i]); } }
void TextOverlay::render(RenderArgs* args) { if (_visible != _qmlElement->isVisible()) { _qmlElement->setVisible(_visible); } float pulseLevel = updatePulse(); static float _oldPulseLevel = 0.0f; if (pulseLevel != _oldPulseLevel) { } }
void HexagonGame::update(float mFT) { if(!assets.pIsLocal() && Config::isEligibleForScore()) { assets.playedSeconds += mFT / 60.f; if(assets.playedSeconds >= 60.f) { assets.playedSeconds = 0; Online::trySendMinutePlayed(); } } updateFlash(mFT); effectTimelineManager.update(mFT); if(!status.hasDied) { manager.update(mFT); updateEvents(mFT); updateTimeStop(mFT); updateIncrement(); if(mustChangeSides && !manager.hasEntity(HGGroup::Wall)) sideChange(getRnd(levelStatus.sidesMin, levelStatus.sidesMax + 1)); updateLevel(mFT); if(Config::getBeatPulse()) updateBeatPulse(mFT); if(Config::getPulse()) updatePulse(mFT); if(!Config::getBlackAndWhite()) styleData.update(mFT, pow(difficultyMult, 0.8f)); } else levelStatus.rotationSpeed *= 0.99f; if(Config::get3D()) update3D(mFT); if(!Config::getNoRotation()) updateRotation(mFT); overlayCamera.update(mFT); backgroundCamera.update(mFT); for(auto& c : depthCameras) c.update(mFT); if(status.mustRestart) { changeLevel(restartId, restartFirstTime); if(!assets.pIsLocal() && Config::isEligibleForScore()) { Online::trySendRestart(); } } if(!status.scoreInvalid && Config::getOfficial() && fpsWatcher.isLimitReached()) invalidateScore(); fpsWatcher.update(); }
xColor Text3DOverlay::getBackgroundColor() { if (_colorPulse == 0.0f) { return _backgroundColor; } float pulseLevel = updatePulse(); xColor result = _backgroundColor; if (_colorPulse < 0.0f) { result.red *= (1.0f - pulseLevel); result.green *= (1.0f - pulseLevel); result.blue *= (1.0f - pulseLevel); } else { result.red *= pulseLevel; result.green *= pulseLevel; result.blue *= pulseLevel; } return result; }
glm::u8vec3 Text3DOverlay::getBackgroundColor() { if (_colorPulse == 0.0f) { return _backgroundColor; } float pulseLevel = updatePulse(); glm::u8vec3 result = _backgroundColor; if (_colorPulse < 0.0f) { result.x *= (1.0f - pulseLevel); result.y *= (1.0f - pulseLevel); result.z *= (1.0f - pulseLevel); } else { result.x *= pulseLevel; result.y *= pulseLevel; result.z *= pulseLevel; } return result; }
void HexagonGame::update(FT mFT) { updateText(); updateFlash(mFT); effectTimelineManager.update(mFT); if(!status.started && (!Config::getRotateToStart() || inputImplCCW || inputImplCW || inputImplBothCWCCW)) { status.started = true; messageText.setString(""); assets.playSound("go.ogg"); assets.musicPlayer.resume(); if(Config::getOfficial()) fpsWatcher.enable(); } // Naive touch controls for(const auto& p : window.getFingerDownPositions()) { if(p.x < window.getWidth() / 2.f) inputImplCCW = 1; else inputImplCW = 1; } if(inputImplCW && !inputImplCCW) inputMovement = 1; else if(!inputImplCW && inputImplCCW) inputMovement = -1; else if(inputImplCW && inputImplCCW) { if(!inputImplBothCWCCW) { if(inputMovement == 1 && inputImplLastMovement == 1) inputMovement = -1; else if(inputMovement == -1 && inputImplLastMovement == -1) inputMovement = 1; } } else inputMovement = 0; if(status.started) { if(!assets.pIsLocal() && Config::isEligibleForScore()) { assets.playedSeconds += ssvu::getFTToSeconds(mFT); if(assets.playedSeconds >= 60.f) { assets.playedSeconds = 0; Online::trySendMinutePlayed(); } } if(!status.hasDied) { manager.update(mFT); updateEvents(mFT); updateTimeStop(mFT); updateIncrement(); if(mustChangeSides && !manager.hasEntity(HGGroup::Wall)) sideChange(getRndI( levelStatus.sidesMin, levelStatus.sidesMax + 1)); updateLevel(mFT); if(Config::getBeatPulse()) updateBeatPulse(mFT); if(Config::getPulse()) updatePulse(mFT); if(!Config::getBlackAndWhite()) styleData.update(mFT, pow(difficultyMult, 0.8f)); } else levelStatus.rotationSpeed *= 0.99f; if(Config::get3D()) update3D(mFT); if(!Config::getNoRotation()) updateRotation(mFT); } overlayCamera.update(mFT); backgroundCamera.update(mFT); if(status.started) { if(status.mustRestart) { fpsWatcher.disable(); changeLevel(restartId, restartFirstTime); if(!assets.pIsLocal() && Config::isEligibleForScore()) { Online::trySendRestart(); } } if(!status.scoreInvalid && Config::getOfficial() && fpsWatcher.isLimitReached()) invalidateScore(); fpsWatcher.update(); } }
void Circle3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } float alpha = getAlpha(); if (alpha == 0.0f) { return; // do nothing if our alpha is 0, we're not visible } bool geometryChanged = _dirty; _dirty = false; const float FULL_CIRCLE = 360.0f; const float SLICES = 180.0f; // The amount of segment to create the circle const float SLICE_ANGLE = FULL_CIRCLE / SLICES; const float MAX_COLOR = 255.0f; auto geometryCache = DependencyManager::get<GeometryCache>(); Q_ASSERT(args->_batch); auto& batch = *args->_batch; if (args->_pipeline) { batch.setPipeline(args->_pipeline->pipeline); } // FIXME: THe line width of _lineWidth is not supported anymore, we ll need a workaround auto transform = getTransform(); transform.postScale(glm::vec3(getDimensions(), 1.0f)); batch.setModelTransform(transform); // for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise // we just draw a line... if (getIsSolid()) { if (!_quadVerticesID) { _quadVerticesID = geometryCache->allocateID(); } if (geometryChanged) { QVector<glm::vec2> points; QVector<glm::vec4> colors; float pulseLevel = updatePulse(); vec4 pulseModifier = vec4(1); if (_alphaPulse != 0.0f) { pulseModifier.a = (_alphaPulse >= 0.0f) ? pulseLevel : (1.0f - pulseLevel); } if (_colorPulse != 0.0f) { float pulseValue = (_colorPulse >= 0.0f) ? pulseLevel : (1.0f - pulseLevel); pulseModifier = vec4(vec3(pulseValue), pulseModifier.a); } vec4 innerStartColor = vec4(toGlm(_innerStartColor), _innerStartAlpha) * pulseModifier; vec4 outerStartColor = vec4(toGlm(_outerStartColor), _outerStartAlpha) * pulseModifier; vec4 innerEndColor = vec4(toGlm(_innerEndColor), _innerEndAlpha) * pulseModifier; vec4 outerEndColor = vec4(toGlm(_outerEndColor), _outerEndAlpha) * pulseModifier; if (_innerRadius <= 0) { _solidPrimitive = gpu::TRIANGLE_FAN; points << vec2(); colors << innerStartColor; for (float angle = _startAt; angle <= _endAt; angle += SLICE_ANGLE) { float range = (angle - _startAt) / (_endAt - _startAt); float angleRadians = glm::radians(angle); points << glm::vec2(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius); colors << glm::mix(outerStartColor, outerEndColor, range); } } else { _solidPrimitive = gpu::TRIANGLE_STRIP; for (float angle = _startAt; angle <= _endAt; angle += SLICE_ANGLE) { float range = (angle - _startAt) / (_endAt - _startAt); float angleRadians = glm::radians(angle); points << glm::vec2(cosf(angleRadians) * _innerRadius, sinf(angleRadians) * _innerRadius); colors << glm::mix(innerStartColor, innerEndColor, range); points << glm::vec2(cosf(angleRadians) * _outerRadius, sinf(angleRadians) * _outerRadius); colors << glm::mix(outerStartColor, outerEndColor, range); } } geometryCache->updateVertices(_quadVerticesID, points, colors); } geometryCache->renderVertices(batch, _solidPrimitive, _quadVerticesID); } else { if (!_lineVerticesID) { _lineVerticesID = geometryCache->allocateID(); } if (geometryChanged) { QVector<glm::vec2> points; float angle = _startAt; float angleInRadians = glm::radians(angle); glm::vec2 firstPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius); points << firstPoint; while (angle < _endAt) { angle += SLICE_ANGLE; angleInRadians = glm::radians(angle); glm::vec2 thisPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius); points << thisPoint; if (getIsDashedLine()) { angle += SLICE_ANGLE / 2.0f; // short gap angleInRadians = glm::radians(angle); glm::vec2 dashStartPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius); points << dashStartPoint; } } // get the last slice portion.... angle = _endAt; angleInRadians = glm::radians(angle); glm::vec2 lastPoint(cosf(angleInRadians) * _outerRadius, sinf(angleInRadians) * _outerRadius); points << lastPoint; geometryCache->updateVertices(_lineVerticesID, points, vec4(toGlm(getColor()), getAlpha())); } if (getIsDashedLine()) { geometryCache->renderVertices(batch, gpu::LINES, _lineVerticesID); } else { geometryCache->renderVertices(batch, gpu::LINE_STRIP, _lineVerticesID); } } // draw our tick marks // for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise // we just draw a line... if (getHasTickMarks()) { if (_majorTicksVerticesID == GeometryCache::UNKNOWN_ID) { _majorTicksVerticesID = geometryCache->allocateID(); } if (_minorTicksVerticesID == GeometryCache::UNKNOWN_ID) { _minorTicksVerticesID = geometryCache->allocateID(); } if (geometryChanged) { QVector<glm::vec2> majorPoints; QVector<glm::vec2> minorPoints; // draw our major tick marks if (getMajorTickMarksAngle() > 0.0f && getMajorTickMarksLength() != 0.0f) { float tickMarkAngle = getMajorTickMarksAngle(); float angle = _startAt - fmodf(_startAt, tickMarkAngle) + tickMarkAngle; float angleInRadians = glm::radians(angle); float tickMarkLength = getMajorTickMarksLength(); float startRadius = (tickMarkLength > 0.0f) ? _innerRadius : _outerRadius; float endRadius = startRadius + tickMarkLength; while (angle <= _endAt) { angleInRadians = glm::radians(angle); glm::vec2 thisPointA(cosf(angleInRadians) * startRadius, sinf(angleInRadians) * startRadius); glm::vec2 thisPointB(cosf(angleInRadians) * endRadius, sinf(angleInRadians) * endRadius); majorPoints << thisPointA << thisPointB; angle += tickMarkAngle; } } // draw our minor tick marks if (getMinorTickMarksAngle() > 0.0f && getMinorTickMarksLength() != 0.0f) { float tickMarkAngle = getMinorTickMarksAngle(); float angle = _startAt - fmodf(_startAt, tickMarkAngle) + tickMarkAngle; float angleInRadians = glm::radians(angle); float tickMarkLength = getMinorTickMarksLength(); float startRadius = (tickMarkLength > 0.0f) ? _innerRadius : _outerRadius; float endRadius = startRadius + tickMarkLength; while (angle <= _endAt) { angleInRadians = glm::radians(angle); glm::vec2 thisPointA(cosf(angleInRadians) * startRadius, sinf(angleInRadians) * startRadius); glm::vec2 thisPointB(cosf(angleInRadians) * endRadius, sinf(angleInRadians) * endRadius); minorPoints << thisPointA << thisPointB; angle += tickMarkAngle; } } xColor majorColorX = getMajorTickMarksColor(); glm::vec4 majorColor(majorColorX.red / MAX_COLOR, majorColorX.green / MAX_COLOR, majorColorX.blue / MAX_COLOR, alpha); geometryCache->updateVertices(_majorTicksVerticesID, majorPoints, majorColor); xColor minorColorX = getMinorTickMarksColor(); glm::vec4 minorColor(minorColorX.red / MAX_COLOR, minorColorX.green / MAX_COLOR, minorColorX.blue / MAX_COLOR, alpha); geometryCache->updateVertices(_minorTicksVerticesID, minorPoints, minorColor); } geometryCache->renderVertices(batch, gpu::LINES, _majorTicksVerticesID); geometryCache->renderVertices(batch, gpu::LINES, _minorTicksVerticesID); } }