getBoundingBox().getSize() not exactly?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
abreu20011
Gnoblar
Posts: 2
Joined: Thu Jan 30, 2014 3:34 am

getBoundingBox().getSize() not exactly?

Post by abreu20011 »

Hi everyone! :)

I'm trying to create a Hexagonal Map, creating several Entities to create a "Hexagonal Map tool" to use later in a game
The algorithm that I used is the next:

Code: Select all

			float offset = y % 2 != 0 ? f_eWidth / 2 : 0;
            float _x = x * f_eWidth + offset;
            float _y = y * f_eHeight * .75f;
I used this to create a "even-r" hexagonal map in a doble for. I'm tried in Unity and was fine, but how you can see in the image, here can see a little separation between hexagons.

Image

The values of f_eWidth and f_eHeight is calculated as follow:

Code: Select all

	f_eWidth = e_hexagon->getBoundingBox().getSize().x;
	f_eHeight = e_hexagon->getBoundingBox().getSize().z;
It's meaby this the problem? I looked in documentation but don't saw anything more appropiate that this function.
Can you help me with this little problem? Thanks very much!


The complete code is here:

Code: Select all

	Ogre::Entity *e_hexagon = mSceneMgr->createEntity("e_hexagon", "hexagon.mesh");
	
	//Get hexagon scale
	f_eWidth = e_hexagon->getBoundingBox().getSize().x;
	f_eHeight = e_hexagon->getBoundingBox().getSize().z;

	for(int x = 0; x < 24; x++)
	{
		for(int y = 0; y < 24; y++)
		{
			std::ostringstream os_name;
			std::ostringstream os_node;

			os_name << "e" << y << "," << x;
			os_node << "n" << y << "," << x;

			float offset = y % 2 != 0 ? f_eWidth / 2 : 0;
            float _x = x * f_eWidth + offset;
            float _y = y * f_eHeight * .75f;

			Ogre::Entity *e_hexa = mSceneMgr->createEntity(os_name.str(), "hexagon.mesh");
			Ogre::SceneNode *sn_hexa = mSceneMgr->getRootSceneNode()->createChildSceneNode(os_node.str());
			sn_hexa->setPosition(_x, 0, _y);

			sn_hexa->attachObject(e_hexa);
		}
	}
Regards,
abreu20011
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: getBoundingBox().getSize() not exactly?

Post by Kojack »

Bounding boxes are given a slight padding by default, making them bigger than the mesh they contain. This is so you can do stuff like manipulate them in a vertex shader without hurting the culling.
You can change the padding factor using Ogre::MeshManager::setBoundsPaddingFactor.
abreu20011
Gnoblar
Posts: 2
Joined: Thu Jan 30, 2014 3:34 am

Re: getBoundingBox().getSize() not exactly?

Post by abreu20011 »

Kojack wrote:Bounding boxes are given a slight padding by default, making them bigger than the mesh they contain. This is so you can do stuff like manipulate them in a vertex shader without hurting the culling.
You can change the padding factor using Ogre::MeshManager::setBoundsPaddingFactor.
You'r the best Kojack! Thanks very much ^^
Post Reply