aerys / minko

3D framework for web, desktop and mobile devices.
http://minko.io
Other
904 stars 210 forks source link

Getting bounds of 3D model #245

Closed unco182 closed 8 years ago

unco182 commented 8 years ago

Hi,

I would like to put the center of the 3D universe of my app in the center of my 3D model and make the camera look at it. I thought that using canvas->width() and canvas->height() would help me to get to the center. But the size of my canvas is (640,920). How can I get the max size of my 3D model instead?

Thx in advance

warrenseine commented 8 years ago

You should add a BoundingBox component to your model node and get its box() property.

unco182 commented 8 years ago

Thanks !

Is there any up to date example that use BoundingBox ?

I already saw this : example/raycasting/src/main.cpp about raycasting but it seems outdated

By using this example, I got a bounding box size of (0,0). How should I proceed to resize this box to the size of my 3D model?

JMLX42 commented 8 years ago
auto bbox = component::BoundingBox::create();
node->addComponent(bbox);

Then you have the bbox->box()->width(), ->height() and ->depth() properties.