Of node >> setParent[vector[0]]

i need to create dynamic ofNode and set dynamic parent
something like that

ofNode nodeParent;
	nodes.push_back(nodeParent);
for(int i=0;i<10; i++) {
	ofNode tempNode;
	tempNode.setParent(nodes[0]);
node.push_back(tempNode);
	}
}

and that always crash cause this line

//----------------------------------------
ofMatrix4x4 ofNode::getGlobalTransformMatrix() const {
	if(parent) return getLocalTransformMatrix() * parent->getGlobalTransformMatrix();
	else return getLocalTransformMatrix();
}

They are a special technique to set parent dynamically ?
thanks

Do you have to use pointer ?

yes if you push back things in a vector the vector contents can move in memory so the pointer to the parent in the ofNode can become invalid, you can use a vector of pointers or make sure that the vector won’t reallocate, by creating all the elements first and then setting the parents afterwards

Thanks you very much again
i follow your advise,
first i create Boids, then i affect there parent using pointer
that should work

cout << "I am"<<boids[i].myName<<"\n";
		cout<<"getParent"<<boids[i].getParent()<<"\n";
		cout<<"getParentPosition"<<boids[i].getParent()->getPosition()<<"\n\n\n";
		boids[i].transformGL();
	//	boids[i].setPosition(boids[i].position.x+100,0,0);
		boids[i].renderName(myFont);
		boids[i].restoreTransformGL();

But when i render it, child does’not move at all

OK i found the trouble
because i try to affect the position by changing directly the position of the parent.
mow i work setPosition(newPosition); and that works nice.