"3D-Edit" Model File
A little tiny warm-up article wound't hurt anyone, right?
This article, unlike most of my article, only created to warm up my Python knowledge for bigger (and tougher) project. And also probably a first article in 2020.. After not posting anything for like 6 months (or so). College life awaits, friends.
3D-Edit
3D-Edit is a 3d modeler program in 1986 by Colin Olson. This program does what it said. It allows you to create a simple 3d model.
Teardown
To figure out this.. stuff. I've created a very very basic "octogon cylinder". I think it should be enough.
Now you all wondering. How in the world am I gonna transfer file from emulated Mac to the host. Well for emulated Mac, there's program called "HFVExplorer" which allowed you to open variant Classic Mac disk images (and floppies). For emulated mac, its storage is in the ".DSK" format. So to transfer the files, I simply open .DSK file in the program. Then drag files from it into somewhere safe in my host.
Transfered files sometimes don't come with its extension name. But if you know the source format, you can directly open them in programs that supported the formats, or convert it into other formats. Success or not depends on files and converters.
The worst case is your files are in a specific old formats that have no suitable modern programs for opening. I'll talk about this "later".
But now, our "test" file seems to be in readable text. Which is good.
Transfered files sometimes don't come with its extension name. But if you know the source format, you can directly open them in programs that supported the formats, or convert it into other formats. Success or not depends on files and converters.
The worst case is your files are in a specific old formats that have no suitable modern programs for opening. I'll talk about this "later".
But now, our "test" file seems to be in readable text. Which is good.
Hmm.. these numbers looks familiar. Oh.. right! It's .obj syntax. But a little bit off.
Since .obj syntax started with Vertices first, I'll assume line 1 - line 16 are Vertices values. And what comes after Vertices? Of course they're Faces. I also will assume line 18 - line 27 are Faces.
Let's talk about line 17 and line 28. They look odd here. I (once again) assume they might be some kind of "seperate" values.
Now back to Faces. What are these strange beginning values.. I'll leave that aside for now.
Let's assemble this model.
Let's assemble this model.
.OBJ, Handmade Edition
Since they aren't too many Vertices and Faces. I decided to do it.. manually by adding 'v' (Vertice), 'f' (Faces) to each lines and '#' (Comments) to "breaks". Now let's see how this thing turn out :
That.. doesn't look quite like a cylinder. Faces somehow don't sew properly. Now I'm suspecting those first values from Faces might be the cause of this. But if they really cause it, then what are those values anyway.
Our cylinder have 10 Faces, correct? top and bottom are octagon. And sides are rectangles. Now according to that info, you might be able to guess what are those beginning values. Those values are amount of Vertices that Faces need to connect. But since .obj syntax doesn't need those values.
The answer is in. Delete them all. Now let's see how does it look now:
Now that's a octagon cylinder!
Summary
It turned out we can "convert" files from old Macintosh into desired formats by using a tiny bit of knowledge and "Edit in Notepad++" button. We also know it's possible to create "converter scripts" for it. In this article, the file were in basic text format. So it was quite easy to handle.
Now I wonder if there's anyway to handle (obscure) binary files from Classic Macintosh.. The world will never know unless I try to come up with some kind of ways. But for now, I need to focus on my things first.
Anyway. Thanks for reading. See you somewhere around April. May. (Due to Covid-19, my Uni delayed all finals until.. uh.. unknown. Good thing is I got more times to read subject's materials.)
And also. Here's the quick dirty code that I talked about:
And also. Here's the quick dirty code that I talked about:
import sys
f = open(sys.argv[1], 'r')
w = open(sys.argv[1] + ".obj", 'w')
time = 0
constr = "\n"
to_str = str(f.read())
strarray = to_str.splitlines()
#print(strarray)
for line in strarray:
if '32760 32760 32760' in line:
time = 1
continue
if time == 1:
line = line[2:]
r = 'f ' + line
constr += r + "\n"
continue
r = 'v ' + line
constr += r + "\n"
#print(constr)
w.write(constr)
w.close()
f.close()
Comments
Post a Comment