# HG changeset patch # User game@zeus.cr.ie.u-ryukyu.ac.jp # Date 1279296450 -32400 # Node ID fb23a3cce84848d6c2c8500b54df146f598eebf0 # Parent 56a752736db28e58eb39101709a05978272593b0 [aquarium] add direction of fish diff -r 56a752736db2 -r fb23a3cce848 Renderer/Test/aquarium.cc --- a/Renderer/Test/aquarium.cc Sat Jul 17 00:00:28 2010 +0900 +++ b/Renderer/Test/aquarium.cc Sat Jul 17 01:07:30 2010 +0900 @@ -52,9 +52,10 @@ aquarium::set_position(SceneGraphPtr node, unsigned char *reply) { aqua::Position *pos = new aqua::Position(); pos->ParseFromArray(reply + LINDA_HEADER_SIZE, psx_get_datalength(reply)); - node->stack_xyz[0] = node->xyz[0] = pos->x() - start_x; - node->stack_xyz[1] = node->xyz[1] = pos->y(); - + node->xyz[0] = pos->x() - start_x; + node->xyz[1] = pos->y(); + node->angle[0] = pos->angle_x(); + node->angle[1] = pos->angle_y(); delete pos; } @@ -148,6 +149,8 @@ aqua::Position *pos = new aqua::Position(); pos->set_x(node->xyz[0] + start_x); pos->set_y(node->xyz[1]); + pos->set_angle_x(node->angle[0]); + pos->set_angle_y(node->angle[1]); int size = pos->ByteSize(); unsigned char *msg = (unsigned char *) sgroot->manager->allocate(sizeof(char) * size); pos->SerializeToArray(msg, size); // 更新したデータを再度シリアライズ @@ -164,9 +167,11 @@ if (pad->right.isHold() || pad->left.isHold()) { if (pad->right.isHold()) { node->xyz[0] += 5.0f; + node->angle[0] = 0.0f; flag = 1; } else if (pad->left.isHold()) { node->xyz[0] -= 5.0f; + node->angle[0] = 180.0f; flag = 1; } } @@ -181,7 +186,7 @@ } } - /* ここで座標を送信 */ + /* ここで座標を送信 */ if (flag || node->resend_flag) { aquarium::send_position(node); } @@ -197,20 +202,25 @@ sgp->set_move_collision(my_move, null_collision); par->addChild(sgp); + sgp->c_xyz[0] = 0.0f; + sgp->c_xyz[1] = 0.0f; + sgp->c_xyz[2] = 0.0f; int xml_id = serial_id * 10; psx_out(linda, xml_id, (unsigned char *)addr, size); - int pos_id = serial_id * 10 + 1; - - aqua::Position *pos = new aqua::Position(); - pos->set_x(0.0f + start_x); - pos->set_y(0.0f); - unsigned char *msg = (unsigned char *) viewer->manager->allocate(sizeof(unsigned char *) * size); - pos->SerializeToArray(msg, size); + int pos_id = serial_id * 10 + 1; + + aqua::Position *pos = new aqua::Position(); + pos->set_x(0.0f + start_x); + pos->set_y(0.0f); + pos->set_angle_x(0.0f); + pos->set_angle_y(0.0f); + unsigned char *msg = (unsigned char *) viewer->manager->allocate(sizeof(unsigned char *) * size); + pos->SerializeToArray(msg, size); psx_out(linda, pos_id, (unsigned char *)msg, pos->ByteSize()); - delete pos; - sgp->seq = 0; - sgp->resend_flag = 0; + delete pos; + sgp->seq = 0; + sgp->resend_flag = 0; } MainLoopPtr diff -r 56a752736db2 -r fb23a3cce848 Renderer/Test/protobuf/aquarium.proto --- a/Renderer/Test/protobuf/aquarium.proto Sat Jul 17 00:00:28 2010 +0900 +++ b/Renderer/Test/protobuf/aquarium.proto Sat Jul 17 01:07:30 2010 +0900 @@ -7,4 +7,6 @@ message Position { required float x = 1; required float y = 2; + required float angle_x = 3; + required float angle_y = 4; }