I think there is a bug on ITerrainSceneNode, where AbsolutePosition is not returning the correct value, if the terrain is moved, even if updateAbsolutePosition is called.
Using Irrlicht 1.8 .
Code:
Code: Select all
#include <irrlicht.h>
#include "driverChoice.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace irr;
using namespace std;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
irr::SIrrlichtCreationParameters params;
params.DriverType=driverType;
params.WindowSize=core::dimension2d<u32>(800, 600);
params.Fullscreen= false;
IrrlichtDevice* device = createDeviceEx(params);
if (device == 0)
return 1;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::IMeshSceneNode* pinet1 = smgr->addMeshSceneNode(smgr->getMesh("./f_pinetree1/b3d__pinet1.b3d"));
cout << "------------------ TEST IMeshSceneNode before setPosition ------------\n";
cout << "(";
cout << pinet1->getAbsolutePosition().X;
cout << ":";
cout << pinet1->getAbsolutePosition().Z;
cout << ")=(";
cout << pinet1->getPosition().X;
cout << ":";
cout << pinet1->getPosition().Z;
cout << ")\n";
pinet1->setPosition(core::vector3df(11,100,11));
cout << "------------------ TEST IMeshSceneNode after setPosition, before updateAbsolutePosition ------------\n";
cout << "(";
cout << pinet1->getAbsolutePosition().X;
cout << ":";
cout << pinet1->getAbsolutePosition().Z;
cout << ")=(";
cout << pinet1->getPosition().X;
cout << ":";
cout << pinet1->getPosition().Z;
cout << ")\n";
pinet1->updateAbsolutePosition();
cout << "------------------ TEST IMeshSceneNode after updateAbsolutePosition ------------\n";
cout << "(";
cout << pinet1->getAbsolutePosition().X;
cout << ":";
cout << pinet1->getAbsolutePosition().Z;
cout << ")=(";
cout << pinet1->getPosition().X;
cout << ":";
cout << pinet1->getPosition().Z;
cout << ")\n\n";
scene::ITerrainSceneNode* terrain3 = smgr->addTerrainSceneNode("terrain.bmp");
cout << "------------------ TEST TerrainSceneNode before setPosition ------------\n";
cout << "(";
cout << terrain3->getAbsolutePosition().X;
cout << ":";
cout << terrain3->getAbsolutePosition().Z;
cout << ")=(";
cout << terrain3->getPosition().X;
cout << ":";
cout << terrain3->getPosition().Z;
cout << ")\n";
terrain3->setPosition(core::vector3df(11,100,11));
cout << "------------------ TEST TerrainSceneNode after setPosition, before updateAbsolutePosition ------------\n";
cout << "(";
cout << terrain3->getAbsolutePosition().X;
cout << ":";
cout << terrain3->getAbsolutePosition().Z;
cout << ")=(";
cout << terrain3->getPosition().X;
cout << ":";
cout << terrain3->getPosition().Z;
cout << ")\n";
terrain3->updateAbsolutePosition();
cout << "------------------ TEST TerrainSceneNode after updateAbsolutePosition ------------\n";
cout << "(";
cout << terrain3->getAbsolutePosition().X;
cout << ":";
cout << terrain3->getAbsolutePosition().Z;
cout << ")=(";
cout << terrain3->getPosition().X;
cout << ":";
cout << terrain3->getPosition().Z;
cout << ")\t\n\n";
exit(0);
}
Code: Select all
------------------ TEST IMeshSceneNode before setPosition ------------
(0:0)=(0:0)
------------------ TEST IMeshSceneNode after setPosition, before updateAbsolutePosition ------------
(0:0)=(11:11)
------------------ TEST IMeshSceneNode after updateAbsolutePosition ------------
(11:11)=(11:11)
Generated terrain data (129x129) in 0.0440 seconds
------------------ TEST TerrainSceneNode before setPosition ------------
(0:0)=(0:0)
------------------ TEST TerrainSceneNode after setPosition, before updateAbsolutePosition ------------
(0:0)=(11:11)
------------------ TEST TerrainSceneNode after updateAbsolutePosition ------------
(0:0)=(11:11)