Ejemplo n.º 1
0
AnimationGroupUnrecPtr setupAnimation(SimpleMaterial* const TheTorusMaterial,
                                      Transform* const TorusNodeTrans)
{
    //Color Keyframe Sequence
    KeyframeColorSequenceColor3fUnrecPtr ColorKeyframes = KeyframeColorSequenceColor3f::create();
    ColorKeyframes->addKeyframe(Color4f(1.0f,0.0f,0.0f,1.0f),0.0f);
    ColorKeyframes->addKeyframe(Color4f(0.0f,1.0f,0.0f,1.0f),2.0f);
    ColorKeyframes->addKeyframe(Color4f(0.0f,0.0f,1.0f,1.0f),4.0f);
    ColorKeyframes->addKeyframe(Color4f(1.0f,0.0f,0.0f,1.0f),6.0f);

    //Color Animator
    KeyframeAnimatorUnrecPtr TheColorAnimator = KeyframeAnimator::create();
    TheColorAnimator->setKeyframeSequence(ColorKeyframes);

    //Color Animation
    FieldAnimationUnrecPtr TheColorAnimation = FieldAnimation::create();
    TheColorAnimation->setAnimator(TheColorAnimator);
    TheColorAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    TheColorAnimation->setCycling(2);
    TheColorAnimation->setAnimatedField(TheTorusMaterial, std::string("diffuse"));

    //Transformation Keyframe Sequence
    KeyframeTransformationSequenceMatrix4fUnrecPtr TransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();
    Matrix TempMat;
    TempMat.setTransform(Vec3f(0.0f,0.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.0f));
    TransformationKeyframes->addKeyframe(TempMat,0.0f);
    TempMat.setTransform(Vec3f(0.0f,1.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.5f));
    TransformationKeyframes->addKeyframe(TempMat,1.0f);
    TempMat.setTransform(Vec3f(1.0f,1.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.0f));
    TransformationKeyframes->addKeyframe(TempMat,2.0f);
    TempMat.setTransform(Vec3f(1.0f,0.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.5f));
    TransformationKeyframes->addKeyframe(TempMat,3.0f);
    TempMat.setTransform(Vec3f(0.0f,0.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*2.0f));
    TransformationKeyframes->addKeyframe(TempMat,4.0f);

    //Transformation Animator
    KeyframeAnimatorUnrecPtr TheTransformationAnimator = KeyframeAnimator::create();
    TheTransformationAnimator->setKeyframeSequence(TransformationKeyframes);

    //Transformation Animation
    FieldAnimationUnrecPtr TheTransformationAnimation = FieldAnimation::create();
    TheTransformationAnimation->setAnimator(TheTransformationAnimator);
    TheTransformationAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    TheTransformationAnimation->setCycling(2);
    TheTransformationAnimation->setAnimatedField(TorusNodeTrans, std::string("matrix"));

    AnimationGroupUnrecPtr TheAnimationGroup = AnimationGroup::create();
    TheAnimationGroup->pushToAnimations(TheColorAnimation);
    TheAnimationGroup->pushToAnimations(TheTransformationAnimation);

    return AnimationGroupTransitPtr(TheAnimationGroup);
}
void setupAnimation(void)
{
    //Color Keyframe Sequence
    ColorKeyframes = KeyframeColorSequenceColor3f::create();
    ColorKeyframes->addKeyframe(Color4f(1.0f,0.0f,0.0f,1.0f),0.0f);
    ColorKeyframes->addKeyframe(Color4f(0.0f,1.0f,0.0f,1.0f),2.0f);
    ColorKeyframes->addKeyframe(Color4f(0.0f,0.0f,1.0f,1.0f),4.0f);
    ColorKeyframes->addKeyframe(Color4f(1.0f,0.0f,0.0f,1.0f),6.0f);
    
    //Color Animator
    KeyframeAnimatorUnrecPtr TheColorAnimator = KeyframeAnimator::create();
    TheColorAnimator->setKeyframeSequence(ColorKeyframes);
    
    //Color Animation
    FieldAnimationUnrecPtr TheColorAnimation = FieldAnimation::create();
    TheColorAnimation->setAnimator(TheColorAnimator);
    TheColorAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    TheColorAnimation->setCycling(2);
    TheColorAnimation->setAnimatedField(TheTorusMaterial, std::string("diffuse"));

	//Vector Keyframe Sequence
    VectorKeyframes = KeyframeVectorSequenceVec3f::create();
    VectorKeyframes->addKeyframe(Vec3f(0.0f,0.0f,0.0f),0.0f);
    VectorKeyframes->addKeyframe(Vec3f(0.0f,1.0f,0.0f),1.0f);
    VectorKeyframes->addKeyframe(Vec3f(1.0f,1.0f,0.0f),2.0f);
    VectorKeyframes->addKeyframe(Vec3f(1.0f,0.0f,0.0f),3.0f);
    VectorKeyframes->addKeyframe(Vec3f(0.0f,0.0f,0.0f),4.0f);
    
    
    //Vector Animator
    KeyframeAnimatorUnrecPtr TheVectorAnimator = KeyframeAnimator::create();
    TheVectorAnimator->setKeyframeSequence(VectorKeyframes);
    
    //Vector Animation
    FieldAnimationUnrecPtr TheVectorAnimation = FieldAnimation::create();
    TheVectorAnimation->setAnimator(TheVectorAnimator);
    TheVectorAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    TheVectorAnimation->setCycling(2);
	//TheVectorAnimation->setAnimatedField(getFieldContainer("Transform",std::string("TorusNodeVectorCore")), std::string("matrix"));
    
	//Transformation Keyframe Sequence
    TransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();
	Matrix TempMat;
	TempMat.setTransform(Vec3f(0.0f,0.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.0f));
    TransformationKeyframes->addKeyframe(TempMat,0.0f);
	TempMat.setTransform(Vec3f(0.0f,1.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.5f));
    TransformationKeyframes->addKeyframe(TempMat,1.0f);
	TempMat.setTransform(Vec3f(1.0f,1.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.0f));
    TransformationKeyframes->addKeyframe(TempMat,2.0f);
	TempMat.setTransform(Vec3f(1.0f,0.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.5f));
    TransformationKeyframes->addKeyframe(TempMat,3.0f);
	TempMat.setTransform(Vec3f(0.0f,0.0f,0.0f), Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*2.0f));
    TransformationKeyframes->addKeyframe(TempMat,4.0f);
    
    //Transformation Animator
    KeyframeAnimatorUnrecPtr TheTransformationAnimator = KeyframeAnimator::create();
    TheTransformationAnimator->setKeyframeSequence(TransformationKeyframes);
    
    //Transformation Animation
    FieldAnimationUnrecPtr TheTransformationAnimation = FieldAnimation::create();
    TheTransformationAnimation->setAnimator(TheTransformationAnimator);
    TheTransformationAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    TheTransformationAnimation->setCycling(2);
	TheTransformationAnimation->setAnimatedField(TorusNodeTrans, std::string("matrix"));

    TheAnimationGroup = AnimationGroup::create();
    TheAnimationGroup->pushToAnimations(TheColorAnimation);
    TheAnimationGroup->pushToAnimations(TheTransformationAnimation);

    TheAnimationGroup->attachUpdateProducer(TutorialWindow->editEventProducer());
    TheAnimationGroup->start();
}
Ejemplo n.º 3
0
AnimationTransitPtr setupAnimation(Transform* const TheJoint, Transform* const TheChildJoint)
{
    //Create an animation for TheJoint
    //TheJoint Transformation keyframes (we'll animate TheJoint's translation)
    Matrix transform = TheJoint->getMatrix();

    KeyframeTransformationSequenceUnrecPtr TheJointTranformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();

    transform.setTranslate(0.0f,0.0f,0.0f);
    TheJointTranformationKeyframes->addKeyframe(transform, 0.0f);

    transform.setTranslate(2.0f,0.0f,0.0f);
    TheJointTranformationKeyframes->addKeyframe(transform, 2.0f);

    transform.setTranslate(1.0f,0.0f,0.0f);
    TheJointTranformationKeyframes->addKeyframe(transform, 4.0f);

    transform.setTranslate(3.0f,0.0f,0.0f);
    TheJointTranformationKeyframes->addKeyframe(transform, 6.0f);

    transform = TheJoint->getMatrix();
    transform.setTranslate(0.0f,0.0f,0.0f);
    TheJointTranformationKeyframes->addKeyframe(transform, 8.0f);

    //TheJoint Animator
    AnimatorUnrecPtr TheJointAnimator = KeyframeAnimator::create();
    dynamic_pointer_cast<KeyframeAnimator>(TheJointAnimator)->setKeyframeSequence(TheJointTranformationKeyframes);

    //TheJoint Animation
    FieldAnimationUnrecPtr TheJointAnimation = FieldAnimation::create();
    TheJointAnimation->setAnimator(TheJointAnimator);
    TheJointAnimation->setInterpolationType(Animator::CUBIC_INTERPOLATION);
    TheJointAnimation->setCycling(-1);
    TheJointAnimation->setAnimatedField(TheJoint,
                                        std::string("matrix"));

    //Create an animation for TheChildJoint
    //TheChildJoint Transformation keyframes (we'll animate TheChildJoint's rotation)
    transform = TheChildJoint->getMatrix();

    KeyframeTransformationSequenceUnrecPtr TheChildJointTransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();

    TheChildJointTransformationKeyframes->addKeyframe(transform, 0.0f);

    transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),0.0));
    TheChildJointTransformationKeyframes->addKeyframe(transform, 2.0f);

    transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),0.5*Pi));
    TheChildJointTransformationKeyframes->addKeyframe(transform, 4.0f);

    transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),Pi));
    TheChildJointTransformationKeyframes->addKeyframe(transform, 6.0f);

    transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),1.5*Pi));
    TheChildJointTransformationKeyframes->addKeyframe(transform, 8.0f);

    transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),2.0*Pi));
    TheChildJointTransformationKeyframes->addKeyframe(transform, 10.0f);

    //TheChildJoint Animator
    AnimatorUnrecPtr TheChildJointAnimator = KeyframeAnimator::create();
    dynamic_pointer_cast<KeyframeAnimator>(TheChildJointAnimator)->setKeyframeSequence(TheChildJointTransformationKeyframes);

    //TheChildJoint Animation
    FieldAnimationUnrecPtr TheChildJointAnimation = FieldAnimation::create();
    TheChildJointAnimation->setAnimator(TheChildJointAnimator);
    TheChildJointAnimation->setInterpolationType(Animator::CUBIC_INTERPOLATION);
    TheChildJointAnimation->setCycling(-1);
    TheChildJointAnimation->setAnimatedField(TheChildJoint, std::string("matrix"));

    AnimationGroupUnrecPtr TheAnimationGroup = AnimationGroup::create();
    TheAnimationGroup->pushToAnimations(TheJointAnimation);
    TheAnimationGroup->pushToAnimations(TheChildJointAnimation);

    return AnimationTransitPtr(TheAnimationGroup);
}