im trying to reset some textures inside a IMesh but it doesn't work.
getMaterial() returns a copy of the Material and not a pointer?
how do i get a pointer to the Material?
getMaterial returns a reference (just as you used). A reference is different to a copy, it's basically a better pointer if you want. So just use ut as you did and it will work.
No, given the code you provided, there is no copy made. Either you aren't getting the material for the mesh buffer you think you are [because meshbuffer_id is wrong], or you are doing something else wrong.
// this is _not_ a copy of the mesh buffers material. the
// getMeshBuffer() method returns a reference, which is
// essentially a pointer that cannot be reassigned. you
// are explicitly copying the returned reference, so no
// copy will be made.
irr::video::SMaterial& mat = mesh->getMeshBuffer(meshbuffer_id)->getMaterial();
// you would get a copy if you wrote this. notice the
// missing &...
irR::video::SMaterial copy = mesh->getMeshBuffer(meshbuffer_id)->getMaterial();
If you are so sure that it is broken, write a short testcase to prove it.
This is because each mesh scene node optionally maintains a copy of the materials [see IMeshSceneNode::setReadOnlyMaterials()]. When you say node->setMaterialTexture() that modifies the copy held by that mesh scene node, and those are the materials used to render [by default].
When you modify the mesh buffer material via buf->getMaterial(), you are changing the materials in the source mesh. Since those materials aren't used to render default constructed mesh scene nodes, it will only take effect for mesh scene nodes created after you make that call.
You should either use node->setMaterialTexture() or node->getMaterial() if you want to modify the material for an individual mesh scene node that uses its own material copy, or you can use the technique you are currently using if you setReadOnlyMaterials(true).