model faces missing/wrong culling

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
MrGoodbytes
Posts: 2
Joined: Sun Mar 27, 2016 11:16 pm

model faces missing/wrong culling

Post by MrGoodbytes »

I have a model which looks fine in Blender, but when I try to use it in irrlicht some of the faces are gone. If I move inside the model, they reappear. I have tried setAutomaticCulling(EAC_OFF), but there is no difference.
The code I am using to load the model is this:

Code: Select all

IMesh *testm = g->scene->getMesh("model.obj");
IMeshSceneNode *test = g->scene->addMeshSceneNode(testm);
Any suggestions?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: model faces missing/wrong culling

Post by mongoose7 »

test->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);

The winding of your vertices is not correct, so you should render front-facing triangles AND back-facing triangles.
MrGoodbytes
Posts: 2
Joined: Sun Mar 27, 2016 11:16 pm

Re: model faces missing/wrong culling

Post by MrGoodbytes »

Thanks! Works perfectly now.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: model faces missing/wrong culling

Post by CuteAlien »

You can also fix it in blender by ensuring all normals go towards the outside of the model. Which is better for performance as you can then keep backface culling enabled in Irrlicht.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: model faces missing/wrong culling

Post by mongoose7 »

You know it has nothing to do with the normals, right?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: model faces missing/wrong culling

Post by CuteAlien »

I thought the winding order of vertices on export is set by the normal direction you use inside Blender. Or am I wrong there? I'm not much of a modeller, but that's how I remember it...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: model faces missing/wrong culling

Post by Foaly »

As far as I know the exporters in blender determine the index order based on the normals, as there is no way to set it explicitly in Blender.
So it has to do with the normals.
Post Reply