本文整理汇总了C++中osg::Quat::slerp方法的典型用法代码示例。如果您正苦于以下问题:C++ Quat::slerp方法的具体用法?C++ Quat::slerp怎么用?C++ Quat::slerp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Quat
的用法示例。
在下文中一共展示了Quat::slerp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InterpretCameraForUse
int InterpretCameraForUse(NVAnimObject *Cam, double Moment, osg::Vec3 &EyePoint, osg::Quat &Orientation, float &HFOV)
{
int NumValid;
float HFOV_S, HFOV_N, HFOV_E;
NumValid = Cam->GetBracketingKeyFrames(Moment, PrevKey, NextKey, false); // don't use caching yet, we're not set up for it
if(NumValid)
{
if(NumValid == 2)
{ // interpolate
double KeyTimeDif, MomentTimeDif;
//determine interpolation fraction
KeyTimeDif = NextKey->GetTimeValue() - PrevKey->GetTimeValue();
MomentTimeDif = Moment - PrevKey->GetTimeValue();
if(KeyTimeDif > 0.0 && MomentTimeDif >= 0.0) // do rationality checking before a risky divide
{
double MomentFrac;
osg::Vec3 EyePoint_S, EyePoint_E;
osg::Quat Orientation_S, Orientation_E;
MomentFrac = MomentTimeDif / KeyTimeDif; // divide by zero prevented by rationality checking above
MiscReadout = MomentFrac;
if(MomentFrac > 1.0)
{
Cam->GetBracketingKeyFrames(Moment, PrevKey, NextKey, false); // trace only
} // if
// HFOV
HFOV_S = PrevKey->ChannelValues[NVAnimObject::CANONHANGLE];
HFOV_E = NextKey->ChannelValues[NVAnimObject::CANONHANGLE];
HFOV_N = flerp(MomentFrac, HFOV_S, HFOV_E);
HFOV = HFOV_N;
// create start and end eye/orient pairs
InterpretCameraConfiguration(PrevKey, EyePoint_S, Orientation_S);
InterpretCameraConfiguration(NextKey, EyePoint_E, Orientation_E);
// Eye position
EyePoint = EyePoint_S + ((EyePoint_E - EyePoint_S) * MomentFrac);
// Orientation quat via slerp
Orientation.slerp(MomentFrac, Orientation_S, Orientation_E);
return(1);
} // if
else
{ // drop back ten and punt by going with NumValid == 1 code below
NumValid = 1;
} // else
} // if
if(NumValid == 1) // not an else-if, this is a fail-safe case if the above NumValid=2 fails somehow
{ // only have one, only use PrevKey, NextKey is identical and tweening would be a waste of time
InterpretCameraConfiguration(PrevKey, EyePoint, Orientation);
HFOV = PrevKey->ChannelValues[NVAnimObject::CANONHANGLE];
} // else
} // if
return(0);
} // InterpretCameraForUse