当前位置: 首页>>代码示例>>C++>>正文


C++ Quat::slerp方法代码示例

本文整理汇总了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
开发者ID:AlphaPixel,项目名称:3DNature,代码行数:62,代码来源:CameraSupport.cpp


注:本文中的osg::Quat::slerp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。