Topic: Changing mesh origin via code

I've tried moving all the vertices by the amount that I need. It works but basing on the camera angle sometimes the mesh disappears. I guess it has something to do with normals or text coords?
Any help?

Re: Changing mesh origin via code

you need to recompute the bounding box
if it's just a translation of vertices, translate the bounding box too.

Re: Changing mesh origin via code

Oh I had thought that! But then I just confused the bounding box for a collision thing and said "no it doesn't matter" eheh.
For collision it's the collision shape, not the bounding box.

Solved.

Re: Changing mesh origin via code

I bring up this again because while changing the bounding box does work, I noticed that the entity is not immediately visible until the camera exits and re-enter the new bounding box. I'm wondering what I need to update to avoid this little glitch.

Re: Changing mesh origin via code

try to use :

// for each sub mesh you modify :
subMesh->getBoundingBox()->initFromPoints(subMesh->getVertices(), subMesh->getVerticesSize());

// then update the mesh :
mesh->updateBoundingBox();

Re: Changing mesh origin via code

Nope, it doesn't solve it.

Re: Changing mesh origin via code

so maybe your entity bounding box is not up to date :
*entity->getBoundingBox() = *mesh->getBoundingBox();

Re: Changing mesh origin via code

That's it, thank you big_smile

Re: Changing mesh origin via code

smile