How to load a blender model?

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.
Post Reply
binford
Posts: 28
Joined: Tue Nov 14, 2006 10:32 am
Location: Munich

How to load a blender model?

Post by binford »

Hi Forum,

I spent days trying to load a blender model (I tried 3ds, obj, and directx), but I couldnt get It working properly. I spent the most time using .X cause it appears to me that most people use .X to load Blender models.

I used various DirectX exporters which have been posted in this forum. The result is more or less the same: The model loads without warnings/errors (i have to remove the ";;" in MeshMaterialList before, though), but it is screwed up.

This is a screenshot taken from my irrlicht app using the .X file:
Image

Exporting/Loading OBJ works slightly better, but for some reason the material isnt exported properly (there is no reference to the texture I used in the .mtl file). The lightning looks strange as well.
Image

The model I tried to use is this http://binford3000.de/tank.zip


Any ideas what might went wrong?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You might want to try out Irrlicht SVN (or wait some more until 1.2 is released). These versions fix several problems with mesh loaders.
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

WELL U DIDNT ASSIGN A TEXTURE. :wink:
binford
Posts: 28
Joined: Tue Nov 14, 2006 10:32 am
Location: Munich

Post by binford »

WELL U DIDNT ASSIGN A TEXTURE. Wink
Ok this is true for my obj file not for the .X file. With a texture applied it looks like this:
Image
Not really what I wished to see. Is there a way to achieve smoother shading?
and does someone know why the texture isnt applied? (the file is in the same folder as the mtl file)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Check the console output to see if Irrlicht couldnt find the texture to load it, or if it's not being loaded at all then just load it and apply it to the model yourself.

Also try out the gourad shading in setMaterialFlag, that may improve the shading but only works if you dont have a texture i believe.
Image Image Image
binford
Posts: 28
Joined: Tue Nov 14, 2006 10:32 am
Location: Munich

Post by binford »

the console tells me that everything was loaded successfuly. To make things easy I abandoned all textures. The result is - again - very disappointing. In Blender it looks like this:
Image

and in Irrlicht it looks like this:
Image

As you can see the shading looks strange. There seems to be no ambient lightning (even if I set the ambient color in the mtl file manually). And btw how can I get shaddows for my obj model?

It really drives my nuts. Is there no straight forward way for using blender & irrlicht?

Plz help, thx.

[EDIT: The OBJ and Blender files I used can be downloaded here]
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

firstly, you should set in blender as "smooth".Anyway I never remember if this engine could do smooth shading... (if so, apply the needed code for it...)

Did you make UVs and applied a texture to it?better in same folder than all files. Did you brought all mesh and texture files together for loading into irrlicht?

Also, remember, subdivided mode , be it as a modifier, or the like, not yet applied , is not exported in obj. Make it real first, or subdivide manually. And then export.

Imho your main problems are with normals.


Also, in blender, check you dont have double faces(overlapping faces), and once that, that you have made a ctrl n with all selected, which recalculates normals outside.

If theloader does not read ambient color, or whatever the setting in the mtl file, nothing to do...if the exporter wont carry it, even worse...
Finally making games again!
http://www.konekogames.com
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

one thing


in blender...you dont have yet smoothing groups or hard edges...but you can actually break the mesh to improve the shading. In static objects, is not bringing strong probs...

Do this way, in edit (tab key) mode, you select a bunch of faces, so knowing that the contour of the bunch, is gonna be the "hard edge" .. hit key "p" , and so , it ask u ...tell it "selected".

If you use a latest build, you can also use the feature of autosmooth, as finally is imho working as it should...just know that it is not real smooth groups, blender can only shade all solid or all smooth. Applying autosmooth or what I mentioned, you actually are breaking the mesh manually(first explanation) , or by angle threshold between every two adjacent faces (second). Second is fast, but less control.
Finally making games again!
http://www.konekogames.com
binford
Posts: 28
Joined: Tue Nov 14, 2006 10:32 am
Location: Munich

Post by binford »

ok with a few tweaks, it looks somewhat better. Its still not really convicing.
The tank looks a bit different cause I made changes to the blender model. This is NOT due to irrlichts loading mechanism
Image

btw, what I did to get this result is the following:
  • used irrlicht svn version
  • for the nice smooth sphere: In Blender in "Object Mode" -> "Editing"(F9) ->"Set Smooth"
  • modify the scene node like shown below:

Code: Select all

m_node->getMaterial(0).NormalizeNormals=true;
m_node->getMaterial(0).Shininess=20;
How do I make irrlicht calculate shaddows?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You can probably change the shading and brightness by fiddling with the ambient light (driver->setAmbientLight() i think), and also changing the parameters of the light in your scene. Also by messing around with the ambient, specular etc. parts of the node's material.
Image Image Image
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

vermeer wrote:one thing


in blender...you dont have yet smoothing groups or hard edges.
Hi :)
Im new around here but I have been using Blender for a few years now. I just wanted to point out that Blender DOES support smooth groups. Just select the faces you want smoothed in edit mode and press the Smooth button. In the .obj file the groups will be separated with "s 0" or s 1".

