Professional Web Applications Themes

strange transformation - Macromedia Director 3D

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, ...

  1. #1

    Default 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
    doent about the transformation.

    on beginSprite
    clearglobals()
    _movie.member(2).resetWorld()


    pModelResource=sprite(1).member.newmodelResource(" modelResource",#plane,#back)

    Group1=_movie.member(2).newgroup("group1")
    Group1.transform.position=vector(0.0,0.0,0.0)
    Group1.transform.rotation=vector(0.0,45.0,0.0)
    Group1.transform.scale=vector(2.0,1.0,1.0)

    Group2=_movie.member(2).newgroup("group2")
    Group1.addChild(Group2,#preserveWorld)
    Group2.transform.position=vector(0.0,0.0,0.0)
    Group2.transform.rotation=vector(0.0,0.0,0.0)
    Group2.transform.scale=vector(1.0,1.0,1.0)

    pModel=_movie.member(2).newModel("model1",pModelRe source)
    Group2.addChild(pModel,#preserveWorld)

    pModel.transform.position=vector(1.0,0.0,0.0)
    pModel.transform.rotation=vector(0.0,0.0,0.0)
    pModel.transform.scale=vector(1.0,1.0,1.0)

    a=pModel.getworldtransform()

    end

    Starter Guest

  2. #2

    Default Re: strange transformation

    [q]I don't know why. if someone can give me a explanation or give me some
    doent about the transformation.[/q]

    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?

    on beginSprite
    clearglobals()
    _movie.member(1).resetWorld()


    pModelResource=sprite(1).member.newmodelResource(" modelResource",#plane,#back)

    Group1=_movie.member(1).newgroup("group1")
    Group1.transform.position=vector(0.0,0.0,0.0)
    Group1.transform.rotation=vector(0.0,45.0,0.0)
    Group1.transform.scale=vector(2.0,1.0,1.0)

    Group2=_movie.member(1).newgroup("group2")
    Group2.transform.position=vector(0.0,0.0,0.0)
    Group2.transform.rotation=vector(0.0,0.0,0.0)
    Group2.transform.scale=vector(1.0,1.0,1.0)
    Group1.addChild(Group2,#preserveParent)

    pModel=_movie.member(1).newModel("model1",pModelRe source)
    pModel.transform.position=vector(0.0,0.0,0.0)
    pModel.transform.rotation=vector(0.0,0.0,0.0)
    pModel.transform.scale=vector(1.0,1.0,1.0)
    Group2.addChild(pModel,#preserveParent)

    a=pModel.getworldtransform()


    -- just some code to see something in this test scenario
    --------------------------------------------------------
    pLight = _movie.member(1).newlight("licht", #ambient)
    _movie.member(1).camera[1].worldposition = vector(0,0,10)
    end

    Erhard Guest

  3. #3

    Default Re: strange transformation

    [q]I don't know why. if someone can give me a explanation or give me some
    doent about the transformation.[/q]

    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?

    on beginSprite
    clearglobals()
    _movie.member(1).resetWorld()


    pModelResource=sprite(1).member.newmodelResource(" modelResource",#plane,#back)

    Group1=_movie.member(1).newgroup("group1")
    Group1.transform.position=vector(0.0,0.0,0.0)
    Group1.transform.rotation=vector(0.0,45.0,0.0)
    Group1.transform.scale=vector(2.0,1.0,1.0)

    Group2=_movie.member(1).newgroup("group2")
    Group2.transform.position=vector(0.0,0.0,0.0)
    Group2.transform.rotation=vector(0.0,0.0,0.0)
    Group2.transform.scale=vector(1.0,1.0,1.0)
    Group1.addChild(Group2,#preserveParent)

    pModel=_movie.member(1).newModel("model1",pModelRe source)
    pModel.transform.position=vector(0.0,0.0,0.0)
    pModel.transform.rotation=vector(0.0,0.0,0.0)
    pModel.transform.scale=vector(1.0,1.0,1.0)
    Group2.addChild(pModel,#preserveParent)

    a=pModel.getworldtransform()


    -- just some code to see something in this test scenario
    --------------------------------------------------------
    pLight = _movie.member(1).newlight("licht", #ambient)
    _movie.member(1).camera[1].worldposition = vector(0,0,10)
    end

    Erhard Guest

  4. #4

    Default 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.

    Starter Guest

  5. #5

    Default Re: strange transformation

    [q]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
    doent about the transformation.[/q]

    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).
    try to do your best




    Romeo.Marian Guest

  6. #6

    Default Re: strange transformation

    with transform position, when you child your models with #preserveParent you should have what you wish
    Erhard Guest

  7. #7

    Default 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
    doent about the transform in director

    Starter Guest

  8. #8

    Default Re: strange transformation

    [q]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
    doent about the transform in director[/q]

    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.



    on beginSprite me
    w = member("w3d")
    pModel = w.newModel("model1")
    Group2 = w.newgroup("group2")
    Group2.addChild(pModel)
    Group1 = w.newgroup("group1")
    Group1.addChild(Group2)
    pModel.transform.position = vector(1.0,0.0,0.0)
    Group1.transform.rotation = vector(0.0,45.0,0.0)
    Group1.transform.scale = vector(2.0,1.0,1.0)
    put pModel.getWorldTransform().position
    put pModel.getWorldTransform().rotation
    put pModel.getWorldTransform().scale
    end

    Romeo.Marian Guest

  9. #9

    Default 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.

    on beginSprite
    clearglobals()
    _movie.member(2).resetWorld()

    Group1=_movie.member(2).newgroup("group1")
    Group1.transform.rotation=vector(0.0,45.0,0.0)
    Group1.transform.scale=vector(2.0,1.0,1.0)
    Group1.transform.position=vector(0.0,0.0,0.0)

    pModel=_movie.member(2).newModel("model1")
    Group1.addChild(pModel,#preserveWorld)

    pModel.transform.position=vector(0.0,0.0,0.0)
    pModel.transform.rotation=vector(0.0,0.0,0.0)
    pModel.transform.scale=vector(1.0,1.0,1.0)

    put pModel.getworldtransform().position
    put pModel.getworldtransform().scale
    put pModel.getworldtransform().rotation
    end

    Starter Guest

  10. #10

    Default 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.

    on beginSprite
    clearglobals()
    _movie.member(2).resetWorld()

    Group1=_movie.member(2).newgroup("group1")
    Group1.transform.position=vector(0.0,0.0,0.0)
    Group1.transform.rotation=vector(0.0,45.0,0.0)
    Group1.transform.scale=vector(2.0,1.0,1.0)
    pModel=_movie.member(2).newModel("model1")
    Group1.addChild(pModel,#preserveWorld)

    pModel.transform.position=vector(0.0,0.0,0.0)
    pModel.transform.rotation=vector(0.0,0.0,0.0)
    pModel.transform.scale=vector(1.0,1.0,1.0)

    put pModel.transform.position
    put pModel.transform.rotation
    put pModel.transform.scale
    end

    Starter Guest

  11. #11

    Default Re: strange transformation

    [q]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.[/q]

    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:
    Group1.addChild(pModel,#preserveParent)

    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.



    Romeo.Marian Guest

  12. #12

    Default Re: strange transformation

    Thanks a lot. I've got it.
    I find I didn't comprehend the doent currectly for my poor English. That's my mistake.
    Starter Guest

  13. #13

    Default Re: strange transformation

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

    No ProblemO.
    Take your time.



    Romeo.Marian Guest

Similar Threads

  1. XSL Transformation Error
    By The WereMike in forum Coldfusion Server Administration
    Replies: 3
    Last Post: November 29th, 04:47 PM
  2. Transformation bug?
    By ccnk in forum Macromedia Fireworks
    Replies: 5
    Last Post: October 17th, 02:33 PM
  3. Transformation panel
    By David Conner in forum Macromedia Freehand
    Replies: 0
    Last Post: August 17th, 11:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139