开发者

How to reverse a transformation by matrix in Blender?

开发者 https://www.devze.com 2023-01-27 10:30 出处:网络
I have a selected mesh (creatively called \'selected\') which I want to work with in its local space so I use the following:

I have a selected mesh (creatively called 'selected') which I want to work with in its local space so I use the following:

    tmesh = NMesh.GetRawFromObject(selected.name)
    tmesh.transform(selected.matrix)

I then do a bunch of calculations on its verticies and remove them by index, which works great.

What doesn't work so great is when I try to add them back later from a list of vert.co obj开发者_StackOverflow社区ects. They end up being positioned correctly relative to each other, but nowhere near the original verticies.

            for v in tmesh.verts:
                 toAdd.append(v.co)
              mesh = selected.getData(mesh=1)
              mesh.verts.extend(toAdd)

I realized this is because the object is in a different space. So I think what I need to do is translate the new verticies back to the old space... but my understanding of what exactly is going on here is fuzzy at best. How do I "undo" the tmesh.transform(selected.matrix) command?

A more thoroug explanation of what I'm doing can be found here: http://www.kellbot.com/2010/11/lego-plans-now-with-better-rendering/


I'm not familiar with Blender specfically, but after a quick peek at the documentation, in principle it seems like you ought to be able to use the invert() Matrix method to obtain the inverse transformation of the selected.matrix (perhaps after first making a copy() of it).

0

精彩评论

暂无评论...
验证码 换一张
取 消