comparison old/simple_render/task/create_sgp.cpp @ 507:735f76483bb2

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents TaskManager/Test/simple_render/task/create_sgp.cpp@62679f4cae18
children
comparison
equal deleted inserted replaced
506:1d4a8a86f26b 507:735f76483bb2
1 #include <iostream>
2 #include "scene_graph_pack.h"
3 #include "polygon.h"
4 using namespace std;
5
6 int create_sgp(Polygon *sg, SceneGraphPack *sgp)
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 //node->tex_addr = t->texture_image->pixels;
49 node->tex_width = t->texture_image->w;
50 node->tex_height = t->texture_image->h;
51
52 if(t->child != NULL)
53 {
54 nnpn = i;
55 t = t->child;
56 }
57 else if(t->brother != NULL)
58 {
59 nnpn = node->pn;
60 t = t->brother;
61 }
62 else
63 {
64 while(t)
65 {
66 if(t->brother != NULL)
67 {
68 t = t->brother;
69 break;
70 }
71 else
72 {
73 if(t->parent == NULL)
74 {
75 t = NULL;
76 break;
77 }
78 nnpn = sgp->node[nnpn].pn;
79 t = t->parent;
80 }
81 }
82 }
83 i++;
84 }
85 sgp->info.size = i;
86
87 return sizeof(SceneGraphPack);
88 }