annotate TaskManager/Test/simple_pack/task/create_sgp.cpp @ 69:c9b973f0673e

*** empty log message ***
author chiaki
date Sun, 17 Feb 2008 23:07:52 +0900
parents 35a6cf176c38
children 459f54b49648
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
1 #include <iostream>
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
2 #include "scene_graph_pack.h"
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
3 #include "polygon.h"
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
4 using namespace std;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
5
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
6 int create_sgp(Polygon *sg, SceneGraphPack *sgp)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
7 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
8 int i = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
9 int nnpn = -1;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
10 SceneGraphNodePtr node;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
11
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
12 Polygon *t;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
13 t = sg;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
14
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
15 while(t)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
16 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
17 node = &sgp->node[i];
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
18
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
19 node->size = t->size;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
20 int d,tex;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
21 for(d=0,tex=0; d<t->size*3; d+=3,tex+=2)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
22 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
23 node->vertex[d] = t->data[d];
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
24 node->vertex[d+1] = t->data[d+1];
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
25 node->vertex[d+2] = t->data[d+2];
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
26 node->texture[tex] = t->data[d+t->size*6];
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
27 node->texture[tex+1] = t->data[d+t->size*6+1];
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
28 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
29
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
30 node->obj_pos[0] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
31 node->obj_pos[1] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
32 node->obj_pos[2] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
33 node->obj_pos[3] = 1;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
34 node->angle[0] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
35 node->angle[1] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
36 node->angle[2] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
37 node->angle[3] = 1;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
38
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
39 for(int tm=0; tm<16; tm++)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
40 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
41 node->translation[tm] = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
42 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
43 node->id = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
44 node->move = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
45 node->interaction = 0;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
46 node->pn = nnpn;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
47
68
35a6cf176c38 *** empty log message ***
chiaki
parents: 53
diff changeset
48 //node->tex_addr = t->texture_image;
35a6cf176c38 *** empty log message ***
chiaki
parents: 53
diff changeset
49 node->tex_width = t->texture_image->w;
35a6cf176c38 *** empty log message ***
chiaki
parents: 53
diff changeset
50 node->tex_height = t->texture_image->h;
35a6cf176c38 *** empty log message ***
chiaki
parents: 53
diff changeset
51
53
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
52 if(t->child != NULL)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
53 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
54 nnpn = i;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
55 t = t->child;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
56 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
57 else if(t->brother != NULL)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
58 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
59 nnpn = node->pn;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
60 t = t->brother;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
61 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
62 else
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
63 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
64 while(t)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
65 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
66 if(t->brother != NULL)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
67 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
68 t = t->brother;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
69 break;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
70 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
71 else
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
72 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
73 if(t->parent == NULL)
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
74 {
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
75 t = NULL;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
76 break;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
77 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
78 nnpn = sgp->node[nnpn].pn;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
79 t = t->parent;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
80 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
81 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
82 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
83 i++;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
84 }
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
85 sgp->info.size = i;
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
86
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
87 return sizeof(SceneGraphPack);
0c8ae614d421 Initial revision
chiaki
parents:
diff changeset
88 }