コード例 #1
0
AnimationUnrecPtr createColorAnimation(FieldContainerUnrecPtr AnimatedObject, std::string AnimatedField)
{
    //Color Keyframe Sequence
    KeyframeVectorSequenceUnrecPtr ColorKeyframes = KeyframeVectorSequenceVec4f::create();
    ColorKeyframes->addKeyframe(Vec4f(1.0f,0.0f,0.0f,1.0f),0.0f);
    ColorKeyframes->addKeyframe(Vec4f(0.0f,1.0f,0.0f,1.0f),2.0f);
    ColorKeyframes->addKeyframe(Vec4f(0.0f,0.0f,1.0f,1.0f),4.0f);
    ColorKeyframes->addKeyframe(Vec4f(1.0f,0.0f,0.0f,1.0f),6.0f);

    //Animator
    AnimatorUnrecPtr Animator = KeyframeAnimator::create();
    dynamic_pointer_cast<KeyframeAnimator>(Animator)->setKeyframeSequence(ColorKeyframes);
    
    //Animation
    FieldAnimationUnrecPtr ColorAnimation = FieldAnimation::create();
    dynamic_pointer_cast<FieldAnimation>(ColorAnimation)->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    dynamic_pointer_cast<FieldAnimation>(ColorAnimation)->setCycling(-1);
	ColorAnimation->setAnimatedField(AnimatedObject, AnimatedField);

	return ColorAnimation;
}
コード例 #2
0
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();
}