Create mixed reality models in PowerShell

0

Over the holidays, I found myself reading about the .obj file format. I forget why.

.obj (as in object) is the trusty old geometry definition format that nearly every 3D software can interpret, including Blender, Unity, and new Windows 10 built-in apps like Paint 3D and Mixed Reality Viewer. I’d seen it around, but frankly, I’d not thought about it much.

It turns out, the .obj file format is remarkably simple!

Lines beginning with v define vertices (points) by their x-y-z coordinates. For example, v 0 0 0 is the origin. And lines beginning with f define faces by connecting vertices using their index (their position, in order) within the file. For example, f 1 2 3 is the triangle connecting the first three vertices. And that’s… pretty much it. Whoa.

You could author one of these by hand, I thought to myself.

So I did. In Notepad. Here it is:

# Cube, by Cosmos

v 0 0 0
v 0 0 1
v 0 1 1
v 0 1 0
v 1 0 0
v 1 0 1
v 1 1 1
v 1 1 0

f 1 2 3 4
f 8 7 6 5
f 1 5 6 2
f 4 8 5 1
f 2 6 7 3
f 3 7 8 4

Save it as .obj extension, open it in Mixed Reality Viewer, and voila!

Read on

LEAVE A REPLY

Please enter your comment!
Please enter your name here