# HG changeset patch # User kazz@kazz187.st.ie.u-ryukyu.ac.jp # Date 1256787298 -32400 # Node ID d5d8e1cf1899b588bf50697d03e47d33e7160e2e # Parent bdeb424ce649ff225322f9ae022522ab5df0f8e5 send position test diff -r bdeb424ce649 -r d5d8e1cf1899 Renderer/Test/send_linda.cc --- a/Renderer/Test/send_linda.cc Wed Oct 28 20:28:17 2009 +0900 +++ b/Renderer/Test/send_linda.cc Thu Oct 29 12:34:58 2009 +0900 @@ -15,32 +15,63 @@ #define PORT_NUM 10000 #define LISTEN_PORT 1 #define MULTI_NUM 10 +#define SEND_DATA_SIZE 24 //sizeof(float) * 6; +void +send_position(SceneGraphPtr node) +{ + char *data; + char send_data[SEND_DATA_SIZE]; // xyz[3] and angle[3] + int tapleid = node->id * 10 + 1; + int fd = *(int*)node->propertyptr; + int seq; + int i; + + for (i = 0; i < 3; i ++) { + ((float *)send_data)[i] = htonl(node->xyz[i]); + ((float *)send_data)[i+3] = htonl(node->angle[i]); + } + seq = psx_in(fd, tapleid); + do { + psx_sync_n(); + data = (char *)psx_reply(seq); + } while (data == NULL); + psx_out(fd, tapleid, (unsigned char *)send_data, SEND_DATA_SIZE); + psx_sync_n(); + psx_free(data); +} void root_move(SceneGraphPtr node, int w, int h) { Pad *pad = sgroot->getController(); - + int flag = 0; if (pad->right.isHold() || pad->left.isHold()) { if (pad->right.isHold()) { node->xyz[0] += 5.0f; + flag = 1; } else if (pad->left.isHold()) { node->xyz[0] -= 5.0f; + flag = 1; } } if (pad->down.isHold() || pad->up.isHold() ) { if (pad->down.isHold()) { node->xyz[1] += 5.0f; + flag = 1; } else if (pad->up.isHold()) { node->xyz[1] -= 5.0f; + flag = 1; } } - /* + /* ここでキー入力を向こうに送る */ - + + if (flag) { + send_position(node); + } } void @@ -160,14 +191,26 @@ root->addChild(sgp); tspace = open_linda_java(linda, PORT_NUM); + root->propertyptr = sgroot->tmanager->allocate(sizeof(int)); + root->property_size = sizeof(int); + *(int *)root->propertyptr = tspace; + serial = get_serial_id(tspace); + root->id = serial; xml_id = serial * 10; send_xml(tspace, xml_id, addr, size); int client_id = htonl(serial); printf("serial id = %d\n", client_id); send_xml(tspace, LISTEN_PORT, (unsigned char *)&client_id, sizeof(int)); - + + int pos_id = serial * 10 + 1; + char pos_data[SEND_DATA_SIZE]; + for (int i = 0; i < 6; i++) { + ((float *)pos_data)[i] = htonl(0.0f); + } + send_xml(tspace, pos_id, (unsigned char *)pos_data, SEND_DATA_SIZE); + sgroot->setSceneData(root); return sgr; } @@ -191,11 +234,11 @@ manager->set_TMend(TMend); for(int i=0;i