2

want to do some 3d model processing using Python.

I was told 3d models are made up of 4d matrices. Is it possible to import a 3d model from meshlab or blender or some other software and convert it into a matrix or something of the sort so I could do some processing?

John Jepson
  • 21
  • 1
  • 5
  • 1
    I would recommend the trimesh library. https://pypi.python.org/pypi/trimesh It is quite easy to use and quite fast. – max9111 Jan 15 '18 at 12:38

2 Answers2

1

Yes it is possible. You need the plyfile library. Since it's Meshlab, I am assuming the file format that you're trying to import is .ply. Use the code below.

from plyfile import PlyData

data = PlyData.read('my_data.ply')
troymyname00
  • 670
  • 1
  • 14
  • 32
0

While you can use a 4D matrix to apply multiple transformations in one step, for the most part I would say it is more common to access each property either as an array of three or four values or to directly access each element.

import bpy
obj = bpy.context.active_object
obj.location.x += 1.0
obj.location.y -= 0.2
obj.location.z += 0.8
obj.rotation_euler = (radians(45.0),radians(15.8), radians(0.0))

Blender includes a full python interpreter, so you should be able to do most of what you want using blender without having to export any data.

If you want to try blender, you can get more blender specific help at blender.stackexchange.

sambler
  • 6,917
  • 1
  • 16
  • 23