# How to create objects in blender using matrices

So i have gathered that matrices are 4x4, and I'm hoping to try to create a neural network to take pictures of trees and such and convert it into a 4x4 matrix with openCV, but my one question is how would you import a 4x4 matrix into blender and spit out the 3d object?

• A 4x4 matrix has only 16 numbers. A 3D object in Blender is made up of a set of several vertices, each of which is defined by three numbers: the X, Y and Z coordinates. Simple objects may need only a few vertices, but complex ones need hundreds, thousands or even millions. I don't see how a 4x4 matrix could suffice to represent that. If I miss some point, perhaps someone would care to clarify? – user27640 Aug 15 '16 at 19:39
• Welcome to BSE. At the moment your question is super broad to me. Please edit your question to make it understandable for people not dealing with neural network trees on a daily basis :) The more specific you can be the more likely a solution will be provided. For instance: in Blender a matrix is a property of any object, describing orientation, location and scale of it. It make no sense to import raw matrices without knowing what the object should look like in the end. – aliasguru Aug 15 '16 at 19:43
• Thanks Alot. My understand of Matrics was appaerntly off, ignoring the open cv, and neural networks. What way would you import a 3x3 matrix? – sjm Aug 15 '16 at 19:53
• For a neural network you would want a list of 4x4 matrices, one for each point. This answer could be adapted to produce something like what you want. – sambler Aug 16 '16 at 14:38

A matrix on its own is not a model, as discussed in the comments. In 3d graphics, 4x4 matrices are normally used to for projections (e.g. camera projection) and transformations (e.g. specifying the location, rotation and scale of an object).

To load a matrix into blender, you best bet would be to export the data from whatever program you are creating it in as a text file like a csv or something and use python to read it in. You will need to use a python script to do anything useful with it anyway.

However, having some experience working with computer vision and related concepts, if you don't understand what a matrix is, and some of the underlying maths, what you are proposing is likely to be exceedingly difficult for you, so I would recommend learning some of the basic concepts first.

• Out of touch practice, as far as programming sides goes, yes im a little bit of a noob, Being that i have 2 years of college in programming like 4 years ago, and im relearning it all , but i was in calc 2. So im having to relearn alot of concepts. Anyways. I thank you for your incite it was very helpful – sjm Aug 16 '16 at 8:48

It IS possible to load and render points, although as mentioned this may not be what you are attempting. I'm just answering the actual question ;)

Blender has a full python scripting engine, and you can load your data in via python, or load it via the text view. A matrix of values is the equivalent of a point cloud, and depending on what you want to accomplish you can use the Blender Python Engine to create either points, empties or objects at each location in your matrix, create faces and you have an 'object' in space. You can even map a texture to that object (For instance a frame of video from openCV) using a UV map.

Blender Add-Ons are often just python scripts that do almost exactly that, and you can look at them as examples.

You can get a lot of information on making objects from scratch by looking at the following modules listing in blenders source tree.

I recommend examining add_mesh_triangles.py to see exactly how to construct the points, and how to create faces.