CuteAlien wrote:Yeah, often all the default-materials are not doing exactly what you want and you have to write your own material shader.
Actually... I run into something even more interesting.
Code is as following, almost no difference from the original one. I test different parameters and find out something interesting, the results of rendering is depended on the scale of the model.
If the lighting is disabled (but added like in the code), the model looks fine and have no relation with the scale with the model.
But if the light is enabled, the render result of some part of the model will be related to the scale of the model (The larger scale factor, the darker the window part is). It is something really wired and I think it should never happen. (I have test the result of putting the light quite far away from the model, seems no difference.)
Would you mind to check what happened?
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
IrrlichtDevice *device =
createDevice(video::EDT_OPENGL, dimension2d<u32>(800, 600), 16,
false, true, true, 0);
if (!device)
return 1;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IAnimatedMesh* mesh = smgr->getMesh("../media/f14/f14d.obj");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, true);
node->setScale(core::vector3df(1,1,1));
node->setRotation(core::vector3df(0,135,0));
}
smgr->addLightSceneNode(0, core::vector3df(2000, 2000, 2000), video::SColorf(1.0f, 1.0f, 1.0f), 20000);
smgr->addLightSceneNode(0, core::vector3df(2000, 2000, -2000), video::SColorf(1.0f, 1.0f, 1.0f), 20000);
smgr->setAmbientLight(video::SColorf(0.3f, 0.3f, 0.3f));
scene::ICameraSceneNode* currentCamera = smgr->addCameraSceneNodeFPS();
currentCamera->setFarValue(20000.f);
currentCamera->setPosition(core::vector3df(0, 0, -70));
currentCamera->setTarget(core::vector3df(0, 30, 0));
while (device->run())
{
driver->beginScene(true, true, SColor(255, 100, 101, 140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
node->setMaterialFlag(EMF_LIGHTING, false);
node->setScale(core::vector3df(1,1,1));
node->setMaterialFlag(EMF_LIGHTING, true);
node->setScale(core::vector3df(2,2,2));
node->setMaterialFlag(EMF_LIGHTING, true);
node->setScale(core::vector3df(3,3,3));
node->setMaterialFlag(EMF_LIGHTING, true);
node->setScale(core::vector3df(3,3,3));
node->setMaterialFlag(EMF_LIGHTING, true);
node->setScale(core::vector3df(10,10,10));
node->setMaterialFlag(EMF_LIGHTING, true);
node->setScale(core::vector3df(10,10,10));
node->setMaterialFlag(EMF_LIGHTING, false);