[Solved] How to correctly load obj file.

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
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

[Solved] How to correctly load obj file.

Post by thanhle »

Hi all
I'm noob with material and stuff like that as I haven't look into it in Irrlicht.
I'm trying to load obj file exported from 3DSMax, but have some issue with it displaying correctly.
Can anyone show me how to do it correctly please.

Image
The mesh file is the path to "media/Robot/Kuko/Axis1.obj"

The code I used is given below:

IAnimatedMesh* mesh = smgr->getMesh(m_meshFile);
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);

scene::ITriangleSelector* selector = 0;
if (node)
{
node->setName(name);
node->setMaterialFlag(EMF_LIGHTING, false);

if (pickable == true)
{
selector = smgr->createTriangleSelector(node);
node->setID(ID_PICKABLE);
node->setTriangleSelector(selector);
selector->drop();
}
else
{
node->setID(ID_NOPICK);
}
}

Thanks
Thanh
Last edited by thanhle on Thu Nov 06, 2014 5:33 pm, edited 1 time in total.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: How to correctly load obj file.

Post by hendu »

The only reason you see those contours in Max is because of lighting, and you disabled lighting in irr.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: How to correctly load obj file.

Post by thanhle »

Thanks mate,
I'll start reading tutorial on light.

Regards
Thanh
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

[Solved] How to correctly load obj file.

Post by thanhle »

Now it looks much better. Although needs more tweaking to get it right.
Image

My current lights setting are:

Code: Select all

 
smgr->setAmbientLight(irr::video::SColorf(0.4, 0.4, 0.4));
 
scene::ILightSceneNode* light = smgr->addLightSceneNode();
irr::video::SLight &slight = light ->getLightData();
slight.Type = video::ELT_DIRECTIONAL;
slight.DiffuseColor = irr::video::SColorf(0.75, 0.75, 0.75, 1.0);
slight.AmbientColor = irr::video::SColorf(0.1, 0, 0.1, 1.0);
slight.SpecularColor = irr::video::SColorf(0.2, 0.2, 0.2, 1.0);
 
scene::ILightSceneNode* light2 = smgr->addLightSceneNode(0, vector3df( 0, 0, 0));
light2->setRotation(vector3df(120, 0, 0));
irr::video::SLight &slight2 = light2->getLightData();
slight2.Type = video::ELT_DIRECTIONAL;
slight2.DiffuseColor = irr::video::SColorf(0.75, 0.75, 0.75, 1.0);
slight2.AmbientColor = irr::video::SColorf(0.1, 0.1, 0.1, 1.0);
slight2.SpecularColor = irr::video::SColorf(0.3, 0.3, 0.3, 1.0);
Anyone have any better light values that we can share?

Thanks
thanh
Post Reply