Hi everyone. I have this 3D model which works as a tile in my game, I'm moving its vertices based on a height-map and it's working like a charm. Now I'm trying to pick the tiles individually using the triangle selector. That is also working, the problem is that when I change the mesh through the mesh buffer, the bounding box is not updated and the triangle selector only counts the previous bb. I did find an updatebb method, but not on the scene node or anywhere I could understand... how can I fix this?
Thanks (:
Updating the Bounding Box
The meshbuffer has a function called setDirty which should be called when the mesh has changed. I think that might help with the bounding-box.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
nop, I'm still getting the same error.
The moveVertex function:
The moveVertex function:
Code: Select all
void moveVertex(IAnimatedMeshSceneNode* node, s32 index, f32 step)
{
IMeshBuffer* meshBuffer = node->getMesh()->getMeshBuffer(0);
S3DVertex* mb_vertices = (S3DVertex*)meshBuffer->getVertices();
u16* mb_indices = meshBuffer->getIndices();
mb_vertices[index].Pos.Y += -step;
meshBuffer->setDirty();
} have you tried....
Code: Select all
meshBuffer->recalculateBoundingBox ();Hm, only bounding-box updates. I see right now no way to update the triangle selector for non-animated meshes. Strange... hm, which triangle selector are you using here?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
That did update the bounding box, but only the pink one (from setDebugDataVisible(scene::EDS_BBOX_ALL); ), I'm guessing the selector uses the white one since the selection is still based on the old bounding box.Klunk wrote:have you tried....
Code: Select all
meshBuffer->recalculateBoundingBox ();
Is this what you want?Hm, only bounding-box updates. I see right now no way to update the triangle selector for non-animated meshes. Strange... hm, which triangle selector are you using here?
Code: Select all
ITriangleSelector* selector = 0;
selector = device->getSceneManager()->createTriangleSelector(me.getTile());
me.getTile()->setTriangleSelector(selector);
IAnimatedMeshSceneNode* selectedSceneNode = (IAnimatedMeshSceneNode*)device->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(device->getCursorControl()->getPosition()/*,IDFlag_IsPickable*/); This is what I mean by pink and white bounding boxes:

edit: hm, now that I see it, its also updating the white bounding box, but only to the model scale, not the new vertex position... is there a way to copy the meshbuffer bounding box to the node bounding box?
yay I fixed 
Code: Select all
note->getMesh()->getMeshBuffer(0)->recalculateBoundingBox();
core::aabbox3df box = node->getMesh()->getMeshBuffer(0)->getBoundingBox();
node->getMesh()->getMesh(0)->setBoundingBox(box);