How do I scale Bullet Physics collision objects [to fit in Irrlicht terrain mesh]?
This is the setup of my terrain mesh:
ITexture *texture=driver->getTexture("./assets/map_image_resize.jpg");
ITerrainSceneNode *terrain=smgr->addTerrainSceneNode(texture->getName(), 0 , -1, vector3df(0.0f, 0.0f,0.0f),
vector3df(0.0f, 0.0f, 0.0f), vector3df(1.0f, 1.0f, 1.0f));
terrain->setMaterialFlag(EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("./assets/map_texture.jpg"));
terrain->setPosition(vector3df(0.0f, 0.0f, 0.0f));
terrain->setScale(vector3df(4.0f, 1.0f, 4.0f));
My question originated here. Since the heightmap image is only 512x512px and I wanted the mesh to be 2048x2048 I had to scale the scene node [last line in the code above]. However I used the ITexture *texture as the reference for creating the collision object shape[code below].
int arraySize=texture->getSize().Height;
f32 heightData[arraySize*arraySize];
I think it's safe to assume that the collision shape is 512x512 like the height map image, but it's hard to say for sure since there isn't any visible output. The following code is my feeble attempt at trying to answer to my own question, but it didn't work as expected:
btCollisionShape *groundShape=new btHeightfieldTerrainShape(arraySize, arraySize, heightDataPtr, 1.f, minHeight, maxHeight, 1, PHY_FLOAT, false);
groundShape->setLocalScaling(btVector3(4.0f, 1.0f, 4.0f));
I'll add the whole source code in a reply post in order to keep everything organized.
P.S. I'm posting this in the beginners section because this seems like a simple problem to resolve...for someone with more knowledge pertaining to Bullet Physics.