Getting the size of a mesh/node
Getting the size of a mesh/node
Hi,
I'm wondering how to get the size (not the scale) of a mesh or a node. For example if I make a box in Blender that is 4 units long, 1 unit high and 2 units wide, how do then I get these values within Irrlicht?
Thanks in advance,
Lu
I'm wondering how to get the size (not the scale) of a mesh or a node. For example if I make a box in Blender that is 4 units long, 1 unit high and 2 units wide, how do then I get these values within Irrlicht?
Thanks in advance,
Lu
on the mesh you can call getBoundingBox that will return the actual boundingbox of the mesh. on a scenenode you can also call getTransformedBoundingBox which will give you the scaled and positioned bounding box. everything axis aligned.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Hey KungFuLu...
I'm just starting to work with Irrlicht and I have the exact problem you had, and I was wondering if you could point me out in the right direction to solve it...
I'm doing kind of a mesh viewer, and I need that all the models that I load have more or less the same size (i.e. fill the screen)...
Problem is some models are just too small and some others too huge, hence I can't scale them always by the same factor...
Did you manage to find a way to get the mesh size?
If i can get the size of a mesh, I can do some calculations as to what is the right scaling factor to make 'em fill the screen; but so far, I'm completely blank as to how can I get the size...
Any help would be appreciated.
Thanks!
I'm just starting to work with Irrlicht and I have the exact problem you had, and I was wondering if you could point me out in the right direction to solve it...
I'm doing kind of a mesh viewer, and I need that all the models that I load have more or less the same size (i.e. fill the screen)...
Problem is some models are just too small and some others too huge, hence I can't scale them always by the same factor...
Did you manage to find a way to get the mesh size?
If i can get the size of a mesh, I can do some calculations as to what is the right scaling factor to make 'em fill the screen; but so far, I'm completely blank as to how can I get the size...
Any help would be appreciated.
Thanks!
You can easily take the 8 edges of the bounding box, using a code like this:raveneyex wrote:Hey KungFuLu...
I'm just starting to work with Irrlicht and I have the exact problem you had, and I was wondering if you could point me out in the right direction to solve it...
I'm doing kind of a mesh viewer, and I need that all the models that I load have more or less the same size (i.e. fill the screen)...
Problem is some models are just too small and some others too huge, hence I can't scale them always by the same factor...
Did you manage to find a way to get the mesh size?
If i can get the size of a mesh, I can do some calculations as to what is the right scaling factor to make 'em fill the screen; but so far, I'm completely blank as to how can I get the size...
Any help would be appreciated.
Thanks!
Code: Select all
ISceneNode* mesh;
[..]
vector3d<f32> * edges = new vector3d<f32>[8]; //Bounding BOX edges
aabbox3d<f32> boundingbox ; //Mesh's bounding box
boundingbox=mesh->getTransformedBoundingBox(); //Let's get BB...
boundingbox.getEdges(edges); //Fill the array with edges's coords...
Code: Select all
/3--------/7
/ | / |
/ | / |
1---------5 |
| /2- - -|- -6
| / | /
|/ | /
0---------4/
Thanks!
Thank you very much Zurzaza!
You were absolutely right
Here's the code I made:
Just in case anyone else need this
You were absolutely right
Here's the code I made:
Code: Select all
void getMeshSize(scene::ISceneNode* mesh)
{
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; //OK
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;
}
you can do this much easily
Code: Select all
vector3df extent= node->getTransformedBoundingBox.getExtent();
//now extent.X is the X size of the box, .Y is Y etc.
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps
Step back! I have a void pointer, and I'm not afraid to use it!
Height2Normal v. 2.1 - convert height maps to normal maps
Step back! I have a void pointer, and I'm not afraid to use it!
Oh...
Oh sh*t!
I didn't know...
:/
well, It's already done so
Thanks anyway
I didn't know...
:/
well, It's already done so
Thanks anyway
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
No, it is not.
You can always use API documentation if you'r not sure.Get extent of the box (maximal distance of two points in the box).
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps
Step back! I have a void pointer, and I'm not afraid to use it!
Height2Normal v. 2.1 - convert height maps to normal maps
Step back! I have a void pointer, and I'm not afraid to use it!