I have been attempting to build model importer scripts for video games, and I have been successful in figuring out the model format for several games, including several Spyro the Dragon games. Since I don’t know much about python, I was wondering if there exists a generic script that will import a simple file I compile that consists of just an array of N-floating point triplets, followed by an array, of M-vertex connection triplets. No headers, no normals, Just that the variables N-float and M-vertex will have to be entered manually in the, .py file. I know enough about hex editors and “find replace and copy”, to get the models into the array format I just mentioned, but python seems unreachable to me despite me, reading python’s scripting documents (I have no programming lanuage experience). So if any one can help, that would be great.
So, you have a number “n”, followed by “[f f f]” then “m” followed by “[v v v]”. N, M and V being integers and F being floating points?
How do you have this information? in a file? Or in a “text document” or what?
If you have it in a file, I can make a script to quickly convert it…
If you have python variables, it would also be simple, if you could just provide the file (in wichever format). It would be quite like this:
import BPyAddMesh import Blender vertexes = [list-of-vertexes-here] # e.g.: vertexes=[[0, 0, 0],[1,1,1],[2,2,2],[3,3,3]] faces = [list-of-faces-here] # e.g.: faces=[[0,1,2],[1,2,3],[2,3,0]] BPyAddMesh.add_mesh_simple('Imported-Mesh', vertexes, , faces)
Thank you for your help. I have the model info in a plain binary file, which beginning at byte 0 are all the floats in the whole file, followed by the all the face lists for the entire file. So the import script would have to be told three things, the name of the file, the number of vertexes and the number of faces. I am not good at explaining things, here is a link to a video I made, that shows a model I extracted in blender, but just the vertexes (using someone’s else script, and a hex editor). I need a script to do the faces, that would go under the import menu.
Here’s a quick-and-dirty (and untested) script for you to play with:
# We assume that the file have a 4-byte integer and 4-byte float. import BPyAddMesh import Blender import struct # Variables filename = "filename.dat" vertex_count = 99 faces_count = 99 # The program vertexes =  faces =  f = open(filename, "rb") for i in range(vertex_count): v =  for k in range(3): v.append(struct.pack("f", f.read(4)) vertexes.append(v) for i in range(vertex_count): v =  for k in range(3): v.append(struct.pack("I", f.read(4)) faces.append(v) BPyAddMesh.add_mesh_simple('Imported-Mesh', vertexes, , faces)
Change the variables
filename = “filename.dat”
vertex_count = 99
faces_count = 99
to your own values and run the script in blender.
Thank you very much Ismoura, I’ll be to post pictures, and exe/scripts of the model viewers/converters when they are done.