Blender importer [WIP]

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.

Blender importer [WIP]

Postby haffax » Sun Apr 03, 2005 5:01 pm

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:
Image

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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby Clay » Sun Apr 03, 2005 6:08 pm

Awesome work. =)
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
 
Posts: 668
Kudos: 0
Joined: 17 Mar 2004

Postby bana » Sun Apr 03, 2005 10:58 pm

Wow, I was unaware that this was even feasible but looks like its working great :) Can't wait to see/use it myself.
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
User avatar
bana
Gremlin
 
Posts: 179
Kudos: 0
Joined: 02 Aug 2004
Location: Austin, Texas

Postby haffax » Sun Apr 03, 2005 11:19 pm

Thanks. :)
I have a busy week ahead now, so I don't know if I have time for the importer. But next weekend I will have time and fix some minor things and then publish it.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby spline » Tue Apr 05, 2005 8:56 am

that looks great, nice work
:lol:
spline
Gnoblar
 
Posts: 18
Kudos: 0
Joined: 27 Feb 2005
Location: Oxford, UK

Postby haffax » Sun Apr 10, 2005 1:35 am

Ok. Got the first public release ready.

Image
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. :D

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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby RoundSparrow » Sun Apr 10, 2005 2:49 am

Three cheers! keep it up!

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
RoundSparrow
Gremlin
 
Posts: 159
Kudos: 0
Joined: 19 Jan 2005
Location: Arica, Chile

Postby spline » Sun Apr 10, 2005 6:55 pm

this is great any chance you can explane how to set up a environment variable,thanx, keep up the great work :lol:
spline
Gnoblar
 
Posts: 18
Kudos: 0
Joined: 27 Feb 2005
Location: Oxford, UK

Postby haffax » Sun Apr 10, 2005 7:03 pm

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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby haffax » Mon Apr 11, 2005 4:40 pm

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.
Last edited by haffax on Sat Aug 27, 2005 12:48 pm, edited 1 time in total.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby StaticVoid » Wed Apr 13, 2005 11:42 am

Using blender 2.36, linux, latest importer & robot.mesh.xml. PC locks up when rendering imported model. I know the answer is probably don't render (as I don't really need to), but I thought it may be some indication of a problem with the imported model.
User avatar
StaticVoid
Halfling
 
Posts: 46
Kudos: 0
Joined: 15 Jan 2004
Location: UK

Postby haffax » Wed Apr 13, 2005 11:52 am

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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby haffax » Wed Apr 13, 2005 7:05 pm

StaticVoid, I cannot reproduce your problem. I was able to render models just fine with the build-in renderer and with yafray. But as said without texture atm, because the script doesn't create a render material.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby P » Fri May 06, 2005 5:26 pm

Nice work Tanis !

Did you plan to work on importing shared vertex buffer ? I need it so if you are not working on it I ll try :)

Thank you for this nice tool !
P
OGRE Expert User
OGRE Expert User
 
Posts: 431
Kudos: 1
Joined: 07 Jan 2005
Location: UK

Postby haffax » Fri May 06, 2005 8:35 pm

Thanks :)
P, give me a mesh with shared vertices to test, and I'll gladly do it. (Preferably with texture(s))
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby P » Sat May 07, 2005 2:53 am

I'll make and texture a quick mesh using several submeshes (probably 2) and several uv for them

I ll send you that tomorrow

Thank you :)
P
OGRE Expert User
OGRE Expert User
 
Posts: 431
Kudos: 1
Joined: 07 Jan 2005
Location: UK

Postby alphageek » Sat May 07, 2005 1:47 pm

Blender rules. Nice one.
Axiomatic: action-packed space shooter
TaskScheduler 0.3
User avatar
alphageek
Gnome
 
Posts: 372
Kudos: 0
Joined: 03 Jan 2005

Postby P » Mon May 09, 2005 9:45 am

@ 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
:lol:

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 ? )
P
OGRE Expert User
OGRE Expert User
 
Posts: 431
Kudos: 1
Joined: 07 Jan 2005
Location: UK

Postby haffax » Mon May 09, 2005 10:35 am

Thank you, P. This will proove very helpful. I will do it later this week. Maybe Thursday.

I don't know if this is a question of luck, though. Good speed! is the phrase, iirc. :)
Edit:(But LEO probably botched the translation, as good speed sounds stupid)
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby P » Mon May 09, 2005 10:57 am

i only meant luck is almost not involved into coding, i tried luck with cooking too but it s not working such as expected

Good coding ? maybe just simple as that !
P
OGRE Expert User
OGRE Expert User
 
Posts: 431
Kudos: 1
Joined: 07 Jan 2005
Location: UK

Postby haffax » Wed May 11, 2005 11:59 pm

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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby haffax » Fri May 13, 2005 12:03 am

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
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby discipline » Sun May 29, 2005 5:05 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.
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.
User avatar
discipline
OGRE Community Helper
OGRE Community Helper
 
Posts: 766
Kudos: 0
Joined: 16 May 2005
Location: San Diego, CA, USA

Postby haffax » Sun May 29, 2005 11:57 am

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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 5084
Kudos: 3
Joined: 18 Jun 2004
Location: Berlin, Germany

Postby dermont » Mon May 30, 2005 8:46 am

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).
dermont
Gnoll
 
Posts: 674
Kudos: 26
Joined: 09 Dec 2004
Location: Kuala Lumpur

Next

Return to Artists & Content Creators

Who is online

Users browsing this forum: No registered users and 4 guests