applyTransformation does not work

Software: Away3D 4.x

koblongata, Newbie
Posted: 20 September 2013 06:19 PM   Total Posts: 28
var headGeometry:CubeGeometry = new CubeGeometry(406040131);
var 
m:Matrix3D = new Matrix3D(new <Number>[10000101200010]);
headGeometry.applyTransformation(m); 

the code above does not move the geometry at all
Please help me understand how you can apply transformation matrix to a geometry..

   

Avatar
dottob, Jr. Member
Posted: 21 September 2013 02:48 AM   Total Posts: 49   [ # 1 ]

Maybe like this?

var headGeometry:CubeGeometry = new CubeGeometry(406040131);
   var 
m:Matrix3D = new Matrix3D();
   
m.appendTranslation(0,120,0)
   
m.appendRotation(45,Vector3D.Y_AXIS)
   
m.appendScale(2,2,2)    
   var 
ms:Mesh=new Mesh(headGeometry,new ColorMaterial(0xffcc00))
   
ms.geometry.applyTransformation(m)
   
view.scene.addChild(ms
   

John Brookes, Moderator
Posted: 21 September 2013 07:59 AM   Total Posts: 732   [ # 2 ]

Not sure what you expect that to do?
Matrix is 16 Numbers.
eg
[1,0,0,0,0,1,0,0,0,0,1,0,X,Y,Z,1]

   

koblongata, Newbie
Posted: 21 September 2013 04:48 PM   Total Posts: 28   [ # 3 ]

Thanks!
geometry.applyTransformation would work now, but I found that this method is the same as setting “y” of mesh to 120.
What I wanted to achieve was translate all the vertices in the geometry up 120 in y direction, in pv3d there was a method like this:

mesh.geometry.transformVertices( new Matrix3D([1000010,  1200010])); 

which would move the geometry up, instead of move the mesh object up…

   

John Brookes, Moderator
Posted: 22 September 2013 11:42 AM   Total Posts: 732   [ # 4 ]

Thats exactly what it does.
Its not the same as setting the y pos of the mesh.

[1,0,0,0,0,1,0,0,0,0,1,0,0,120,0,1]

Would move all the vertices +120 in Y

The actual position values (xyz) of the mesh dont change.


Another way would be to use movePivot

mymesh.movePivot(0,-120,0)
mymesh.y +=120;

   

Avatar
Fabrice Closier, Administrator
Posted: 22 September 2013 12:30 PM   Total Posts: 1265   [ # 5 ]

Another option: Meshhelper.applyPosition, applyRotations.
if mesh is having 100, 0, 0 position
and it’s having vertices x values ranging from -50 to 50 in own object data.
if you applyPosition
mesh.position will trace 0,0,0
mesh data will range from 50 to 150.

   

koblongata, Newbie
Posted: 22 September 2013 10:36 PM   Total Posts: 28   [ # 6 ]

Yes, I am wrong, applyTranformation indeed transformed all the vertices.
And cool, move pivot seems to be a nice and simple way to do the same.
Meshhelper.applyPosition seems to be more advanced usage, it changed the scale of things of itself.

it turns out that it’s the as3dmod library is grabbing the bottom position of the geometry regardless of the position of the mesh or the geometry…

Thank you guys for all the replies!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X