Blender import template
Posted: Sat Aug 06, 2011 6:07 pm
I can write scripts in python, but I don't want to take the time to spend reading blender's API because I don't see myself doing much with blender.
I want something very intuitive that anyone with basic programming knowledge would be able to write working import scripts. This way, if file format specs are available, people have a better chance of doing it themselves (because the biggest roadblock is "how do I draw the model?") Chances are, if I am someone that is only interested in modeling, and don't really understand programming but have a very slight idea how it works, I'm not going to be motivated enough to learn blender scripting.
And it's not about being lazy, though in my case it is.
For those that would argue that it's up to the user to learn it themselves "if they really wanted it": have you ever programmed without using a single library that wasn't written by yourself? If you have, that's great, but is that very productive? Efficient? effective? Bug-free?
Requirements:
-the user does not need to know anything about the functions that load the model. We can assume the user is a skilled modeler and can use blender, but just doesn't know how to load a model cause that's "techy programming stuff".
-a set of functions should be available to allow the user to provide the data required to draw the model. The user should not need to think about how to store the data
For instance, if your Vertex object needs coords, normals, and texcoords, then write three separate functions like "add_coords", "add_normals", and "add_texcoords" that will take an arbitrary number of parameters and then load them into some data structure (ie: a list of lists maybe, or what you think would be most optimal). Then the internal function that will actually create the Vertex will grab the data from these lists, and the user only needs to say "these are my coords and my normals" and move on.
-works for versions that are probably in use the most, like 2.49 and 2.57, so people have a choice which they want to use.
Essentially, all the user needs to do is fill in a parser function and call the appropriate functions that will accept their data. The user can follow existing file specs to parse the file, and that is all that is required. Then anyone can write good blender importers.
Anyone up for it?
A general outline would look like
EDIT: thinking about it, you should probably place the parser function at the top so people don't have to scroll past all the stuff they don't need to know about.
I want something very intuitive that anyone with basic programming knowledge would be able to write working import scripts. This way, if file format specs are available, people have a better chance of doing it themselves (because the biggest roadblock is "how do I draw the model?") Chances are, if I am someone that is only interested in modeling, and don't really understand programming but have a very slight idea how it works, I'm not going to be motivated enough to learn blender scripting.
And it's not about being lazy, though in my case it is.
For those that would argue that it's up to the user to learn it themselves "if they really wanted it": have you ever programmed without using a single library that wasn't written by yourself? If you have, that's great, but is that very productive? Efficient? effective? Bug-free?
Requirements:
-the user does not need to know anything about the functions that load the model. We can assume the user is a skilled modeler and can use blender, but just doesn't know how to load a model cause that's "techy programming stuff".
-a set of functions should be available to allow the user to provide the data required to draw the model. The user should not need to think about how to store the data
For instance, if your Vertex object needs coords, normals, and texcoords, then write three separate functions like "add_coords", "add_normals", and "add_texcoords" that will take an arbitrary number of parameters and then load them into some data structure (ie: a list of lists maybe, or what you think would be most optimal). Then the internal function that will actually create the Vertex will grab the data from these lists, and the user only needs to say "these are my coords and my normals" and move on.
-works for versions that are probably in use the most, like 2.49 and 2.57, so people have a choice which they want to use.
Essentially, all the user needs to do is fill in a parser function and call the appropriate functions that will accept their data. The user can follow existing file specs to parse the file, and that is all that is required. Then anyone can write good blender importers.
Anyone up for it?
A general outline would look like
Code: Select all
#import stuff
...
#global declarations and stuff
...
#"private" things I don't need to know about that tells blender what to do
...
#functions that I will interface with to store the data without knowing the data structures
#efficiency is not important here, as having all of these extra interfaces rather than
#accessing the objects directly will definitely slow things down
def add_vertex(...)
'''SAMPLE: Appends a Vertex object to the list of vertices'''
...
#parser function wrapper (if necessary)
...
#parser function
#TO-DO - this is what the user will fill in