[SOLVED!] Polygon render order problem

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
bgsteffens
Posts: 39
Joined: Wed Oct 04, 2006 8:00 am

[SOLVED!] Polygon render order problem

Post by bgsteffens »

Hello all :)

I made a basic mesh of a house in Maya, exported to OBJ format, and loaded into Irrlicht with the following code:

Code: Select all

IAnimatedMesh* meshHouse = smgr->getMesh("house.obj");
IAnimatedMeshSceneNode* house = smgr->addAnimatedMeshSceneNode(meshHouse);
if(house)
{
	house->setMaterialFlag(EMF_LIGHTING, false);
}
As you can see below, the house seems to display correctly..
Image

But when viewed from the side or below..
Image

Download the evil mesh here

Any insight into the cause of this problem would be greatly appreciated. Thanks!
Last edited by bgsteffens on Sat Dec 09, 2006 11:13 pm, edited 1 time in total.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Turn the back face culling off, i think it's setMaterialFlag(EMF_BACK_FACE_CULLING, false);
Image Image Image
bgsteffens
Posts: 39
Joined: Wed Oct 04, 2006 8:00 am

Post by bgsteffens »

That just makes everything turn inside-out. O_O

With back-face culling set to false:
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Ok, now just after you load the mesh, but before you create a node with it, use the meshManipulator from the smgr to flip the surfaces of your model and that might fix it.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Better fix the model in your 3d editor.
bgsteffens
Posts: 39
Joined: Wed Oct 04, 2006 8:00 am

Post by bgsteffens »

Thanks for the replies, guys.

JP: After flipping the surfaces:
Image

hybrid: I did assume this was a problem with the model itself, not the code used to load it. Any insight into what the problem with the model could be? I know next-to-nothing about modelling and am only trying to understand it as it applies to game programming so that I can make basic testing meshes.

Thanks both of you :)
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

I know nothing about modeling myself, but is it looking like no matter where you view your model from it is "inside-out"? If this is the case, then see if you have an option in your modeling program about "flipping normals." In 3DS Max you can do this by applying a normal modifier and check/uncheck "flip normals." I'm assuming it would be done a similar way in any other modeling program. Hope this helps.
bgsteffens
Posts: 39
Joined: Wed Oct 04, 2006 8:00 am

Post by bgsteffens »

After flipping normals:

Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

as i was about to say on irc, it could be a transparency problem. try setting a solid material with setMaterial
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
bgsteffens
Posts: 39
Joined: Wed Oct 04, 2006 8:00 am

Post by bgsteffens »

Code: Select all

house->setMaterialType(EMT_SOLID);
FIXED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

bitplane, I love you =P
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

for future reference, the wrong material was set due to a bug in the MTL loader- if your .MTL file includes the line-

Code: Select all

Tf 1.0,1.0,1.0
then EMT_TRANSPARENT_VERTEX_ALPHA was set, this is now fixed in the latest revision.
if you're exporting non-transparent objects from Maya, either delete the line out of your MTL file, or use svn revision 335 or later :)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply