This is a simple python script that allows users to
- Import 3D objects
- Edit 3D objects (limited to the functions I define)
- Export 3D objects
It provides a standardized way for me to import/export 3D objects and easily expandable to include more 3D formats.
There are many import/exports tools out there for various formats, but for my own purposes, I only need a fast way to convert other formats to MQO or directx. And so I wrote this.
There are many import/exports tools out there for various formats, but for my own purposes, I only need a fast way to convert other formats to MQO or directx. And so I wrote this.
The design itself is simple; it consists of two components: The importer/exporter engine, and separate classes for each format that contain parsing and printing methods.
The engine makes an attempt to auto-detect the format of the input file and then exports it to the specified format of your choice. If it fails, then you'll have to specify the format yourself.
Each format comes as a stand-alone class that inherits from a Model3D class I wrote. The Model3D class stores all of the information that is required to produce a 3D object. The following data structures are defined:
- Model3D.faces - for each object, stores the vertices that make up each face and the material assigned to it
- Model3D.vertices - for each object, stores the coordinates, normals, UV, and later on bones and skin weights.
- Model3D.materials - stores materials' names, light properties, and texture(s).
- Model3D.frames - stores frame names, transformation matrix, contained meshes, and child/parent frames
- Model3D.bones - will store bone information (not sure what yet)
Each class will define its own set of parsing methods, using the methods that are defined in Model3D to access the data structures and update them. No class should access the data structures directly.
Editing models
Editing models
When the file has been parsed, you can choose to edit the data. Currently, some of the editing functions I've defined include
- UV flipping (horizontally and vertically)
- Triangulating faces (quads only)
- Inverting faces (which is basically flipping axis')
More will be added when I figure out how to do them, usually demand-based (like everything else I do)
Finally, you can export the data to a format of your choice (provided that it is supported).
As mentioned above, each class has its own set of printing methods. These will retrieve data from the data structures and export the object.
This design effectively separates formats from the engine itself.
New formats can be added by simply writing the proper parsing/printing functions and adding it to the engine.
I haven't figured out how to best implement this expansion idea.
Currently, the following formats are supported:
Import:
- smd (no bones)
- 32-bit .x (no bones)
- 64-bit .x (no bones)
- mqo
- obj (not all variations)
Export:
- mqo
No comments:
Post a Comment