hello acki, thank your test. I get a small step forward. I change the addLightSceneNode's argument, and use a md2 model, then I can see the lighting effect. But I still can't see the lighting effect on PIN model. I think the specific point is that it is a MeshSceneNode.
Can you get lighting effect from MeshSceneNode?
Code: Select all
int main()
{
IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;
if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 128);
if (node)
node->setPosition(core::vector3df(-1350,-130,-1400));
// add pins
scene::IAnimatedMesh* aPinMesh = smgr->getMesh("../../media/pin.x");
core::vector3df aGroupPos(20,-30,0);
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < i; j++)
{
scene::ISceneNode* aPinSceneNode = smgr->addMeshSceneNode(aPinMesh->getMesh(0));
aPinSceneNode->setScale(core::vector3df(30, 30, 30));
aPinSceneNode->setRotation(core::vector3df(0, 0, 0));
aPinSceneNode->setPosition(aGroupPos + core::vector3df(-j*12.0f, -0, 0.0f + i*12.0f));
aPinSceneNode->setMaterialType(video::EMT_SOLID);
aPinSceneNode->setMaterialFlag(video::EMF_LIGHTING, true);
}
}
video::SMaterial material;
material.setTexture(0, driver->getTexture("../../media/faerie2.bmp"));
material.Lighting = true;
scene::IAnimatedMeshSceneNode* fnode = 0;
scene::IAnimatedMesh* faerie = smgr->getMesh("../../media/faerie.md2");
if (faerie)
{
fnode = smgr->addAnimatedMeshSceneNode(faerie);
fnode->setPosition(core::vector3df(-20,-30,12));
fnode->setMD2Animation(scene::EMAT_RUN);
fnode->getMaterial(0) = material;
}
scene::ICameraSceneNode* iCameraSceneNode = smgr->addCameraSceneNodeFPS();
iCameraSceneNode->setRotation(core::vector3df(20.833364f, -14.875068f, 0.000000f));
iCameraSceneNode->setPosition(core::vector3df(53.800972f, 23.301916f, -174.089157f));
// add light
scene::ILightSceneNode* light = smgr->addLightSceneNode(0,
core::vector3df(0, 30, 0),
video::SColorf(1.0f, 1.0f, 1.0f),
600);
scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode(light);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
bill->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZBUFFER, false);
bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
I also post the pin.x file.
----------------------------------------
xof 0303txt 0032
// DirectX - from MilkShape3D
Frame pinFrame
{
FrameTransformMatrix
{
1.000000,0.000000,0.000000,0.000000,
0.000000,1.000000,0.000000,0.000000,
0.000000,0.000000,1.000000,0.000000,
0.000000,0.000000,0.000000,1.000000;;
}
Mesh pinMesh
{
89;
0.239091;-1.270630;0.000000;,
0.167662;-1.270630;-0.176149;,
-0.004783;-1.270630;0.000000;,
0.158660;1.872034;0.000000;,
-0.004783;1.948957;0.000000;,
0.110788;1.872034;-0.115572;,
0.239091;-1.270630;0.000000;,
0.336936;-0.943240;0.000000;,
0.167662;-1.270630;-0.176149;,
0.236848;-0.943240;-0.241632;,
0.497591;-0.335459;0.000000;,
0.350449;-0.335459;-0.361588;,
0.417092;0.231505;0.000000;,
0.293528;0.231505;-0.298311;,
0.205694;0.818168;0.000000;,
0.146594;0.818168;-0.142681;,
0.228114;1.309533;0.000000;,
0.162447;1.309533;-0.158534;,
0.272009;1.692469;0.000000;,
0.190938;1.692469;-0.195722;,
0.110788;1.872034;-0.115572;,
-0.004783;-1.270630;-0.249113;,
-0.004783;1.872034;-0.163443;,
-0.004783;-0.943240;-0.341719;,
-0.004783;-1.270630;-0.249113;,
-0.004783;-0.335459;-0.511362;,
-0.004783;0.231505;-0.421875;,
0.003912;0.818168;-0.201781;,
0.003912;1.309533;-0.224202;,
-0.004783;1.692469;-0.276792;,
-0.004783;1.872034;-0.163443;,
-0.177228;-1.270630;-0.176149;,
-0.120355;1.872034;-0.115572;,
-0.177228;-1.270630;-0.176149;,
-0.246415;-0.943240;-0.241632;,
-0.360015;-0.335459;-0.361588;,
-0.303094;0.231505;-0.298311;,
-0.138769;0.818168;-0.142681;,
-0.154622;1.309533;-0.158534;,
-0.200505;1.692469;-0.195722;,
-0.120355;1.872034;-0.115572;,
-0.248657;-1.270630;-0.000000;,
-0.168226;1.872034;-0.000000;,
-0.346502;-0.943240;-0.000000;,
-0.248657;-1.270630;-0.000000;,
-0.507157;-0.335459;-0.000000;,
-0.426658;0.231505;-0.000000;,
-0.197869;0.818168;-0.000000;,
-0.220289;1.309533;-0.000000;,
-0.281575;1.692469;-0.000000;,
-0.168226;1.872034;-0.000000;,
-0.177228;-1.270630;0.176149;,
-0.120355;1.872034;0.115572;,
-0.177228;-1.270630;0.176149;,
-0.246415;-0.943240;0.241632;,
-0.360015;-0.335459;0.361588;,
-0.303094;0.231505;0.298311;,
-0.138769;0.818168;0.142681;,
-0.154622;1.309533;0.158534;,
-0.200505;1.692469;0.195722;,
-0.120355;1.872034;0.115572;,
-0.004783;-1.270630;0.249113;,
-0.004783;1.872034;0.163443;,
-0.004783;-0.943240;0.341719;,
-0.004783;-1.270630;0.249113;,
-0.004783;-0.335459;0.511362;,
-0.004783;0.231505;0.421875;,
0.003912;0.818168;0.201781;,
0.003912;1.309533;0.224202;,
-0.004783;1.692469;0.276792;,
-0.004783;1.872034;0.163443;,
0.167662;-1.270630;0.176149;,
0.110788;1.872034;0.115572;,
0.167662;-1.270630;0.176149;,
0.236848;-0.943240;0.241632;,
0.350449;-0.335459;0.361588;,
0.293528;0.231505;0.298311;,
0.146594;0.818168;0.142681;,
0.162447;1.309533;0.158534;,
0.190938;1.692469;0.195722;,
0.110788;1.872034;0.115572;,
0.336936;-0.943240;0.000000;,
0.239091;-1.270630;0.000000;,
0.497591;-0.335459;0.000000;,
0.417092;0.231505;0.000000;,
0.205694;0.818168;0.000000;,
0.228114;1.309533;0.000000;,
0.272009;1.692469;0.000000;,
0.158660;1.872034;0.000000;;
128;
3;0,2,1;,
3;3,5,4;,
3;6,8,7;,
3;7,8,9;,
3;7,11,10;,
3;7,9,11;,
3;10,11,12;,
3;12,11,13;,
3;12,15,14;,
3;12,13,15;,
3;14,15,16;,
3;16,15,17;,
3;16,19,18;,
3;16,17,19;,
3;18,19,3;,
3;3,19,20;,
3;1,2,21;,
3;5,22,4;,
3;8,23,9;,
3;8,24,23;,
3;9,23,11;,
3;11,23,25;,
3;11,26,13;,
3;11,25,26;,
3;13,26,15;,
3;15,26,27;,
3;15,28,17;,
3;15,27,28;,
3;17,28,19;,
3;19,28,29;,
3;19,30,20;,
3;19,29,30;,
3;21,2,31;,
3;22,32,4;,
3;24,33,23;,
3;23,33,34;,
3;23,35,25;,
3;23,34,35;,
3;25,35,26;,
3;26,35,36;,
3;26,37,27;,
3;26,36,37;,
3;27,37,28;,
3;28,37,38;,
3;28,39,29;,
3;28,38,39;,
3;29,39,30;,
3;30,39,40;,
3;31,2,41;,
3;32,42,4;,
3;33,43,34;,
3;33,44,43;,
3;34,43,35;,
3;35,43,45;,
3;35,46,36;,
3;35,45,46;,
3;36,46,37;,
3;37,46,47;,
3;37,48,38;,
3;37,47,48;,
3;38,48,39;,
3;39,48,49;,
3;39,50,40;,
3;39,49,50;,
3;41,2,51;,
3;42,52,4;,
3;44,53,43;,
3;43,53,54;,
3;43,55,45;,
3;43,54,55;,
3;45,55,46;,
3;46,55,56;,
3;46,57,47;,
3;46,56,57;,
3;47,57,48;,
3;48,57,58;,
3;48,59,49;,
3;48,58,59;,
3;49,59,50;,
3;50,59,60;,
3;51,2,61;,
3;52,62,4;,
3;53,63,54;,
3;53,64,63;,
3;54,63,55;,
3;55,63,65;,
3;55,66,56;,
3;55,65,66;,
3;56,66,57;,
3;57,66,67;,
3;57,68,58;,
3;57,67,68;,
3;58,68,59;,
3;59,68,69;,
3;59,70,60;,
3;59,69,70;,
3;61,2,71;,
3;62,72,4;,
3;64,73,63;,
3;63,73,74;,
3;63,75,65;,
3;63,74,75;,
3;65,75,66;,
3;66,75,76;,
3;66,77,67;,
3;66,76,77;,
3;67,77,68;,
3;68,77,78;,
3;68,79,69;,
3;68,78,79;,
3;69,79,70;,
3;70,79,80;,
3;71,2,0;,
3;72,3,4;,
3;73,81,74;,
3;73,82,81;,
3;74,81,75;,
3;75,81,83;,
3;75,84,76;,
3;75,83,84;,
3;76,84,77;,
3;77,84,85;,
3;77,86,78;,
3;77,85,86;,
3;78,86,79;,
3;79,86,87;,
3;79,88,80;,
3;79,87,88;;
MeshNormals
{
66;
0.576166;-0.817333;0.000000;,
0.540144;-0.648203;-0.536729;,
0.000000;-1.000000;0.000000;,
0.727902;0.685681;0.000000;,
0.000000;1.000000;-0.000000;,
0.464976;0.753388;-0.464976;,
0.962599;-0.270931;-0.000000;,
0.680680;-0.270764;-0.680707;,
0.998259;-0.058986;0.000000;,
0.708355;-0.058587;-0.703421;,
0.970168;0.242435;-0.000000;,
0.685423;0.247016;-0.684966;,
0.988628;0.150383;0.000000;,
0.699028;0.152303;-0.698687;,
0.996812;-0.079792;-0.000000;,
0.704762;-0.083061;-0.704564;,
0.974107;0.226088;0.000000;,
0.689418;0.222914;-0.689211;,
0.000000;-0.814698;-0.579886;,
-0.000000;0.685681;-0.727902;,
0.000000;-0.270589;-0.962695;,
0.000000;-0.058188;-0.998306;,
0.000344;0.254213;-0.967148;,
0.000349;0.156920;-0.987611;,
0.000223;-0.090935;-0.995857;,
0.000235;0.215251;-0.976559;,
-0.540144;-0.648203;-0.536728;,
-0.464976;0.753388;-0.464976;,
-0.680680;-0.270764;-0.680707;,
-0.708355;-0.058587;-0.703421;,
-0.683431;0.255988;-0.683661;,
-0.697645;0.161511;-0.698001;,
-0.703525;-0.098777;-0.703772;,
-0.691573;0.207588;-0.691834;,
-0.576166;-0.817333;0.000000;,
-0.727902;0.685681;-0.000000;,
-0.962599;-0.270931;-0.000000;,
-0.998259;-0.058986;0.000000;,
-0.966908;0.255127;0.000000;,
-0.986559;0.163404;0.000000;,
-0.994783;-0.102017;0.000000;,
-0.978884;0.204415;0.000000;,
-0.540144;-0.648203;0.536729;,
-0.464976;0.753388;0.464976;,
-0.680680;-0.270764;0.680707;,
-0.708355;-0.058587;0.703421;,
-0.683431;0.255988;0.683661;,
-0.697645;0.161511;0.698001;,
-0.703525;-0.098777;0.703772;,
-0.691573;0.207588;0.691834;,
0.000000;-0.814698;0.579886;,
0.000000;0.685681;0.727902;,
-0.000000;-0.270589;0.962695;,
0.000000;-0.058188;0.998306;,
0.000344;0.254213;0.967148;,
0.000349;0.156920;0.987611;,
0.000223;-0.090935;0.995857;,
0.000235;0.215251;0.976559;,
0.540144;-0.648203;0.536728;,
0.464976;0.753388;0.464976;,
0.680680;-0.270764;0.680707;,
0.708355;-0.058587;0.703421;,
0.685423;0.247016;0.684966;,
0.699028;0.152303;0.698687;,
0.704762;-0.083061;0.704564;,
0.689418;0.222914;0.689211;;
128;
3;0,2,1;,
3;3,5,4;,
3;0,1,6;,
3;6,1,7;,
3;6,9,8;,
3;6,7,9;,
3;8,9,10;,
3;10,9,11;,
3;10,13,12;,
3;10,11,13;,
3;12,13,14;,
3;14,13,15;,
3;14,17,16;,
3;14,15,17;,
3;16,17,3;,
3;3,17,5;,
3;1,2,18;,
3;5,19,4;,
3;1,20,7;,
3;1,18,20;,
3;7,20,9;,
3;9,20,21;,
3;9,22,11;,
3;9,21,22;,
3;11,22,13;,
3;13,22,23;,
3;13,24,15;,
3;13,23,24;,
3;15,24,17;,
3;17,24,25;,
3;17,19,5;,
3;17,25,19;,
3;18,2,26;,
3;19,27,4;,
3;18,26,20;,
3;20,26,28;,
3;20,29,21;,
3;20,28,29;,
3;21,29,22;,
3;22,29,30;,
3;22,31,23;,
3;22,30,31;,
3;23,31,24;,
3;24,31,32;,
3;24,33,25;,
3;24,32,33;,
3;25,33,19;,
3;19,33,27;,
3;26,2,34;,
3;27,35,4;,
3;26,36,28;,
3;26,34,36;,
3;28,36,29;,
3;29,36,37;,
3;29,38,30;,
3;29,37,38;,
3;30,38,31;,
3;31,38,39;,
3;31,40,32;,
3;31,39,40;,
3;32,40,33;,
3;33,40,41;,
3;33,35,27;,
3;33,41,35;,
3;34,2,42;,
3;35,43,4;,
3;34,42,36;,
3;36,42,44;,
3;36,45,37;,
3;36,44,45;,
3;37,45,38;,
3;38,45,46;,
3;38,47,39;,
3;38,46,47;,
3;39,47,40;,
3;40,47,48;,
3;40,49,41;,
3;40,48,49;,
3;41,49,35;,
3;35,49,43;,
3;42,2,50;,
3;43,51,4;,
3;42,52,44;,
3;42,50,52;,
3;44,52,45;,
3;45,52,53;,
3;45,54,46;,
3;45,53,54;,
3;46,54,47;,
3;47,54,55;,
3;47,56,48;,
3;47,55,56;,
3;48,56,49;,
3;49,56,57;,
3;49,51,43;,
3;49,57,51;,
3;50,2,58;,
3;51,59,4;,
3;50,58,52;,
3;52,58,60;,
3;52,61,53;,
3;52,60,61;,
3;53,61,54;,
3;54,61,62;,
3;54,63,55;,
3;54,62,63;,
3;55,63,56;,
3;56,63,64;,
3;56,65,57;,
3;56,64,65;,
3;57,65,51;,
3;51,65,59;,
3;58,2,0;,
3;59,3,4;,
3;58,6,60;,
3;58,0,6;,
3;60,6,61;,
3;61,6,8;,
3;61,10,62;,
3;61,8,10;,
3;62,10,63;,
3;63,10,12;,
3;63,14,64;,
3;63,12,14;,
3;64,14,65;,
3;65,14,16;,
3;65,3,59;,
3;65,16,3;;
}
MeshTextureCoords
{
89;
0.000000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.000000;1.000000;,
0.000000;0.857143;,
0.125000;1.000000;,
0.125000;0.857143;,
0.000000;0.714286;,
0.125000;0.714286;,
0.000000;0.571429;,
0.125000;0.571429;,
0.000000;0.428571;,
0.125000;0.428571;,
0.000000;0.285714;,
0.125000;0.285714;,
0.000000;0.142857;,
0.125000;0.142857;,
0.125000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.250000;0.857143;,
0.250000;1.000000;,
0.250000;0.714286;,
0.250000;0.571429;,
0.250000;0.428571;,
0.250000;0.285714;,
0.250000;0.142857;,
0.250000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.375000;1.000000;,
0.375000;0.857143;,
0.375000;0.714286;,
0.375000;0.571429;,
0.375000;0.428571;,
0.375000;0.285714;,
0.375000;0.142857;,
0.375000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.500000;0.857143;,
0.500000;1.000000;,
0.500000;0.714286;,
0.500000;0.571429;,
0.500000;0.428571;,
0.500000;0.285714;,
0.500000;0.142857;,
0.500000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.625000;1.000000;,
0.625000;0.857143;,
0.625000;0.714286;,
0.625000;0.571429;,
0.625000;0.428571;,
0.625000;0.285714;,
0.625000;0.142857;,
0.625000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.750000;0.857143;,
0.750000;1.000000;,
0.750000;0.714286;,
0.750000;0.571429;,
0.750000;0.428571;,
0.750000;0.285714;,
0.750000;0.142857;,
0.750000;0.000000;,
0.000000;0.000000;,
0.000000;0.000000;,
0.875000;1.000000;,
0.875000;0.857143;,
0.875000;0.714286;,
0.875000;0.571429;,
0.875000;0.428571;,
0.875000;0.285714;,
0.875000;0.142857;,
0.875000;0.000000;,
1.000000;0.857143;,
1.000000;1.000000;,
1.000000;0.714286;,
1.000000;0.571429;,
1.000000;0.428571;,
1.000000;0.285714;,
1.000000;0.142857;,
1.000000;0.000000;;
}
MeshMaterialList
{
1;
128;
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0;
Material Material01
{
0.800000;0.800000;0.800000;1.000000;;
128.000000;
1.000000;1.000000;1.000000;;
0.168627;0.168627;0.168627;;
TextureFileName
{
"pin.png";
}
}
}
}
}
-----------------------------------------