generic questions about mesh creation

Hi,
in order to try and learn blender and Python a bit better I’ve been writing a Quake 3 BSP import script. Well, writing is overstating it … really I’ve been refactoring the existing script by bob holcomb which provides great BSP reading support but the final bit of creating the blender objects is not finished.

In a BSP, the main geomerty of all the non-moving objects is stored as one large (very large - 30,000 vertices or more) mesh. This mesh is broken into bsp_faces. Each bsp face is a convex object that has a single UV mapped texture and consists of a number of trianges (blender faces).
There are many bsp_faces in a bsp_model.
In the naive implementation of treating the world as a single blender mesh, the problem is that the texturing does not work. This is (I suspect) because a single blender mesh can be assigned hundreds of textures … and only 10 are supported in the GUI (or maybe 16 - whatever, it’s certainly less that the 150 or more that a BSP generally assigns).

So, it seems that the way to do this is to split the world mesh into a number of smaller meshes. My first thought is that each bsp_face should be a separate blender mesh. Then, each blender mesh only has one texture assigned to it. The question is how to do this in blender python.

My thought is as follows:

Create a an object and link this to the scene. For every bsp_face create a new blender mesh and link this to the object previously created.
Is this a good way to do it? Will it work? Is there a better way?

I’m still a bit unsure about the difference between linking objects and the child-parent relationship in blender. Any comments would be helpful.

Thanks,

Ian

ps: for those interested, the longer term goal is to be able to read a BSP and then export it as an Ogre .scene file using reimpell’s script. There’s no plan to be able to round-trip the BSP … it’s purely for import.

As nobody seemed to have any ideas, I went ahead and implemented what I thought best. The result is okay. I’m testing with a map from the western quake 3 mod.

The geometry imports and the 3d textured view looks good.

The one thing that is puzzling me is that the Render view is not right. Is this because UV mapping is not supported by the render window? It’s weird because the 3d view is fine in textured mode.

I’m looking for suggestions on how to improve the import…
You need to edit the script to tell it where your textures are. There isn’t a GUI yet.

Here it is:
http://www.ijbrown.net/blender/bsp_import.zip

I dont’ have any bsp models to play with [I’m not really looking for any either], but blender ought to not have a limit on the number of textures [no, not materials] assigned to faces

hit texface in the material buttons to use these textures and their uv coordiantes…

So, you mean that I should be able to assign just one material to each mesh and have lots of textures in that material?

Is there any sample code of anything similar?

Thanks for the reply,

Ian

If reimell is reading this thread … can you comment on what can be done to make the imported objects friendly to the Ogre export. i.e. will having one material with lots of textures give the Ogre exporter a problem?

The background is to be able to read in BSP files … edit / clean them up a bit in blender and then use the Ogre .scene export script to export them as .scenes.
Given that there are quite a few free (and by free I mean freely licenced) BSP / .map files available and it would seem to be a good source of test / example files for the Ogre .scene work.

Ian

If you mean TexFace material option with different image files for different faces, that should work. The exporter does only handle image textures assigned with uv coordinates.

wow this would be very cool. I wonder if the gamengine should be doing this kind of stuff… You would be using blender as a level editor almost.

There’s a new version available. Use the same link as in the first post.

Now, each mesh has only one material and only one texture. This means many more meshes, but the advantage is that the texture mapping now works correctly both in the texture 3d view and also in the redered view.

Also, breaking up the meshes like this makes it easier to put them together again for a .scene export.

please post and comments, problems etc…

Ian

ps: I’ve been testing with the maps from Western Quake3