I have a question about how to avoid using up memory when loading the same mesh thousands of times. My current project requires to duplicate the selected objects thousands of times (>3600), the mesh is a .obj file with a .mtl texture, which are altogether 1MB. I duplicated this object by the following codes:
Code: Select all
scene::IAnimatedMesh* m = smgr->getMesh(filename.c_str());
for (int i = 0; i < 3600; i++) {
// set default material properties
scene::ISceneNode* newModel;
/*set mesh as pickable and hightlightable
*/
if (Octree)
{
newModel = smgr->addOctreeSceneNode(m->getMesh(0), 0, ID_IsNotPickable);
}
...
}
Any suggestions about how should I avoid these problems? Thanks in advance.
Best.