[Bf-python] How to get inside faces from inside verts?
joe
joeedh at gmail.com
Thu May 21 23:23:38 CEST 2009
What do you want? The global positions of each vertex? Or in
relation to the object center? To only apply the rot/scale, I believe
you can simply multiply (do this temporarily though, don't store the
result back in the mesh) with the rotation/scale matrix, which I
believe is something like:
(matrix.rotationPart() * matrix.scalePart()) * vert_co
. . .but I could be wrong, look it up in the docs. It'd help if you
could give a more complete description of what your trying to do.
Joe
On Thu, May 21, 2009 at 11:17 AM, <lynx.abraxas at freenet.de> wrote:
> On 20/05/09 17:33:20, joe wrote:
>> If applying rot/scale works, then it means your script isn't properly
>> taking the object matrix into account. To calculate the final
>> transformed position of a vertex, you have to multiply it with the
>> object's matrix, like so:
>
> Is this OK too?
>
> ellmesh= ell.getData(mesh=1)
> ellmesh.transform(ell.matrix) #apply any transform, just in case it wasn't done already
> ell.setMatrix(ell.matrix.identity())
>
>
> This sadly has the unwanted side effect that the ellipsoids have their blender
> centres at the global origin.
> Without the matrix application they have their blender centers at the centers
> of each ellipsoid.
> I created the ellipsoids by adding a UVsphere at the origin, rotating, scaling
> and displacing it:
>
>
> me= B.Mesh.Primitives.UVsphere(segments, rings, diameter)
>
> sc= B.Scene.GetCurrent() # get current scene
> #http://www.blender.org/documentation/246PythonDoc/Object-module.html
> obn= "Ellipsoid_%0.4d" % dl[15]
> ob= sc.objects.new(me, obn) # add a new mesh-type object to the scene
>
> #http://www.blender.org/documentation/246PythonDoc/Object.Object-class.html
> mat= B.Mathutils.Matrix([dl[6],dl[7],dl[8], 0], [dl[9],dl[10],dl[11], 0], [dl[12],dl[13],dl[14], 0], [0,0,0,1])
>
> local_rot(ob, mat)
> ob.setSize(dl[0], dl[1], dl[2])
> ob.setLocation(dl[3], dl[4], dl[5])
> me= ob.getData(mesh=1) #blender shows the obj. according to its matrix
> me.transform(ob.matrix)#but does not apply it on the obj verts
> ob.setMatrix(ob.matrix.identity())#set identity to avoid double effect
>
>
> Why is blender showing the ellipsoids correctly where as their verts are still
> the unit sphere until I apply the matrix to the mesh?
> Can You point me to some docs explaining this behavior?
> Is there a way to apply only rot and scale to the mesh but not the translation
> at creation time?
> How can I later some how translate the mesh (for pointInside to work) but
> leave the object as it is?
>
> Well, at least I'm slowly getting what I want;)
>
> Thanks for any help
> Lynx
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
More information about the Bf-python
mailing list