本文整理汇总了C++中TransformKeyFrame::getScale方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformKeyFrame::getScale方法的具体用法?C++ TransformKeyFrame::getScale怎么用?C++ TransformKeyFrame::getScale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformKeyFrame
的用法示例。
在下文中一共展示了TransformKeyFrame::getScale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hasNonZeroKeyFrames
//---------------------------------------------------------------------
bool NodeAnimationTrack::hasNonZeroKeyFrames(void) const
{
KeyFrameList::const_iterator i = mKeyFrames.begin();
for (; i != mKeyFrames.end(); ++i)
{
// look for keyframes which have any component which is non-zero
// Since exporters can be a little inaccurate sometimes we use a
// tolerance value rather than looking for nothing
TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
Vector3 trans = kf->getTranslate();
Vector3 scale = kf->getScale();
Vector3 axis;
Radian angle;
kf->getRotation().ToAngleAxis(angle, axis);
Real tolerance = 1e-3f;
if (!trans.positionEquals(Vector3::ZERO, tolerance) ||
!scale.positionEquals(Vector3::UNIT_SCALE, tolerance) ||
!Math::RealEqual(angle.valueRadians(), 0.0f, tolerance))
{
return true;
}
}
return false;
}
示例2: optimise
//---------------------------------------------------------------------
void NodeAnimationTrack::optimise(void)
{
// Eliminate duplicate keyframes from 2nd to penultimate keyframe
// NB only eliminate middle keys from sequences of 5+ identical keyframes
// since we need to preserve the boundary keys in place, and we need
// 2 at each end to preserve tangents for spline interpolation
Vector3 lasttrans = Vector3::ZERO;
Vector3 lastscale = Vector3::ZERO;
Quaternion lastorientation;
KeyFrameList::iterator i = mKeyFrames.begin();
Radian quatTolerance(1e-3f);
std::list<unsigned short> removeList;
unsigned short k = 0;
ushort dupKfCount = 0;
for (; i != mKeyFrames.end(); ++i, ++k)
{
TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
Vector3 newtrans = kf->getTranslate();
Vector3 newscale = kf->getScale();
Quaternion neworientation = kf->getRotation();
// Ignore first keyframe; now include the last keyframe as we eliminate
// only k-2 in a group of 5 to ensure we only eliminate middle keys
if (i != mKeyFrames.begin() &&
newtrans.positionEquals(lasttrans) &&
newscale.positionEquals(lastscale) &&
neworientation.equals(lastorientation, quatTolerance))
{
++dupKfCount;
// 4 indicates this is the 5th duplicate keyframe
if (dupKfCount == 4)
{
// remove the 'middle' keyframe
removeList.push_back(k-2);
--dupKfCount;
}
}
else
{
// reset
dupKfCount = 0;
lasttrans = newtrans;
lastscale = newscale;
lastorientation = neworientation;
}
}
// Now remove keyframes, in reverse order to avoid index revocation
std::list<unsigned short>::reverse_iterator r = removeList.rbegin();
for (; r!= removeList.rend(); ++r)
{
removeKeyFrame(*r);
}
}
示例3: _applyBaseKeyFrame
//--------------------------------------------------------------------------
void NodeAnimationTrack::_applyBaseKeyFrame(const KeyFrame* b)
{
const TransformKeyFrame* base = static_cast<const TransformKeyFrame*>(b);
for (KeyFrameList::iterator i = mKeyFrames.begin(); i != mKeyFrames.end(); ++i)
{
TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
kf->setTranslate(kf->getTranslate() - base->getTranslate());
kf->setRotation(base->getRotation().Inverse() * kf->getRotation());
kf->setScale(kf->getScale() * (Vector3::UNIT_SCALE / base->getScale()));
}
}
示例4: oldKf
void OgreSample19App::tweakSneakAnim()
{
SkeletonPtr skel = SkeletonManager::getSingleton().load("jaiqua.skeleton",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Animation * anim = skel->getAnimation("Sneak");
Animation::NodeTrackIterator tracks = anim->getNodeTrackIterator();
while(tracks.hasMoreElements())
{
NodeAnimationTrack * track = tracks.getNext();
TransformKeyFrame oldKf(0,0);
track->getInterpolatedKeyFrame(ANIM_CHOP,&oldKf);
while (track->getKeyFrame(track->getNumKeyFrames()-1)->getTime() >= ANIM_CHOP - 0.3f)
{
track->removeKeyFrame(track->getNumKeyFrames()-1);
}
TransformKeyFrame * newKf = track->createNodeKeyFrame(ANIM_CHOP);
TransformKeyFrame * startKf = track->getNodeKeyFrame(0);
Bone * bone = skel->getBone(track->getHandle());
if (bone->getName() == "Spineroot")
{
mSneakStartPos = startKf->getTranslate() + bone->getInitialPosition();
mSneakEndPos = oldKf.getTranslate() + bone->getInitialPosition();
mSneakStartPos.y = mSneakEndPos.y;
newKf->setTranslate(oldKf.getTranslate());
newKf->setRotation(oldKf.getRotation());
newKf->setScale(oldKf.getScale());
}
else
{
newKf->setTranslate(startKf->getTranslate());
newKf->setRotation(startKf->getRotation());
newKf->setScale(startKf->getScale());
}
}
}
示例5: buildInterpolationSplines
//---------------------------------------------------------------------
void NodeAnimationTrack::buildInterpolationSplines(void) const
{
// Allocate splines if not exists
if (!mSplines)
{
mSplines = OGRE_NEW_T(Splines, MEMCATEGORY_ANIMATION);
}
// Cache to register for optimisation
Splines* splines = mSplines;
// Don't calc automatically, do it on request at the end
splines->positionSpline.setAutoCalculate(false);
splines->rotationSpline.setAutoCalculate(false);
splines->scaleSpline.setAutoCalculate(false);
splines->positionSpline.clear();
splines->rotationSpline.clear();
splines->scaleSpline.clear();
KeyFrameList::const_iterator i, iend;
iend = mKeyFrames.end(); // precall to avoid overhead
for (i = mKeyFrames.begin(); i != iend; ++i)
{
TransformKeyFrame* kf = static_cast<TransformKeyFrame*>(*i);
splines->positionSpline.addPoint(kf->getTranslate());
splines->rotationSpline.addPoint(kf->getRotation());
splines->scaleSpline.addPoint(kf->getScale());
}
splines->positionSpline.recalcTangents();
splines->rotationSpline.recalcTangents();
splines->scaleSpline.recalcTangents();
mSplineBuildNeeded = false;
}
示例6: bake
SkeletonPtr MergeSkeleton::bake()
{
MeshCombiner::getSingleton().log(
"Baking: New Skeleton started" );
SkeletonPtr sp = SkeletonManager::getSingleton().create( "mergeSkeleton",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true );
for( std::vector< Ogre::SkeletonPtr >::iterator it = m_Skeletons.begin();
it != m_Skeletons.end(); ++it )
{
if( it == m_Skeletons.begin() )
{
MeshCombiner::getSingleton().log(
"Baking: using " + (*it)->getName() + " as the base skeleton" );
MeshCombiner::getSingleton().log(
"Baking: adding bones" );
Skeleton::BoneIterator bit = (*it)->getBoneIterator();
while( bit.hasMoreElements() )
{
Bone* bone = bit.getNext();
Bone* newbone = sp->createBone( bone->getName(), bone->getHandle() );
newbone->setScale( bone->getScale() );
newbone->setOrientation( bone->getOrientation() );
newbone->setPosition( bone->getPosition() );
}
MeshCombiner::getSingleton().log(
"Baking: building bone hierarchy" );
// bone hierarchy
bit = (*it)->getBoneIterator();
while( bit.hasMoreElements() )
{
Bone* bone = bit.getNext();
Node* pnode = bone->getParent();
if( pnode != NULL )
{
Bone* pbone = static_cast<Bone*>( pnode );
sp->getBone( pbone->getHandle() )->addChild( sp->getBone( bone->getHandle() ) );
}
}
}
MeshCombiner::getSingleton().log(
"Baking: adding animations for " + (*it)->getName() );
// insert all animations
for (unsigned short a=0; a < (*it)->getNumAnimations(); ++a )
{
Animation* anim = (*it)->getAnimation( a );
Animation* newanim = sp->createAnimation( anim->getName(), anim->getLength() );
if( anim->getNumNodeTracks() > 0 )
MeshCombiner::getSingleton().log(
"Baking: adding node tracks" );
for( unsigned short na=0; na < anim->getNumNodeTracks(); ++na )
{
if( anim->hasNodeTrack( na ) )
{
NodeAnimationTrack* nat = anim->getNodeTrack( na );
NodeAnimationTrack* newnat = newanim->createNodeTrack( na );
// all key frames
for( unsigned short nf=0; nf < nat->getNumKeyFrames(); ++nf )
{
TransformKeyFrame* tkf = nat->getNodeKeyFrame( nf );
TransformKeyFrame* newtkf = newnat->createNodeKeyFrame( tkf->getTime() );
newtkf->setRotation( tkf->getRotation() );
newtkf->setTranslate( tkf->getTranslate() );
newtkf->setScale( tkf->getScale() );
}
newnat->setAssociatedNode( sp->getBone( nat->getHandle() ) );
}
}
if( anim->getNumNumericTracks() > 0 )
MeshCombiner::getSingleton().log(
"Baking: adding numeric tracks" );
for( unsigned short na=0; na < anim->getNumNumericTracks(); ++na )
{
if( anim->hasNumericTrack( na ) )
{
NumericAnimationTrack* nat = anim->getNumericTrack( na );
NumericAnimationTrack* newnat = newanim->createNumericTrack( na );
// all key frames
for( unsigned short nf=0; nf < nat->getNumKeyFrames(); ++nf )
{
NumericKeyFrame* nkf = nat->getNumericKeyFrame( nf );
NumericKeyFrame* newnkf = newnat->createNumericKeyFrame( nkf->getTime() );
newnkf->setValue( nkf->getValue() );
}
}
}
if( anim->getNumVertexTracks() > 0 )
MeshCombiner::getSingleton().log(
"Baking: adding vertex tracks" );
for( unsigned short va=0; va < anim->getNumVertexTracks(); ++va )
{
//.........这里部分代码省略.........
示例7: ExportSkeleton
void ModelConverter::ExportSkeleton( const Ogre::Skeleton* pSkeleton, const Ogre::String& filename )
{
LogManager::getSingleton().logMessage("Populating DOM...");
// Write main skeleton data
LogManager::getSingleton().logMessage("Exporting bones..");
DiMotionPtr mt = Demi::DiAssetManager::GetInstancePtr(
)->CreateOrReplaceAsset<DiMotion>(pSkeleton->getName().c_str());
DiSkeleton* skeleton = mt->CreateSkeleton();
// save bones
WriteSkeleton(pSkeleton,skeleton);
LogManager::getSingleton().logMessage("Bones exported.");
unsigned short numAnims = pSkeleton->getNumAnimations();
String msg = "Exporting animations, count=" + StringConverter::toString(numAnims);
LogManager::getSingleton().logMessage(msg);
// save animations
for (unsigned short i = 0; i < numAnims; ++i)
{
Animation* pAnim = pSkeleton->getAnimation(i);
msg = "Exporting animation: " + pAnim->getName();
LogManager::getSingleton().logMessage(msg);
Demi::DiAnimation* anim = mt->CreateAnimation(
pAnim->getName().c_str(), pAnim->getLength());
// save tracks
Animation::NodeTrackIterator trackIt = pAnim->getNodeTrackIterator();
size_t count = 0;
while (trackIt.hasMoreElements())
{
NodeAnimationTrack* track = trackIt.getNext();
Bone* bone = (Bone*)track->getAssociatedNode();
Demi::DiNodeClip* clip = anim->CreateNodeClip(count++,skeleton->GetBone(bone->getHandle()));
// save key frames
for (unsigned short i = 0; i < track->getNumKeyFrames(); ++i)
{
TransformKeyFrame* kf = track->getNodeKeyFrame(i);
Demi::DiTransformKeyFrame* pKeyframe = clip->CreateNodeKeyFrame(kf->getTime());
pKeyframe->SetTranslate(Demi::DiVec3(kf->getTranslate().x,
kf->getTranslate().y,kf->getTranslate().z));
pKeyframe->SetRotation(Demi::DiQuat(kf->getRotation().w,
kf->getRotation().x,kf->getRotation().y,kf->getRotation().z));
pKeyframe->SetScale(Demi::DiVec3(kf->getScale().x,
kf->getScale().y,kf->getScale().z));
}
}
LogManager::getSingleton().logMessage("Animation exported.");
}
if (mt)
{
// save to file
DiMotionSerializer ms;
ms.ExportMotion(mt,filename);
}
}