【问题标题】:Jmonkey animation-jump to waypointJmonkey 动画-跳转到航点
【发布时间】:2014-11-27 12:41:39
【问题描述】:

我已经搞砸了一段时间,似乎无法找到如何做到这一点。 问题是当我启动 MotionControl 时,它总是会在第一个航路点产生空间并从那里移动。 但是,我确实需要使空间和运动从用户定义的航点(例如:航点 10)开始并从那里开始。

你能帮忙吗?

谢谢

【问题讨论】:

    标签: 3d jmonkeyengine


    【解决方案1】:

    我在MotionEvent 中能找到的唯一改变轨道位置的方法是setTime(float)。 合理的值介于 0.0f (0%) 和 initialDuration (100%) 之间。

    每次您向MotionPath 添加航路点时,它都会更新基础Spline、其总长度和每个段的长度。

    使用此信息,您可以为您的航路点计算相应的“时间标记”:

    public float calcWaypointTime(MotionPath path, MotionEvent motionEvent, int waypointIndex) {
        // Distance between start and waypoint
        float wpDistance = 0;
    
        // Sum up segment lengths until waypoint is reached
        List<Float> segLen = path.getSpline().getSegmentsLength();
        for(int i=0; i<segLen.size() && i<waypointIndex; ++i)
            wpDistance += segLen.get(i);
    
        // Transform distance to time
        return (wpDistance / path.getSpline().getTotalLength()) * motionEvent.getInitialDuration();
    }
    

    【讨论】:

      猜你喜欢
      • 2015-03-13
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多