Mercurial > hg > Game > Cerium
view TaskManager/Test/test_render/task/create_sgp.cpp @ 123:e9e12e2088bd draft
delete scene_graph->child (instead use "children")
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 25 Nov 2008 10:32:23 +0900 |
parents | 80d93fe0601d |
children | 95e2046eb46f |
line wrap: on
line source
#include <iostream> #include "scene_graph_pack.h" #include "polygon.h" #include "create_sgp.hpp" #include "TaskManager.h" using namespace std; SchedDefineTask(Create_SGP); /** * TODO * 入りきらない分は SceneGraphPack を next で繋げてるので * node->pn をつかって sgp->node[node->pn] とかやって * 親?の要素を探す事は出来ないかもしれません。 * next を辿って node->pn == とかやるのは確実だけどさ。。。 */ int //create_sgp(Polygon *sg, SceneGraphPack *sgp) Create_SGP::run(void *rbuf, void *wbuf) { Polygon *sg = (Polygon*)get_input(rbuf, 0); //SceneGraphPack *sgp = (SceneGraphPack*)get_output(wbuf, 0); SceneGraphPack *sgp = (SceneGraphPack*)get_param(0); sgp->init(); int curNumber = 0; int nnpn = -1; SceneGraphNodePtr node; Polygon *t = sg; while(t) { // blocking はこれでいいのかな? if (curNumber >= MAX_NODE ){ SceneGraphPack *sgp_new = //(SceneGraphPack*)manager->malloc(sizeof(SceneGraphPack)); (SceneGraphPack*)smanager->allocate(sizeof(SceneGraphPack)); sgp_new->init(); sgp->info.size = curNumber-1; curNumber = 0; sgp->next = sgp_new; sgp = sgp_new; } node = &sgp->node[curNumber]; node->init(); for (int i = 0,d = 0,tex = 0; i < t->size; i++, d += 3, tex += 2) { if (node->size >= MAX_POLYGON) { SceneGraphNodePtr node_new = (SceneGraphNodePtr)smanager->allocate(sizeof(SceneGraphNode)); node_new->init(); node->next = node_new; node = node_new; d = 0; tex = 0; } /** * struct texture { * int texture_id; * float vertex[3]; * float texture[2]; * } */ node->vertex[d] = t->data[i*3]; node->vertex[d+1] = t->data[i*3+1]; node->vertex[d+2] = t->data[i*3+2]; node->texture[tex] = t->data[i*3+t->size*6]; node->texture[tex+1] = t->data[i*3+t->size*6+1]; node->size++; } node = &sgp->node[curNumber]; SceneGraphNode *p = node; do { p->obj_pos[0] = 0; p->obj_pos[1] = 0; p->obj_pos[2] = 0; p->obj_pos[3] = 1; p->angle[0] = 0; p->angle[1] = 0; p->angle[2] = 0; p->angle[3] = 1; for (int tm = 0; tm < 16; tm++) { p->translation[tm] = 0; } p->id = 0; p->move = 0; p->interaction = 0; p->pn = nnpn; //node->tex_addr = t->texture_image->pixels; p->tex_width = t->texture_image->w; p->tex_height = t->texture_image->h; p = p->next; } while (p); if (t->children != NULL) { nnpn = curNumber; t = t->children; printf("children\n"); } else if (t->brother != NULL) { nnpn = node->pn; t = t->brother; printf("brother\n"); } else { while (t) { if (t->brother != NULL) { t = t->brother; printf("brother2\n"); break; } else { if (t->parent == NULL) { t = NULL; break; } nnpn = sgp->node[nnpn].pn; t = t->parent; } } } curNumber++; } sgp->info.size = curNumber; return 0; }