Hello, I have a somewhat complicated question. I have a vector (structures) in a struct (instances). I make a declaration of this struct called instance. The vector is a 3-layer vector of pointers, like so: vector < vector < vector<scene::IAnimatedMeshSceneNode*> > > structures; (The type is from Irrlicht 3D). I have 3 nested "for" loops which looks similar to the following:
1 2 3 4 5 6 7 8 9 10 11 12
for (int a = 0; a < instance.structures.size(); a++) { /*note:vector size previously set*/
for (int b = 0; b < instance.structures[a].size(); b++){
for (int c = 0; c < instance.structures[a][b].size(); c++) {
if (1) { //checking value of variable not included in snippet
(instance.structures)[a][b][c] = smgr->addAnimatedMeshSceneNode(fl);
(instance.structures)[a][b][c]->setPosition(renderPos);
}
}
}
}
These are currently referencing the pointers, it seems. The program compiles but crashes at this point. I need them to reference the values of the pointers. Problem is, I don't know where to put the dereference operator (*). Where should it go?
The code looks correct to me. Because if the code reaches till the inner loop, the indexes should be valid. Did you check the trace where the program exactly crashing ?
It was actually the seventh line. Which makes me think that in line 6 I set the pointer to the value after the equals and I didn't set the value pointed to, which is why I though I needed a * somewhere. I don't really know, I'm pretty new to pointers but I have to use a vector of pointers because of certain functions in the IAnimatedMeshSceneNode class.
Irrlicht uses it's own types called "dimension3df" - I'm not sure if looking into this will help you at all - Its been a while since I've had to do anything surrounding this in Irrlicht.