[Bf-python] Extracting cloth vertices position

Bastien Montagne montagne29 at wanadoo.fr
Fri Mar 14 14:57:30 CET 2014


Hi,

Yep, this way you’ll only get org data, before any modifier is applied… 
Since cloth's pointcache data do not seem to be available from Python, 
the only thing you can do to get cloth cos of vertices is to applies all 
modifiers, like this e.g.:

     # Generate temp mesh from object, with modifiers applied.
     tmp_me = obj.to_mesh(/scene/, True, '/RENDER///')

     # Use data from tmp_me...

     # And then free it!
bpy.data.meshes.remove(tmp_me)


On 14/03/2014 13:49, fmart wrote:
> Hello,
>
> I'm trying to obtain all vertices global position of a piece of cloth
> after colliding with a table. My simulation starts with a plane as a
> piece of cloth and another plane below as a table with the Collision
> modifier.
>
> To obtain all the data I need I'm using the following code (I've the
> cloth selected):
>
> import bpy
> current_obj = bpy.context.active_object
> print("="*40) # printing marker
> for face in current_obj.data.polygons:
> 	verts_in_face = face.vertices[:]
> 	print("face index", face.index)
> 	print("normal", face.normal)
> 	for vert in verts_in_face:
> 		local_point = current_obj.data.vertices[vert].co
> 		world_point = current_obj.matrix_world * local_point
> 		print("vert", vert, " vert co", world_point)
>
>
> The simulation works well, I think the code also works well. However,
> all that I obtain are vertices global position of the cloth in the
> initial position, it doesn't matter whenever I pause the simulation.
>
> Is there any possibility to obtain cloth vertices position after a
> collision?
>
> Thanks!
>
> Felip
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20140314/df4d9329/attachment.html>


More information about the Bf-python mailing list