This is just a little code I made to scale a node to an specified size.
It takes as parameters a pointer to an ISceneNode and your desired size (specified in X, Y, Z UNITS) and then calculates the needed factor and scales the Node.
Code: Select all
void scaleMesh(scene::ISceneNode* mesh,
f32 desiredX = 40,
f32 desiredY = 40,
f32 desiredZ = 40)
{
core::vector3d<f32> * edges = new core::vector3d<f32>[8];
core::aabbox3d<f32> boundingbox =
mesh->getTransformedBoundingBox();
boundingbox.getEdges(edges);
f32 height = edges[1].Y - edges[0].Y;
//std::cout<<"height: "<<height<<std::endl;
f32 width = edges[5].X - edges[1].X;
//std::cout<<"width: "<<width<<std::endl;
f32 depth = edges[2].Z - edges[0].Z;
//std::cout<<"depth: "<<depth<<std::endl;
f32 factorX = desiredX/width;
f32 factorY = desiredY/height;
f32 factorZ = desiredZ/depth;
core::vector3d<f32> factorEscalate(factorX,factorY,factorZ);
mesh->setScale(factorEscalate);
}