views:

679

answers:

4

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).

A: 

I thing you are looking for this: http://www.kelvinluck.com/assets/papervision3d/cube_tweaks/

Red33mer
That is mildly entertaining, but definitely *not* an arcball.
A: 

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;
sharvey
This is not the same as the link @roygbiv provided. In yours, when you drag and move in circular motion(eg. clockwise), the sphere will rotate slowly.
Andy Li
A: 

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

davek
Thank you. I had found the same link myself and it is a standard quaternion implementation just like my own. However it suffers from the same issue, it doesn't work as one would expect it to on a standard pv3d objects such as a cube. In fact, I believe the current revision of the above link totally eliminates the arcball module.
They are using their *rotater* module instead of the arcball module.
+1  A: 

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)

godel
I don't need quaternion knowledge or arcball examples, I can implement an arcball in my sleep. What I need to know is why it doesn't work on pv3d objects like a cube etc... or an example showing how to make it work on a pv3d object.
I guess I'm just not sure of what you're looking for then. You had asked for an example of an arcball in PV3D which a number of people provided, of which I believe http://pv3d.org/tag/quaternion/ has numerous examples. Other than that I don't know how to help you without an example of some sort, all I know so far from your question is that your implementation is not working and goes weird. I guess what I'm trying to convey is that for all I know it could be your implementation that is wrong or you could have hit an edge case but its rather difficult to tell without more specifics.
godel
@godel - The link you provide in the comment does not contain any arcball examples. It contains examples of quaternions. My question is clear, I want a pv3d scene with a cube that can be spun by using a quaternion based arcball. As far as if it's my implementation that is wrong or my implementations application to pv3d, well, that is what I'm trying to figure out. I believe my implementation is ok because it works in DirectX. However, in pv3d it seems to only "attach" to one face of the cube. FWIW, I don't believe your answer is worth an upvote, now had you provided a working example...
@roygbiv - No worries, was just trying to help out.
godel