About Animation System

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

About Animation System

Postby spracle » Wed Mar 16, 2011 07:51

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)
..

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: About Animation System

Postby Kulik » Wed Mar 16, 2011 09:54

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

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: About Animation System

Postby spracle » Thu Mar 17, 2011 06:00

Ok,I got it.
Actully, you guys have done this and I can use the API:instantiation->setSpeed() :D

ogre2012
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Wed Mar 23, 2011 07:55

Re: About Animation System

Postby ogre2012 » Thu Mar 31, 2011 07:36

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.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: About Animation System

Postby Kulik » Thu Mar 31, 2011 07:54

ogre2012: Are you injecting time pulses via CEGUI::System::injectTimePulse? You can also step animation instance manually via CEGUI::AnimationInstance::step(delta)

ogre2012
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Wed Mar 23, 2011 07:55

Re: About Animation System

Postby ogre2012 » Fri Apr 08, 2011 16:10

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>
 

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: About Animation System

Postby Kulik » Fri Apr 08, 2011 16:37

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.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 2 guests