comparison TaskManager/Test/simple_render/task/create_sgp.cpp @ 35:1e17e0b441a7

*** empty log message ***
author gongo
date Tue, 12 Feb 2008 19:19:06 +0900
parents
children 70a0ac46133e
comparison
equal deleted inserted replaced
34:34dd03a8a612 35:1e17e0b441a7
1 #include <iostream>
2 #include "scene_graph_pack.h"
3 #include "polygon.h"
4 using namespace std;
5
6 int create_sgp(SceneGraphPack *sgp, Polygon *sg)
7 {
8 int i = 0;
9 int nnpn = -1;
10 SceneGraphNodePtr node;
11
12 Polygon *t;
13 t = sg;
14
15 while(t)
16 {
17 node = &sgp->node[i];
18
19 node->size = t->size;
20 int d,tex;
21 for(d=0,tex=0; d<t->size*3; d+=3,tex+=2)
22 {
23 node->vertex[d] = t->data[d];
24 node->vertex[d+1] = t->data[d+1];
25 node->vertex[d+2] = t->data[d+2];
26 node->texture[tex] = t->data[d+t->size*6];
27 node->texture[tex+1] = t->data[d+t->size*6+1];
28 }
29
30 node->obj_pos[0] = 0;
31 node->obj_pos[1] = 0;
32 node->obj_pos[2] = 0;
33 node->obj_pos[3] = 1;
34 node->angle[0] = 0;
35 node->angle[1] = 0;
36 node->angle[2] = 0;
37 node->angle[3] = 1;
38
39 for(int tm=0; tm<16; tm++)
40 {
41 node->translation[tm] = 0;
42 }
43 node->id = 0;
44 node->move = 0;
45 node->interaction = 0;
46 node->pn = nnpn;
47
48 if(t->child != NULL)
49 {
50 nnpn = i;
51 t = t->child;
52 }
53 else if(t->brother != NULL)
54 {
55 nnpn = node->pn;
56 t = t->brother;
57 }
58 else
59 {
60 while(t)
61 {
62 if(t->brother != NULL)
63 {
64 t = t->brother;
65 break;
66 }
67 else
68 {
69 if(t->parent == NULL)
70 {
71 t = NULL;
72 break;
73 }
74 nnpn = sgp->node[nnpn].pn;
75 t = t->parent;
76 }
77 }
78 }
79 i++;
80 }
81 sgp->info.size = i;
82
83 return sizeof(SceneGraphPack);
84 }