I came across a bug with the ITerrainSceneNode's position/rotation. Basically it doesn't work the same way as the other nodes. For the position I guess it's normal because there's a getTerrainCenter method but it still is weird imo. The position data are sent by bullet so I had to write something that deal with it :
Code: Select all
core::vector3df newPosition;
ITerrainSceneNode* terrain = sceneManager->addTerrainSceneNode(/*with all the parameters you want*/);
//let's say you do something here that fills newPosition
terrain->setPosition(core::vector3df(
newPosition.X - (terrain->getBoundingBox().MaxEdge.X - terrain->getBoundingBox().MinEdge.X)/2,
newPosition.Y - (terrain->getBoundingBox().MaxEdge.Y - terrain->getBoundingBox().MinEdge.Y)/2,
newPosition.Z - (terrain->getBoundingBox().MaxEdge.Z - terrain->getBoundingBox().MinEdge.Z)/2)
);
About the rotations I think they're inverted so I wrote a (very ugly, non optimized, probably dumb, etc... ) bit of code that seems to make things work :
Code: Select all
core::vector3df newRotation;
//fill newRotation
terrain->setRotation(core::vector3df(0,0,0));
core::matrix4 transfo = terrain->getAbsoluteTransformation();
terrain->setRotation(
(
core::quaternion(core::vector3df(-newRotation.X,0,0)*core::DEGTORAD).getMatrix()
*core::quaternion(core::vector3df(0,-newRotation.Y,0)*core::DEGTORAD).getMatrix()
*core::quaternion(core::vector3df(0,0,-newRotation.Z)*core::DEGTORAD).getMatrix()
*transfo
).getRotationDegrees()
);
About the spotlight bug if it's not a bug feel free to fill me in, I'm still searching for the solution.