Copy3x3 Matrix

Software: Away3D 4.x

John Brookes, Moderator
Posted: 06 December 2011 03:06 PM   Total Posts: 732

Just wondering if there is an easier way?

public function copy3x3(copyTo:Matrix3DcopyFrom:Matrix3D ):void
{
 
var ct:Vector.<Number> = copyTo.rawData
 
var cf:Vector.<Number> = copyFrom.rawData
 ct[0] 
cf[0];  ct[4] cf[4];   ct[8] cf[8];
 
ct[1] cf[1];  ct[5] cf[5];   ct[9] cf[9];
 
ct[2] cf[2];  ct[6] cf[6];   ct[10] cf[10];

copyTo.copyRawDataFrom(ct);

use it for things like


parent.roll(1)
copy3x3(childMesh.transform, parent.inverseSceneTransform)

   

Somokon, Member
Posted: 06 December 2011 07:31 PM   Total Posts: 75   [ # 1 ]
parent.inverseSceneTransform.copyToMatrix3D(childMesh.transform

should work.

   

John Brookes, Moderator
Posted: 06 December 2011 08:11 PM   Total Posts: 732   [ # 2 ]

No theres a difference, yours copies the whole matrix
Basically that above leaves the position info intact.

so even if the parent rotates an offset child will remain level and keep its offset

eg
pivot = new ObjectContainer3D();
scene.addChild(pivot);
 
c = new Cube(new ColorMaterial(0xff0000), 500, 100, 100);
c.x = 500
pivot.addChild(c);

//render
pivot.roll(0.5)
pivot.yaw( -1)
pivot.pitch(0.3)
copy3x3(c.transform,pivot.inverseSceneTransform)

   

Somokon, Member
Posted: 06 December 2011 09:15 PM   Total Posts: 75   [ # 3 ]

Ah, I thought you were copying the whole matrix, I see I didn’t read carefully enough.

You could use the recompose/decompose methods of the Matrix3D class but it’s not really any different from what you are doing now.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X