Mercurial > hg > Game > Cerium
comparison Renderer/Test/send_linda.cc @ 841:8d702fc5d77a draft
dynamic loading demo bug fix
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 02 Jun 2010 01:39:15 +0900 |
parents | 91e2c96be77b |
children | de64695a7f02 |
comparison
equal
deleted
inserted
replaced
837:1ba88b4cfe44 | 841:8d702fc5d77a |
---|---|
21 | 21 |
22 void | 22 void |
23 send_position(SceneGraphPtr node) | 23 send_position(SceneGraphPtr node) |
24 { | 24 { |
25 char *data; | 25 char *data; |
26 if ((data = (char *)psx_reply(node->seq)) == NULL) { | 26 if (node->seq == 0) { |
27 //float send_data[6]; // xyz[3] and angle[3] | 27 } else if ((data = (char *)psx_reply(node->seq)) == NULL) { |
28 int tapleid = node->id * 10 + 1; | 28 psx_free(data); |
29 int fd = *(int*)node->propertyptr; | 29 } else { |
30 | 30 node->resend_flag = 1; |
31 // XDRの準備 | 31 return; |
32 XDR xdrs; | 32 } |
33 char send_data[SEND_DATA_SIZE]; | 33 node->resend_flag = 0; |
34 xdrmem_create(&xdrs, send_data, SEND_DATA_SIZE, XDR_ENCODE); | 34 |
35 //float send_data[6]; // xyz[3] and angle[3] | |
36 int tapleid = node->id * 10 + 1; | |
37 int fd = *(int*)node->propertyptr; | |
38 | |
39 // XDRの準備 | |
40 XDR xdrs; | |
41 char send_data[SEND_DATA_SIZE]; | |
42 xdrmem_create(&xdrs, send_data, SEND_DATA_SIZE, XDR_ENCODE); | |
35 | 43 |
36 for (int i = 0; i < 3; i ++) { | 44 for (int i = 0; i < 3; i ++) { |
37 xdr_float(&xdrs, &node->xyz[i]); | 45 xdr_float(&xdrs, &node->xyz[i]); |
38 } | 46 } |
39 for (int i = 0; i < 3; i ++) { | 47 for (int i = 0; i < 3; i ++) { |
40 xdr_float(&xdrs, &node->angle[i]); | 48 xdr_float(&xdrs, &node->angle[i]); |
41 } | 49 } |
42 node->seq = psx_in(fd, tapleid); | 50 node->seq = psx_in(fd, tapleid); |
43 psx_out(fd, tapleid, (unsigned char *)send_data, SEND_DATA_SIZE); | 51 psx_out(fd, tapleid, (unsigned char *)send_data, SEND_DATA_SIZE); |
44 psx_free(data); | |
45 } | |
46 } | 52 } |
47 | 53 |
48 void | 54 void |
49 root_move(SceneGraphPtr node, void *sgroot_, int w, int h) | 55 root_move(SceneGraphPtr node, void *sgroot_, int w, int h) |
50 { | 56 { |
72 } | 78 } |
73 | 79 |
74 /* | 80 /* |
75 ここでキー入力を向こうに送る | 81 ここでキー入力を向こうに送る |
76 */ | 82 */ |
77 if (flag) { | 83 if (flag || node->resend_flag) { |
78 send_position(node); | 84 send_position(node); |
79 } | 85 } |
80 } | 86 } |
81 | 87 |
82 void | 88 void |
143 psx_out(tspace, xml_id, (unsigned char *)addr, size); | 149 psx_out(tspace, xml_id, (unsigned char *)addr, size); |
144 psx_sync_n(); | 150 psx_sync_n(); |
145 } | 151 } |
146 | 152 |
147 static char *xml; | 153 static char *xml; |
148 static const char *linda = HOSTNAME; | 154 static char *linda = HOSTNAME; |
149 | 155 |
150 MainLoopPtr | 156 MainLoopPtr |
151 send_linda::init(Viewer *sgr, int screen_w, int screen_h) | 157 send_linda::init(Viewer *sgr, int screen_w, int screen_h) |
152 { | 158 { |
153 void *addr; | 159 void *addr; |
198 | 204 |
199 // serial_idを十倍して1足したところに座標データを送る | 205 // serial_idを十倍して1足したところに座標データを送る |
200 // 初期化のout() | 206 // 初期化のout() |
201 int pos_id = serial * 10 + 1; | 207 int pos_id = serial * 10 + 1; |
202 char pos_data[SEND_DATA_SIZE] = {0}; | 208 char pos_data[SEND_DATA_SIZE] = {0}; |
203 // float pos_data[6]; | 209 |
204 // for (int i = 0; i < 6; i++) { | 210 // init seq |
205 // pos_data[i] = 0.0f; | 211 // send_position()でinの終了を確認する分岐が最初にあるため |
206 // } | |
207 psx_out(tspace, pos_id, (unsigned char *)pos_data, SEND_DATA_SIZE); | 212 psx_out(tspace, pos_id, (unsigned char *)pos_data, SEND_DATA_SIZE); |
208 | 213 root->seq = 0; |
209 // 初期化のin() | 214 root->resend_flag = 0; |
210 // send_position()でinの終了を確認する分岐が最初にあるため | |
211 root->seq = psx_in(tspace, pos_id); | |
212 sgr->setSceneData(root); | 215 sgr->setSceneData(root); |
213 | 216 |
214 return sgr; | 217 return sgr; |
215 } | 218 } |
216 | 219 |