Mercurial > hg > Members > kono > Cerium
changeset 591:7cbffb81e214
send linda not work...
author | kazz@kazzone.st.ie.u-ryukyu.ac.jp |
---|---|
date | Sun, 01 Nov 2009 06:14:52 +0900 |
parents | c81018fbf51e |
children | 56e63fc45105 |
files | Renderer/Engine/SceneGraphRoot.h Renderer/Test/dynamic_create.cc Renderer/Test/send_linda.cc |
diffstat | 3 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.h Fri Oct 30 18:41:56 2009 +0900 +++ b/Renderer/Engine/SceneGraphRoot.h Sun Nov 01 06:14:52 2009 +0900 @@ -54,6 +54,9 @@ // SceneGraphIterator SceneGraphIteratorPtr iterator; + // fd of Linda taple space + int tid; + /** * Functions */
--- a/Renderer/Test/dynamic_create.cc Fri Oct 30 18:41:56 2009 +0900 +++ b/Renderer/Test/dynamic_create.cc Sun Nov 01 06:14:52 2009 +0900 @@ -62,8 +62,8 @@ prev = clist; } if (c->id == id) { - prev->next = c->next; - return; + prev->next = c->next; + return; } } @@ -84,7 +84,24 @@ moon_move(SceneGraphPtr node, int screen_w, int screen_h) { //node->angle[0] += 3.0f; - node->xyz[1] += 1.0f; + //node->xyz[1] += 1.0f; + + // LindaServerから座標データを取得してオブジェクトに反映させる。 + static int seq = 0; + unsigned char *reply; + + printf("%d ", node->id); + if (seq == 0) + seq = psx_wait_rd(sgroot->tid, node->id * 10 + 1); + + reply = psx_reply(seq); + if (reply != NULL) { + float *data = (float *)(reply + LINDA_HEADER_SIZE); + for (int i = 0; i < 3; i++) { + node->xyz[i] = ntohl(data[i]); + } + seq = psx_wait_rd(sgroot->tid, node->id * 10 + 1); + } } @@ -102,6 +119,7 @@ // 読み込んだオブジェクトは、すべて、child の child になる。 sgroot->createFromXMLmemory(sgroot->tmanager, child, (char *)data, len); child->set_move_collision(moon_move, moon_collision); + child->id = serial_id; return child; } @@ -110,7 +128,7 @@ callback_get_xml(unsigned char *xml_tuple, void *arg) { int xml_len = psx_get_datalength(xml_tuple); callback_arg *carg = (callback_arg *)arg; - unsigned char *xml_data = xml_tuple+LINDA_HEADER_SIZE; + unsigned char *xml_data = xml_tuple + LINDA_HEADER_SIZE; SceneGraphPtr sgp; // ここで create // fwrite(xml_data, 1, 10, stdout); @@ -123,14 +141,14 @@ } static void -callbacker(unsigned char *tuple, void *arg) { +callbacker(unsigned char *taple, void *arg) { int serial_id, xml_id; unsigned char *data; callback_arg *carg = (callback_arg *)arg; // 最初の4byteデータは使わない - data = tuple+LINDA_HEADER_SIZE; + data = taple+LINDA_HEADER_SIZE; // clientのSerialIDを取得 serial_id = ntohl(*(int *)data); // serial_id = *(int *)data; @@ -148,7 +166,7 @@ /* dataは'\0'で終わっている事を期待 (writerで保証する) */ //printf("get data[%d]: `%s'\n", len, data); - free(tuple); + free(taple); psx_callback_in(carg->tid, carg->read_id, callbacker, arg); } @@ -162,6 +180,7 @@ callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg)); carg->tid = open_linda_java(linda, PORT); + sgroot->tid = carg->tid; carg->read_id = SERIAL_REGIST_TUPLE_NO; carg->node = node; carg->manager = manager; @@ -182,7 +201,7 @@ parent = sgroot->createSceneGraph(); parent->set_move_collision(earth_move, earth_collision); parent->xyz[0] += 300; - + parent->xyz[1] += 300; linda_init(sgroot->manager, clist, parent); // SceneGraphRoot に、使用する SceneGraph を設定する