Papervision3D 的 Arcball 实施

发布于 2024-08-06 01:56:04 字数 750 浏览 3 评论 0 原文

Papervision3D 是否有 arcball 实现?

有许多针对 Flash/ActionScript 的轨迹球实现,但没有专门针对 Papervision3D 的实现。

以下是 Flash 的 arcball 实现示例:

http://www.unitzeroone.com/blog/2009/09/08/source-better-flash-10-3d-interaction-arcball/

我已经开始编写自己的基于实现的在 DirectX ArcBall 类上。

然而,它无法正常工作,我不知道为什么。

从立方体的初始位置,我可以按照预期单击并拖动轨迹球。

但是,如果我开始累积四元数中的轴/角度,当立方体旋转足够时,方向就会相反。不应出现旋转方向反转或任何其他奇怪的行为。

我搜索了互联网,没有发现任何与 Papervision3D 和 arcballs 直接相关的内容。 (也许有另一个 3D Flash 引擎的 arcball 实现?)如果您能

在这方面提供任何帮助,我们将不胜感激。

** 编辑 ** 为 Papervision3D 的工作轨迹球实现的答案添加了 500 点赏金(场景中必须至少有 1 个对象(即)立方体)。

Is there an arcball implementation for Papervision3D?

There are many arcball implementations for Flash/ActionScript but none specifically for Papervision3D.

Here's an example of an arcball implementation for flash:

http://www.unitzeroone.com/blog/2009/09/08/source-better-flash-10-3d-interaction-arcball/

I have taken to writing my own implementation based on the DirectX ArcBall class.

It does not work correctly, however, and I am at a loss as to why.

From the cubes initial position I can click and drag the arcball as one would expect.

However, if I start accumulating the axis/angles in a quaternion, the directions reverse when the cube is rotated enough. There should be no reversing of the directions of rotation or any other weird behaviour.

I have scoured the internet and found nothing directly related to Papervision3D and arcballs. (Perhaps there is an arcball implementation for another 3D Flash engine?)

Any help in this matter would be greatly appreciated.

** EDIT ** Added a 500 point bounty for an answer with a working arcball implementation for Papervision3D (must have at least 1 object (i.e.) cube in the scene).

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

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

发布评论

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

评论(4

寂寞花火° 2024-08-13 01:56:04

Dave K 之前提到的页面有许多 arcball 示例,这里 符合轨迹球的典型物理特性。然而,您可能想扩大搜索范围并寻找四元数和纸视觉。

如果您不熟悉四元数,它们是 4 维向量空间的元素,并且您正在寻找的轨迹球效果背后的基础。这个教程将帮助您快速了解四元数数学,这相当容易理解。

四元数由 Papervision 本地处理,因此教程并不难找到。快速浏览一下 google 产生了以下结果。

Papervision3D 中的四元数

A 关于 papervision3d 和可怕的万向节锁的对话

最后,一个 讨论该主题的 WordPress 博客列表(并非全部与 Flash 相关)

The page mentioned by Dave K earlier has a number of arcball examples, here is one that conforms to the typical physics expected out of a trackball. However you may want to broaden your search a bit and look for quaternions and papervision.

If you are unfamiliar with quaternions, they are an element of a 4 dimensional vector-space and the basis behind the arcball effect you are looking for. This tutorial will get you up to speed on quaternion math that is fairly easy to understand.

Quaternions are handled natively by Papervision so tutorials are not that hard to find. A quick look at google produced the following results.

Quaternions in Papervision3D

A conversation on papervision3d and the dreaded Gimbal lock

Finally, a list of wordpress blogs discussing the topic (not all flash related)

千笙结 2024-08-13 01:56:04

完全不确定这是否是您想要的,但该项目基本上是一个 Flash 实现,其中有一些针对 papervision3D 的元素:

http://code.google.com/p/spinnyglobe/

特别是:

http://code.google.com/p/spinnyglobe/source/browse/trunk/flash/org/makerlab/ArcBall.as? r=122

Not at all sure if this is what you want, but this project is basically a Flash implementation, with some elements aimed at papervision3D:

http://code.google.com/p/spinnyglobe/

particularly:

http://code.google.com/p/spinnyglobe/source/browse/trunk/flash/org/makerlab/ArcBall.as?r=122

甜味超标? 2024-08-13 01:56:04

这就是您要查找的内容:拖动对象进行旋转

这是有趣的部分:

    var currentMousePoint:Point = new Point(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);

    if(isMouseDown)
    {
        var difference:Point = currentMousePoint.subtract(previousMousePoint);
        var vector:Number3D = new Number3D(difference.x, difference.y, 0);

        var rotationAxis:Number3D = Number3D.cross(vector, FORWARD);
        rotationAxis.normalize();

        var distance:Number = Point.distance(currentMousePoint, previousMousePoint);
        var rotationMatrix:Matrix3D = Matrix3D.rotationMatrix(rotationAxis.x, -rotationAxis.y, rotationAxis.z, distance/250);

        sphere.transform.calculateMultiply3x3(rotationMatrix, sphere.transform);
    }

    previousMousePoint = currentMousePoint;

This is what you are looking for:Dragging an object to rotate ?

here's the interesting part:

    var currentMousePoint:Point = new Point(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);

    if(isMouseDown)
    {
        var difference:Point = currentMousePoint.subtract(previousMousePoint);
        var vector:Number3D = new Number3D(difference.x, difference.y, 0);

        var rotationAxis:Number3D = Number3D.cross(vector, FORWARD);
        rotationAxis.normalize();

        var distance:Number = Point.distance(currentMousePoint, previousMousePoint);
        var rotationMatrix:Matrix3D = Matrix3D.rotationMatrix(rotationAxis.x, -rotationAxis.y, rotationAxis.z, distance/250);

        sphere.transform.calculateMultiply3x3(rotationMatrix, sphere.transform);
    }

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