TnTonly wrote:I created a simple function in order to add objects into the scene easier
Code: Select all
void addMesh(IMeshSceneNode* node, const path &meshFile, const path &texFile, vector3df pos)
The problem is that you are passing a copy of a variable to a function. That copy is being modified by the function, but you don't see those changes in the calling scope. You are just being confused by the fact that pointers are involved.
node is a variable holding a pointer to an IMeshSceneNode. You send a copy of that pointer to your function. It creates an IMeshSceneNode object, but it can't change your
node variable, because it only has a copy.
Change your approach to something like this, if you want pointers:
Code: Select all
void addMesh(IMeshSceneNode** node, const path &meshFile, const path &texFile, vector3df pos)
{
...
*node = smgr->addMeshSceneNode(mesh);
...
}
which you call this way:
Code: Select all
addMesh(&node, "sydney.md2", "sydney.bmp", vector3df(0,0,0));
Or use a reference for
node. I avoid this approach because it isn't obvious by looking at the function call that
node might be changed by the function.