BZW exporter for blender, Released, complete!
BZW exporter for blender, Released, complete!
I made one.
Well hacked apart someone else's old code for a different exporter.
In short it replaces exporting from blender to .obj, and then running modeltool on the obj file.
It will:
1) export selected meshes with local vertex positions so you can add them to an object group
2) export all scene meshes with global vertex postions so the make a whole map
3) export all used untextured materials (specular emit deffuse ans shiny incl alpha, colours basically)
4) Allow individual face material definitions
5) export face images at textures
6) assign texcoords and index them in the mesh definition
7) define both bzw faces if the blender face is set to twoside (for hollow objects you drive into/through)
There isn't an importer and *I* won't be writing one.(edit, unless i get bored)
Any rotation transforms on objects have to be done in edit mode cos' it's to much (i'm to lazy) to impliment it in object mode, dx dy dz transforms are fine though (for scene export)
Textures have to be applied in the uv editor window NOT AS MATERIAL TEX
Materials must have unique names (not mat.001 mat.002 ma1.0030, or the routine for not exporting the same material twice can get confused (I'm not gonna change it, to costly to impliment, see above comment)
Here's a screenie of a simple world exhibiting most of the features of the exporter.
Notes:
Please don't turn this thread in to a blender tutorial, there are plenty of those allready
This is a python script for blender, find your blah/blah/blender/scripts folder and stick it in there, you'll get an option to export to bzw in the file/export menu.
Before someone asks it won't work in wings, there is one for that allready.
AFAIK it will work with windoze but I'll have to check the import and exit protocols first
Before you run the script, open it up in an editor and change http://www.teppic.homelinux.net/ for the host you use for textures.
TODO:
If I can be bothered, maybe some implimentation of shootthrough and drivethrough for faces
Use specific objects (not meshes) to define other world classes (ground texture, server variables, world weapons, bases, teleporters and links, physics drivers etc)
I think that about covers it.
EDIT:This post is old, read the README for instructions. Exporter and tools
Updated see below (the last edited thingy).
Well hacked apart someone else's old code for a different exporter.
In short it replaces exporting from blender to .obj, and then running modeltool on the obj file.
It will:
1) export selected meshes with local vertex positions so you can add them to an object group
2) export all scene meshes with global vertex postions so the make a whole map
3) export all used untextured materials (specular emit deffuse ans shiny incl alpha, colours basically)
4) Allow individual face material definitions
5) export face images at textures
6) assign texcoords and index them in the mesh definition
7) define both bzw faces if the blender face is set to twoside (for hollow objects you drive into/through)
There isn't an importer and *I* won't be writing one.(edit, unless i get bored)
Any rotation transforms on objects have to be done in edit mode cos' it's to much (i'm to lazy) to impliment it in object mode, dx dy dz transforms are fine though (for scene export)
Textures have to be applied in the uv editor window NOT AS MATERIAL TEX
Materials must have unique names (not mat.001 mat.002 ma1.0030, or the routine for not exporting the same material twice can get confused (I'm not gonna change it, to costly to impliment, see above comment)
Here's a screenie of a simple world exhibiting most of the features of the exporter.
Notes:
Please don't turn this thread in to a blender tutorial, there are plenty of those allready
This is a python script for blender, find your blah/blah/blender/scripts folder and stick it in there, you'll get an option to export to bzw in the file/export menu.
Before someone asks it won't work in wings, there is one for that allready.
AFAIK it will work with windoze but I'll have to check the import and exit protocols first
Before you run the script, open it up in an editor and change http://www.teppic.homelinux.net/ for the host you use for textures.
TODO:
If I can be bothered, maybe some implimentation of shootthrough and drivethrough for faces
Use specific objects (not meshes) to define other world classes (ground texture, server variables, world weapons, bases, teleporters and links, physics drivers etc)
I think that about covers it.
EDIT:This post is old, read the README for instructions. Exporter and tools
Updated see below (the last edited thingy).
Last edited by Teppic on Sat Dec 24, 2005 9:26 am, edited 7 times in total.
I am a busy boy, the link above is now to version 1.1beta.
Extra funtions include
Setting a mesh as a parent to an empty object(s) will export said mesh as a group definition, then all the child empty objects as group implimentaions with the empty object(s) postion and z axis rotaion.
No longer exits on faces with no assigned texture, just warns.
After the main header, it will insert a blender text object named prefix if it exists, so general map parameters can be set, i.e. options groundtexture definitions, or even a 'base' bzw map with existing bzw objects.
As above, if a text object named suffix exists this will be appended to the file. Useful for world weapon definition, bases, basically all the stuff that isn't implemented yet.
DON'T have empty lines in the pre/suffix texts for now.
Oh, the extra code for windows is under the import math line (49)and on line 138 under the 'print Finished BZWXport BLAH BLAH' line.
Extra funtions include
Setting a mesh as a parent to an empty object(s) will export said mesh as a group definition, then all the child empty objects as group implimentaions with the empty object(s) postion and z axis rotaion.
No longer exits on faces with no assigned texture, just warns.
After the main header, it will insert a blender text object named prefix if it exists, so general map parameters can be set, i.e. options groundtexture definitions, or even a 'base' bzw map with existing bzw objects.
As above, if a text object named suffix exists this will be appended to the file. Useful for world weapon definition, bases, basically all the stuff that isn't implemented yet.
DON'T have empty lines in the pre/suffix texts for now.
Oh, the extra code for windows is
Code: Select all
import sys
Code: Select all
sys.stdout.flush()
Last edited by Teppic on Thu Nov 17, 2005 9:26 pm, edited 1 time in total.
- Spazzy McGee
- Sergeant Major
- Posts: 1405
- Joined: Mon Mar 21, 2005 4:59 pm
- Location: Planet MoFo, Sheffield Division; United Kingdom
- RPG
- Lieutenant, Junior Grade
- Posts: 2015
- Joined: Fri Sep 17, 2004 2:37 am
- Location: Chicago, Illinois
- Contact:
I would say Blender is more advanced, and it has the capability of doing animations, but it comes at a great price: an easy user interface.Spazzy Mcgee wrote:is blender more advanced than wings then? i have never tried blender.
You'd need to spend hours with the Blender UI to figure out how to do the simplist of things.
Yes blender is much more advanced.
Also another update to the script, objects that are present in the second layer will have the shootthrough attribute set, objects that are present in the third layer will have the drivethrough attribute set. Obviously objects in both will have both attributes set.
Next, world weapons........
Also another update to the script, objects that are present in the second layer will have the shootthrough attribute set, objects that are present in the third layer will have the drivethrough attribute set. Obviously objects in both will have both attributes set.
Next, world weapons........
Just do a couple of those video tutorials, once you know the interface it is very quick to use.RPG wrote: I would say Blender is more advanced, and it has the capability of doing animations, but it comes at a great price: an easy user interface.
You'd need to spend hours with the Blender UI to figure out how to do the simplist of things.
I finished implementing export of bases, world weapons, transporters, links and zones today.
The GUI for setting the properties of objects is currently about 1/3 done, dealing with bases and w/weapons so far. I feel the whole project should be working completely by next weekend. If there are any beta testers who would like to try and break it let me know. I've coded about 2000 lines of working code in 4 days, and can't stop thinking python, goToBed(self.me,now).
The GUI for setting the properties of objects is currently about 1/3 done, dealing with bases and w/weapons so far. I feel the whole project should be working completely by next weekend. If there are any beta testers who would like to try and break it let me know. I've coded about 2000 lines of working code in 4 days, and can't stop thinking python, goToBed(self.me,now).
All done. This is a fully featured .bzw file exporter for blender.
Try it out, read the README and off you go...
EDITED: use the link at the bottom of the first post.
Try it out, read the README and off you go...
EDITED: use the link at the bottom of the first post.
Last edited by Teppic on Sat Dec 24, 2005 9:22 am, edited 1 time in total.
- Saturos
- Art Master General
- Posts: 1111
- Joined: Mon Apr 19, 2004 2:48 pm
- Location: Berlin/Germany
- Contact:
Everytime I try to export my scene via bzwexporter I get a "python script error"... I have blender 2.37.
Saturos ([phagozytose] : www.phago.de)
Post the error, line no. and OS, it may be something simple.
If not post the blend file too.
Make sure the default scrpits path (python dir) in the user setup is correct.
EDIT:
Sorry, run blender from a terminal with the -window switch, then set the terminal to ontop, that way you can read all the error outputs.
If not post the blend file too.
Make sure the default scrpits path (python dir) in the user setup is correct.
EDIT:
Sorry, run blender from a terminal with the -window switch, then set the terminal to ontop, that way you can read all the error outputs.
- Saturos
- Art Master General
- Posts: 1111
- Joined: Mon Apr 19, 2004 2:48 pm
- Location: Berlin/Germany
- Contact:
Seems to be a problem with my blender...
OS is SuSE 9.3 with Linux 2.6.Saturos@linux:~> /home/Saturos/Desktop/Saturos/blender-2.37/blender -window
Using Python version 2.3
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
No installed Python found.
Only built-in modules are available. Some scripts may not run.
Continuing happily.
Traceback (most recent call last):
File "<string>", line 85, in ?
ImportError: No module named math
Saved session recovery to /tmp/quit.blend
Blender quit
Saturos@linux:~>
Saturos ([phagozytose] : www.phago.de)
OK, math is the only non blender module imported, and pi is the only variable called from it, so in bzwXport.py changeto
Then do a find and replace on any 'math.pi' to change it to 'math_pi'
That should sort it out.
If it works tell me and I'll change it in the next beta release.
All this said just installing python should do the trick too, what happens if you type python on a command line?
Code: Select all
import math
Code: Select all
math_pi=3.14159265359
That should sort it out.
If it works tell me and I'll change it in the next beta release.
All this said just installing python should do the trick too, what happens if you type python on a command line?
- Saturos
- Art Master General
- Posts: 1111
- Joined: Mon Apr 19, 2004 2:48 pm
- Location: Berlin/Germany
- Contact:
Yes, it works... thank you!
Everything seems to be a little small though. And half-stuck in the ground. Maybe I just have to get used to it.
Everything seems to be a little small though. And half-stuck in the ground. Maybe I just have to get used to it.
Saturos ([phagozytose] : www.phago.de)
Blenders x-y plane is the ground in bzflag, make sure no vertices are below z=0. I didn't make the exporter do any scaling either so if you add a cube a 0,0,0 it will be one unit in each direction, then if you move the bottom vertices so there z=0, the exported cube will be the eqivalent to a
While your getting used to the scale, press shift:c, 7, add a plane, scale in edit mode to 400, and that will represent the worlds floor.
I'm gonna add the routines to allow scaling in object mode for the next beta release, along with loosing the use of the python math library, and a 'filp normals on export' function to bzwtoolkit.
I'm also going to include a sample .blend file creating a simple ctf world with a couple of tele's etc.
Code: Select all
box
position 0 0 0
size 1 1 1
rotation 0
end
I'm gonna add the routines to allow scaling in object mode for the next beta release, along with loosing the use of the python math library, and a 'filp normals on export' function to bzwtoolkit.
I'm also going to include a sample .blend file creating a simple ctf world with a couple of tele's etc.
actualy if it REALY is one unit in each dir ( + and - ) then it would be
in bzflag ( totaling 2 units wide in each axis ).
Z is handled difrent from X and Y in bzflag. Z is distance from bottom to top, X and Y are distance from center to each +- edge, so to make a cube the Z value needs to be 2x the X and Y.
Code: Select all
size 1 1 2
Z is handled difrent from X and Y in bzflag. Z is distance from bottom to top, X and Y are distance from center to each +- edge, so to make a cube the Z value needs to be 2x the X and Y.
JeffM
JeffM2501 wrote:actualy if it REALY is one unit in each dir ( + and - ) then it would bein bzflag ( totaling 2 units wide in each axis ).Code: Select all
size 1 1 2
Z is handled difrent from X and Y in bzflag. Z is distance from bottom to top, X and Y are distance from center to each +- edge, so to make a cube the Z value needs to be 2x the X and Y.
Teppic was right wrote:move the bottom vertices so there z=0
Beta 4 now ready.
Added:
Option to flip face normals on export
Different twosided method
Physics drivers and linking
Material export upgrades
Option to export face vertex normals(for nice lighting)
Removed the indentation in the bzw file(saves d/l time for clients)
Smoothbounce method
sample.blend and textures added to the archive
Updated README
Well that about does it...
EDITED: use link at bottom of first post.
Added:
Option to flip face normals on export
Different twosided method
Physics drivers and linking
Material export upgrades
Option to export face vertex normals(for nice lighting)
Removed the indentation in the bzw file(saves d/l time for clients)
Smoothbounce method
sample.blend and textures added to the archive
Updated README
Well that about does it...
EDITED: use link at bottom of first post.
I've been having some problems with this (forgive me if I sound ignorant)
I am very familiar with Blender and I can model fairly well.
Scale is my problem.
I have the latest with the importer. If I import a map just to test, it appears so large compared to the typical scale of thing in Blender, that it is unrealistic to try to model a map sucessfully.
Is there either
1. A feature in Blender to change modelling scale.
2. A setting on the exporter to scale things up a bit.
or
1. Am I just doing something extremely dumb?
-Raytek2
I am very familiar with Blender and I can model fairly well.
Scale is my problem.
I have the latest with the importer. If I import a map just to test, it appears so large compared to the typical scale of thing in Blender, that it is unrealistic to try to model a map sucessfully.
Is there either
1. A feature in Blender to change modelling scale.
2. A setting on the exporter to scale things up a bit.
or
1. Am I just doing something extremely dumb?
-Raytek2
In blender, try increasing: View -> View Properties -> Clip End.
Unfortunately they've got it limited to 1000 (at least in blender 2.41).
There might be a way to get around that limit via config files, but I
haven't found it (or really looked for it, as I prefer wings3d for doing
most of my modelling, using blender only when necessary).
It would also be nice for the plugin to provide import/export scales.
Unfortunately they've got it limited to 1000 (at least in blender 2.41).
There might be a way to get around that limit via config files, but I
haven't found it (or really looked for it, as I prefer wings3d for doing
most of my modelling, using blender only when necessary).
It would also be nice for the plugin to provide import/export scales.
If you have trouble navigating around a large scene in blender you have two choices
1:- mess with the settings (camera lens size and end clipping) and learn the shortcuts for re-center etc
2:- Be aware that the exporter works on a 1 to 1 scale, build everything to 1/10, center the cursor, scale around it by 10 ( . a Shift-c c s 10 ent )
Blenders base grid (in free rotation) is about 30x30, this doesn't equate to any sensible factor for import/export scaling, and would just complicate simple arithmetic when working out object placement, hence the decision to keep the scale as 1 to 1.
1:- mess with the settings (camera lens size and end clipping) and learn the shortcuts for re-center etc
2:- Be aware that the exporter works on a 1 to 1 scale, build everything to 1/10, center the cursor, scale around it by 10 ( . a Shift-c c s 10 ent )
Blenders base grid (in free rotation) is about 30x30, this doesn't equate to any sensible factor for import/export scaling, and would just complicate simple arithmetic when working out object placement, hence the decision to keep the scale as 1 to 1.