Java3d 行为和运动

发布于 2024-07-17 23:38:57 字数 123 浏览 3 评论 0原文

我想在一个简单的宇宙中以随机方向移动一个球体。 我如何通过逐帧少量改变位置来通过行为来实现这一目标。 我尝试这样做的原因是在宇宙中产生随机运动,并最终建立粒子之间的简单碰撞检测。

任何建议/链接将不胜感激

I would like to move a sphere in a random direction within a simple universe. How could i achieve this with behaviours by changing the location a small amount frame by frame. The reason I am trying to do this is to produce random movement within the universe and eventually build in simple collision detection between the particles.

Any advice/links would be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-07-24 23:38:57

使用此骨架添加一个扩展Behavior的新类:

public class XXXBehavior extends Behavior
{
    private WakeupCondition wc = new WakeupOnElapsedTimer(1000); // 1000 ms

    public void initialize()
    {
        wakeupOn(wc);
    }

    public void processStimulus(Enumeration criteria)
    {
        // Move the shape here

        // prepare for the next update
        wakeupOn(wc);
    }
}

稍后您需要实例化该类并将其添加到场景图中。 您还需要定义边界,否则什么也不会发生!

xxxEffect = new XXXBehavior();
xxxEffect.setSchedulingBounds(bounds);
sceneBG.addChild(xxxEffect);

Add a new class that extends Behavior, using this skeleton:

public class XXXBehavior extends Behavior
{
    private WakeupCondition wc = new WakeupOnElapsedTimer(1000); // 1000 ms

    public void initialize()
    {
        wakeupOn(wc);
    }

    public void processStimulus(Enumeration criteria)
    {
        // Move the shape here

        // prepare for the next update
        wakeupOn(wc);
    }
}

You later need to instantiate the class and add it to the scene graph. You also need to defined the bounds, otherwise nothing will happen!

xxxEffect = new XXXBehavior();
xxxEffect.setSchedulingBounds(bounds);
sceneBG.addChild(xxxEffect);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文