-
-
Save agustinsivoplas/22ba7c8286938f6c6003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Luego de que termino de crear los objetos hago la asociacion de hijos | |
char* tokenHijos; | |
SceneNode* hijos; | |
SceneNode* nodeHijo = NULL; | |
int posHijo; | |
for (int i = 0; i < nObjetos; i++) { | |
SceneNode* scnNode = &scene->nodes[i]; | |
if (scnNode->num_hijos > 0) { | |
tokenHijos = strtok(scnNode->hijos_str, ",\n"); | |
if (tokenHijos != NULL) { | |
posHijo = 0; | |
hijos = (SceneNode*) malloc(sizeof (SceneNode) * scnNode->num_hijos); | |
while (tokenHijos != NULL) { | |
//Recorremos nuevamente buscando la posicion del hijo | |
for (int j = 0; j < nObjetos; j++) { | |
SceneNode* nodeAux = &scene->nodes[j]; | |
if (nodeAux ->id == atoi(tokenHijos)) { | |
nodeHijo = nodeAux; | |
break; | |
} | |
} | |
hijos[posHijo] = *nodeHijo; | |
//Leo el siguiente | |
tokenHijos = strtok(NULL, ",\n"); | |
posHijo++; | |
} | |
scnNode->hijos = hijos; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment