[Papervision3D] DisplayObject Transform matrix scale part fix

alex winx winxalex at yahoo.com
Mon Feb 25 13:40:49 PST 2008


Following the practice of all major 3D prof. programs in their orientation of using of  transform  mtx in 3D object control (DisplayObject3D in our case) and not using rotation,scale,postion manualy (many speed performans issues), i tried to use
DisplayObject3D.transform=transformMTX 

This changes the transform mtx of 3DObject but check (rotationX..Z,scaleX.Y properties) you will found no changes. 

DisplayObject3D.transform=copyTransform(transformMTX) will solve rotationX,..Z
by calling updateRotation but what about scale.There is no updateScale() function that will set unused property _scaleDirty=true and refresh scaleX,scaleY,scaleZ...prop.

Open your DisplayObject3D.as and add this function
/**
        * Update scale values
        */
        public function updateScale():void
        {
            var scale:Number3D=Matrix3D.matrix2scale(this.transform);
            
            this._scaleX = scale.x;
            this._scaleY = scale.y;
            this._scaleZ = scale.z;
            this._scaleDirty = false;
        }

Also very useful function to Matrix3D so you will have access of scale properties from the transform mtx.


public static function matrix2scale(t:Matrix3D):Number3D
    {
        var scale:Number3D = new Number3D(1,1,1);
        
        scale.x = (new Number3D(t.n11, t.n12, t.n13)).modulo;
        scale.y = (new Number3D(t.n21, t.n22, t.n23)).modulo;
        scale.z = (new Number3D(t.n31, t.n32, t.n33)).modulo;

        return scale;
    }


When you will put manual scale values let say scaleX=2,13 scaleY=3, scale=1
you will find that trasform mtx following theory
    scale.x = (new Number3D(t.n11, t.n12, t.n13)).modulo;
has incorrect (or maybe different way of storing) information for scaling inside.

The problem is in line (DisplayObject3D.as updateTransform())

this.transform.calculateMultiply( transform,scaleM  );

should be changed with left multiplication of  transformMTX instead  of  right
 
this.transform.calculateMultiply( scaleM,transform  );

Enjoy




       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20080225/0d136395/attachment.html 


More information about the Papervision3D mailing list