Problem exporting from Blender for Irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Cardinal4
Posts: 97
Joined: Sun Jun 11, 2006 1:20 am
Location: SG
Contact:

Problem exporting from Blender for Irrlicht

Post by Cardinal4 »

I tried exporting a model from Blender 2.44 for use in Irrlicht. I'm using IrrEdit 7.1 to check the results of the export.

The exporters I'm using are the built-in ones in the Blender interface, and the model I'm using taken from: http://www.katorlegaz.com/3d_models/tra ... /index.php
When I exported it as .3ds, nothing shows up in IrrEdit. When I exported it as .x, with Flip Norm and Recalculate Norm, IrrEdit shows a weird image instead:Image

This is my first time ever dealing with 3D models... If I can't even get a model exported, I really don't know what to do... :(
Sketches of a rambling mind
Still a long way on learning Irrlicht...
fireside
Posts: 158
Joined: Thu Dec 01, 2005 10:55 pm

Post by fireside »

I've only experimented with directX so far with Blender. Try this:
http://24.240.192.29/blender/xFileExporter242.zip
Turn off the flip z. I haven't tried textures with it, but animated objects get loaded into the mesh viewer. Try an obj file for static mesh.
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

The axis system of blender and irrlicht are different. If you got your model in blender you have to rotate it by 90° on the world-X-axis and apply scale and rotation by pressing Ctrl+A. Do this to all objects.
Z-axis in Blender = Y-axis in irrlicht and vice versa.
In the built in X-File exporter deselect everything (If you need animation you can enable it.). Especially the flip normals button. It seems not to work right, it's better to flip normals in blender. Now export it. It should look right now. You might have to flip the normals if it looks strange.
Cardinal4
Posts: 97
Joined: Sun Jun 11, 2006 1:20 am
Location: SG
Contact:

Post by Cardinal4 »

@vi-wer: I tried to rotate everything on the Blender scene by 90 about the x-axis, then exported it with nothing enabled but Bl.Normals, but still nothing showed up in IrrEdit. Oh, I forgot to mention I had this error:
Index count per face not equal to face material index count in x file.
Mesh without material found in x file.
Loaded mesh: ../Documents and Setting<deleted>
Polycount:0
Would not having a texture material make it invisible?

I did however manage to get my model into IrrEdit by another way. I exported from Blender as .obj with the default settings, imported into Wings3D and reexported as .3ds or .obj. It appears kinda alright in IrrEdit, except that the material lighting seems to be off. How would I enable it, it's currently looking so cel-shaded.
Image
Also, if I look underneath my model, it has transparent patches where I can see to the other side of the skybox?! Is it something wrong with the normals?
Sketches of a rambling mind
Still a long way on learning Irrlicht...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

There can be something wrong with the normal, but it is hard to see from the picture. The problem with the holes seen from the bottom is, that your model is not closed, some faces can be seen from either side. A quick-fix is to deactivate the EMF_BACK_FACE_CULLING material flag and make Irrlicht render polygons from both sides. The proper way is to close the mesh in Blender(or any other modelling program), especially when you plan to add shadows, they will probably look totally broken with your model.

As for the plastic look, what is your car's material? Reduce ambient, increase diffuse, add a light to the scene, if there is none yet. These are the basics, using shaders you can improve this and add a metallic effect etc..
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

Mesh without material found in x file.
Have you assigned a texture via UV Editor in Blender? (All faces need one.) The X-File exporter won't export Blender materials. But sometimes it doesn't export anything even if everything seems to be ok. :(
As long you don't need animation I would recommend to use the OGRE mesh exporter. It doesn't export animation but therefore blender materials. You would have to install/use OgreCommandLineTools in order to use models in irrlicht.
The proper way is to close the mesh in Blender
Enter edit mode, select all vertices and hit Rem Doubles (at least if the mesh looks already closed.). Then check the normals and recalculate them if it's necessary.
Cardinal4
Posts: 97
Joined: Sun Jun 11, 2006 1:20 am
Location: SG
Contact:

Post by Cardinal4 »

The model was coloured using vertex normals . Would that explain the lighting problem since there's no texture to speak of?

Backface culling didn't work; there was something really wrong with the curved surface of the car hood on the inside and I think I really need to cover it with some faces. Just a thought, would making two faces for a single 4 vertex plane, one for each side, solve the problem of not seeing something from the other side? I had the same problem when I made a custom BillboardSceneNode that did not rotate, and had to repeat the index buffer again to render the other side.

Sorry for more questions, but how would one know whether the mesh is closed or not, if the model is like really complex and overlapping with many meshes it's going to be hard to tell. Or worse, how to even know which is the inner side and which is the external side?

EDIT: I meant *coloured using vertex colours*.
Last edited by Cardinal4 on Sat Jul 28, 2007 3:35 pm, edited 1 time in total.
Sketches of a rambling mind
Still a long way on learning Irrlicht...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

Coloring with vertex normals doesn't make sense. Either you use vertex color, or vertex lighting, which among others uses the vertex normal to calculate the final color.

Having two faces one back and front on the thin places will resolve the hole-problem in your car. Though it can still have ugly shadows, but this is to be seen.

Blender has a few display options to help you here. In the Mesh Tools section (button window / edit panel) there is the option double sided. By default it is activated, deactivate it to see cull backfaces in blender, so that you can see the problem there too. Also in edit mode when you want to know where normals are directed, use the Draw Normals/Draw VNormals option.
Cardinal4
Posts: 97
Joined: Sun Jun 11, 2006 1:20 am
Location: SG
Contact:

Post by Cardinal4 »

Yay, the inner surfaces are now so glaringly obvious, which completely explains the invisible portions [backface culled].

Now I just have to learn UV mapping. =D Thanks for all the help guys.
Sketches of a rambling mind
Still a long way on learning Irrlicht...
Cardinal4
Posts: 97
Joined: Sun Jun 11, 2006 1:20 am
Location: SG
Contact:

Post by Cardinal4 »

Erm... another question I forgot to ask. When I exported an animation as .obj I get a separate .obj for each frame of animation. :shock: How would I load that into Irrlicht and make it into an animated mesh?
Sketches of a rambling mind
Still a long way on learning Irrlicht...
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

you can't (well perhaps you can, but not easily)
Irrlicht supports the following animated mesh formats: b3d, x, ms3d, md2 or md3
try exporting as one of those
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Cardinal4
Posts: 97
Joined: Sun Jun 11, 2006 1:20 am
Location: SG
Contact:

Post by Cardinal4 »

The b3d exporter doesn't seem to be working. I tried using it on this free model here: http://www.katorlegaz.com/3d_models/fur ... /index.php , but the texture was not visible inside of the mesh viewer... The .x exporter wasn't working well either => No texture and entire shelves were missing.

Anyone has got any idea on what's going wrong? I've been trying at this for hours and it still hasn't worked... :(

PS: Does anyone know why sometimes my mesh objects stick together one whole bunch at the center when using .x export?
Sketches of a rambling mind
Still a long way on learning Irrlicht...
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

I've had some success with most all the animation formats that Blender exports and Irrlicht accepts. My favorite has been .x

First, make sure you have the latest version of Blender, because I remember awhile back the bundled .x exporter didn't work very well, but the newer ones do.

http://www.blender.org/download/get-blender/

I found a small list of checks you can look at if you want.

1. To "attatch" the bones to the mesh, they must be the parent of the mesh.
2. All bones must have a parent bone, except of course for the "master" bone.
3. You MUST apply scale and rotation (Ctrl-A) to both the mesh AND the armature object before export.
4. .x does NOT support vertex animations (.md2 works well for that)
5. All animations MUST be baked before export, or your animations will not look like you expect.
6. All character actions must be recorded in the same Blender action (I can't seem to get multiple Blender actions to export to the same x file)
7. Remember to rewind to frame 1 before export.
8. I have to uncheck "Flip z" , and export as if exporting to a right-handed system. If not, my mesh appears inside out. (regardless of normals vector)
9. I do not recommend using "swap zy" button or even rotating in Blender at all. This can cause your recorded animations to go all weird (bones think they are moving forward when they are actually moving upward!) I just rotate in my code.

Im sure there is more I left out, but maybe this will help. I remember the frustration I had when first trying to to get .x files from Blender to Irrlicht.

Recently.....
I found a finished .b3d export script !

http://gandaldf.altervista.org/b3dexporter.htm

I've only tried it once, so I don't have any tips or anything, but it worked first try, and it was really simple, so this may be my new favorite :D

Edit: I forgot to say, the .x exporter will export everything to 0,0,0. You have to position it in you code, or in some level editor, or whatever.
Signature? I ain't signin nuthin!
virious
Posts: 11
Joined: Wed Aug 22, 2007 8:16 am
Location: Poland, Cracow

Post by virious »

I've got the same problems. Exporting to .X doesn't work properly, exporting to .3ds and to .b3d too. I've tried every type of settings and still nothing. I'm a little bit concerned, I mean how I will create levels for my game? :? .
Sorry for my english.
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

How exactly does b3d exporting not work? That's the format I always use. With this script.

That script may not export normals, if that's the problem I can give you a fix for it.
Post Reply