void BlenderSceneExporter::storeAnimations( TamyAnimation* arrAnimations, int animationsCount ) { ResourcesManager& resMgr = TSingleton< ResourcesManager >::getInstance(); for ( int i = 0; i < animationsCount; ++i ) { TamyAnimation& exportedAnimation = arrAnimations[i]; Skeleton* skeleton = NULL; if ( exportedAnimation.skeletonIdx >= 0 ) { skeleton = m_exportedSkeletons[exportedAnimation.skeletonIdx]; } // create pose tracks array Transform* poseTransforms = new Transform[ exportedAnimation.framesCount * exportedAnimation.poseTracksCount ]; for ( int trackIdx = 0; trackIdx < exportedAnimation.poseTracksCount; ++trackIdx ) { TamyAnimationTrack& exportedTrack = exportedAnimation.poseTracks[trackIdx]; // find the bone this track corresponds to uint boneTrackIdx = 0; if ( skeleton ) { boneTrackIdx = skeleton->getBoneIndex( exportedTrack.boneName ); } for ( int frameIdx = 0; frameIdx < exportedAnimation.framesCount; ++frameIdx ) { uint transformIdx = frameIdx * exportedAnimation.poseTracksCount + boneTrackIdx; exportedTrack.frameKeys[frameIdx].applyTo( poseTransforms[transformIdx] ); } } // create the motion track transforms array Transform* motionTransforms = new Transform[ exportedAnimation.framesCount ]; for ( int frameIdx = 0; frameIdx < exportedAnimation.framesCount; ++frameIdx ) { exportedAnimation.motionTrack.frameKeys[frameIdx].applyTo( motionTransforms[frameIdx] ); } FilePath animationPath( m_animationsExportDir + exportedAnimation.name + "." + SnapshotAnimation::getExtension() ); SnapshotAnimation* animation = resMgr.create< SnapshotAnimation >( animationPath ); SnapshotAnimation::build( *animation, exportedAnimation.playbackSpeed, exportedAnimation.framesCount, exportedAnimation.poseTracksCount, poseTransforms, motionTransforms ); delete [] poseTransforms; delete [] motionTransforms; // save the animation if ( m_exportSettings.saveAnimations ) { animation->saveResource(); } } }
void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned, SVGSMILElement*) { SVGElement* targetElement = this->targetElement(); if (!targetElement) return; AffineTransform* transform = targetElement->supplementalTransform(); if (!transform) return; if (RenderObject* targetRenderer = targetElement->renderer()) targetRenderer->setNeedsTransformUpdate(); if (!isAdditive()) transform->makeIdentity(); // FIXME: Implement accumulate. if (animationMode() == PathAnimation) { ASSERT(!animationPath().isEmpty()); Path path = animationPath(); float positionOnPath = path.length() * percentage; bool ok; FloatPoint position = path.pointAtLength(positionOnPath, ok); if (ok) { transform->translate(position.x(), position.y()); RotateMode rotateMode = this->rotateMode(); if (rotateMode == RotateAuto || rotateMode == RotateAutoReverse) { float angle = path.normalAngleAtLength(positionOnPath, ok); if (rotateMode == RotateAutoReverse) angle += 180; transform->rotate(angle); } } return; } FloatSize diff = m_toPoint - m_fromPoint; transform->translate(diff.width() * percentage + m_fromPoint.x(), diff.height() * percentage + m_fromPoint.y()); }
SVGAnimationElement::AnimationMode SVGAnimationElement::animationMode() const { // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues if (hasTagName(SVGNames::setTag)) { return ToAnimation; } if (!animationPath().isEmpty()) { return PathAnimation; } if (hasAttribute(SVGNames::valuesAttr)) { return ValuesAnimation; } if (!toValue().isEmpty()) { return fromValue().isEmpty() ? ToAnimation : FromToAnimation; } if (!byValue().isEmpty()) { return fromValue().isEmpty() ? ByAnimation : FromByAnimation; } return NoAnimation; }
void GameResources::load(Console &console, Sound &sound, TextureManager &textureManager) { console.printLine("\n===Initializing game resources==="); console.printLine("\n...Weapon initialization"); Weapon::initialize(sound, textureManager); console.printLine("...Building water-list"); Water::initialize(sound, textureManager); console.printLine("...Loading game sounds"); roundStartSound = sound.loadSample("sound/game/round-start.wav"); gameOverSound = sound.loadSample("sound/game/game-over.wav"); console.printLine(Format("...Loading block meta data: {0}") << D6_FILE_BLOCK_META); blockMeta = Block::loadMeta(D6_FILE_BLOCK_META); console.printLine(Format("...Loading block textures: {0}") << D6_TEXTURE_BLOCK_PATH); blockTextures = textureManager.loadStack(D6_TEXTURE_BLOCK_PATH, TextureFilter::Linear, true); console.printLine(Format("...Loading explosion textures: {0}") << D6_TEXTURE_EXPL_PATH); explosionTextures = textureManager.loadStack(D6_TEXTURE_EXPL_PATH, TextureFilter::Nearest, true); console.printLine(Format("...Loading bonus textures: {0}") << D6_TEXTURE_EXPL_PATH); bonusTextures = textureManager.loadStack(D6_TEXTURE_BONUS_PATH, TextureFilter::Linear, true); console.printLine(Format("...Loading elevator textures: {0}") << D6_TEXTURE_ELEVATOR_PATH); elevatorTextures = textureManager.loadStack(D6_TEXTURE_ELEVATOR_PATH, TextureFilter::Linear, true); console.printLine(Format("...Loading background textures: {0}") << D6_TEXTURE_BCG_PATH); bcgTextures = textureManager.loadDict(D6_TEXTURE_BCG_PATH, TextureFilter::Linear, true); std::string animationPath(D6_TEXTURE_MAN_PATH); animationPath += "man.ase"; playerAnimation = textureManager.loadAnimation(animationPath); console.printLine(Format("...Loading fire textures: {0}") << D6_TEXTURE_FIRE_PATH); for (const FireType &fireType : FireType::values()) { Texture texture = textureManager.loadStack(Format("{0}{1,3|0}/") << D6_TEXTURE_FIRE_PATH << fireType.getId(), TextureFilter::Nearest, true); fireTextures[fireType.getId()] = texture; } Texture burn = textureManager.loadStack("textures/fire/burn/", TextureFilter::Linear, true); burningTexture = burn; console.printLine("\n...Bonus initialization"); BonusType::initialize(); }