Being a beginner, I have only yet experimented with .obj's in Irrlicht, all exported from Blender. I have found that if the MTL file and images are in the same folder as the .obj, you do not even have to tell Irrlicht to load the texture, it does it automatically. Just carefully examine your exporting in options in Blender for the best results.

I am very much enjoying the engine and ecpecially the community here :)
Signature? I ain't signin nuthin!
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

er...
Hi Smile
Im new around here but I have been using Blender for a few years now. I just wanted to point out that Blender DOES support smooth groups. Just select the faces you want smoothed in edit mode and press the Smooth button. In the .obj file the groups will be separated with "s 0" or s 1".

ehm...solid or smooth. That is not smooth groups. Smooth groups, or normals hard-edges (vertex normals) must allow to set a hard edge or an smooth group, even inside a whole "smooth" chunk of faces. The workaround in blender is which I did mention: hit P, or some othe rmethod to actually break the mesh. As mesh is broken, smoothing is broken there.

This is not a pro way to do in games. You pick Wings, Maya, Max, XSI, (I did in all them, but is general well known facts ) and you can do real hard edges/smooth groups. Is a long, long petition from game ppl in blender forums, but imho, we may have it soon.

Often, exporting in a format for games, is essential to not break the mesh. Indeed, some of the game format exporters of blender can have issues with weights stuff if doing so.

Anyway, i can live with the workaround, but wont say it's wonderful ;) No way.

Being a beginner, I have only yet experimented with .obj's in Irrlicht, all exported from Blender.
hmm...blender has a large number of formats to export...usually all carries to using an older blender version, as often plugins werent updated, etc.

I have exported already from blender in:

md5(great!), ase(several probs or unsupported features), md2(quite good), md3(some probs, fixed with trial and error with script settings) , x (yeah, ha sits problems. But can be used perfectly with some pains), b3d(way to go), obj(no probs till date, tho sometimes I use other plugins, depends on needs), dxf(too poor, just used for some hi res mesh), vrml, vrml2(for when trying to provide a full all way round game editing system...), 3ds(is not a format of my likings anyway), oct (yeah, murphy rocks) , and more which cant remember now.


...each fro different needs I were having, tho my main use of blender is experimental/curiousity of game worker that likes to play around with free tools for a change when arrives home...

I have found that if the MTL file and images are in the same folder as the .obj, you do not even have to tell Irrlicht to load the texture, it
That is cause actually, the mtl's purpose is set the material settings: specularity, shininess, ambient color, base color, etc, etc, is all specified there... *and* ...the actual bitmap names for each channel. Ie alpha texture, diffuse channel texture, bumb texture...The thing is, like with all formats I handled for all 3d tools... how much supported in the whole set of features of a format -like OBJ, x, etc- by: a) the 3d package. b) the exporter that exports the file from there c) the loader used by the engine d) the engine itself. e) sometimes, if target platform or 3d card, is actually limitting using certain features. Etc.

So, as the route is...just the name of texture...that's why you saw it was taking it...because...as I read you...seems now irrlicht is taking in account the mtl file, which is explendid.

In my talks you would see I am just an artist. usually involved in game tools, and in game projects. Just not in any of irrlicht, other that some helping with some art tool/pipeline.
So i dont know ever which is the updated irrlict state.
does it automatically. Just carefully examine your exporting in options in Blender for the best results.

There's also as improtant how you deal with the mesh before.


Indeed:
@binford

hey. It seems...you need to do this for the too dark prob:

-Do select the base faces of hemisphere [the ones that are just in contact with the tank body) .This you can do selecting the object, hitting tab.then hitting ctrl+tab, choose "faces" . with ctrl+click, go selecting those below faces (I should have maybe tell u first to hide the tank body to do this, but the post would be too long, and surely u know how to do that(fast way: F7, in object buttons, set display the other object as "bounds" )] , then hit P. This way you break the mesh exactly by the base circle contour.(and there are very fast ways to select that base, dont go one by one if is hi res!(use B and drag, then invert selection))
As you are breaking there the mesh, it wont produce the extra darkening. This works so in any opengl/dx viewer, engine, viewport that I happened to know at least...But am no irrlicht coder.


And of course, extra wrecking can come on how you treat it in export, converts, and loader/engine.
I am very much enjoying the engine and ecpecially the community here Smile
You are welcome :)
Finally making games again!
http://www.konekogames.com
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

oh, and the too bright prob...I do a dirty trick, dunno if works in this engine...I set specular color to black.


It is the setting for reflecting the light what is wrecking it.
Finally making games again!
http://www.konekogames.com
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

I'm terrible for the names, but as far as I remember(i use it everyday, am just a bit of a disaster...), shininess is the size of the hi light, the shiny point. If u set it to wide, you make the look of a non shiny metal, but more dirty or wasted or simply less sharp hi light. But if you set specular to black, shininess should not affect as no specular really...
Finally making games again!
http://www.konekogames.com
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

As i dont know code, I dont know what this :

m_node->getMaterial(0).NormalizeNormals=true;


does.


if just respects the normals from Blender, way to go.


If it recalculate em, not so good.... ;)

If is the only way to have normals in Irrlicht, well, at least would be something :)
Finally making games again!
http://www.konekogames.com
Post Reply