MeshBuffer and Bounding Box
MeshBuffer and Bounding Box
When I create a custom mesh, my bounding box remains this small cube at the center. I use recalculateBoundingBox and nothing substantial happens. Any tips for this? Using SMeshBuffer.
Re: MeshBuffer and Bounding Box
Maybe the problem isn't the meshbuffer but the mesh. You have to first recalculate the boundingbox of the meshbuffer - and once all meshbuffers are up-to-date you have to recalculate the boundingbox of the mesh.
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
Re: MeshBuffer and Bounding Box
Is there working code to refer to for this? What you suggested does not work for me. I have been making a voxel game and oddly enough, saving it as a .dae and reimporting it has a fixed bounding box.
Re: MeshBuffer and Bounding Box
Just set a breakpoint and step through with the debugger - it's just a few lines code where it's adding vertex positions to the boundingbox. You should see immediately what goes wrong. Not many options I can think of really. Either vertices don't exist at the point you recalculate. The above mentioned order of updates is wrong. Or the code where you check your bbox isn't actually using that meshbuffer bbox you expect it to use for some reason.
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
Re: MeshBuffer and Bounding Box
I've done this and I don't see anything out of the ordinary.
bbox.addInternalPoint(buffer->Vertices[currentIndex].Pos);
bbox.addInternalPoint(buffer->Vertices[currentIndex + 1].Pos);
bbox.addInternalPoint(buffer->Vertices[currentIndex + 2].Pos);
I do this when I add a new triangle face to my mesh, but this seemingly does nothing of use. I have also tried directly overriding the bounding box of the mesh with ->getMeshBuffer(0).BoundingBox but that also doesn't do anything substantial.
bbox.addInternalPoint(buffer->Vertices[currentIndex].Pos);
bbox.addInternalPoint(buffer->Vertices[currentIndex + 1].Pos);
bbox.addInternalPoint(buffer->Vertices[currentIndex + 2].Pos);
I do this when I add a new triangle face to my mesh, but this seemingly does nothing of use. I have also tried directly overriding the bounding box of the mesh with ->getMeshBuffer(0).BoundingBox but that also doesn't do anything substantial.
Re: MeshBuffer and Bounding Box
Sorry, I'm pretty certain the bug is in the code you didn't post.
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
Re: MeshBuffer and Bounding Box
I've figured it out. The bounding box function was just done on the wrong object. A bit confusing but it works now.