Blender importer [WIP]
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
Blender importer [WIP]
Yesterday I started to work on a blender importer for mesh files.
Mesh import for a single submesh and UVs are working.
the imported robot.mesh:
Edit: Permanent download address: http://cvs.sourceforge.net/viewcvs.py/* ... _import.py
or ogreaddons/blenderimporter in the ogre cvs.
Mesh import for a single submesh and UVs are working.
the imported robot.mesh:
Edit: Permanent download address: http://cvs.sourceforge.net/viewcvs.py/* ... _import.py
or ogreaddons/blenderimporter in the ogre cvs.
Last edited by haffax on Sat Aug 27, 2005 12:46 pm, edited 3 times in total.
- Clay
- OGRE Community Helper
- Posts: 518
- Joined: Wed Mar 17, 2004 4:14 am
- Contact:
- bana
- Greenskin
- Posts: 132
- Joined: Mon Aug 02, 2004 7:40 am
- Location: Austin, Texas
- Contact:
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
Ok. Got the first public release ready.
Now working:
* multiple submeshes (triangle list)
* uvs
* materials (textures only)
* vertex colours
Meshes that I know to not work:
* Meshes having multiple texture coordinate sets
* Meshes using a shared vertex buffer
* Meshes with submeshes given as triangle strip or triangle fan
Neither of these points is any difficult, but I just didn't have time to add them and I don't have test meshes for these.
So if anyone is interested in these features being implemented, I'd be happy to receive test meshes.
Anyway here is the script [EDIT]Use the download link in the first post.[/EDIT]
Note there are two options inside the script:
* IMPORT_SCALE_FACTOR: this scales the mesh with the given factor, default is 0.1
* IMPORT_OGREXMLCONVERTER: this is the path to your copy of the OgreXMLConverter, if given and valid, you can import meshes directly instead of converting them beforehand to mesh.xml files
Just copy the script into your .blender/scripts directory and restart blender. You should now have the option to import ogre meshes under File->Import. The importer expects the material script(s) and all used textures to be in the same directory as your mesh.
This is still a very early version, so your mesh might not work. If it doesn't I'd like to receive error reports, best with your meshes, or hints on what your meshes include (like multiple submeshes, with some of them containing vertex colours others not and such). And make sure to copy the error messages in the blender console window.
Another point: I didn't test the script with linux/mac, so it might fail. Error reports or patches are very welcome.
Anyway just try it out and report back.
Edit: Forgot to mention, that you need Python 2.3.x for it to work. After installing python create an environment variable called PYTHON that contains the full path to your python.exe ("C:\python23\python.exe" for the default installation destination).
Now working:
* multiple submeshes (triangle list)
* uvs
* materials (textures only)
* vertex colours
Meshes that I know to not work:
* Meshes having multiple texture coordinate sets
* Meshes using a shared vertex buffer
* Meshes with submeshes given as triangle strip or triangle fan
Neither of these points is any difficult, but I just didn't have time to add them and I don't have test meshes for these.
So if anyone is interested in these features being implemented, I'd be happy to receive test meshes.
Anyway here is the script [EDIT]Use the download link in the first post.[/EDIT]
Note there are two options inside the script:
* IMPORT_SCALE_FACTOR: this scales the mesh with the given factor, default is 0.1
* IMPORT_OGREXMLCONVERTER: this is the path to your copy of the OgreXMLConverter, if given and valid, you can import meshes directly instead of converting them beforehand to mesh.xml files
Just copy the script into your .blender/scripts directory and restart blender. You should now have the option to import ogre meshes under File->Import. The importer expects the material script(s) and all used textures to be in the same directory as your mesh.
This is still a very early version, so your mesh might not work. If it doesn't I'd like to receive error reports, best with your meshes, or hints on what your meshes include (like multiple submeshes, with some of them containing vertex colours others not and such). And make sure to copy the error messages in the blender console window.
Another point: I didn't test the script with linux/mac, so it might fail. Error reports or patches are very welcome.
Anyway just try it out and report back.
Edit: Forgot to mention, that you need Python 2.3.x for it to work. After installing python create an environment variable called PYTHON that contains the full path to your python.exe ("C:\python23\python.exe" for the default installation destination).
Last edited by haffax on Sat Aug 27, 2005 12:47 pm, edited 2 times in total.
-
- Greenskin
- Posts: 145
- Joined: Wed Jan 19, 2005 4:36 am
- Location: Arica, Chile
Three cheers! keep it up!
Having Blender as a free option for people to tweak Ogre meshes is a very important thing!
Having Blender as a free option for people to tweak Ogre meshes is a very important thing!
Looking to hire people working out of their home to do C++ Ogre programming. Blender artists also wanted. Looking for long-term relationships. PM on forums or contact via AIM or email Art@Arica3D.com
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
To set up an environment variable on WindowsXP right click on the "My Computer" icon on the desktop, choose Properties. In the dialog choose the tab "Extended" and here the button "environment". Under "system variables" click the "new" button and type PYTHON for the name and the path to and including the python.exe as value. Leave all the dialogs with the ok buttons. You have to restart Belnder for that to take effect.
I don't have an english Windows, so I don't know if the names are correct, they are just guesses.
I don't have an english Windows, so I don't know if the names are correct, they are just guesses.
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
Small update: some bugfixes and graceful handling of missing textures or materials.
with the bugfixes even my biggest testmesh with over 50 distinct textures loaded just fine: http://team-pantheon.de/~haffax/ruchin.jpg
download URL see first post.
with the bugfixes even my biggest testmesh with over 50 distinct textures loaded just fine: http://team-pantheon.de/~haffax/ruchin.jpg
download URL see first post.
Last edited by haffax on Sat Aug 27, 2005 12:48 pm, edited 1 time in total.
- StaticVoid
- Halfling
- Posts: 41
- Joined: Thu Jan 15, 2004 12:52 pm
- Location: UK
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
Rendering is indeed not supported right now, because I don't create any render materials right now. Last time I tested rendering was before I made the imported mesh a scene object. At that time the model was rendered, but without proper material. I'll have look at it this evening, because a lock-up should never happen here. That said, I can only test on Windows right now.
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
-
- OGRE Expert User
- Posts: 421
- Joined: Fri Jan 07, 2005 9:49 pm
- Location: UK
- x 2
- Contact:
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
-
- OGRE Expert User
- Posts: 421
- Joined: Fri Jan 07, 2005 9:49 pm
- Location: UK
- x 2
- Contact:
- alphageek
- Gnome
- Posts: 365
- Joined: Mon Jan 03, 2005 11:56 am
-
- OGRE Expert User
- Posts: 421
- Joined: Fri Jan 07, 2005 9:49 pm
- Location: UK
- x 2
- Contact:
@ Tanis : sorry i m 2 days later but here is the mesh i had promised to model :
lost fountain
*textures, .mesh, .xml & .material included
I made it quickly but i tried to use all that can make the importer fail
It s a FFEEFMG model (Free For Everybody Except For Microsoft Guys) so feel free to do what you want with, althought i doubt something can be done with it..
Good luck on the importer ( luck ? )
lost fountain
*textures, .mesh, .xml & .material included
I made it quickly but i tried to use all that can make the importer fail
It s a FFEEFMG model (Free For Everybody Except For Microsoft Guys) so feel free to do what you want with, althought i doubt something can be done with it..
Good luck on the importer ( luck ? )
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
-
- OGRE Expert User
- Posts: 421
- Joined: Fri Jan 07, 2005 9:49 pm
- Location: UK
- x 2
- Contact:
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
I just released a new version. The download link is shown in the first post of this thread. Tomorrow I will upload the script to ogreaddons/blenderimport in the Ogre CVS.
This new version now imports shared vertices and can handle meshes with multiple texture coordinate sets, but only the first set will be used, since Blender only supports one uv set.
I decided to gradually implement import of all features Blender and Ogre support. Namely skeleton and animations. It will take time though, since I cannot invest too much time in this project right now.
As always please report bugs/problems/suggestion about the importer in this thread.
This new version now imports shared vertices and can handle meshes with multiple texture coordinate sets, but only the first set will be used, since Blender only supports one uv set.
I decided to gradually implement import of all features Blender and Ogre support. Namely skeleton and animations. It will take time though, since I cannot invest too much time in this project right now.
As always please report bugs/problems/suggestion about the importer in this thread.
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
The script is now part of the ogreaddons. It can be found under ogreaddons/blenderimport
Or directly using the sf checkout script from here: http://cvs.sourceforge.net/viewcvs.py/* ... _import.py
Or directly using the sf checkout script from here: http://cvs.sourceforge.net/viewcvs.py/* ... _import.py
- discipline
- OGRE Community Helper
- Posts: 766
- Joined: Mon May 16, 2005 12:09 am
Haffax, I think it's great that you created this. I would definitely like to see it import animation as well.
I'm having trouble importing materials. I'm running under linux, with blender 2.36.
I copied ninja.*, Example.material, nskingr.jpg, robot.* and r2skin.jpg to a single directory.
Next, I import the mesh which loads just fine, minus the texture.
Browsing through your script, I added in some print lines and here's what I found out:
- The '\\' character doesn't work for linux as a path separator. You use it twice on lines 323 and 336. Changing this to '/' allows the following to happen.
- After doing the above, and inserting some print lines in collect_materials, I see it processes each material file and does find the "Example/Ninja" material.
- In CreateBlenderMesh in the transfer faces section material.getTexture() is successful.
- getTexture successfully loads nskingr.jpg on the first call, and does not on the second call (having already loaded it).
After this point, it gets into blender specific code that I didn't trace. After changing the path character it looks like the texture is loaded. However browsing through my blender interface, I don't see any textures in there, nothing was put on the ninja and only a grey untextured figure is rendered. Same thing with the robot, texture loads, but doesn't appear in blender. I get no errors from the script or interface.
I'm having trouble importing materials. I'm running under linux, with blender 2.36.
I copied ninja.*, Example.material, nskingr.jpg, robot.* and r2skin.jpg to a single directory.
Next, I import the mesh which loads just fine, minus the texture.
Browsing through your script, I added in some print lines and here's what I found out:
- The '\\' character doesn't work for linux as a path separator. You use it twice on lines 323 and 336. Changing this to '/' allows the following to happen.
- After doing the above, and inserting some print lines in collect_materials, I see it processes each material file and does find the "Example/Ninja" material.
- In CreateBlenderMesh in the transfer faces section material.getTexture() is successful.
- getTexture successfully loads nskingr.jpg on the first call, and does not on the second call (having already loaded it).
After this point, it gets into blender specific code that I didn't trace. After changing the path character it looks like the texture is loaded. However browsing through my blender interface, I don't see any textures in there, nothing was put on the ninja and only a grey untextured figure is rendered. Same thing with the robot, texture loads, but doesn't appear in blender. I get no errors from the script or interface.
Code: Select all
...
Material: /home/cory/devl/3d/blender/Example.material: Material #9
Texture: LEGS.jpg
Material: /home/cory/devl/3d/blender/Example.material: Examples/Fish
Texture: steelhead.png
Material: /home/cory/devl/3d/blender/Example.material: Examples/Ninja
Texture: nskingr.jpg
Material: /home/cory/devl/3d/blender/Example.material: Examples/Robot
Texture: r2skin.jpg
Material: /home/cory/devl/3d/blender/Example.material: Examples/GrassFloor
Texture: grass_1024.jpg
Material: /home/cory/devl/3d/blender/Example.material: Examples/GrassBlades
Texture: gras_02.png
Material: /home/cory/devl/3d/blender/Example.material: Examples/Rockwall
Texture: rockwall.tga
Material: /home/cory/devl/3d/blender/gingerbread.material: Gingerbread
Mesh with 0 vertices.
CreateBlenderMesh: Submesh material: Examples/Robot
CreateBlenderMesh: matched material
Submesh 0 with 295 vertices and 308 faces...
getTexture: Opening file: /home/cory/devl/3d/blender/r2skin.jpg
done.
- haffax
- OGRE Retired Moderator
- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 7
- Contact:
Hello discipline, thank you for the feedback.
Your proposed changes concerning the path seperator are already done on my local copy. Works fine under Windows too this way.
As for the texture, I just tried the Ninja mesh and it gets textured for me in the 3D View. I am working on the Material import (too little time lately )
Currently no render material is created, this is why the rendering output is grey and there is no mentioning of the texture in other places. I'm almost done with this part here. So expect a new version next week.
Aftwerwards I'll refactor a bit (much needed), put more logging output in and start skeleton import.
Your proposed changes concerning the path seperator are already done on my local copy. Works fine under Windows too this way.
As for the texture, I just tried the Ninja mesh and it gets textured for me in the 3D View. I am working on the Material import (too little time lately )
Currently no render material is created, this is why the rendering output is grey and there is no mentioning of the texture in other places. I'm almost done with this part here. So expect a new version next week.
Aftwerwards I'll refactor a bit (much needed), put more logging output in and start skeleton import.
-
- Bugbear
- Posts: 812
- Joined: Thu Dec 09, 2004 2:51 am
- x 42
Haffax really appreciate the work that both you and reimpell are doing on the blender import/export side of things.
I'm attempting to use your script as a basis for importing an Ogre skeleton and animation(not very sucessfully).
Looking at your script I don't quite understand why we need to loop through and append vertices for each submesh that uses shared vertices in CreateBlenderMesh. Shouldn't this only be done once?.
I checked this using Monster's racingcircuit mesh, with the script as is and modified to only append vertices on the first submesh.
On select remove doubles (original 102,202 are removed) and a modified version (4533 vertices are removed).
I'm attempting to use your script as a basis for importing an Ogre skeleton and animation(not very sucessfully).
Looking at your script I don't quite understand why we need to loop through and append vertices for each submesh that uses shared vertices in CreateBlenderMesh. Shouldn't this only be done once?.
I checked this using Monster's racingcircuit mesh, with the script as is and modified to only append vertices on the first submesh.
On select remove doubles (original 102,202 are removed) and a modified version (4533 vertices are removed).