Revision 2426396a src/spin/GroupNode.cpp
| b/src/spin/GroupNode.cpp | ||
|---|---|---|
| 304 | 304 |
|
| 305 | 305 |
float dt = osg::Timer::instance()->delta_s(lastTick_,tick); |
| 306 | 306 |
|
| 307 |
|
|
| 308 |
if (motion_.valid()) |
|
| 309 |
{
|
|
| 310 |
motion_->update(dt); |
|
| 311 |
float motionIndex = motion_->getValue(); |
|
| 312 |
osg::Vec3 newPos = motionStart_ + ((motionEnd_-motionStart_) * motionIndex); |
|
| 313 |
this->setTranslation( newPos.x(), newPos.y(), newPos.z() ); |
|
| 314 |
|
|
| 315 |
if (motion_->getTime() >= motion_->getDuration()) |
|
| 316 |
{
|
|
| 317 |
BROADCAST(this, "sss", "event", "translateTo", "done"); |
|
| 318 |
motion_ = NULL; |
|
| 319 |
} |
|
| 320 |
} |
|
| 321 |
|
|
| 322 |
|
|
| 307 | 323 |
if (velocity_.length() > EPSILON) |
| 308 | 324 |
{
|
| 309 | 325 |
if (this->velocityMode_==GroupNode::TRANSLATE) |
| ... | ... | |
| 962 | 978 |
|
| 963 | 979 |
// ***************************************************************************** |
| 964 | 980 |
|
| 981 |
|
|
| 982 |
|
|
| 983 |
void GroupNode::translateTo (float x, float y, float z, float duration, const char *motion) |
|
| 984 |
{
|
|
| 985 |
|
|
| 986 |
if (motion_.valid()) |
|
| 987 |
{
|
|
| 988 |
motion_ = NULL; |
|
| 989 |
} |
|
| 990 |
|
|
| 991 |
motionStart_ = getTranslation(); |
|
| 992 |
motionEnd_ = osg::Vec3(x,y,z); |
|
| 993 |
|
|
| 994 |
std::string motionType = std::string(motion); |
|
| 995 |
|
|
| 996 |
osgAnimation::Motion::TimeBehaviour tb = osgAnimation::Motion::CLAMP; |
|
| 997 |
float init = 0.0f; |
|
| 998 |
float d = 1.0f; |
|
| 999 |
|
|
| 1000 |
if (!motionType.compare("OutQuadMotion"))
|
|
| 1001 |
motion_ = new osgAnimation::OutQuadMotion(init, duration, d, tb); |
|
| 1002 |
else if (!motionType.compare("InQuadMotion"))
|
|
| 1003 |
motion_ = new osgAnimation::InQuadMotion(init, duration, d, tb); |
|
| 1004 |
else if (!motionType.compare("InOutQuadMotion"))
|
|
| 1005 |
motion_ = new osgAnimation::InOutQuadMotion(init, duration, d, tb); |
|
| 1006 |
else if (!motionType.compare("OutCubicMotion"))
|
|
| 1007 |
motion_ = new osgAnimation::OutCubicMotion(init, duration, d, tb); |
|
| 1008 |
else if (!motionType.compare("InCubicMotion"))
|
|
| 1009 |
motion_ = new osgAnimation::InCubicMotion(init, duration, d, tb); |
|
| 1010 |
else if (!motionType.compare("InOutCubicMotion"))
|
|
| 1011 |
motion_ = new osgAnimation::InOutCubicMotion(init, duration, d, tb); |
|
| 1012 |
else if (!motionType.compare("OutQuartMotion"))
|
|
| 1013 |
motion_ = new osgAnimation::OutQuartMotion(init, duration, d, tb); |
|
| 1014 |
else if (!motionType.compare("InQuartMotion"))
|
|
| 1015 |
motion_ = new osgAnimation::InQuartMotion(init, duration, d, tb); |
|
| 1016 |
else if (!motionType.compare("InOutQuartMotion"))
|
|
| 1017 |
motion_ = new osgAnimation::InOutQuartMotion(init, duration, d, tb); |
|
| 1018 |
else if (!motionType.compare("OutBounceMotion"))
|
|
| 1019 |
motion_ = new osgAnimation::OutBounceMotion(init, duration, d, tb); |
|
| 1020 |
else if (!motionType.compare("InBounceMotion"))
|
|
| 1021 |
motion_ = new osgAnimation::InBounceMotion(init, duration, d, tb); |
|
| 1022 |
else if (!motionType.compare("InOutBounceMotion"))
|
|
| 1023 |
motion_ = new osgAnimation::InOutBounceMotion(init, duration, d, tb); |
|
| 1024 |
else if (!motionType.compare("OutElasticMotion"))
|
|
| 1025 |
motion_ = new osgAnimation::OutElasticMotion(init, duration, d, tb); |
|
| 1026 |
else if (!motionType.compare("InElasticMotion"))
|
|
| 1027 |
motion_ = new osgAnimation::InElasticMotion(init, duration, d, tb); |
|
| 1028 |
else if (!motionType.compare("InOutElasticMotion"))
|
|
| 1029 |
motion_ = new osgAnimation::InOutElasticMotion(init, duration, d, tb); |
|
| 1030 |
else if (!motionType.compare("OutSineMotion"))
|
|
| 1031 |
motion_ = new osgAnimation::OutSineMotion(init, duration, d, tb); |
|
| 1032 |
else if (!motionType.compare("InSineMotion"))
|
|
| 1033 |
motion_ = new osgAnimation::InSineMotion(init, duration, d, tb); |
|
| 1034 |
else if (!motionType.compare("InOutSineMotion"))
|
|
| 1035 |
motion_ = new osgAnimation::InOutSineMotion(init, duration, d, tb); |
|
| 1036 |
else if (!motionType.compare("OutBackMotion"))
|
|
| 1037 |
motion_ = new osgAnimation::OutBackMotion(init, duration, d, tb); |
|
| 1038 |
else if (!motionType.compare("InBackMotion"))
|
|
| 1039 |
motion_ = new osgAnimation::InBackMotion(init, duration, d, tb); |
|
| 1040 |
else if (!motionType.compare("InOutBackMotion"))
|
|
| 1041 |
motion_ = new osgAnimation::InOutBackMotion(init, duration, d, tb); |
|
| 1042 |
else if (!motionType.compare("OutCircMotion"))
|
|
| 1043 |
motion_ = new osgAnimation::OutCircMotion(init, duration, d, tb); |
|
| 1044 |
else if (!motionType.compare("InCircMotion"))
|
|
| 1045 |
motion_ = new osgAnimation::InCircMotion(init, duration, d, tb); |
|
| 1046 |
else if (!motionType.compare("InOutCircMotion"))
|
|
| 1047 |
motion_ = new osgAnimation::InOutCircMotion(init, duration, d, tb); |
|
| 1048 |
else if (!motionType.compare("OutExpoMotion"))
|
|
| 1049 |
motion_ = new osgAnimation::OutExpoMotion(init, duration, d, tb); |
|
| 1050 |
else if (!motionType.compare("InExpoMotion"))
|
|
| 1051 |
motion_ = new osgAnimation::InExpoMotion(init, duration, d, tb); |
|
| 1052 |
else if (!motionType.compare("InOutExpoMotion"))
|
|
| 1053 |
motion_ = new osgAnimation::InOutExpoMotion(init, duration, d, tb); |
|
| 1054 |
else |
|
| 1055 |
motion_ = new osgAnimation::LinearMotion(init, duration, d, tb); |
|
| 1056 |
|
|
| 1057 |
if (computationMode_==CLIENT_SIDE) |
|
| 1058 |
{
|
|
| 1059 |
BROADCAST(this, "sffffs", "translateTo", x, y, z, duration, motion); |
|
| 1060 |
} |
|
| 1061 |
} |
|
| 1062 |
|
|
| 1063 |
// ***************************************************************************** |
|
| 1064 |
|
|
| 965 | 1065 |
|
| 966 | 1066 |
osgManipulator::Dragger* createDragger(const std::string& name, float size, osg::Vec3 offset, osg::Vec3 scale) |
| 967 | 1067 |
{
|
Also available in: Unified diff