本文整理汇总了C++中Transformable::SetTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformable::SetTransform方法的具体用法?C++ Transformable::SetTransform怎么用?C++ Transformable::SetTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformable
的用法示例。
在下文中一共展示了Transformable::SetTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMessage
/**
* Message handler callback.
*
* @param data the message data
*/
void CadworkFlyMotionModel::OnMessage(MessageData* data)
{
Transformable *target = GetTarget();
if (target != NULL && IsEnabled() &&
(data->message == dtCore::System::MESSAGE_POST_EVENT_TRAVERSAL/*MESSAGE_PRE_FRAME*/) &&
// don't move if paused & using simtime for speed (since simtime will be 0 if paused)
(!HasOption(OPTION_USE_SIMTIME_FOR_SPEED) || !System::GetInstance().GetPause()))
{
if(IsMouseGrabbed())
{
// Get the time change (sim time or real time)
double delta = GetTimeDelta(data);
Transform transform;
GetTarget()->GetTransform(transform);
osg::Vec3 xyz, hpr;
transform.Get(xyz, hpr);
// rotation
bool rotationChanged = false;
if(!HasOption(OPTION_REQUIRE_MOUSE_DOWN))
{
hpr = Rotate(hpr, delta, rotationChanged);
if (rotationChanged)
{
transform.SetRotation(hpr);
}
}
// translation
bool translationChanged = false;
xyz = Translate(xyz, delta, translationChanged);
if (translationChanged)
{
transform.SetTranslation(xyz);
}
// homing
if(mHomingButton->GetState())
{
GoToHomePosition();
}
// finalize changes
if (rotationChanged || translationChanged)
{
GetTarget()->SetTransform(transform);
}
}
// release cursor
//if(mCursorReleaseButton->GetState())
//{
// ReleaseMouse();
//}
////grab cursor
//if(mCursorGrabButton->GetState())
//{
// GrabMouse();
//}
/**
* Now some serious work. Below begins the 'animation' of the smooth camera
* movement while zooming (by mouse wheel). First part is rotation when refocusing
* and the second part is changing distance. Default animation duration is 0.4s.
*/
if(mAnimData.isAnimating())
{
double f = (System::GetInstance().GetSimulationTime() - mAnimData._startTime) / mAnimData._motion->getDuration();
f = f<0 ? 0 : f > 1 ? 1 : f; //clamp f into a <0,1> range
float t;
mAnimData._motion->getValueInNormalizedRange(f,t); //gets normalized <0,1> linear value f and turns it into non-lineary interpolated value t also normalized (the function is defined in MathMotionTemplate constructor in AnimationData definition)
/** handle amooth zooming */
if(mAnimData._isZooming)
{
float newdist;
newdist = t * (mAnimData._toDist - mAnimData._fromDist) + mAnimData._fromDist;
Transform trans;
target->GetTransform(trans);
if(mAnimData._isRotating) //rotating while zooming
{
osg::Vec3 xyz,hpr,oldhpr;
trans.Get(xyz,oldhpr);
trans.Set(xyz,mAnimData._toRotation);
trans.Get(xyz,hpr);
//.........这里部分代码省略.........