[Bf-python] How to get inside faces from inside verts?
lynx.abraxas at freenet.de
lynx.abraxas at freenet.de
Thu May 21 19:17:54 CEST 2009
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
More information about the Bf-python
mailing list