« Return to Thread: Re: Rotation around Arbitrary axis addition to DisplayObject3D

Re: RE : RE : Re: Rotation around Arbitrary axis addition to DisplayObject3D

by Peter Kapelyan :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
Actually send me your first code (if you still have it) or test code that I can show you easy way in - the smaller the faster you'll get it back :)

On 6/26/07, Peter Kapelyan <flashnine@...> wrote:
I think you are trying a very hard way - if you are doing something very simple.
You can send me code I a promise I will not show anyone - and send back just to you if you want..
I think I can do what you want in 2-3 lines of code - no more. After that you can always do any other method :)

 
On 6/26/07, Moon Moon <moon_pv3d@...> wrote:
Sorry I thing that I don't understand the errors !!  Please ignore the precedent email.
These are the errors:
 
Error1
Attempted access of inaccessible method IDENTITY through a reference with static type
 
Error2
Call to a possibly undefined method calculateMultiply through a reference with static type org.papervision3d.core:Matrix3D. DisplayObject3D.as 
 


Moon Moon <moon_pv3d@...> a écrit :
I copied and pasted the following method, there is two errors, the first one is that IDENTITY is not a method so we have to put: IDENTITY instead of IDENTITY().
The second is :
calculateMultiply !!!!!!  It doesn't find this method !!

Dustin Sparks <djsparks@...> a écrit :
Hi all,

I couldnt find a better way to do this, so i went ahead and added it into my DisplayObject3D class.

It rotates any DisplayObject3D around another DisplayObject3D (including itself) on any give axis... it basically replaces rotation. ( i saw that there was some little hack-together people had to use to achieve the same effect).

Below is the addition to displayObect3D, link to an example, and usage.

====================================================
SOURCE
http://pixelmixer.mine.nu/papervision/main.as
http://pixelmixer.mine.nu/papervision/DisplayObject3D.as

====================================================
EXAMPLE
http://djsparks.iweb.bsu.edu/papervision/arbitraryRotation_example1.html

====================================================
CLASS ADDITION

/**
    * ________________________________________________________________________________________________
    * ------------------------------------ I N C O M P L E T E ---------------------------------------
    * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    * Rotates the displayObject around an arbitrary axis of a given displayObject.
    *
    * @param    angle:Number                    The angle to rotate;
    * @param     axis:Number3D                    The "axis" around which to rotate;
    * @param    targetObject:DisplayObject3D    The object to rotate around.
    */
    public function rotateArbitrary( angle:Number, axis:Number3D = null, targetObject:DisplayObject3D = null):void
    {
        if(!targetObject) targetObject = this;
        if(!axis) axis = new Number3D(1,0,0);
       
        var direction:Number3D = axis;
        var originPoint:Number3D = new Number3D(targetObject.x , targetObject.y, targetObject.z);
       
        var v:Number = Math.sqrt(direction.x*direction.x + direction.y*direction.y);
        var w:Number = Math.sqrt(v*v + direction.z*direction.z);
       
        var oF:Matrix3D = new Matrix3D([1,0,0,- originPoint.x,
                                       0,1,0,- originPoint.y,
                                       0,0,1,-originPoint.z,
                                       0,0,0,1]);
        var iF:Matrix3D = Matrix3D.inverse(oF);
       
        var oG:Matrix3D;
       
        if(v != 0)
        {
            oG = new Matrix3D([direction.x/v,direction.y/v,0,0,
                                           - direction.y/v,direction.x/v,0,0,
                                            0,0,1,0,
                                            0,0,0,1]);
        }
        else
        {
            oG = Matrix3D.IDENTITY ();
        }
       
        var iG:Matrix3D = Matrix3D.inverse(oG);
       
        var oH:Matrix3D = new Matrix3D([direction.z/w,0,-v/w,0,
                                        0,1,0,0,
                                        v/w,0, direction.z/w,0,
                                        0,0,0,1]);
        var iH:Matrix3D = Matrix3D.inverse(oH);
       
        var W:Matrix3D = new Matrix3D([Math.cos(angle),-Math.sin(angle),0,0,
                                       Math.sin(angle),Math.cos(angle),0,0,
                                       0,0,1,0,
                                       0,0,0,1]);
                                      
        var P:Matrix3D = Matrix3D.multiply (Matrix3D.multiply(Matrix3D.multiply(Matrix3D.multiply(Matrix3D.multiply(Matrix3D.multiply(iF,iG),iH),W),oH),oG),oF);
       
        this.transform.calculateMultiply( P ,transform );
       
        if( this._transformDirty ) updateTransform();
    }



=============================================================
USAGE

        moon.rotateArbitrary (.02, new Number3D(1,1,1), earth);
        earth.rotateArbitrary(.01, new Number3D(-1,1,1));
        camera.rotateArbitrary(.02, new Number3D(1,1,1), earth);
       
        camera.lookAt(earth);

--
Dustin Sparks _______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses._______________________________________________

Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org


Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org




_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 « Return to Thread: Re: Rotation around Arbitrary axis addition to DisplayObject3D