# HG changeset patch # User Shinji KONO # Date 1260001618 -32400 # Node ID f42b303044f71a4f09e67d6efb198f4cb4a29b0e # Parent 9eefc1b24c87c09c1c3388525ae101a67907291d fix several Renderer/Test with (void*)sgroot. diff -r 9eefc1b24c87 -r f42b303044f7 Renderer/Engine/viewer.h --- a/Renderer/Engine/viewer.h Thu Dec 03 09:02:40 2009 +0900 +++ b/Renderer/Engine/viewer.h Sat Dec 05 17:26:58 2009 +0900 @@ -74,6 +74,11 @@ // void setSceneData(SceneGraph *g); void mainLoop(); + void createFromXMLmemory(SceneGraph * node, char *data, int len) + { + sgroot->createFromXMLmemory(manager, node, data, len); + } + void createFromXMLfile(const char *file) { sgroot->createFromXMLfile(manager, file); diff -r 9eefc1b24c87 -r f42b303044f7 Renderer/Test/Chain.h --- a/Renderer/Test/Chain.h Thu Dec 03 09:02:40 2009 +0900 +++ b/Renderer/Test/Chain.h Sat Dec 05 17:26:58 2009 +0900 @@ -22,6 +22,7 @@ void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h); void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg); + MainLoopPtr init_only_sg(SgChange *sgchange, int w, int h); MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); diff -r 9eefc1b24c87 -r f42b303044f7 Renderer/Test/chain_old.cc --- a/Renderer/Test/chain_old.cc Thu Dec 03 09:02:40 2009 +0900 +++ b/Renderer/Test/chain_old.cc Sat Dec 05 17:26:58 2009 +0900 @@ -42,8 +42,9 @@ static void -chain_old_move_ope(SceneGraphPtr node, int screen_w, int screen_h) +chain_old_move_ope(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); if (pad->start.isHold()) { @@ -65,8 +66,9 @@ } void -chain_old_move(SceneGraphPtr sg, int w, int h) +chain_old_move(SceneGraphPtr sg, void *sgroot_, int w, int h) { + int id = sg->id; if(id == 0) { for(int cnt = 0; cnt < 600; cnt++) { @@ -121,7 +123,7 @@ } void -chain_old_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg) +chain_old_collision(SceneGraphPtr sg, void *sgroot_, int w, int h, SceneGraphPtr osg) { } @@ -159,6 +161,13 @@ return sgroot; } +MainLoopPtr +Chain::init_only_sg(SgChange *sgchange, int w, int h) +{ + return sgchange; +} + + extern Application * application() { return new Chain(); diff -r 9eefc1b24c87 -r f42b303044f7 Renderer/Test/dynamic_create.cc --- a/Renderer/Test/dynamic_create.cc Thu Dec 03 09:02:40 2009 +0900 +++ b/Renderer/Test/dynamic_create.cc Sat Dec 05 17:26:58 2009 +0900 @@ -37,6 +37,7 @@ int sid; int read_id; SceneGraphPtr node; + SceneGraphRoot *sgroot; TaskManager *manager; client_t *clist; } callback_arg; @@ -105,13 +106,13 @@ static void -earth_move(SceneGraphPtr node, int screen_w, int screen_h) +earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { // psx_sync_n(); in viewer::MainLoop } SceneGraphPtr -create_sg(TaskManager *manager, SceneGraphPtr parent, unsigned char *data, +create_sg(TaskManager *manager, SceneGraphRoot *sgroot, SceneGraphPtr parent, unsigned char *data, int len, int serial_id) { SceneGraphPtr child = sgroot->createSceneGraph(); @@ -119,8 +120,8 @@ // 読み込んだオブジェクトは、すべて、child の child になる。 sgroot->createFromXMLmemory(sgroot->tmanager, child, (char *)data, len); child->set_move_collision(moon_move, moon_collision); - child->id = serial_id; - child->seq = psx_wait_rd(sgroot->tid, serial_id * 10 + 1); + child->id = serial_id; + child->seq = psx_wait_rd(sgroot->tid, serial_id * 10 + 1); return child; } @@ -134,7 +135,7 @@ SceneGraphPtr sgp; // ここで create // fwrite(xml_data, 1, 10, stdout); - sgp = create_sg(carg->manager, carg->node, xml_data, xml_len, carg->sid); + sgp = create_sg(carg->manager, carg->sgroot, carg->node, xml_data, xml_len, carg->sid); printf("%s size %d loaded\n", sgp->children->name, xml_len); client_list_update(carg->manager, carg->clist, carg->sid, sgp); free(arg); @@ -166,20 +167,23 @@ /* dataは'\0'で終わっている事を期待 (writerで保証する) */ //printf("get data[%d]: `%s'\n", len, data); free(taple); - + + // arg は使い回すらしい。 + psx_callback_in(carg->tid, carg->read_id, callbacker, arg); } static char const *linda = "localhost"; -void -linda_init(TaskManager *manager, client_t *clist, SceneGraphPtr node) +static void +linda_init(TaskManager *manager, SceneGraphRoot *sgroot, client_t *clist, SceneGraphPtr node) { init_linda(); callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg)); carg->tid = open_linda_java(linda, PORT); - sgroot->tid = carg->tid; + carg->sgroot = sgroot; + carg->sgroot->tid = carg->tid; carg->read_id = SERIAL_REGIST_TUPLE_NO; carg->node = node; carg->manager = manager; @@ -201,7 +205,7 @@ parent->set_move_collision(earth_move, earth_collision); // parent->xyz[0] += 300; // parent->xyz[1] += 300; - linda_init(sgroot->manager, clist, parent); + linda_init(sgroot->manager, sgroot->sgroot, clist, parent); // SceneGraphRoot に、使用する SceneGraph を設定する // このとき、ユーザーが記述した SceneGraph の root を渡す。 diff -r 9eefc1b24c87 -r f42b303044f7 Renderer/Test/send_linda.cc --- a/Renderer/Test/send_linda.cc Thu Dec 03 09:02:40 2009 +0900 +++ b/Renderer/Test/send_linda.cc Sat Dec 05 17:26:58 2009 +0900 @@ -46,8 +46,9 @@ } void -root_move(SceneGraphPtr node, int w, int h) +root_move(SceneGraphPtr node, void *sgroot_, int w, int h) { + SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); int flag = 0; if (pad->right.isHold() || pad->left.isHold()) { @@ -79,17 +80,17 @@ } void -root_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +root_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) { } void -move(SceneGraphPtr node, int w, int h) +move(SceneGraphPtr node, void *sgroot_, int w, int h) { } void -collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) { } @@ -155,35 +156,34 @@ int serial; int xml_id; - SceneGraphPtr sgp; - SceneGraphPtr root; // ここら辺長ったるいから、関数で分けるべきか... // root オブジェクト作成 - root = sgroot->createSceneGraph(); + SceneGraphPtr root = sgr->createSceneGraph(); // root_moveはコントローラーの入力で動き、座標をLinda Serverにout root->set_move_collision(root_move, root_collision); // XMLをメモリにmapして、オブジェクト生成 addr = file_map(xml, &size); - sgp = sgroot->createSceneGraph(); - sgroot->createFromXMLmemory(sgroot->tmanager, sgp, (char *)addr, size); + SceneGraphPtr sgp = sgr->createSceneGraph(); + sgr->createFromXMLmemory(sgp, (char *)addr, size); sgp->set_move_collision(move, collision); // rootに接続 root->addChild(sgp); - // Linda Serverに接続 - tspace = open_linda_java(linda, PORT_NUM); + // Linda Serverに接続 + tspace = open_linda_java(linda, PORT_NUM); // rootにLindaのfdを持たせる - root->propertyptr = sgroot->tmanager->allocate(sizeof(int)); - root->property_size = sizeof(int); - *(int *)root->propertyptr = tspace; + root->propertyptr = (void*)malloc(sizeof(int)); + int *p = (int*)root->propertyptr; + root->property_size = sizeof(int); + *p = tspace; - // このclientのserial_idを取得 - serial = get_serial_id(tspace); - root->id = serial; + // このclientのserial_idを取得 + serial = get_serial_id(tspace); + root->id = serial; // ここから先の処理は、裏で何か動かせないかを考える // とりあえず、関数に分けようか @@ -209,11 +209,17 @@ // 初期化のin() // send_position()でinの終了を確認する分岐が最初にあるため root->seq = psx_in(tspace, pos_id); - sgroot->setSceneData(root); + sgr->setSceneData(root); return sgr; } +MainLoopPtr +send_linda::init_only_sg(SgChange *sgchange, int w, int h) +{ + return sgchange; +} + extern Application * application() { return new send_linda(); diff -r 9eefc1b24c87 -r f42b303044f7 Renderer/Test/send_linda.h --- a/Renderer/Test/send_linda.h Thu Dec 03 09:02:40 2009 +0900 +++ b/Renderer/Test/send_linda.h Sat Dec 05 17:26:58 2009 +0900 @@ -7,5 +7,6 @@ class send_linda : public Application { MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + MainLoopPtr init_only_sg(SgChange *sgroot, int screen_w, int screen_h); };