12 Replies Latest reply on Nov 1, 2007 8:28 AM by Romeo.Marian

# strange transformation

I want to use matrix to express the transformtion of the lingo 3D, But I find something strange and cannot find any way to adjust the matrix to match it.
Just like the code bellow, I new two groups:group1 and group2 ,group1 is a member of group("world"), and contain the member group2. group2 contain a member pModel. i set the pModel's position as vector(1.0,0.0,0.0), give the group1a rotation of vector(0.0,45.0,0.0) and a scale of vector(2.0,1.0,1.0). When I use pModel.getworldtransform() to get the pModel's transform in world space, I find the result like bellow:
scales:vector( 1.6720, 1.0000, 1.1961 )
position:vector( 0.6136, 0.0000, -1.5339 )
rotation:vector( 0.0000, 72.9868, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -72.9868]
I don't know why. if someone can give me a explanation or give me some document about the transformation.
• ###### 1. Re: strange transformation
quote:

I don't know why. if someone can give me a explanation or give me some document about the transformation.

hm, well, I thought for a long time what you expected, so it would be a lot easier to explain what you got.

did you expect something more like this?
• ###### 2. Re: strange transformation
quote:

I don't know why. if someone can give me a explanation or give me some document about the transformation.

hm, well, I thought for a long time what you expected, so it would be a lot easier to explain what you got.

did you expect something more like this?
• ###### 3. Re: strange transformation
Thanks for your answer. May be I havn't expressed my problem clearly.
I set the position of pModel in the space of group2. Group2 have no tansform(position,rotation,scale) to the group1. So the space of group2 is always equal to space group1. I give group1 a rotation of vector(0.0,45.0,0.0) and a scale of vector(2.0,1.0,1.0). I think the expected transform of pModel in worldspace is
scales:vector( 1.4142, 1.0000, 1.4142)
position:vector( 1.4142, 0.0000, -1.4142)
rotation:vector( 0.0000, 45.0000, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -45.0000]
But it is not.
We know, just like in OpenGL or Director3D, we achieve model tansform by mutiply it a transform matrix. We can express the transform above using a matrix multiply a matrix and then multiply a vector. The vector is the pModel's position in group2's space. It is vector(1.0,0.0,0.0,1.0)
The scale matrix is:
2.0, 0.0, 0.0, 0.0
0.0, 1.0, 0.0, 0.0
0.0, 0.0, 1.0, 0.0
0.0, 0.0, 0.0, 1.0
the rotation matrix should be:
0.7071, 0.0, 0.7071, 0.0
0.0, 1.0, 0.0, 0.0
-0.7071, 0.0, 0.7071, 0.0
0.0, 0.0, 0.0, 1.0
multiply the three, and we can get the pModel's worldPostion, (in this case,scale matrix multiplying the rotation one and rotation one multiplying the scale one get the same result) .Also ,we can get pModel's scale and rotation in the world space by matrix multiplication.
The result is also should be
scales:vector( 1.4142, 1.0000, 1.4142)
position:vector( 1.4142, 0.0000, -1.4142)
rotation:vector( 0.0000, 45.0000, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -45.0000]
I expect why when I use pModel.getworldtransform() in the code and get the rusult
scales:vector( 1.6720, 1.0000, 1.1961 )
position:vector( 0.6136, 0.0000, -1.5339 )
rotation:vector( 0.0000, 72.9868, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -72.9868]
also I expect how to get the same result to director given using matrix multiply.
• ###### 4. Re: strange transformation
quote:

Originally posted by: Starter Rubby
I want to use matrix to express the transformtion of the lingo 3D, But I find something strange and cannot find any way to adjust the matrix to match it.
Just like the code bellow, I new two groups:group1 and group2 ,group1 is a member of group("world"), and contain the member group2. group2 contain a member pModel. i set the pModel's position as vector(1.0,0.0,0.0), give the group1a rotation of vector(0.0,45.0,0.0) and a scale of vector(2.0,1.0,1.0). When I use pModel.getworldtransform() to get the pModel's transform in world space, I find the result like bellow:
scales:vector( 1.6720, 1.0000, 1.1961 )
position:vector( 0.6136, 0.0000, -1.5339 )
rotation:vector( 0.0000, 72.9868, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -72.9868]
I don't know why. if someone can give me a explanation or give me some document about the transformation.

I cannot figure out what are you trying to achieve there and why do you need a "group of groups" (???)
The main idea is that transform.position, transform.rotation and transform.scale are parent-relative transforms.
It seems that you're looking for absolute transforms aka world relative transforms.
If so, use "groupX.getWorldTransform().position", "groupX.getWorldTransform().rotation", "groupX.getWorldTransform().scale".
Or (better) "groupX.translate(a,b,c)", "groupX.rotate(a,b,c)" and "groupX.scale(a,b,c)".
Also keep in mind: a new created group has always position=vector(0,0,0), rotation=vector(0,0,0) and scale = vector(1,1,1).

