Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

Easing 2 animations / kind of a BlendTree

$
0
0
Hello everyone,

I'm working on a VB6 project where I aim to implement a circle around the mouse pointer that moves along with it and changes its size based on the mouse travel speed. When the mouse pointer remains stationary for approximately 1000 milliseconds, the circle begins to shrink.

After discovering the Ease functions in the Cairo Tutorial, I was inspired to incorporate them into my project. I've created animations with different start and end colors, various easing effects, and different start and end sizes.

However, I've encountered an issue: while the circle changes its color as expected, the grow/shrink effect and the easing are not working properly. The circle's size doesn't reflect the easing effects like bounce or elasticity—it only increases smoothly from the start size to the end size.

I've attached my sample project for reference. In my previous experience with Unity, I used BlendTrees to achieve similar effects. I checked the object browser to see if RC6 provides a solution for blending between states, but I couldn't find any relevant classes or methods.

Could someone please take a look at my sample project and help me identify where I might be going wrong? Additionally, if there is an existing class or method in VB6 or RC6 that facilitates blending between animation states, I would greatly appreciate any recommendations.

Thank you very much for your assistance!
Code:

Private Sub pInterpolateAnimations(ByVal uProgress As Double, ByRef uStartAnim As udtAnim, ByRef uTargetAnim As udtAnim, ByRef uInterpolatedSize As Double, ByRef uInterpolatedColor As Long)
    On Error GoTo errhandler

    Dim weight1 As Double
    Dim weight2 As Double

    If uProgress < 0 Then uProgress = 0
    If uProgress > 1 Then uProgress = 1

    weight1 = 1 - uProgress
    weight2 = uProgress

    Dim totalWeight As Double
    totalWeight = weight1 + weight2
    If totalWeight = 0 Then
        totalWeight = 1
    End If

    Dim easedProgress_StartAnimation As Double
    Dim easedProgress_TargetAnimation As Double

    easedProgress_StartAnimation = Ease(uProgress, uStartAnim.FunctionType, uStartAnim.ModeType)
    easedProgress_TargetAnimation = Ease(uProgress, uTargetAnim.FunctionType, uTargetAnim.ModeType)

    Dim size1 As Double
    Dim size2 As Double

    size1 = uStartAnim.SizeFactorAtStart + (uStartAnim.SizeFactorAtEnd - uStartAnim.SizeFactorAtStart) * easedProgress_StartAnimation
    size2 = uTargetAnim.SizeFactorAtStart + (uTargetAnim.SizeFactorAtEnd - uTargetAnim.SizeFactorAtStart) * easedProgress_TargetAnimation

    uInterpolatedSize = (size1 * weight1 + size2 * weight2) / totalWeight

    Dim color1 As Long
    Dim color2 As Long

    color1 = pInterpolateColor(uStartAnim.StartColor, uStartAnim.TargetColor, uProgress)
    color2 = pInterpolateColor(uTargetAnim.StartColor, uTargetAnim.TargetColor, uProgress)

    uInterpolatedColor = pInterpolateColor(color1, color2, weight2 / totalWeight)

    Exit Sub
errhandler:
    Debug.Print Err.Description
    Debug.Assert False
    On Error GoTo -1
End Sub

Attached Files

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>