Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/Application/Chain.cc @ 529:3527ba243767 draft
modify applications not using SGid but SGname.
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 22 Oct 2009 16:47:49 +0900 (2009-10-22) |
parents | 413667c70a1d |
children |
rev | line source |
---|---|
388
3d1e86396d16
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
382
diff
changeset
|
1 #include <iostream> |
375 | 2 #include <math.h> |
3 #include "SceneGraphRoot.h" | |
395 | 4 #include "SceneGraph.h" |
5 #include "TaskManager.h" | |
6 #include "Func.h" | |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
7 #include "Chain.h" |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
8 #include "Application.h" |
375 | 9 #define FALSE 0 |
10 #define TRUE !FALSE | |
382 | 11 #define CHAIN_LEN 50 |
375 | 12 |
382 | 13 static double chain_width = 10; |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
14 static void post2propertyLoop(void *chain); |
375 | 15 |
395 | 16 /* SceneGraph の property */ |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
17 //ChainPropertyPtr c_properties[2]; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
18 //ChainPropertyPtr c_property; |
431 | 19 |
395 | 20 |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
21 //void createSceneGraphFromProperty(ChainPropertyPtr p) ; |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
22 void createSceneGraphFromProperty(void* p) ; |
395 | 23 |
375 | 24 void |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
25 Chain::init_chain_vars(ChainPropertyPtr cv) { |
375 | 26 cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0; |
27 cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0; | |
28 cv->can_move = TRUE; | |
29 } | |
30 | |
31 void | |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
32 set_vector(ChainPropertyPtr p, SceneGraphPtr sg) { |
395 | 33 sg->xyz[0] = p->next_x; |
34 sg->xyz[1] = p->next_y; | |
375 | 35 sg->xyz[2] = 0.0f; |
395 | 36 sg->angle[0] = p->angle[0]; |
37 sg->angle[1] = p->angle[1]; | |
38 sg->angle[2] = p->angle[2]; | |
375 | 39 } |
40 | |
463 | 41 #if 0 |
375 | 42 static void |
43 chain_move_ope(SceneGraphPtr node, int screen_w, int screen_h) | |
44 { | |
45 Pad *pad = sgroot->getController(); | |
46 | |
47 if (pad->circle.isHold()) { | |
395 | 48 property[CHAIN_LEN-1].can_move = FALSE; |
375 | 49 if (pad->left.isHold()) { |
395 | 50 property[CHAIN_LEN-1].x += -5.0; |
375 | 51 } else if (pad->right.isHold()) { |
395 | 52 property[CHAIN_LEN-1].x += 5.0; |
375 | 53 } |
54 | |
55 if (pad->up.isHold()) { | |
395 | 56 property[CHAIN_LEN-1].y += -5.0; |
375 | 57 } else if (pad->down.isHold()) { |
395 | 58 property[CHAIN_LEN-1].y += 5.0; |
375 | 59 } |
60 } else { | |
395 | 61 property[CHAIN_LEN-1].can_move = TRUE; |
375 | 62 } |
63 } | |
463 | 64 #endif |
375 | 65 |
66 void | |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
67 Chain::chain_switch() |
375 | 68 { |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
69 HTaskPtr chain_cal; |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
70 ChainPropertyPtr output; |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
71 |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
72 // SceneGraph の切り替えもここでやる |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
73 if (property == properties[0]) { |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
74 property = (ChainPropertyPtr)properties[1]; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
75 output = (ChainPropertyPtr)properties[0]; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
76 |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
77 }else{ |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
78 property = (ChainPropertyPtr)properties[0]; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
79 output = (ChainPropertyPtr)properties[1]; |
375 | 80 } |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
81 |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
82 chain_cal = manager->create_task(CHAINCAL_TASK); |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
83 chain_cal->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN); |
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
84 chain_cal->add_outData(output, sizeof(ChainProperty)*CHAIN_LEN); |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
85 chain_cal->set_post(post2propertyLoop, (void *)sg_available_list); |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
86 chain_cal->spawn(); |
375 | 87 } |
88 | |
89 void | |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
90 Chain::chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg) |
375 | 91 { |
449
0bed2a9889f5
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
447
diff
changeset
|
92 |
375 | 93 } |
94 | |
395 | 95 void |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
96 createSceneGraphFromProperty(void* p) |
395 | 97 { |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
98 ChainPropertyPtr chain_p = (ChainPropertyPtr)p; |
520 | 99 SceneGraphPtr chain_copy = sgroot->createSceneGraph("CHAIN"); |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
100 chain_copy->propertyptr = (void*)chain_p; |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
101 chain_copy->property_size = sizeof(ChainProperty); |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
102 set_vector(chain_p, chain_copy); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
103 chain_p->parent->addChild(chain_copy); |
395 | 104 } |
105 | |
375 | 106 void |
506 | 107 Chain::apply_property(void *p, SceneGraphPtr sgptr) |
108 { | |
109 ChainPropertyPtr cp = (ChainPropertyPtr)p; | |
110 | |
111 sgptr->xyz[0] = cp->xyz[0]; | |
112 sgptr->xyz[1] = cp->xyz[1]; | |
113 sgptr->xyz[2] = cp->xyz[2]; | |
114 | |
115 sgptr->angle[0] = cp->angle[0]; | |
116 sgptr->angle[1] = cp->angle[1]; | |
117 sgptr->angle[2] = cp->angle[2]; | |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
118 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
119 cp->frame++; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
120 sgptr->frame = cp->frame; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
121 } |
506 | 122 |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
123 SceneGraphPtr |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
124 Chain::scenegraph_factory(void *p) |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
125 { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
126 ChainPropertyPtr cp = (ChainPropertyPtr)p; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
127 SceneGraphPtr sgptr = (SceneGraphPtr)cp->scenegraph; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
128 apply_property(p, sgptr); |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
129 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
130 return sgptr; |
506 | 131 } |
132 | |
133 void | |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
134 Chain::scenegraph_connector(void *p, SceneGraphPtr sg) |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
135 { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
136 ChainPropertyPtr cp = (ChainPropertyPtr)p; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
137 SceneGraphPtr last = sg_available_list; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
138 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
139 if (!last) { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
140 sg_available_list = sg; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
141 } else { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
142 while (last->next) { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
143 last = last->next; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
144 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
145 last->next = sg; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
146 sg->prev = last; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
147 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
148 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
149 ChainPropertyPtr p_curent = (ChainPropertyPtr)sg->propertyptr; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
150 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
151 // parent_id が 0 , NULL だったらどうすんだ? |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
152 // そこで試合終了じゃね? |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
153 // if ( p_curent_id->parent_id == 0) return -1; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
154 ChainProperty p_parent = cp[p_curent->parent_id]; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
155 SceneGraphPtr s_parent = (SceneGraphPtr)p_parent.scenegraph; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
156 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
157 /* childrenのリストの最後に加える (brother として)*/ |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
158 if (s_parent->lastChild != NULL) { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
159 SceneGraphPtr last_child = s_parent->lastChild; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
160 last_child->brother = sg; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
161 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
162 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
163 s_parent->lastChild = sg; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
164 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
165 if (s_parent->children == NULL) { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
166 s_parent->children = sg; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
167 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
168 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
169 sg->parent = s_parent; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
170 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
171 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
172 int |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
173 is_end(ChainPropertyPtr t) |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
174 { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
175 // どうやって終了させよう? |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
176 // property の個数を保持する必要がある? |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
177 // or for文ではなくて、条件にする |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
178 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
179 return 0; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
180 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
181 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
182 void |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
183 Chain::property_loop() |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
184 { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
185 for (ChainPropertyPtr t = &property[0]; is_end(t); t++){ |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
186 SceneGraphPtr sg = scenegraph_factory(t); // SceneGraphNode を作る |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
187 t->scenegraph = (void *)sg; // property list には SceneGraphへのポインタが入っている |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
188 scenegraph_connector((void *)properties[0], sg); // add する |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
189 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
190 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
191 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
192 void |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
193 post2propertyLoop(void *chain_) |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
194 { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
195 Application *chain = (Application *)chain_; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
196 //chain->property_loop(chain->sg_available_list); |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
197 chain->property_loop(); |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
198 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
199 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
200 void |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
201 Chain::property_ope(SceneGraphPtr sg_available_list_) |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
202 { |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
203 sg_available_list = sg_available_list_; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
204 chain_switch(); |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
205 } |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
206 |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
207 void |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
208 Chain::init(TaskManager *manager_, int w, int h) |
375 | 209 { |
210 SceneGraphPtr root_chain, chain; | |
520 | 211 //ChainProperty r; |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
212 manager = manager_; |
526 | 213 // 未実装 |
214 char *data = {"1"}; | |
215 int len = 0; | |
529
3527ba243767
modify applications not using SGid but SGname.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
526
diff
changeset
|
216 sgroot->createFromXMLfile(manager, "xml_file/chain.xml"); |
375 | 217 |
395 | 218 /* SPE に送る property の配列の領域確保 */ |
453
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
219 properties[0] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN); |
574be19530a5
Chain extends Application. add Application to Viewer.
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
449
diff
changeset
|
220 properties[1] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN); |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
221 property = properties[0]; |
395 | 222 |
520 | 223 root_chain = sgroot->createSceneGraph("CHAIN"); |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
224 init_chain_vars(&property[0]); |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
225 property[0].next_x = w / 2; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
226 property[0].next_y = 0.0; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
227 property[0].angle[0] = 0; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
228 property[0].angle[1] = 0; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
229 property[0].angle[2] = 0; |
395 | 230 |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
231 set_vector(&property[0], root_chain); |
375 | 232 |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
233 for(int i = 1; i < CHAIN_LEN; i++) { |
520 | 234 chain = sgroot->createSceneGraph("CHAIN"); |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
235 property[i].id = i; |
395 | 236 init_chain_vars(&property[i]); |
237 property[i].x = 0; | |
238 property[i].y = chain_width * i; | |
239 set_vector(&property[i], chain); | |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
240 property[i].angle[1] = -90 * (i % 2); |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
241 chain->propertyptr = &property[i]; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
242 chain->property_size = sizeof(ChainProperty); |
375 | 243 root_chain->addChild(chain); |
509
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
244 property[i].parent = root_chain; |
9f23e9d4973f
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
506
diff
changeset
|
245 property[i].parent_id = 0; |
375 | 246 } |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
395
diff
changeset
|
247 property[0].can_move = FALSE; |
375 | 248 |
249 sgroot->setSceneData(root_chain); | |
250 } | |
395 | 251 |