• ###### 5. Re: strange transformation
with transform position, when you child your models with #preserveParent you should have what you wish
• ###### 6. Re: strange transformation
In this case, the group of groups is really not needed, but not for all the case.
The code I posted is just tell a strange transform result of director. I can't express it using tansform matrix.
Give a complex scene with group of groups, with parent-relative transform of groups and models. Then I want to get the model's tranform in the world space. I hope to use transform matrix to express it.
In this case, we can use getworldtransform() to get the model's transform in worldspace. But not all the transform(what I really want is the worldposition) can be obtained easily. Like the vertex's worldposition in a mash model. The model maybe transformed, the group contain the model maybe transformed. If you want to get the worldposition of the vertex. You have to find a way to get it.Use transform matrix is a way(Maybe another way is new a model and move to the position of the vertex in the mash model's space, and then use getworldtransform() or worldposition property to get the worldposition). I think use transform matrix is a more traditional way. But I found the transform of director is strange and I can't express it in transform matrix.
If there is a transformed group and a transformed model in the group, I found it is easy to get the models' tranform in the group's parent's space using transform matrix. But when I want to get the model's transform in the group's parent's parent's space, the transform is not match the result using tranform matrix.
Now, back to the question above: I new two groups:group1 and group2 ,group1 is a member of group("world"), and contain the member group2. group2 contain a member pModel. i set the pModel's position as vector(1.0,0.0,0.0), give the group1a rotation of vector(0.0,45.0,0.0) and a scale of vector(2.0,1.0,1.0)
I want to know why the pModel's transform in world space is
scales:vector( 1.6720, 1.0000, 1.1961 )
position:vector( 0.6136, 0.0000, -1.5339 )
rotation:vector( 0.0000, 72.9868, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -72.9868]
I hope someone can give me a mathematics explaination, or give me some document about the transform in director
• ###### 7. Re: strange transformation
quote:

Originally posted by: Starter Rubby
Now, back to the question above: I new two groups:group1 and group2 ,group1 is a member of group("world"), and contain the member group2. group2 contain a member pModel. i set the pModel's position as vector(1.0,0.0,0.0), give the group1a rotation of vector(0.0,45.0,0.0) and a scale of vector(2.0,1.0,1.0)
I want to know why the pModel's transform in world space is
scales:vector( 1.6720, 1.0000, 1.1961 )
position:vector( 0.6136, 0.0000, -1.5339 )
rotation:vector( 0.0000, 72.9868, 0.0000 )
axisAngle:[vector( 0.0000, -1.0000, 0.0000 ), -72.9868]
I hope someone can give me a mathematics explaination, or give me some document about the transform in director

It's simple enough: your result is wrong because your script is not the right one.
Do it in this way:

Now the result:
-- vector( 1.4142, 0.0000, -1.4142 )
-- vector( 0.0000, 45.0000, 0.0000 )
-- vector( 2.0000, 1.0000, 1.0000 )

As you can see is the right one.

• ###### 8. Re: strange transformation
It is really thank you for your answer and give me the right script.
I find that: If establishing the relation between groups and models at the very first, we will get the result expected. But if we attach a model or a group to a transformed group, there will be an unexpected result. For exanple, I attatch a model to a transformed group. then I set the model's transformation:
position: vector(0.0,0.0,0.0)
rotation: vector(0.0,0.0,0.0)
scale: (1.0,1.0,1.0)
The tansform of the model and group are not same. The result of the code attachand is:
-- vector( 0.0000, 0.0000, 0.0000 )
-- vector( 1.6521, 1.0000, 1.2106 )
-- vector( 0.0000, 68.1986, 0.0000 )
the model's world transform is strange and not easy to explain.
So I wander how director works when attatch a model or group to a transformed group. I hope somebody can give me a explaination in mathematics.
• ###### 9. Re: strange transformation
Another interesting result: As the code attached, how do you think about the result? But it is
-- vector( 0.0000, 0.0000, 0.0000 )
-- vector( 0.0000, 40.6013, 0.0000 )
-- vector( 1.0000, 1.0000, 1.0000 )
I feel confused. It's my mistake or Director's bug? I wander a reply.
• ###### 10. Re: strange transformation
quote:

Originally posted by: Starter Rubby
Another interesting result: As the code attached, how do you think about the result? But it is
-- vector( 0.0000, 0.0000, 0.0000 )
-- vector( 0.0000, 40.6013, 0.0000 )
-- vector( 1.0000, 1.0000, 1.0000 )
I feel confused. It's my mistake or Director's bug? I wander a reply.

You don't get it, isn't it?
How do you expect the "right" (absolute) results if you're using parent-relative transforms?
If you want parent-relative transforms & results, use:

obs:
from now on you should post here: http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=11&catid=186
Please learn the basics first of all.

• ###### 11. Re: strange transformation
Thanks a lot. I've got it.
I find I didn't comprehend the document currectly for my poor English. That's my mistake.
• ###### 12. Re: strange transformation
quote:

Originally posted by: Starter Rubby
Thanks a lot. I've got it.
I find I didn't comprehend the document currectly for my poor English. That's my mistake.

No ProblemO.