// Constructor for moving object, it not create entity (mesh, skeleton) but build animation on pre-exist entity CAnimatedSceneObject::CAnimatedSceneObject( const CEntityId& Id, const list < std::string >& Animations ) { _Id = Id; _ObjectName = ""; _ClusterIG = ""; _MeshName = ""; _SkeletonName = ""; _Distance = 0; _Skeleton = NULL; _Instance = NULL; CEntityCL *entity = getEntity(Id); if(entity) { _Skeleton = *entity->skeleton(); _Transform = _Skeleton; _Position = _Skeleton->getPos(); _Rotation = _Skeleton->getRotQuat(); // create play list manager and animation set _PlayListManager = Scene->createPlayListManager(); _AnimationSet = Driver->createAnimationSet(); //fill animation set for( list< string >::const_iterator its = Animations.begin(); its != Animations.end(); ++its ) { uint idAnim; try { idAnim = _AnimationSet->addAnimation( ( *its + string(".anim") ).c_str(), (*its).c_str() ); } catch(Exception &) { idAnim = UAnimationSet::NotFound; if( idAnim == UAnimationSet::NotFound) { nlwarning( "CAnimatedSceneObject::CAnimatedSceneObject Animation %s not found for entity CEntityId(%u,%f)", (*its).c_str(), Id.Type, (double)(sint64)Id.Id ); continue; } } _MapAnimation.insert( make_pair( *its, idAnim ) ); } // build animation set _AnimationSet->build(); // create playlist _PlayList = _PlayListManager->createPlayList( _AnimationSet ); _Status = SAnimationStatus(); _Status.SequenceAnim = 1; _Status.ApplyDisplacement = 1; // register skeleton in playlist _PlayList->registerTransform( *entity->skeleton() ); // Snap to ground(the snap check if it's a flyer). entity->pacsPos(_Position); entity->snapToGround(); _Position = entity->pos(); CMatrix current; current.identity (); current.setRot (_Rotation); // Rotation 90 degrees CMatrix rot90; rot90.identity (); rot90.rotateZ (-(float)Pi/2); current *= rot90; _Transform->unfreezeHRC(); _Transform->setPos(_Position); _Transform->setRotQuat(current.getRot()); _Transform->freezeHRC(); _IdAnimationPlayed = -1; if( _Id.Type == RYZOMID::npc ) { sendEndSequenceMessage( _Id, 1 ); } } else { _PlayList = NULL; _AnimationSet = NULL; _PlayListManager = NULL; } }