Page 1 of 1

About Animation System

Posted: Wed Mar 16, 2011 07:51
by spracle
Requirement: A point moves from Place.1 to Place.2 with uniform speed.
case 1:
duration of time is 1s
case 2:
duration of time is 5s
case 3:
duraiton of time is 10s
case 4:
....
....

If there are 1,000 situations,we need 1,000 configurations.Kind of unacceptable :?

So,is there any convenient way to do this?

-------------------------------------------------------
I think it looks like:
(If we have "anim" configuration for the case:duration of time is 1s)
CEGUI::AnimationInstance* instance = CEGUI::AnimationManager::getSingleton().instantiateAnimation(anim);
instance->setSpeedFactor(1);
instance->setSpeedFactor(5);
instance->setSpeedFactor(10)
..

Re: About Animation System

Posted: Wed Mar 16, 2011 09:54
by Kulik
Hmm, right now animation doesn't allow "dynamic duration" but you can get around this quite simply I think. Lets say you have animation defined and you use current position as Point1 and some property ("NewPosition") as Point2. Like this:

Code: Select all

affector->createKeyFrame(0, "", desiredProgression, "OldPosition");
affector->createKeyFrame(1, "", desiredProgression, "NewPosition");

The same thing can be done with XML.

Please note that OldPosition and NewPosition must be defined in the target Window and have absolute screen space pixel values, get them using CoordConverter.

The animation simply has 2 keyframes from Point1 to Point2. Now when instantiating the animation, you compute the distance from Point1 to Point2 and this gives you a speed factor "denominator". Lets say your normal speed factor is 1.0f, then just do:

Code: Select all

instantiation->setSpeedFactor(1.0f / distance);


(Make sure the distance is not 0 or very close to 0.)

This will make all instantiations move their target with the same speed.

HTH

EDIT: nominator vs denominator

Re: About Animation System

Posted: Thu Mar 17, 2011 06:00
by spracle
Ok,I got it.
Actully, you guys have done this and I can use the API:instantiation->setSpeed() :D

Re: About Animation System

Posted: Thu Mar 31, 2011 07:36
by ogre2012
Kulik wrote:Hmm, right now animation doesn't allow "dynamic duration" but you can get around this quite simply I think. Lets say you have animation defined and you use current position as Point1 and some property ("NewPosition") as Point2. Like this:

Code: Select all

affector->createKeyFrame(0, "", desiredProgression, "OldPosition");
affector->createKeyFrame(1, "", desiredProgression, "NewPosition");

The same thing can be done with XML.

Please note that OldPosition and NewPosition must be defined in the target Window and have absolute screen space pixel values, get them using CoordConverter.

The animation simply has 2 keyframes from Point1 to Point2. Now when instantiating the animation, you compute the distance from Point1 to Point2 and this gives you a speed factor "denominator". Lets say your normal speed factor is 1.0f, then just do:

Code: Select all

instantiation->setSpeedFactor(1.0f / distance);


(Make sure the distance is not 0 or very close to 0.)

This will make all instantiations move their target with the same speed.

HTH

EDIT: nominator vs denominator


Can you tell me how to form KeyFrame1 go to the keyFrme2 ? I have no seen it is in connection with the sysetm time . for example the elapsed time.

Re: About Animation System

Posted: Thu Mar 31, 2011 07:54
by Kulik
ogre2012: Are you injecting time pulses via CEGUI::System::injectTimePulse? You can also step animation instance manually via CEGUI::AnimationInstance::step(delta)

Re: About Animation System

Posted: Fri Apr 08, 2011 16:10
by ogre2012
Kulik wrote:ogre2012: Are you injecting time pulses via CEGUI::System::injectTimePulse? You can also step animation instance manually via CEGUI::AnimationInstance::step(delta)


thank you very much!
I have met another problem about Animation.

Code: Select all

CEGUI::AnimationManager::getSingleton().loadAnimationsFromXML("example.xml");
int num2 = CEGUI::AnimationManager::getSingleton().getNumAnimationInstances();

the value of num2 is 0.
why is not 2?
the example.xml as following:

Code: Select all

<?xml version="1.0" ?>
<Animations>

    <AnimationDefinition name="Example1A" duration="0.3" replayMode="once">
        <Affector property="Alpha" interpolator="float">
            <KeyFrame position="0" value="1" />
            <KeyFrame position="0.3" value="0.66" progression="quadratic decelerating" />
        </Affector>
        <Subscription event="MouseLeavesArea" action="Start" />
    </AnimationDefinition>

    <AnimationDefinition name="Example1B" duration="0.3" replayMode="once">
        <Affector property="Alpha" interpolator="float">
            <KeyFrame position="0" value="0.66" />
            <KeyFrame position="0.3" value="1" progression="quadratic accelerating" />
        </Affector>
        <Subscription event="MouseEntersArea" action="Start" />
    </AnimationDefinition>

</Animations>
 

Re: About Animation System

Posted: Fri Apr 08, 2011 16:37
by Kulik
You have to understand the distinction between Animation Definition and Animation Instance. You can define just 1 animation and instantiate it for 10 different widgets or vice versa.