1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
local FORCE_WIND_VELOCITY_UPDATE = true
local UI_WIDTH , UI_HEIGHT = 1920 , 1080
local UI_CENTER_X , UI_CENTER_Y = UI_WIDTH * 0.5 , UI_HEIGHT * 0.5
-- minR, maxR, minG, maxG, minB, maxB, minA, maxA
local LEAF_COLORS =
{
}
local LEAF_ANCHOR_CONTROLS =
{
BACKGROUND = 1 ,
TREES_LEFT = 2 ,
TREES_RIGHT = 3 ,
}
local LEAF_ANCHOR_CONTROL_REFS = { }
-- minForwardX, maxForwardX, minForwardY, maxForwardY
anchorTo = LEAF_ANCHOR_CONTROLS . TREES_LEFT ,
anchorPoint = TOPRIGHT ,
drawLevel = 100 ,
forwardRotationAngleCoefficient = 1 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_RIGHT ,
-- minX, maxX, minY, maxX, minNormalizedZ, maxNormalizedZ
} , 300 ) ,
anchorTo = LEAF_ANCHOR_CONTROLS . TREES_RIGHT ,
anchorPoint = TOPRIGHT ,
drawLevel = 325 , -- On top of the front right tree
forwardRotationAngleCoefficient = 1 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_LEFT ,
positionRanges = ZO_WeightedVectorRanges : New ( ZO_VectorRange : New ( 1880 - UI_WIDTH , 1970 - UI_WIDTH , 0 , 40 , 0.75 , 1 ) ) ,
} , 100 ) ,
anchorTo = LEAF_ANCHOR_CONTROLS . TREES_RIGHT ,
anchorPoint = TOPRIGHT ,
drawLevel = 265 , -- On top of the left and back right trees
forwardRotationAngleCoefficient = 1 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_LEFT ,
positionRanges = ZO_WeightedVectorRanges : New ( ZO_VectorRange : New ( 1340 - UI_WIDTH , 1520 - UI_WIDTH , 0 , 75 , 0.5 , 0.75 ) ) ,
} , 100 ) ,
anchorTo = LEAF_ANCHOR_CONTROLS . BACKGROUND ,
anchorPoint = TOP ,
drawLevel = 275 , -- On top of the left and back right trees
forwardRotationAngleCoefficient = 1 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_LEFT ,
positionRanges = ZO_WeightedVectorRanges : New ( ZO_VectorRange : New ( 1320 - UI_CENTER_X , 1400 - UI_CENTER_X , 150 , 200 , 0.25 , 0.5 ) ) ,
} , 80 ) ,
anchorTo = LEAF_ANCHOR_CONTROLS . BACKGROUND ,
anchorPoint = TOP ,
drawLevel = 285 , -- On top of the left and back right trees
forwardRotationAngleCoefficient = 0.1 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_RIGHT_STRONG ,
positionRanges = ZO_WeightedVectorRanges : New ( ZO_VectorRange : New ( 1300 - UI_CENTER_X , 1375 - UI_CENTER_X , 350 , 375 , 0.0 , 0.25 ) ) ,
} , 50 ) ,
anchorTo = LEAF_ANCHOR_CONTROLS . BACKGROUND ,
anchorPoint = TOP ,
drawLevel = 4000 , -- On top of all other elements.
forwardRotationAngleCoefficient = 0.25 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_DOWN_RIGHT ,
} , 30 ) ,
anchorTo = LEAF_ANCHOR_CONTROLS . BACKGROUND ,
anchorPoint = TOP ,
drawLevel = 4010 , -- On top of all other elements.
forwardRotationAngleCoefficient = 0.25 ,
forwardVectorRange = LEAF_FORWARD_VECTOR_DOWN_LEFT ,
} , 30 ) )
-- Custom parameter definitions
-- CreateBackgroundParameter* arguments: parameterKey, defaultValue, minValue, maxValue, formatString
CreateBackgroundParameterFloat ( "ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_FADE_IN_INTERVAL_SECONDS" , 2 , 0.01 , 60 , "%.2f seconds" )
CreateBackgroundParameterInteger ( "ZO_BACKGROUND_WIND_UPDATE_INTERVAL_MAX_SECONDS" , 16 , 1 , 60 , "%d seconds" )
CreateBackgroundParameterInteger ( "ZO_BACKGROUND_WIND_UPDATE_INTERVAL_MIN_SECONDS" , 3 , 1 , 60 , "%d seconds" )
CreateBackgroundParameterFloat ( "ZO_BACKGROUND_WIND_VELOCITY_OVERRIDE_TRANSITION_INTERVAL_SECONDS" , 0.1 , 0 , 5 , "%.1f seconds" )
-- [ Required ]
-- After defining the parameters, the global table -must- be
-- updated with the current/calculated parameter values.
-- Pregame Animated Background
-- Override Method Implementations
self . titleFadeInTimeline = ANIMATION_MANAGER : CreateTimelineFromVirtual ( "ZO_PeninsulaBackgroundAnimation_TitleFadeIn" , self . control )
self . sunRaysFadeInTimeline = ANIMATION_MANAGER : CreateTimelineFromVirtual ( "ZO_PeninsulaBackgroundAnimation_SunRaysFadeIn" , self . control )
end
-- Order matters
end
-- Order matters
end
return false
end
return true
end
end
self . ouroborosGlowTexture : SetTextureSampleProcessingWeight ( TEX_SAMPLE_PROCESSING_RGB , ZO_BACKGROUND_OUROBOROS_GLOW_RGB_WEIGHT_MIN )
self . sunRaysTexture : SetVertexColors ( VERTEX_POINTS_BOTTOMLEFT + VERTEX_POINTS_BOTTOMRIGHT , 1 , 1 , 1 , 0 )
FLICKER_EFFECT : RegisterControl ( self . ouroborosGlowTexture , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_SPEED , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_ALPHA_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_COLOR_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_BLUR_FACTOR_MAX , OUROBOROS_GLOW_COLOR )
end
-- Suppress the default behavior of ZO_BaseBackground.OnIntroAnimationStop.
-- This background class manages the visibility of the ouroboros and title manually.
self . backgroundTexture : SetMaskThresholdZeroAlphaEdge ( - self . backgroundTexture : GetMaskThresholdThickness ( ) )
end
-- Suppress the default behavior of ZO_BaseBackground.OnIntroAnimationUpdate.
-- Masked fade in Background, Terrain and Trees.
local backgroundMaskThreshold = zo_lerp ( 1 , - self . backgroundTexture : GetMaskThresholdThickness ( ) , progress )
-- Fade in Tree Silhouettes.
-- Transition Background from the Gold Road color to full color.
do
end
end
if frameTimeS <= 0 then
return
end
-- Animate leaf particles.
-- Determine whether the left mouse button or left stick is, or was, engaged.
-- Interpolate the interaction coefficient to 1 while engaged; otherwise to 0.
local interactionCoefficientChanged = false
if interactionCoefficient < 1 and ( self . mouseDownX or self . movementControllerVectorX ~= 0 or self . movementControllerVectorY ~= 0 ) then
interactionCoefficientChanged = true
interactionCoefficientChanged = true
end
-- Update audible wind intensity and direction.
local windIntensityFromMagnitude = zo_lerp ( 0 , 0.5 , self . windMagnitude / ZO_BACKGROUND_WIND_MOUSE_VELOCITY_COEFFICIENT )
-- Clamp to [0, 1]
self . audioWindIntensity = zo_clamp ( windIntensityFromInteractionDuration + windIntensityFromMagnitude , 0 , 1 )
local windDirectionX , windDirectionY
-- Normalize from [-1, 1] to [0, 1]
else
-- Normalize to [0, 1]
end
SetPregameAnimatedBackgroundWindState ( self . audioWindIntensity , self . audioWindDirectionX , self . audioWindDirectionY )
if interactionCoefficientChanged then
-- Left mouse button or left stick is, or was, engaged;
-- apply the interpolated wind and ouroboros glow visual states.
-- Simulate wind by increasing the tree wave speed.
self . treeWaveSpeedCoefficient = zo_lerp ( ZO_BACKGROUND_TREES_WAVE_SPEED_COEFFICIENT_BASE , ZO_BACKGROUND_WIND_MOUSE_TREE_WAVE_SPEED_COEFFICIENT , interactionCoefficient )
-- Increase ouroboros glow intensity.
self . ouroborosGlowStrength = zo_lerp ( ZO_BACKGROUND_OUROBOROS_GLOW_RGB_WEIGHT_MIN , ZO_BACKGROUND_OUROBOROS_GLOW_RGB_WEIGHT_MAX , ouroborosCoefficient )
self . ouroborosGlowTexture : SetTextureSampleProcessingWeight ( TEX_SAMPLE_PROCESSING_RGB , self . ouroborosGlowStrength )
-- Reduce flicker strength.
do
local alphaFlickerStrength = zo_lerp ( ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_ALPHA_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_ALPHA_STRENGTH * 0.5 , easedOuroborosCoefficient )
local colorFlickerStrength = zo_lerp ( ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_COLOR_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_COLOR_STRENGTH * 0.5 , easedOuroborosCoefficient )
FLICKER_EFFECT : SetAlphaAndColorFlickerStrength ( self . ouroborosGlowTexture , alphaFlickerStrength , colorFlickerStrength )
end
-- Change ouroboros glow to amber.
OUROBOROS_GLOW_COLOR : SetLerpRGB ( OUROBOROS_GLOW_COLOR_BASE , OUROBOROS_GLOW_COLOR_INTENSE , ouroborosCoefficient )
end
end
-- Fade in key elements.
if fadeInProgress < 10 then
fadeInProgress = fadeInProgress * fadeInProgress
end
-- Manipulate the vertex UV coordinates to simulate waving of the
-- tree elements as this produces a more convincing visual effect
-- than the wave shader effect.
local OFFSET_X_MAX = ZO_BACKGROUND_TREES_WAVE_OFFSET_X_MAX
local OFFSET_Y_MAX = ZO_BACKGROUND_TREES_WAVE_OFFSET_Y_MAX
-- Front left tree wave.
local u1 = ( distribution1 * sin1 + ( 1 - distribution1 ) * sin2 ) * OFFSET_X_MAX
local v1 = cos1 * OFFSET_Y_MAX
do
local u , v = u1 * 0.2 , v1 * 0.2 + OFFSET_Y_MAX
end
do
local u , v = 1 + u1 , v1 + OFFSET_Y_MAX
end
-- Back right tree wave.
local u2 = ( 0.5 * sin1 + 0.5 * sin2 ) * OFFSET_X_MAX
local v2 = 0
do
local u , v = u2 , v2
end
do
local v = cos2 * OFFSET_Y_MAX + OFFSET_Y_MAX
end
-- Front right tree wave.
local u3 = ( distribution2 * sin2 + ( 1 - distribution2 ) * sin1 ) * OFFSET_X_MAX
local v3 = ( distribution2 * cos1 + ( 1 - distribution2 ) * cos2 ) * OFFSET_Y_MAX
do
local u , v = u3 , v3 + OFFSET_Y_MAX
end
do
local u , v = 1 + u3 * 0.2 , v3 * 0.1 + OFFSET_Y_MAX
end
end
-- Class-Specific Methods
self . leafTexturePool = ZO_ControlPool : New ( "ZO_PeninsulaBackgroundLeaf" , self . control , "BackgroundLeaf" )
self . leafTexturePool : SetCustomAcquireBehavior ( ZO_GetCallbackForwardingFunction ( self , self . OnLeafTextureAcquired ) )
self . leafTexturePool : SetCustomFactoryBehavior ( ZO_GetCallbackForwardingFunction ( self , self . OnLeafTextureCreated ) )
end
return movementController
end
{
[ MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL ] = CreateMovementController ( MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL ) ,
[ MOVEMENT_CONTROLLER_DIRECTION_VERTICAL ] = CreateMovementController ( MOVEMENT_CONTROLLER_DIRECTION_VERTICAL ) ,
}
end
end
end
end
end
end
local normalizedTransitionIntervalElapsed = transitionIntervalElapsedS > 0 and ( transitionIntervalElapsedS / self . windVelocityTransitionIntervalS ) or 0
return normalizedTransitionIntervalElapsed
end
-- Choose a leaf spawner randomly.
-- Initial position.
control : SetAnchor ( control . anchorPoint , control . anchorToControl , control . anchorPoint , self : GetScaledAnchorOffsets ( startX , startY ) )
-- Draw level.
-- Color and scale.
-- Forward vector.
-- Rotation angle.
local forwardRotationAngleCoefficient = leafSpawner . forwardRotationAngleCoefficient
control . startForwardRotationAngle = zo_lerp ( ZO_BACKGROUND_LEAF_FORWARD_ROTATION_ANGLE_MIN , ZO_BACKGROUND_LEAF_FORWARD_ROTATION_ANGLE_MAX , zo_random ( ) ) * forwardRotationAngleCoefficient
control . endForwardRotationAngle = - zo_sign ( control . startForwardRotationAngle ) * ZO_BACKGROUND_LEAF_FORWARD_ROTATION_ANGLE_MAX * zo_random ( ) * forwardRotationAngleCoefficient
-- Rotation velocity.
control . rotationVelocityY = zo_lerp ( ZO_BACKGROUND_LEAF_ROTATION_VELOCITY_MIN , ZO_BACKGROUND_LEAF_ROTATION_VELOCITY_MAX , zo_random ( ) ) * forwardRotationAngleCoefficient
control . rotationVelocityZ = zo_lerp ( ZO_BACKGROUND_LEAF_ROTATION_VELOCITY_MIN , ZO_BACKGROUND_LEAF_ROTATION_VELOCITY_MAX , zo_random ( ) ) * forwardRotationAngleCoefficient
end
-- Apply the current screen scale to the new leaf control.
end
-- Start wind velocity override.
end
end
-- Stop wind velocity override.
-- Force the generation of a new wind velocity.
end
end
-- Initialize Title.
local START_PROGRESS = 0
if not completed then
-- Initialize Ouroboros Glow flicker.
FLICKER_EFFECT : RegisterControl ( self . ouroborosGlowTexture , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_SPEED , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_ALPHA_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_COLOR_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_BLUR_FACTOR_MAX , OUROBOROS_GLOW_COLOR )
end
end
end
-- Title blur in.
local blurOriginX , blurOriginY , numSamples , blurRadius , offsetRadius = self . titleTexture : GetRadialBlur ( )
-- Title fade in.
end
if not completed then
-- Initialize Ouroboros.
-- Initialize Sun Rays.
self . sunRaysTexture : SetVertexColors ( VERTEX_POINTS_BOTTOMLEFT + VERTEX_POINTS_BOTTOMRIGHT , 1 , 1 , 1 , 0 )
end
end
do
-- Slight scaling in of the Ouroboros.
local ANGLE = 0
local ORIGIN_X , ORIGIN_Y = 0.5 , 0.5
end
do
-- Fade in Ouroboros with darker shading initially for higher contrast
-- during the initial sun ray burst.
local alpha = easedProgress
end
do
-- Ouroboros glow fade in and/or flicker setting sync for the dev tool.
-- Note that the fade in interval's overflow time interval is to ensure
-- that the max alpha is ultimately applied to the flicker effect.
FLICKER_EFFECT : RegisterControl ( self . ouroborosGlowTexture , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_SPEED , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_ALPHA_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_FLICKER_COLOR_STRENGTH , ZO_BACKGROUND_OUROBOROS_GLOW_BLUR_FACTOR_MAX , OUROBOROS_GLOW_COLOR )
end
do
-- Fade in sun rays.
local sunRaysAlpha
if progress <= 0.5 then
else
end
self . sunRaysTexture : SetVertexColors ( VERTEX_POINTS_BOTTOMLEFT + VERTEX_POINTS_BOTTOMRIGHT , 1 , 1 , 1 , sunRaysAlpha )
self . sunRaysTexture : SetVertexColors ( VERTEX_POINTS_TOPLEFT + VERTEX_POINTS_TOPRIGHT , 1 , 1 , 1 , sunRaysAlpha )
end
end
self . sunRaysTexture : SetVertexColors ( VERTEX_POINTS_BOTTOMLEFT + VERTEX_POINTS_BOTTOMRIGHT , 1 , 1 , 1 , 0 )
end
if not overrideTransitionIntervalS then
-- The previous transition did not complete; interpolate the new "previous"
-- wind velocity between the current the current and previous velocities.
local normalizedTransitionIntervalElapsed = ZO_EaseOutQuadratic ( transitionIntervalElapsedS / self . windVelocityTransitionIntervalS )
self . previousWindVelocityX = zo_lerp ( self . previousWindVelocityX , self . windVelocityX , normalizedTransitionIntervalElapsed )
self . previousWindVelocityY = zo_lerp ( self . previousWindVelocityY , self . windVelocityY , normalizedTransitionIntervalElapsed )
end
else
-- Transfer the current wind velocity to the previous wind velocity.
end
self . windVelocityTransitionIntervalS = overrideTransitionIntervalS or ZO_BACKGROUND_WIND_TRANSITION_INTERVAL_SECONDS
self . nextWindVelocityUpdateS = frameTimeS + zo_random ( ZO_BACKGROUND_WIND_UPDATE_INTERVAL_MIN_SECONDS , ZO_BACKGROUND_WIND_UPDATE_INTERVAL_MAX_SECONDS , zo_random ( ) )
end
if nextSpawnTimeS <= frameTimeS then
-- Spawn a new leaf.
leafControl . startTimeS = frameTimeS
end
-- Queue the next leaf spawn.
local intervalCoefficient = ( self . mouseDownX or self . movementControllerVectorX ~= 0 or self . movementControllerVectorY ~= 0 ) and 0.35 or 1
self . nextLeafSpawnTimeS = frameTimeS + ( intervalCoefficient * zo_lerp ( ZO_BACKGROUND_LEAF_SPAWN_INTERVAL_MIN_SECONDS , ZO_BACKGROUND_LEAF_SPAWN_INTERVAL_MAX_SECONDS , zo_random ( ) ) )
end
end
local hasMovement = false
-- Interpolate toward -1 or 1 when the left stick is moved left or right respectively;
-- otherwise interpolate toward 0, at a slower rate, when disengaged.
local horizontalMovement = self . movementControllers [ MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL ] : CheckMovement ( )
if horizontalMovement == MOVEMENT_CONTROLLER_MOVE_PREVIOUS then
hasMovement = true
elseif horizontalMovement == MOVEMENT_CONTROLLER_MOVE_NEXT then
hasMovement = true
else
end
-- Interpolate toward -1 or 1 when the left stick is moved up or down respectively;
-- otherwise interpolate toward 0, at a slower rate, when disengaged.
local verticalMovement = self . movementControllers [ MOVEMENT_CONTROLLER_DIRECTION_VERTICAL ] : CheckMovement ( )
if verticalMovement == MOVEMENT_CONTROLLER_MOVE_PREVIOUS then
hasMovement = true
elseif verticalMovement == MOVEMENT_CONTROLLER_MOVE_NEXT then
hasMovement = true
else
end
if hasMovement then
-- Track the last time that left stick movement was detected.
-- The left stick was, but is no longer, engaged.
-- The left stick has remained idle; force the generation
-- of a new wind velocity and vector.
end
end
end
local minX , minY = - guiWidth , - guiHeight
local maxX , maxY = guiWidth * 2 , guiHeight
-- Update wind velocity and calculate the wind vector for this frame.
local normalizedWindVelocity = zo_distance ( 0 , 0 , self . windVectorX , self . windVectorY ) / ZO_BACKGROUND_WIND_MOUSE_VELOCITY_COEFFICIENT
local normalizedWindCoefficient = 1 + normalizedWindVelocity
-- Spawn new leaf particles; then update all leaf particle animations.
local maxBrightness = ZO_BACKGROUND_LEAF_BRIGHTNESS_MAX
local minBrightness = ZO_BACKGROUND_LEAF_BRIGHTNESS_MIN
local gravityX , gravityY = ZO_BACKGROUND_LEAF_GRAVITY_VECTOR_X , ZO_BACKGROUND_LEAF_GRAVITY_VECTOR_Y
local minForwardY = gravityY * - 0.5
local textureReleaseQueue = nil
-- Calculate translated position and determine whether this leaf
-- has traveled out of bounds.
local releaseControl = false
local translationX , translationY
local positionX , positionY
translationY = ( gravityY + ( zo_max ( minForwardY , control . forwardY ) * normalizedWindCoefficient ) + ( windVectorY * windFactor ) ) * frameDeltaS
if positionY > maxY or positionY < minY then
releaseControl = true
else
translationX = ( gravityX + ( control . forwardX * normalizedWindCoefficient ) + ( windVectorX * windFactor ) ) * frameDeltaS
if positionX > maxX or positionX < minX then
releaseControl = true
end
end
if releaseControl then
-- This leaf has moved out of bounds; queue the control
-- for release from the pool.
if textureReleaseQueue then
else
end
else
-- Apply alpha.
-- Move this texture control to its new position.
control : SetAnchor ( control . anchorPoint , control . anchorToControl , control . anchorPoint , self : GetScaledAnchorOffsets ( control . positionX , control . positionY ) )
-- Apply forward vector rotation.
local forwardRotationAngle = zo_lerp ( control . startForwardRotationAngle , control . endForwardRotationAngle , lifetimeInterpolant ) * frameDeltaS
control . forwardX , control . forwardY = ZO_Rotate2D ( forwardRotationAngle , control . forwardX , control . forwardY )
-- Apply rotation velocity.
local progressiveFrameDeltaS = frameDeltaS * ( 1 - ( lifetimeInterpolant * 0.75 ) )
local NO_ROTATION = 0
local normalizedScaleX , normalizedScaleY = ZO_RotateTexture3D ( control , NO_ROTATION , control . rotationY , control . rotationZ )
-- Apply lighting.
local normalizedCameraFacing = ZO_GetNormalizedCameraFacingDirectionFromNormalizedAxisScales ( normalizedScaleX , normalizedScaleY )
end
end
if textureReleaseQueue then
end
end
end
local hasMouseInput = mouseX1 and mouseY1
local hasControllerInput = controllerX ~= 0 or controllerY ~= 0
if forceWindVelocityUpdate or ( not ( hasMouseInput or hasControllerInput ) and frameTimeS >= self . nextWindVelocityUpdateS ) then
-- Update the wind velocity vector to point in a random direction with
-- a magnitude in the configured velocity range.
-- Generate wind angles between 70-90 and 270-290 degrees (positive Y-axis
-- pushes downward)
local velocityX = directionX * magnitude
local velocityY = directionY * magnitude
elseif hasControllerInput then
-- Override the wind velocity in relation to the magnitude of the
-- continuous direction of the controller left stick.
local magnitude = controllerDistance * ZO_BACKGROUND_WIND_MOUSE_VELOCITY_COEFFICIENT
self : SetWindVelocity ( magnitude , velocityX , velocityY , - ZO_BACKGROUND_WIND_VELOCITY_OVERRIDE_TRANSITION_INTERVAL_SECONDS )
elseif hasMouseInput then
-- Override the wind velocity in relation to the distance that the mouse
-- has traveled since the button was first pressed.
local directionX , directionY = mouseX2 - mouseX1 , mouseY2 - mouseY1
if directionX ~= 0 or directionY ~= 0 then
local magnitude = zo_clamp ( cursorDistance / 150 , 0 , 1 ) * ZO_BACKGROUND_WIND_MOUSE_VELOCITY_COEFFICIENT
self : SetWindVelocity ( magnitude , velocityX , velocityY , - ZO_BACKGROUND_WIND_VELOCITY_OVERRIDE_TRANSITION_INTERVAL_SECONDS )
end
end
end
-- Interpolate between the previous wind velocity and the current wind velocity
-- relative to the time elapsed since the last wind velocity change.
local normalizedTransitionIntervalElapsed = ZO_EaseOutQuintic ( zo_clamp ( transitionIntervalElapsedS / self . windVelocityTransitionIntervalS , 0 , 0.9 ) )
self . windVectorX = zo_lerp ( self . previousWindVelocityX , self . windVelocityX , normalizedTransitionIntervalElapsed )
self . windVectorY = zo_lerp ( self . previousWindVelocityY , self . windVelocityY , normalizedTransitionIntervalElapsed )
end |