# HG changeset patch # User Shinji KONO # Date 1256223332 -32400 # Node ID 8fca17aa57dfe07aeff46a3ae1707c795c762d72 # Parent 47b61865ea8ceb9dac10b1d74dd7402c53ea46e3# Parent 4cff1ffa60dbfbb743372e0f52cfcccbf4945ba0 merge diff -r 4cff1ffa60db -r 8fca17aa57df .hgtags --- a/.hgtags Tue Oct 20 20:36:13 2009 +0900 +++ b/.hgtags Thu Oct 22 23:55:32 2009 +0900 @@ -1,7 +1,13 @@ ce5755f544c1a882c7e28b7c78d8b31a82bd9eda cvs 1f4c3f3238e6278fa3c73594e027036a1404ec34 fullHD_omedetou 30568cef3899caea3db0fb9e28b0e6f889c60679 double-linked-task-list +<<<<<<< local +0000000000000000000000000000000000000000 ball_bound +0000000000000000000000000000000000000000 513 +53f6939d7c970bbde5bbe9f32b64463f4ded8f01 ball_bound +======= f8d9830d94cda230d8d544002436a1462a5f8949 ball_bound 2bc1e486e71d12555fa31ea16b8d47a1bbbee20a ball_bound 2bc1e486e71d12555fa31ea16b8d47a1bbbee20a -r 2bc1e486e71d12555fa31ea16b8d47a1bbbee20a 513 +>>>>>>> other diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/MainLoop.h --- a/Renderer/Engine/MainLoop.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/MainLoop.h Thu Oct 22 23:55:32 2009 +0900 @@ -9,4 +9,4 @@ }; typedef MainLoop *MainLoopPtr; -#endif MAINLOOP +#endif /* MAINLOOP */ diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/Makefile --- a/Renderer/Engine/Makefile Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/Makefile Thu Oct 22 23:55:32 2009 +0900 @@ -4,11 +4,11 @@ @echo "Make for Mac OS X" @$(MAKE) -f Makefile.macosx -cell: +cell: FORCE @echo "Make for PS3 (Cell)" @$(MAKE) -f Makefile.cell -linux: +linux: FORCE @echo "Make for Linux" @$(MAKE) -f Makefile.linux @@ -22,8 +22,8 @@ @$(MAKE) -f Makefile.linux depend FORCE: - -mkdir -p ../include/Cerium - rsync `find . -name Test -prune -or -name '*.h' -print` ../../include/Cerium + -mkdir -p ../../include/Cerium + rsync `find . -name Test -prune -or -name spe -prune -or -name task -prune -or -name '*.h' -print` ../../include/Cerium clean: diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/Makefile.cell --- a/Renderer/Engine/Makefile.cell Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/Makefile.cell Thu Oct 22 23:55:32 2009 +0900 @@ -26,7 +26,7 @@ all: $(TARGET) speobject $(TARGET): $(OBJS) $(TASK_OBJS) - $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + $(AR) crus $@ $(OBJS) $(TASK_OBJS) SGList.o: create_sg_list $(CC) $(CFLAGS) $(INCLUDE) -c SGList.cc -o $@ diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/SceneGraphRoot.cc --- a/Renderer/Engine/SceneGraphRoot.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Thu Oct 22 23:55:32 2009 +0900 @@ -6,18 +6,23 @@ #include "sys.h" #include "TextureHash.h" #include "texture.h" -#include +//#include "SGList.h" +#include "Application.h" -static int cnt = 0; +int cnt = 0; +static const int SGLIST_LENGTH = 138; -#define SGLIST_INIT_LENGTH 128 + +SceneGraphRoot *sgroot; SceneGraphRoot::SceneGraphRoot(float w, float h) { - sg_src = (SceneGraphPtr)malloc(sizeof(SceneGraphPtr)*SGLIST_INIT_LENGTH ); - sg_src_length = SGLIST_INIT_LENGTH ; + // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな + // + sg_src = new SceneGraphPtr[SGLIST_LENGTH]; camera = new Camera(w, h); iterator = new SceneGraphIterator; + sglist = new SceneGraphList; controller = create_controller(); sg_exec_tree = NULL; @@ -25,6 +30,8 @@ sg_available_list = NULL; sg_remove_list = NULL; + sgroot = this; + // TODO // 今はとりあえず camera を Root にしています // 今はそれすらもしてません @@ -51,7 +58,7 @@ cnt--; } - free(sg_src); + delete [] sg_src; delete camera; delete iterator; delete controller; @@ -62,26 +69,9 @@ * * @param sg SceneGraph created by xmlfile */ - -extern const char *sglist_table[]; - void SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) { - for (int i = 0; i < sg_src_length && sglist_table[i]; i++) { - if (strcmp(sg->name, sglist_table[i]) == 0) { - sg->sgid = i; - if (i>= sg_src_length) { - sg_src_length += sizeof(SceneGraphPtr)*SGLIST_INIT_LENGTH ; - sg_src = (SceneGraphPtr)realloc(sg_src, sg_src_length); - } - sg_src[i] = sg; - return; - } - } - - fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n", - __FUNCTION__, __LINE__, sg->name); } void @@ -109,7 +99,7 @@ xmlDocPtr doc; xmlNodePtr cur; SceneGraphPtr tmp; - + /* パース DOM生成 */ doc = xmlParseFile(xmlfile); cur = xmlDocGetRootElement(doc); @@ -119,18 +109,20 @@ /* XMLのノードを一つずつ解析 */ for (cur=cur->children; cur; cur=cur->next) { - /* 扱うのはsurfaceオンリー */ - if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { - continue; - } + /* 扱うのはsurfaceオンリー */ + if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { + continue; + } - /* ポリゴン(SceneGraph)生成 */ - tmp = new SceneGraph(manager, cur); + /* ポリゴン(SceneGraph)生成 */ + tmp = new SceneGraph(manager, cur); - registSceneGraph(tmp); + addSceneGraphList(manager, tmp); + registSceneGraphList(tmp); } xmlFreeDoc(doc); + } SceneGraphPtr @@ -139,12 +131,12 @@ SceneGraphPtr src; SceneGraphPtr p; - if (id < 0 || id > sg_src_length) { + if (id < 0 || id > SGLIST_LENGTH) { return NULL; } /* オリジナルの SceneGraph */ - src = sg_src+id; + src = sg_src[id]; /* ユーザーにはオリジナルの clone を返す */ p = src->clone(); @@ -154,6 +146,102 @@ return p; } +void +SceneGraphRoot::registSceneGraphList(SceneGraphPtr sg) +{ + /* + SceneGraphRoot にメンバ変数 SceneGraphList を持たせておくか + SceneGraphList sglist + sg->name で検索して、有れば sg_src に追加。 + sgid は sglist のメンバ変数 sgid で管理する感じ + */ + + SgStruct *s = sglist->get(sg->name); + if (s != NULL) { + sg->sgid = sglist->sgid; + s->id = sglist->sgid; + sg_src[sg->sgid] = sg; + sglist->sgid++; + return; + } + + fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n", + __FUNCTION__, __LINE__, sg->name); +} + +void +SceneGraphRoot::createFromXMLmemory(TaskManager *manager, char *data, int len) +{ + xmlDocPtr doc; + xmlNodePtr cur; + + // size は取れるはず、テスト用に mmap したデータを使う + /* パース DOM生成 */ + + doc = xmlParseMemory(data, len); + cur = xmlDocGetRootElement(doc); + + /* ?? */ + xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); + + /* XMLのノードを一つずつ解析 */ + for (cur=cur->children; cur; cur=cur->next) { + /* 扱うのはsurfaceオンリー */ + if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { + continue; + } + + /* ポリゴン(SceneGraph)生成 */ + SceneGraphPtr tmp = new SceneGraph(manager, cur); + + addSceneGraphList(manager, tmp); + + registSceneGraphList(tmp); + } + + xmlFreeDoc(doc); +} + +/* 生成された SceneGraph のを sglist に登録 */ +void +SceneGraphRoot::addSceneGraphList(TaskManager *manager, SceneGraphPtr tmp) +{ + SgStruct *sg_t = (SgStruct *)manager->allocate(sizeof(SgStruct)); + sg_t->name = tmp->name; + sglist->addLast(sg_t); +} + +SceneGraphPtr +SceneGraphRoot::createSceneGraph(const char *name) +{ + SceneGraphPtr src; + SceneGraphPtr p; + + // SceneGraphList から name を検索して id 取得 + SgStruct *e = sglist->get(name); + int id = e->id; + if (id < 0) { + return NULL; + } + + /* オリジナルの SceneGraph */ + src = sg_src[id]; + + /* ユーザーにはオリジナルの clone を返す */ + p = src->clone(); + + addNext(p); + + return p; +} + +int +SceneGraphRoot::getSgid(const char *name) +{ + SgStruct *e = sglist->get(name); + return e->id; +} + /** * 何も表示しない、move,collision もしない SceneGraph を生成 * いずれ、Transform3D 的なものに回す予定 @@ -208,14 +296,69 @@ /*removeのflagをもとにtreeを形成*/ /* spe から送り返されてきた property の配列を見て生成する for()*/ /* - for (Property *t = property[0]; is_end(t); t++){ - SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る - t->scenegraph = s; // property list には SceneGraphへのポインタが入っている - application->scenegraph_connector(property[0], s); // add する - } + for (Property *t = (Property*)app->property[0]; is_end(t); t++){ + SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = s; // property list には SceneGraphへのポインタが入っている + app->scenegraph_connector(property[0], s); // add する + } + */ + + + // 現在、allExecute が終わった時点では + // camera->children が User SceneGraph の root になる + + /** + * NULL じゃなかったら、setSceneData が呼ばれてるから + * そっちを次の Scene にする + */ + + sg_exec_tree = camera->children; +} + +void +SceneGraphRoot::speExecute(int screen_w, int screen_h, Application *app) +{ + // SceneGraphPtr t = sg_exec_tree; + // SceneGraphPtr cur_parent = camera; + + // 前フレームで描画した SceneGraph は削除 + allRemove(sg_remove_list); + + // 前フレームに作られた SceneGraph は描画用に移行 + // 現フレームでの操作は以下の tree,list には適用されない + sg_draw_tree = sg_exec_tree; + sg_remove_list = sg_available_list; + + // 現フレームで新しく SceneGraph がコピーされるので初期化 + sg_exec_tree = NULL; + sg_available_list = NULL; + + camera->move_execute(screen_w, screen_h); + camera->update(screen_w, screen_h); + + camera->children = NULL; + camera->lastChild = NULL; + + + if(sg_exec_tree != NULL) { + return; + } + + /*removeのflagをもとにtreeを形成*/ + /* spe から送り返されてきた property の配列を見て生成する for()*/ + /* Application内に移動 */ + + // app->property_ope(sg_available_list); + + /* + for (Property *t = (Property *)properties[0]; is_end(t); t++){ + SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = s; // property list には SceneGraphへのポインタが入っている + app->scenegraph_connector(property[0], s); // add する + } */ - - + + // 現在、allExecute が終わった時点では // camera->children が User SceneGraph の root になる diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/SceneGraphRoot.h --- a/Renderer/Engine/SceneGraphRoot.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/SceneGraphRoot.h Thu Oct 22 23:55:32 2009 +0900 @@ -5,16 +5,33 @@ #include "SceneGraphArray.h" #include "Camera.h" #include "SceneGraphIterator.h" +// #include "Application.h" +#include "SceneGraphList.h" +#include "SgStruct.h" +// #include "TaskManager.h" +#include + +typedef struct { + caddr_t file_mmap; + off_t size; +} st_mmap_t; + +class Application; class SceneGraphRoot { public: /* Constructor, Destructor */ SceneGraphRoot(float w, float h); - ~SceneGraphRoot(void); + ~SceneGraphRoot(); /* Variables */ + TaskManager *tmanager; + + // sgid と name を持った SgStruct のリスト + SceneGraphList *sglist; + // xml から読み込んだ、オリジナルの SceneGraph - SceneGraphPtr sg_src; + SceneGraphPtr *sg_src; int sg_src_length; // move, collision 用の SceneGraph (tree) @@ -48,33 +65,49 @@ */ /* User API */ void createFromXMLfile(TaskManager *manager, const char *); + //void createFromXMLmemory(TaskManager *manager, const char *xml); + //void createFromXMLmemory(TaskManager *manager, st_mmap_t mmap_t); + void createFromXMLmemory(TaskManager *manager, char *data, int len); SceneGraphPtr createSceneGraph(int id); - SceneGraphPtr createSceneGraph(void); + SceneGraphPtr createSceneGraph(); + SceneGraphPtr createSceneGraph(const char *name); + int getSgid(const char *name); + void setSceneData(SceneGraphPtr sg); - Pad *getController(void); - SceneGraphIteratorPtr getIterator(void); + Pad *getController(); + SceneGraphIteratorPtr getIterator(); SceneGraphIteratorPtr getIterator(SceneGraphPtr list); - CameraPtr getCamera(void); + CameraPtr getCamera(); /* Other System API */ void allExecute(int screen_w, int screen_h); - void checkRemove(void); - SceneGraphPtr getExecuteSceneGraph(void); - SceneGraphPtr getDrawSceneGraph(void); - void updateControllerState(void); + void checkRemove(); + SceneGraphPtr getExecuteSceneGraph(); + SceneGraphPtr getDrawSceneGraph(); + void updateControllerState(); void speExecute(int screen_w, int screen_h); + void speExecute(int screen_w, int screen_h, Application *app); /* System API */ void registSceneGraph(SceneGraphPtr sg); + void registSceneGraphList(SceneGraphPtr sg); + void addSceneGraphList(TaskManager *manager, SceneGraphPtr tmp); void addNext(SceneGraphPtr sg); void allRemove(SceneGraphPtr list); + + int getLast() { + return sglist->getLast()->id; + } + }; typedef SceneGraphRoot *SceneGraphRootPtr; -#endif // 大域変数は無くすこと -extern SceneGraphRootPtr sgroot; -extern SceneGraphRootPtr sgroot_2; +extern SceneGraphRoot *sgroot; + +#endif + +/* end */ diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/lindaapi.h --- a/Renderer/Engine/lindaapi.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/lindaapi.h Thu Oct 22 23:55:32 2009 +0900 @@ -1,8 +1,15 @@ -// $Id: lindaapi.h,v 1.8 2005/12/21 07:29:38 yasumura Exp $ -// +#ifndef _LINDAAPI_H + +#define _LINDAAPI_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* $Id$ */ /*---------------------------------------------------------------------- - ޥ + マクロ定義 ----------------------------------------------------------------------*/ #define FAIL (-1) @@ -13,8 +20,10 @@ #define INT_SIZE 4 // Byte = sizeof(int) +#define LDSERV_PORT 11511 + /*---------------------------------------------------------------------- - ѥåȥեޥå + パケットフォーマット char short int int Mode + ID + Seq + Data_len + Padding + Data 0 1 3 7 11 12 @@ -24,63 +33,65 @@ #define LINDA_ID_OFFSET 1 #define LINDA_SEQ_OFFSET 3 #define LINDA_DATA_LENGTH_OFFSET 7 -#define LINDA_TID_OFFSET 11 #define LINDA_HEADER_SIZE 12 /*---------------------------------------------------------------------- - ¤ + 構造体定義 ----------------------------------------------------------------------*/ typedef struct psx_reply{ unsigned char *answer; unsigned int seq; struct psx_reply *next; char mode; - void(*callback)(char * tuple, void * obj); + void(*callback)(unsigned char * tuple, void * obj); void * obj; -} REPLY, *REPLY_PTR; - +} REPLY; + typedef struct command_queue{ + struct command_queue *next; + unsigned int tspace_id; /* ID of destination Tuple Space */ + unsigned int size; unsigned char *command; - struct command_queue *next; - unsigned int size; -} COMMAND, *COMMAND_PTR; +} COMMAND; + /*---------------------------------------------------------------------- - Ūؿƥץ졼 + Linda API ----------------------------------------------------------------------*/ -int start_linda(char *hostname); -void unix_chkserv(); -extern void psx_free(char *tuple); +extern void init_linda(void); +extern int open_linda(char *hostname, int port); +extern int open_linda_java(char *hostname, int port); +extern int close_linda(int tspace_id); -int psx_out(unsigned int id, unsigned char *data, unsigned int size); -int psx_ld(unsigned int id, char mode, void(*callback)(char *,void *),void * obj); +extern void psx_free(void*); -#define psx_in(id) psx_ld(id, 'i', NULL, NULL) -#define psx_rd(id) psx_ld(id, 'r', NULL, NULL) -#define psx_ck(id) psx_ld(id, 'c', NULL, NULL) -#define psx_wait_rd(id) psx_ld(id, 'w', NULL, NULL) - -#define psx_callback_in(id,callback,obj) psx_ld(id, 'i', callback, obj) -#define psx_callback_rd(id,callback,obj) psx_ld(id, 'r', callback, obj) -#define psx_callback_ck(id,callback,obj) psx_ld(id, 'c', callback, obj) -#define psx_callback_wait_rd(id,callback,obj) psx_ld(id, 'w', callback, obj) +extern unsigned char *psx_reply(unsigned int seq); +extern void psx_sync_n(void); +extern unsigned int psx_get_datalength(unsigned char *); +extern unsigned int psx_get_seq(unsigned char *); +extern unsigned short psx_get_id(unsigned char *); +extern unsigned char psx_get_mode(unsigned char *); +extern unsigned char * psx_get_data(unsigned char *); -unsigned char *psx_reply(int seq); -void psx_sync_n(); -//void psx_free(unsigned char *); -int psx_queue(unsigned int id, unsigned int size, unsigned char *data, char mode, - void(*callback)(char *,void *),void * obj); -int psx_get_datalength(unsigned char *); -unsigned char *psx_get_data(unsigned char *); -int psx_get_seq(unsigned char *); -short psx_get_id(unsigned char *); -char psx_get_mode(unsigned char *); +extern int psx_out(unsigned int tspace_id, unsigned int id, + unsigned char *data, unsigned int size); +extern int psx_ld(unsigned int tspace_id, unsigned int id, + char mode, void(*callback)(unsigned char *,void *),void * obj); + +#define psx_in(tid, id) psx_ld(tid, id, 'i', NULL, NULL) +#define psx_rd(tid, id) psx_ld(tid, id, 'r', NULL, NULL) +#define psx_ck(tid, id) psx_ld(tid, id, 'c', NULL, NULL) +#define psx_wait_rd(tid, id) psx_ld(tid, id, 'w', NULL, NULL) -int unix_open(); /* UNIX ̿ߤ */ -int unix_read(int,char *,unsigned int); /* UNIX ɤ߹ */ -int unix_read_w(int,char *,int); /* UNIX ɤ߹(non wait) */ -int unix_write(int,unsigned char *,unsigned int);/* UNIX ؽ񤭹 */ -int unix_write_w(int,unsigned char *,unsigned int);/* UNIX ؽ񤭹(non wait) */ -int send_able(); /* ɤ߽񤭤Ǥѥåȿ */ +#define psx_callback_in(tid, id,callback,obj) psx_ld(tid, id, 'i', callback, obj) +#define psx_callback_rd(tid, id,callback,obj) psx_ld(tid, id, 'r', callback, obj) +#define psx_callback_ck(tid, id,callback,obj) psx_ld(tid, id, 'c', callback, obj) +#define psx_callback_wait_rd(tid, id,callback,obj) psx_ld(tid, id, 'w', callback, obj) + + +#ifdef __cplusplus +}; // for extern "C" +#endif +#endif // _LINDAAPI_H diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/main.cc --- a/Renderer/Engine/main.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/main.cc Thu Oct 22 23:55:32 2009 +0900 @@ -5,16 +5,17 @@ #include "Application.h" /* prototype */ -static int init(TaskManager *manager, int argc, char *argv[]); +extern int init(TaskManager *manager, int argc, char *argv[]); static void TMend(TaskManager *manager); extern void task_initialize(); extern Application *application(); +extern int init(TaskManager *manager, int argc, char *argv[]); -// 帯域変数は禁止 +// 大域変数は禁止 //static Viewer *screen; - +/* const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n\ -cpu Number of SPE (default 1)\n\ -width, -height window size (default 640x480)\n\ @@ -26,6 +27,7 @@ 4: テクスチャテスト:2048x1536\n\ 5: 地球が動き、その周りを月が自転、公転する\n\ 6 以降: キューブが跳ね返りながら、勝手にキューブが増えて行く\n"; + */ int init(TaskManager *manager, int argc, char *argv[]) @@ -72,18 +74,18 @@ screen->video_init(manager); screen->run_init(manager, application()); - manager->set_TMend(TMend); return 0; } +#if 0 int TMmain(TaskManager *manager, int argc, char *argv[]) { task_initialize(); + manager->set_TMend(TMend); return init(manager, argc, argv); - //return 0; } void @@ -91,3 +93,5 @@ { printf("test_nogl end\n"); } + +#endif diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/viewer.cc Thu Oct 22 23:55:32 2009 +0900 @@ -12,22 +12,21 @@ #include "Pad.h" #include "Application.h" -static void post2runLoop(void *viewer); -static void post2runDraw(void *viewer); -static void post2speRendering(void *viewer); -static void post2speDraw(void *viewer); -// static void post2speRunLoop(void *viewer); -//static void post2runMove(void *viewer); -//static void post2exchange_sgroot(void *viewer); -//static void post2speRunLoop(void *viewer); -static void post2runMoveDrawLoop(void *viewer); +static void post2runLoop(SchedTask *s,void *viewer,void *s1); +static void post2runDraw(SchedTask *s,void *viewer,void *s1); +static void post2speRendering(SchedTask *s,void *viewer,void *s1); +static void post2speDraw(SchedTask *s,void *viewer,void *s1); +static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1); /* measure for FPS (Frame Per Second) */ int start_time; int this_time; int frames; +// static void post2speRunLoop(void *viewer); +//static void post2runMove(void *viewer); +//static void post2exchange_sgroot(void *viewer); +//static void post2speRunLoop(void *viewer); -SceneGraphRootPtr sgroot; //SceneGraphRootPtr sgroot_2; /* Data Pack sent to Other CPUs (ex. SPE) */ @@ -91,23 +90,6 @@ SDL_GL_SwapBuffers(); } -void -Viewer::createFromXMLfile(const char *file) -{ - sgroot->createFromXMLfile(manager, file); -} - -SceneGraph * -Viewer::createSceneGraph(int id) -{ - return sgroot->createSceneGraph(id); -} - -void -Viewer::setSceneData(SceneGraph *g) -{ - sgroot->setSceneData(g); -} void Viewer::run_init(TaskManager *manager, Application *app) @@ -119,6 +101,7 @@ frames = 0; sgroot = new SceneGraphRoot(this->width, this->height); + sgroot->tmanger = this; MainLoop *mainloop = app->init(this, this->width, this->height); @@ -200,7 +183,7 @@ HTaskPtr task_switch = manager->create_task(TASK_SWITCH); task_switch->wait_for(task_next); - task_switch->set_post(post2runMoveDrawLoop, (void*)this); + task_switch->set_post(post2runMoveDrawLoop, (void*)this, 0); task_switch->spawn(); } @@ -250,7 +233,7 @@ } static void -post2runMoveDrawLoop(void *viewer_) +post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; @@ -278,14 +261,14 @@ HTaskPtr switch_task = viewer->manager->create_task(TASK_SWITCH); viewer->draw_dummy = draw_dummy; switch_task->wait_for(draw_dummy); - draw_task->set_post(post2speRendering, (void*)viewer); + draw_task->set_post(post2speRendering, (void*)viewer, 0); switch_task->wait_for(move_task); switch_task->wait_for(draw_task); move_task->spawn(); draw_task->spawn(); - switch_task->set_post(post2runMoveDrawLoop, (void*)viewer); + switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0); switch_task->spawn(); } @@ -305,7 +288,7 @@ { HTaskPtr task_next = initLoop(); - task_next->set_post(&post2runLoop, (void *)this); // set_post(function(this->run_loop()), NULL) + task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL) task_next->spawn(); } @@ -333,7 +316,7 @@ } void -post2rendering(void *viewer_) +post2rendering(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer *)viewer_; HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); @@ -347,14 +330,14 @@ // Barrier 同期 // run_draw() を呼ぶ post2runDraw - task_next->set_post(post2runDraw, (void*)this); // set_post(function(this->run_draw()), NULL) + task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL) task_next->spawn(); // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ } static void -post2runLoop(void *viewer_) +post2runLoop(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); @@ -389,7 +372,7 @@ } static void -post2runDraw(void *viewer_) +post2runDraw(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); @@ -402,7 +385,7 @@ { common_draw(task_next); - task_next->set_post(post2runLoop, (void*)this); // set_post(function(this->run_loop()), NULL) + task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) task_next->spawn(); // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ @@ -422,7 +405,7 @@ } static void -post2speRendering(void *viewer_) +post2speRendering(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); @@ -435,13 +418,13 @@ common_rendering(task_next); this->draw_dummy->wait_for(task_next); - task_next->set_post(post2speDraw, (void*)this); + task_next->set_post(post2speDraw, (void*)this, 0); task_next->spawn(); } static void -post2speDraw(void *viewer_) +post2speDraw(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Engine/viewer.h --- a/Renderer/Engine/viewer.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Engine/viewer.h Thu Oct 22 23:55:32 2009 +0900 @@ -8,6 +8,9 @@ #include "KeyStat.h" #include "MainLoop.h" #include "Application.h" +#include "SceneGraphRoot.h" + +class SceneGraphRoot; class Application; @@ -36,6 +39,8 @@ Uint32 video_flags; Uint32 *pixels; + SceneGraphRoot *sgroot; + virtual void video_init(TaskManager *manager) = 0; void init(); @@ -63,11 +68,44 @@ void getKey(); void get_send_controll(); - void createFromXMLfile(const char *file); - SceneGraph *createSceneGraph(int id); - void setSceneData(SceneGraph *g); + // void createFromXMLfile(const char *file); + // SceneGraph *createSceneGraph(int id); + // SceneGraph *createSceneGraph(); + // void setSceneData(SceneGraph *g); void mainLoop(); + void createFromXMLfile(const char *file) + { + sgroot->createFromXMLfile(manager, file); + } + + SceneGraph * createSceneGraph(int id) + { + return sgroot->createSceneGraph(id); + } + + SceneGraph * createSceneGraph(const char *id) + { + return sgroot->createSceneGraph(id); + } + + int getSgid(const char *id) + { + return sgroot->getSgid(id); + } + + SceneGraph * createSceneGraph() + { + return sgroot->createSceneGraph(); + } + + void setSceneData(SceneGraph *g) + { + sgroot->setSceneData(g); + } + + + private: HTaskPtr initLoop(); void speLoop(); diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/Chain.h --- a/Renderer/Test/Chain.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/Chain.h Thu Oct 22 23:55:32 2009 +0900 @@ -22,4 +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(Viewer *viewer, int screen_w, int screen_h); + + }; diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/Makefile --- a/Renderer/Test/Makefile Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/Makefile Thu Oct 22 23:55:32 2009 +0900 @@ -1,42 +1,10 @@ -include ./Makefile.def - -LIBS += -lFifoManager -lCerium - -CFLAGS += `sdl-config --cflags` `xml2-config --cflags` -LIBS += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL - -.SUFFIXES: .cc .o .xml - -.cc.o: - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ - -all: ball_bound - -BALL_BOUND_OBJ = ball_bound.o -BALL_BOUND_XML = xml_file/Ball.xml -ball_bound : $(BALL_BOUND_OBJ) $(BALL_BOUND_XML).o - $(CC) -o $@ $< $(BALL_BOUND_XML).o $(LIBS) - -ball_bound.cc : $(BALL_BOUND_XML).h - -$(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h : $(BALL_BOUND_XML) - perl $(TOOL)/create_sglist.pl -o $@ $(BALL_BOUND_XML) - +all: + make -f Makefile.macosx -run: $(TARGET) - sudo ./$(TARGET) -width 576 -height 384 -bpp 32 - -debug: $(TARGET) - sudo ppu-gdb ./$(TARGET) - -depend: - $(RM) depend.inc - $(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc +cell: + make -f Makefile.cell clean: - rm -f $(TARGET) $(OBJS) $(TASK_OBJS) *.o - rm -f *~ \#* - rm -f $(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h $(BALL_BOUND_OBJ) - --include depend.inc + make -f Makefile.macosx clean + make -f Makefile.cell clean diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/Makefile.cell --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/Makefile.cell Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,84 @@ +include ./Makefile.def + +LIBS += -lCerium -lCellManager -lspe2 -lpthread + +CFLAGS += `sdl-config --cflags` `xml2-config --cflags` +LIBS += `sdl-config --libs` -lSDL_image -lGL `xml2-config --libs` + + +.SUFFIXES: .cc .o .xml + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum + +speobject: + cd spe; $(MAKE) + +run: $(TARGET) + sudo ./$(TARGET) -width 576 -height 384 -bpp 32 +run-hd: $(TARGET) + sudo /usr/sbin/ps3-video-mode -v 133 + sudo ./$(TARGET) -video fb -width 1920 -height 1080 -bpp 32 + + +spe-main: + ln -s ../Engine/spe-main . + + +BALL_BOUND_OBJ = ball_bound.o +ball_bound : $(BALL_BOUND_OBJ) + $(CC) -o $@ $? $(LIBS) + +BOSS_OBJ = boss1_action.o +boss1_action : $(BOSS_OBJ) + $(CC) -o $@ $? $(LIBS) + +DIRECTION_OBJ = direction.o +direction : $(DIRECTION_OBJ) + $(CC) -o $@ $? $(LIBS) + +GAPLAN_OBJ = gaplant.o gaplant_action.o back_action.o ball_action.o +gaplant : $(GAPLAN_OBJ) + $(CC) -o $@ $? $(LIBS) + +IESHOOT_OBJ = ieshoot.o +ieshoot : $(IESHOOT_OBJ) + $(CC) -o $@ $? $(LIBS) + +NODE_OBJ = node.o +node : $(NODE_OBJ) + $(CC) -o $@ $? $(LIBS) + +PANEL_OBJ = panel.o +panel : $(PANEL_OBJ) + $(CC) -o $@ $? $(LIBS) + +UNIV_OBJ = universe.o +universe : $(UNIV_OBJ) + $(CC) -o $@ $? $(LIBS) + +UNTITLED_OBJ = untitled.o +untitled : $(UNTITLED_OBJ) + $(CC) -o $@ $? $(LIBS) + +VACUUM_OBJ = vacuum.o cube.o game_over.o title.o +vacuum : $(VACUUM_OBJ) + $(CC) -o $@ $? $(LIBS) + +debug: $(TARGET) + sudo ppu-gdb ./$(TARGET) + +depend: + $(RM) depend.inc + $(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) *.o + rm -f *~ \#* + rm -f $(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h $(BALL_BOUND_OBJ) + +-include depend.inc + + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/Makefile.macosx --- a/Renderer/Test/Makefile.macosx Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/Makefile.macosx Thu Oct 22 23:55:32 2009 +0900 @@ -1,40 +1,65 @@ include ./Makefile.def -SRCS_TMP = $(wildcard *.cc) $(wildcard Application/*.cc) -SRCS_EXCLUDE = # -SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) -OBJS = $(SRCS:.cc=.o) - -TASK_DIR = task -TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) -TASK_SRCS_EXCLUDE = span_pack_draw.cc -TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) -TASK_OBJS = $(TASK_SRCS:.cc=.o) - -LIBS += -lFifoManager +LIBS += -lFifoManager -lCerium CFLAGS += `sdl-config --cflags` `xml2-config --cflags` LIBS += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL -.SUFFIXES: .cc .o +.SUFFIXES: .cc .o .xml .xml.h .xml.cc .cc.o: $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ -all: $(TARGET) +all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum send_linda dynamic + + +BALL_BOUND_OBJ = ball_bound.o +ball_bound : $(BALL_BOUND_OBJ) + $(CC) -o $@ $? $(LIBS) + +BOSS_OBJ = boss1_action.o +boss1_action : $(BOSS_OBJ) + $(CC) -o $@ $? $(LIBS) -$(TARGET) : $(OBJS) $(TASK_OBJS) - $(AR) crus $@ $(OBJS) $(TASK_OBJS) +DIRECTION_OBJ = direction.o +direction : $(DIRECTION_OBJ) + $(CC) -o $@ $? $(LIBS) + +GAPLAN_OBJ = gaplant.o gaplant_action.o back_action.o ball_action.o +gaplant : $(GAPLAN_OBJ) + $(CC) -o $@ $? $(LIBS) + +IESHOOT_OBJ = ieshoot.o +ieshoot : $(IESHOOT_OBJ) + $(CC) -o $@ $? $(LIBS) -# SGList.o: create_sg_list -# $(CC) $(CFLAGS) $(INCLUDE) -c SGList.cc -o $@ +NODE_OBJ = node.o +node : $(NODE_OBJ) + $(CC) -o $@ $? $(LIBS) + +PANEL_OBJ = panel.o +panel : $(PANEL_OBJ) + $(CC) -o $@ $? $(LIBS) + +UNIV_OBJ = universe.o +universe : $(UNIV_OBJ) + $(CC) -o $@ $? $(LIBS) -create_sg_list: - @if [ ! -f SGList.h ]; then \ - cd tools/;\ - ./create_sglist.pl ../xml_file/*.xml;\ - fi +UNTITLED_OBJ = untitled.o +untitled : $(UNTITLED_OBJ) + $(CC) -o $@ $? $(LIBS) + +VACUUM_OBJ = vacuum.o cube.o game_over.o title.o +vacuum : $(VACUUM_OBJ) + $(CC) -o $@ $? $(LIBS) +DYNAMIC_OBJ = dynamic_create.o +dynamic : $(DYNAMIC_OBJ) + $(CC) -o $@ $? $(LIBS) + +SENDLINDA_OBJ = send_linda.o +send_linda : $(SENDLINDA_OBJ) + $(CC) -o $@ $? $(LIBS) run: $(TARGET) sudo ./$(TARGET) -width 576 -height 384 -bpp 32 @@ -47,8 +72,8 @@ $(CC) -MM -MG $(INCLUDE) $(CFLAGS) $(SRCS) $(TASK_SRCS) > depend.inc clean: - rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) *.o rm -f *~ \#* - rm -f SGList.h SGList.cc + rm -f $(BALL_BOUND_XML).cc $(BALL_BOUND_XML).h $(BALL_BOUND_OBJ) -include depend.inc diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/back_action.cc --- a/Renderer/Test/back_action.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/back_action.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,7 +1,7 @@ #include #include "SceneGraphRoot.h" -#include "SGList.h" #include "ball_action.h" +#include "xml_file/gap_plane_test.xml.h" using namespace std; void @@ -10,7 +10,7 @@ Pad *pad = sgroot->getController(); if (pad->triangle.isPush()) { - SceneGraphPtr ball = sgroot->createSceneGraph(Ball); + SceneGraphPtr ball = sgroot->createSceneGraph("Ball"); ball->xyz[0] = -100; ball->set_move_collision(ball_move, ball_coll); node->addChild(ball); diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/ball_action.cc --- a/Renderer/Test/ball_action.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/ball_action.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,6 +1,6 @@ #include #include "SceneGraphRoot.h" -#include "SGList.h" + using namespace std; void diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/ball_bound.cc --- a/Renderer/Test/ball_bound.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/ball_bound.cc Thu Oct 22 23:55:32 2009 +0900 @@ -2,9 +2,9 @@ #include #include "SceneGraphRoot.h" #include "MainLoop.h" -#include "xml_file/Ball.xml.h" #include "ball_bound.h" + // prototype static void ball_move(SceneGraphPtr node, int screen_w, int screen_h); static void ball_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree); @@ -104,13 +104,8 @@ } } -extern Application * -application() { - return new ball_bound(); -} - MainLoopPtr -ball_bound::init(Viewer *viewer, int screen_w, int screen_h) +ball_bound::init(Viewer *sgroot, int screen_w, int screen_h) { SceneGraphPtr ball; @@ -118,9 +113,9 @@ // random な値が欲しいなら、man random に方法が書いてあります。 srandom(100); - viewer->createFromXMLfile("xml_file/Ball.xml"); + sgroot->createFromXMLfile("xml_file/Ball.xml"); - ball = viewer->createSceneGraph(Ball); + ball = sgroot->createSceneGraph("Ball"); ball->set_move_collision(ball_move, ball_collision); h0 = screen_h/2; @@ -131,9 +126,35 @@ ball->xyz[1] = h0; ball->xyz[2] = 30.0f; - viewer->setSceneData(ball); + sgroot->setSceneData(ball); + + return sgroot; +} + +extern Application * +application() { + return new ball_bound(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; - return viewer; +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); } /* end */ diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/boss1_action.cc --- a/Renderer/Test/boss1_action.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/boss1_action.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,4 +1,5 @@ -#include "SGList.h" +#include "SceneGraphRoot.h" +#include "MainLoop.h" #include "boss1_action.h" /* @@ -114,7 +115,7 @@ } if (pad->circle.isPush()) { - SceneGraphPtr shot = sgroot->createSceneGraph(P_SHOT1); + SceneGraphPtr shot = sgroot->createSceneGraph("P_SHOT1"); shot->set_move_collision(shot_move, shot_collision); shot->xyz[0] = node->xyz[0]; shot->xyz[1] = node->xyz[1] - player_radius; @@ -122,6 +123,8 @@ } } +static int boss1sgid; + static void player_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree) @@ -134,8 +137,8 @@ SceneGraphIteratorPtr it = sgroot->getIterator(tree); - for (; it->hasNext(BOSS1);) { - it->next(BOSS1); + for (; it->hasNext(boss1sgid);) { + it->next(boss1sgid); SceneGraphPtr enemy = it->get(); //各変数の初期化 @@ -179,8 +182,8 @@ SceneGraphIteratorPtr it = sgroot->getIterator(tree); - for (; it->hasNext(BOSS1);) { - it->next(BOSS1); + for (; it->hasNext(boss1sgid);) { + it->next(boss1sgid); SceneGraphPtr enemy = it->get(); x_distant = node->xyz[0] - enemy->xyz[0]; @@ -191,7 +194,7 @@ //円同士のcollision if(distance < boss_radius_y) { - SceneGraphPtr blast = sgroot->createSceneGraph(BLAST1); + SceneGraphPtr blast = sgroot->createSceneGraph("BLAST1"); blast->set_move_collision(blast_move, null_collision); blast->xyz[0] = node->xyz[0]; @@ -202,10 +205,19 @@ } } +extern Application * +application() { + return new boss1_action(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +static int blast8; + static void blast_move(SceneGraphPtr node, int screen_w, int screen_h) { - if(node->sgid > BLAST8) { + if(node->sgid > blast8) { SceneGraphPtr blast = sgroot->createSceneGraph(node->sgid - 1); blast->set_move_collision(blast_move, null_collision); blast->xyz[0] = node->xyz[0]; @@ -213,7 +225,7 @@ node->addBrother(blast); } - if (node->sgid == BLAST8) { + if (node->sgid == blast8) { node->flag_drawable = 1; } @@ -223,31 +235,30 @@ node->frame += 1; } -void -boss1_init(TaskManager *manager, int screen_w, int screen_h) +MainLoopPtr +boss1_action::init(Viewer *sgroot, int screen_w, int screen_h) { - SceneGraphPtr root; - SceneGraphPtr player; - SceneGraphPtr boss1; - SceneGraphPtr left_parts; - SceneGraphPtr right_parts; - sgroot->createFromXMLfile(manager, "xml_file/boss1.xml"); - sgroot->createFromXMLfile(manager, "xml_file/player1.xml"); - sgroot->createFromXMLfile(manager, "xml_file/p_shot.xml"); - sgroot->createFromXMLfile(manager, "xml_file/blast.xml"); - + sgroot->createFromXMLfile("xml_file/boss1.xml"); + sgroot->createFromXMLfile("xml_file/player1.xml"); + sgroot->createFromXMLfile("xml_file/p_shot.xml"); + sgroot->createFromXMLfile("xml_file/blast.xml"); + + blast8 = sgroot->getSgid("BLAST8"); + //rootとなるSceneGraphを生成 - root = sgroot->createSceneGraph(); + SceneGraphPtr root = sgroot->createSceneGraph(); //自機の初期化 - player = sgroot->createSceneGraph(PLAYER); + SceneGraphPtr player = sgroot->createSceneGraph("PLAYER"); player->xyz[0] = screen_w/2; player->xyz[1] = screen_h - player_radius; root->addChild(player); //ボスの初期化 - boss1 = sgroot->createSceneGraph(BOSS1); + SceneGraphPtr boss1 = sgroot->createSceneGraph("BOSS1"); + boss1sgid = boss1->sgid; + boss1->xyz[0] = screen_w/2; boss1->xyz[1] = boss_radius_y; // boss1->xyz[2] = first_boss1_depth; @@ -255,9 +266,9 @@ root->addChild(boss1); //ボスの左右パーツを追加 - left_parts = sgroot->createSceneGraph(BOSS1_L); + SceneGraphPtr left_parts = sgroot->createSceneGraph("BOSS1_L"); boss1->addChild(left_parts); - right_parts = sgroot->createSceneGraph(BOSS1_R); + SceneGraphPtr right_parts = sgroot->createSceneGraph("BOSS1_R"); boss1->addChild(right_parts); //各機体の動きと当たり判定をセット @@ -266,4 +277,26 @@ //仕上げ sgroot->setSceneData(root); + return sgroot; } + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/boss1_action.h --- a/Renderer/Test/boss1_action.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/boss1_action.h Thu Oct 22 23:55:32 2009 +0900 @@ -3,7 +3,15 @@ #include #include "SceneGraphRoot.h" -#include "SGList.h" +#include "Application.h" +#include "MainLoop.h" + + +class boss1_action : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; static const float player_speed = 10.0f; static const float player_radius = 42.0f; diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/chain.cc --- a/Renderer/Test/chain.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/chain.cc Thu Oct 22 23:55:32 2009 +0900 @@ -106,7 +106,7 @@ } void -Chain::init(TaskManager *manager, int w, int h) +Chain::init(Viewer *sgroot, int w, int h) { SceneGraphPtr root_chain, chain; ChainPropertyPtr rcv; @@ -159,5 +159,33 @@ chain_init->spawn(); sgroot->setSceneData(root_chain); + return sgroot; +} + +extern Application * +application() { + return new Chain(); } +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/chain_old.cc --- a/Renderer/Test/chain_old.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/chain_old.cc Thu Oct 22 23:55:32 2009 +0900 @@ -126,8 +126,8 @@ } -void -chain_old_init(TaskManager *manager, int w, int h) +MainLoopPtr +chain_old::init(Viewer *sgroot, int w, int h) { SceneGraphPtr root_old_chain, chain; CHAIN_VARS rcv; @@ -156,4 +156,34 @@ cv[0].can_move = FALSE; sgroot->setSceneData(root_old_chain); + return sgroot; } + +extern Application * +application() { + return new ball_bound(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + +/* end */ + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/cube.cc --- a/Renderer/Test/cube.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/cube.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,7 +1,6 @@ #include #include "SceneGraphRoot.h" #include "vacuum.h" -#include "SGList.h" #define SELECT 2 void @@ -52,6 +51,8 @@ } +extern int redcube ; +extern int enemy ; void cube_split(SceneGraphPtr root,SceneGraphPtr tree) @@ -62,10 +63,10 @@ // SceneGraphPtr root_common_move = root->parent; if(random()%SELECT) { - p = sgroot->createSceneGraph(REDCUBE); + p = sgroot->createSceneGraph(redcube); } else { - p = sgroot->createSceneGraph(ENEMY); + p = sgroot->createSceneGraph(enemy); } root->set_move_collision(cube_move_right, cube_collision); @@ -98,9 +99,9 @@ float dx, dy,ddx,ddy, r; float q = 0; - for (; it->hasNext(REDCUBE);) { + for (; it->hasNext(redcube);) { - it->next(REDCUBE); + it->next(redcube); SceneGraphPtr mcube = it->get(); dx = node->xyz[0] - mcube->xyz[0]; dy = node->xyz[1] - mcube->xyz[1]; @@ -138,8 +139,8 @@ float dx, dy,ddx,ddy, r; float q = 0; - for (; it->hasNext(ENEMY);) { - it->next(ENEMY); + for (; it->hasNext(enemy);) { + it->next(enemy); SceneGraphPtr mcube = it->get(); dx = node->xyz[0] - mcube->xyz[0]; diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/direction.cc --- a/Renderer/Test/direction.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/direction.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,5 +1,5 @@ #include "SceneGraphRoot.h" -#include "SGList.h" +#include "direction.h" static void x_move(SceneGraphPtr node, int w, int h) @@ -61,19 +61,19 @@ { } -void -direction_init(TaskManager *manager) +MainLoopPtr +direction::init(Viewer *sgroot, int screen_w, int screen_h) { SceneGraphPtr dx; SceneGraphPtr dy; SceneGraphPtr dz; SceneGraphPtr back; - sgroot->createFromXMLfile(manager, "xml_file/direction.xml"); + sgroot->createFromXMLfile("xml_file/direction.xml"); - dx = sgroot->createSceneGraph(Dirx); - dy = sgroot->createSceneGraph(Diry); - dz = sgroot->createSceneGraph(Dirz); + dx = sgroot->createSceneGraph("Dirx"); + dy = sgroot->createSceneGraph("Diry"); + dz = sgroot->createSceneGraph("Dirz"); back = sgroot->createSceneGraph(); back->addChild(dx); @@ -90,4 +90,32 @@ back->angle[1] = -30.0f; sgroot->setSceneData(back); + return sgroot; } + +extern Application * +application() { + return new direction(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/direction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/direction.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,11 @@ +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class direction : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/dynamic_create.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/dynamic_create.cc Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,280 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SceneGraphRoot.h" +#include "lindaapi.h" +#include "dynamic_create.h" + +#define PORT 10000 + +#define SERIAL_REGIST_TUPLE_NO 1 + +/* + typedef struct { + caddr_t file_mmap; + off_t size; + } st_mmap_t; +*/ + +typedef struct client_ { + int id; + SceneGraphPtr sgp; + struct client_ *next; +} client_t; + +typedef struct { + int tid; + int sid; + int read_id; + SceneGraphPtr node; + TaskManager *manager; + client_t *clist; +} callback_arg; + + +void +client_list_init(TaskManager* manager, client_t *clist) +{ + clist->id = -1; + clist->next = clist; +} + +void +client_list_update(TaskManager *manager, client_t *clist, int id, SceneGraphPtr sgp) +{ + //client_t *c; + // for (c = clist->next; c != clist; c = c->next) { + // if (c->id == id) { + // c->sgp = sgp; + // return; + // } + // } + + // c->next = (client_t *)manager->allocate(sizeof(client_t)); + // c->next->id = id; + // c->next->sgp = sgp; + // c->next->next = clist; +} + +void +client_list_delete(TaskManager *manager, client_t *clist, int id) +{ + client_t *c, *prev; + for (c = clist->next, prev = clist; c->next != clist; c = c->next) { + if (c->id == id) { + prev->next = c->next; + return; + } + prev = clist; + } + if (c->id == id) { + prev->next = c->next; + return; + } +} + +int +fix_byte(int size,int fix_byte_size) +{ + size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size; + + return size; +} + +st_mmap_t +my_mmap(char *filename) +{ + int fd = -1; + int map = MAP_PRIVATE; + st_mmap_t st_mmap; + struct stat sb; + + if ((fd = open(filename, O_RDONLY, 0666)) == 0 ) { + fprintf(stderr, "Can't open %s\n", filename); + } + + if (fstat(fd, &sb)) { + fprintf(stderr, "Can't fstat %s\n", filename); + } + + printf("file size %d\n", (int)sb.st_size); + + st_mmap.size = fix_byte(sb.st_size, 4096); + + printf("fix 4096byte file size %d\n", (int)st_mmap.size); + + st_mmap.file_mmap = (char *)mmap(NULL, st_mmap.size, PROT_READ, map, fd, (off_t)0); + if (st_mmap.file_mmap == (caddr_t)-1) { + fprintf(stderr, "Can't mmap file\n"); + perror(NULL); + exit(0); + } + + return st_mmap; +} + +static void +earth_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +moon_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +moon_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + //node->angle[0] += 3.0f; + node->xyz[1] += 1.0f; +} + + +static void +earth_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + psx_sync_n(); +} + +SceneGraphPtr +create_sg(TaskManager *manager, SceneGraphPtr node, unsigned char *data, int len, int serial_id) +{ + SceneGraphPtr object; + + sgroot->createFromXMLmemory(sgroot->tmanager, (char *)data, len); + object = sgroot->createSceneGraph(sgroot->getLast()); + object->id = serial_id; + object->set_move_collision(moon_move, moon_collision); + node->addChild(object); + + return object; +} + +void +del_callback(unsigned char *data, void *arg) +{ + free(data); +} + +void +psx_del(int t, int id) +{ + psx_callback_in(t, id, del_callback, NULL); +} + +static void +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; + SceneGraphPtr sgp; + // ここで create + sgp = create_sg(carg->manager, carg->node, xml_data, xml_len, carg->sid); + client_list_update(carg->manager, carg->clist, carg->sid, sgp); + free(arg); + free(xml_tuple); +} + +static void +callbacker(unsigned char *tuple, void *arg) { + int serial_id, xml_id; + + unsigned char *data; + callback_arg *carg = (callback_arg *)arg; + + // 最初の4byteデータは使わない + data = tuple+LINDA_HEADER_SIZE; + // clientのSerialIDを取得 + serial_id = ntohl(*(int *)data); + + // タプルを解放 + psx_del(carg->tid, SERIAL_REGIST_TUPLE_NO); + + // xml fileを取得する もうすでにxml fileが送信済みである事を期待 + // つまり、送信者がserial_idを送る前にxml fileを送信していなくてはならない + xml_id = serial_id * 10; + callback_arg *copy_arg = (callback_arg *)carg->manager->allocate(sizeof(callback_arg)); + *copy_arg = *carg; + copy_arg->sid = serial_id; + psx_callback_in(carg->tid, xml_id, callback_get_xml, (void *)copy_arg); + + /* dataは'\0'で終わっている事を期待 (writerで保証する) */ + //printf("get data[%d]: `%s'\n", len, data); + free(tuple); + + psx_callback_wait_rd(carg->tid, carg->read_id, callbacker, arg); +} + +void +linda_init(TaskManager *manager, client_t *clist, SceneGraphPtr node) +{ + init_linda(); + callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg)); + + carg->tid = open_linda_java("localhost", PORT); + carg->read_id = SERIAL_REGIST_TUPLE_NO; + carg->node = node; + carg->manager = manager; + carg->clist = clist; + psx_callback_wait_rd(carg->tid, carg->read_id, callbacker, carg); +} + +MainLoopPtr +dynamic_create::init(Viewer *sgroot, int screen_w, int screen_h) +{ + //SceneGraphPtr earth; + client_t *clist; + clist = (client_t *)sgroot->manager->allocate(sizeof(client_t)); + + client_list_init(sgroot->manager, clist); + + SceneGraphPtr parent; + parent = sgroot->createSceneGraph(); + parent->set_move_collision(earth_move, earth_collision); + parent->xyz[0] += 300; + + linda_init(sgroot->manager, clist, parent); + + // SceneGraphRoot に、使用する SceneGraph を設定する + // このとき、ユーザーが記述した SceneGraph の root を渡す。 + sgroot->setSceneData(parent); + return sgroot; +} + +extern Application * +application() { + return new dynamic_create(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + +/* end */ + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/dynamic_create.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/dynamic_create.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,11 @@ +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class dynamic_create : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/game_over.cc --- a/Renderer/Test/game_over.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/game_over.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,6 +1,5 @@ #include "SceneGraphRoot.h" #include "vacuum.h" -#include "SGList.h" void @@ -9,7 +8,7 @@ SceneGraphPtr over; - over = sgroot->createSceneGraph(GAMEOVER); + over = sgroot->createSceneGraph("GAMEOVER"); over->xyz[0] = w/2; over->xyz[1] = h/2; over->set_move_collision(gameover_idle,gameover_collision); @@ -31,7 +30,7 @@ SceneGraphPtr title; - title = sgroot->createSceneGraph(TITLE); + title = sgroot->createSceneGraph("TITLE"); title->xyz[0] = screen_w/2; title->xyz[1] = screen_h/2; title->set_move_collision(no_move_idle, title_collision); diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/gaplant.cc --- a/Renderer/Test/gaplant.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/gaplant.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,15 +1,15 @@ #include "SceneGraphRoot.h" -#include "SGList.h" #include "gaplant_action.h" +#include "gaplant.h" #include "back_action.h" -void -init_gaplant(TaskManager *manager, int w, int h) +MainLoopPtr +gaplant::init(Viewer *sgroot, int w, int h) { SceneGraphPtr back; SceneGraphPtr gaplant; - sgroot->createFromXMLfile(manager, "xml_file/gap_plane_test.xml"); - sgroot->createFromXMLfile(manager, "xml_file/Ball.xml"); + sgroot->createFromXMLfile("xml_file/gap_plane_test.xml"); + sgroot->createFromXMLfile("xml_file/Ball.xml"); back = sgroot->createSceneGraph(); back->set_move_collision(back_move, back_coll); @@ -19,12 +19,44 @@ gaplant->angle[1] = 0; gaplant->angle[2] = 0; gaplant->set_move_collision(gaplant_move, gaplant_coll); - - for (int i = arm_L_D; i <= foot_L_A; i++) { + + int foot = sgroot->getSgid("foot_L_A"); + for (int i = sgroot->getSgid("arm_L_D"); i <= foot; i++) { SceneGraphPtr p = sgroot->createSceneGraph(i); gaplant->addChild(p); } back->addChild(gaplant); sgroot->setSceneData(back); + return sgroot; } + + + +extern Application * +application() { + return new gaplant(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + +/* end */ diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/gaplant.h --- a/Renderer/Test/gaplant.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/gaplant.h Thu Oct 22 23:55:32 2009 +0900 @@ -1,2 +1,15 @@ const double CHECK_HIT_RAD = 110; const double BALL_RAD = 100; + +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class gaplant : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/gaplant_action.cc --- a/Renderer/Test/gaplant_action.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/gaplant_action.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,7 +1,7 @@ #include #include #include "SceneGraphRoot.h" -#include "SGList.h" +#include "xml_file/gap_plane_test.xml.h" #include "gaplant.h" using namespace std; diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/ieshoot.cc --- a/Renderer/Test/ieshoot.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/ieshoot.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,5 +1,5 @@ #include "SceneGraphRoot.h" -#include "SGList.h" +#include "ieshoot.h" static const float jiki_speed = 6.0f; static const float jiki_radius = 32.0f; @@ -40,9 +40,9 @@ { SceneGraphIteratorPtr it = sgroot->getIterator(tree); static int damage = 0; - - for (; it->hasNext(IETAMA);) { - it->next(IETAMA); + int ietama = sgroot->getSgid("IETAMA"); + for (; it->hasNext(ietama);) { + it->next(ietama); SceneGraphPtr tama = it->get(); if (node->xyz[0] - boss_radius_x < tama->xyz[0] + tama_radius @@ -52,7 +52,7 @@ node->set_move_collision(ieboss_move, ieboss_collision_invincibil); - SceneGraphPtr iebosstama = sgroot->createSceneGraph(Earth); + SceneGraphPtr iebosstama = sgroot->createSceneGraph("Earth"); iebosstama->set_move_collision(iebosstama_move, ietama_collision); iebosstama->xyz[0] = node->xyz[0]; iebosstama->xyz[1] = node->xyz[1] + boss_radius_y; @@ -179,7 +179,7 @@ } if (pad->circle.isPush()) { - SceneGraphPtr ietama = sgroot->createSceneGraph(IETAMA); + SceneGraphPtr ietama = sgroot->createSceneGraph("IETAMA"); ietama->set_move_collision(ietama_move, ietama_collision); ietama->xyz[0] = node->xyz[0]; ietama->xyz[1] = node->xyz[1]; @@ -188,29 +188,57 @@ } -void -ieshoot_init(TaskManager *manager) +MainLoopPtr +ieshoot::init(Viewer *sgroot, int w, int h) { SceneGraphPtr iejiki; SceneGraphPtr enemy; SceneGraphPtr back; - sgroot->createFromXMLfile(manager, "xml_file/ietama.xml"); - sgroot->createFromXMLfile(manager, "xml_file/ieboss.xml"); - sgroot->createFromXMLfile(manager, "xml_file/iejiki.xml"); - sgroot->createFromXMLfile(manager, "xml_file/universe.xml"); + sgroot->createFromXMLfile( "xml_file/ietama.xml"); + sgroot->createFromXMLfile( "xml_file/ieboss.xml"); + sgroot->createFromXMLfile( "xml_file/iejiki.xml"); + sgroot->createFromXMLfile( "xml_file/universe.xml"); back = sgroot->createSceneGraph(); - iejiki = sgroot->createSceneGraph(IEJIKI); + iejiki = sgroot->createSceneGraph("IEJIKI"); iejiki->set_move_collision(iejiki_move, iejiki_collision); iejiki->xyz[2] = 20; back->addChild(iejiki); - enemy = sgroot->createSceneGraph(IEBOSS); + enemy = sgroot->createSceneGraph("IEBOSS"); enemy->set_move_collision(ieboss_move, ieboss_collision); enemy->xyz[1] = boss_radius_y; back->addChild(enemy); sgroot->setSceneData(back); + return sgroot; } + +extern Application * +application() { + return new ieshoot(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/ieshoot.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/ieshoot.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,12 @@ +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class ieshoot : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/init_position.cc --- a/Renderer/Test/init_position.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/init_position.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,11 +1,11 @@ #include "SceneGraphRoot.h" -#include "SGList.h" #include "player_action.h" #include "enemy_action.h" #include "camera_action.h" +#include "init_position.h" -void -init_position(TaskManager *manager, int w, int h) +MainLoopPtr +posiotion::init(Viewer *sgroot, int w, int h) { SceneGraphPtr back; SceneGraphPtr player; @@ -33,4 +33,5 @@ } sgroot->setSceneData(back); + return sgroot; } diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/init_position.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/init_position.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,12 @@ +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class position : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/long_cube.cc --- a/Renderer/Test/long_cube.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/long_cube.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,5 +1,5 @@ #include "SceneGraphRoot.h" -#include "SGList.h" +#include "long_cube.h" // prototype static void lcube_move(SceneGraphPtr node, int screen_w, int screen_h); @@ -18,8 +18,8 @@ } -void -lcube_init(TaskManager *manager, int screen_w, int screen_h) +MainLoopPtr +lcube_init(Viewer *sgroot, int screen_w, int screen_h) { SceneGraphPtr lcube; @@ -28,4 +28,5 @@ lcube->set_move_collision(lcube_move, lcube_collision); sgroot->setSceneData(lcube); + return sgroot; } diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/long_cube.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/long_cube.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,12 @@ +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class long_cube : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/node.cc --- a/Renderer/Test/node.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/node.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,7 +1,7 @@ #include #include "SceneGraphRoot.h" #include "SceneGraph.h" -#include "xml_file/cube.h" +#include "node.h" static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h, @@ -62,11 +62,42 @@ } } -void -node_init(TaskManager *manager) +MainLoopPtr +node::init(Viewer *sgroot, int screen_w, int screen_h) { - sgroot->createFromXMLfile(manager, "xml_file/cube.xml"); + sgroot->createFromXMLfile( "xml_file/cube.xml"); + SceneGraphPtr Cube = sgroot->createSceneGraph("Cube"); Cube->set_move_collision(cube_move, cube_collision); Cube->stack_xyz[0] = 2.0f; Cube->stack_xyz[1] = 2.0f; + return sgroot; } + +extern Application * +application() { + return new node(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + +/* end */ + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/node.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/node.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,11 @@ +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class node : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/panel.cc --- a/Renderer/Test/panel.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/panel.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,5 +1,5 @@ #include "SceneGraphRoot.h" -#include "SGList.h" +#include "panel.h" static void panel_move(SceneGraphPtr node, int screen_w, int screen_h); static void panel_collision(SceneGraphPtr node, int screen_w, int screen_h, @@ -16,23 +16,60 @@ { } -void -panel_init(TaskManager *manager, int bg) +int bg = 0; + +MainLoopPtr +panel::init(Viewer *sgroot, int screen_w, int screen_h) { SceneGraphPtr panel; if (bg == 2) { - sgroot->createFromXMLfile(manager, "xml_file/panel_512.xml"); - panel = sgroot->createSceneGraph(PANEL_512); + sgroot->createFromXMLfile( "xml_file/panel_512.xml"); + panel = sgroot->createSceneGraph("PANEL_512"); } else if (bg == 3) { - sgroot->createFromXMLfile(manager, "xml_file/panel_1024.xml"); - panel = sgroot->createSceneGraph(PANEL_1024); + sgroot->createFromXMLfile( "xml_file/panel_1024.xml"); + panel = sgroot->createSceneGraph("PANEL_1024"); } else { - sgroot->createFromXMLfile(manager, "xml_file/panel_2048.xml"); - panel = sgroot->createSceneGraph(PANEL_2048); + sgroot->createFromXMLfile( "xml_file/panel_2048.xml"); + panel = sgroot->createSceneGraph("PANEL_2048"); } panel->set_move_collision(panel_move, panel_collision); panel->xyz[2] = 30.0f; sgroot->setSceneData(panel); + return sgroot; } + +extern Application * +application() { + return new panel(); +} + +const char *usr_help_str = "Usage: ./test_nogl -sg [123] [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + for(int i=0;i +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class panel : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/send_linda.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/send_linda.cc Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,213 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SceneGraphRoot.h" +#include "lindaapi.h" +#include "send_linda.h" + +#define HOSTNAME "localhost" +#define PORT_NUM 10000 +#define LISTEN_PORT 1 +#define MULTI_NUM 10 + +void +root_move(SceneGraphPtr node, int w, int h) +{ + Pad *pad = sgroot->getController(); + + if (pad->right.isHold() || pad->left.isHold()) { + if (pad->right.isHold()) { + node->xyz[0] += 5.0f; + } else if (pad->left.isHold()) { + node->xyz[0] -= 5.0f; + } + } + + if (pad->down.isHold() || pad->up.isHold() ) { + if (pad->down.isHold()) { + node->xyz[1] += 5.0f; + } else if (pad->up.isHold()) { + node->xyz[1] -= 5.0f; + } + } + + /* + ここでキー入力を向こうに送る + */ + +} + +void +root_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +{ +} + +void +move(SceneGraphPtr node, int w, int h) +{ +} + +void +collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) +{ +} + +void * +file_map(const char *filename, int *size) { + int fd; + void *addr; + struct stat sb; + + if ((fd = open(filename, O_RDONLY)) == -1) { + fprintf(stderr, "Can't open %s\n", filename); + perror(NULL); + } + if (fstat(fd, &sb) == -1) { + fprintf(stderr, "Can't fstat %s\n", filename); + perror(NULL); + } + *size = sb.st_size; + addr = mmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0); + if (addr == MAP_FAILED) { + perror("mmap error\n"); + exit(EXIT_FAILURE); + } + close(fd); + + return addr; +} + + +void +linda_init(char *addr, int *size) +{ + +} + +int get_serial_id(int fd) { + char *data; + int serial; + int seq; + + seq = psx_in(fd, 65535); + psx_sync_n(); + data = (char *)psx_reply(seq); + serial = atoi(data + LINDA_HEADER_SIZE); + psx_free(data); + + return serial; +} + + +void +send_xml(int tspace, int xml_id, void *addr, int size) { + psx_out(tspace, xml_id, (unsigned char *)addr, size); + psx_sync_n(); +} + +/* +void +mainLoop(int tid, int write_id, int fd) +{ + void *addr; + struct stat sb; + + if (fstat(fd, &sb) == -1) { + perror("fstat"); + exit(1); + } + addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (addr==NULL) { + perror("mmap"); + exit(1); + } + + printf("file size=%d\n", sb.st_size); + + psx_out(tid, write_id, addr, sb.st_size); + psx_sync_n(); + + return; +} +*/ + +static char *xml; + +MainLoopPtr +send_linda::init(Viewer *sgroot, int screen_w, int screen_h) +{ + void *addr; + int size; + int tspace; + int serial; + int xml_id; + + SceneGraphPtr sgp; + SceneGraphPtr root; + root = sgroot->createSceneGraph(); + root->set_move_collision(root_move, root_collision); + + // createFromXMLfile で object name のリストを生成して返したい + sgroot->createFromXMLfile( xml); + // 今だけは決め打ち、本当はリストを回して object 数 create したい + sgp = sgroot->createSceneGraph("Ball"); + sgp->set_move_collision(move, collision); + + root->addChild(sgp); + + init_linda(); + addr = file_map(xml, &size); + tspace = open_linda_java(HOSTNAME, PORT_NUM); + serial = get_serial_id(tspace); + xml_id = serial * 10; + send_xml(tspace, xml_id, addr, size); + + int client_id = htonl(serial); + send_xml(tspace, LISTEN_PORT, (void *)client_id, sizeof(int)); + + sgroot->setSceneData(root); + return sgroot; +} + +extern Application * +application() { + return new send_linda(); +} + + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + + for(int i=0;i +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class send_linda : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/title.cc --- a/Renderer/Test/title.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/title.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,6 +1,7 @@ #include "SceneGraphRoot.h" #include "vacuum.h" -#include "SGList.h" + +extern int redcube; void title_collision(SceneGraphPtr node, int w, int h,SceneGraphPtr tree) @@ -13,14 +14,14 @@ SceneGraphPtr vacuum; SceneGraphPtr back = sgroot->createSceneGraph(); - vacuum = sgroot->createSceneGraph(BIGCUBE); + vacuum = sgroot->createSceneGraph("BIGCUBE"); vacuum->xyz[0] = w/2; vacuum->xyz[1] = h*0.8; vacuum->set_move_collision(vacuum_move, vacuum_coll); back->addChild(vacuum); - add_cubecollision_object(REDCUBE,vacuum,w,h); + add_cubecollision_object(redcube,vacuum,w,h); sgroot->setSceneData(back); diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/universe.cc --- a/Renderer/Test/universe.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/universe.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,6 +1,6 @@ #include #include "SceneGraphRoot.h" -#include "SGList.h" +#include "universe.h" static void earth_collision(SceneGraphPtr node, int screen_w, int screen_h, @@ -40,23 +40,23 @@ } } -void -universe_init(TaskManager *manager) +MainLoopPtr +universe::init(Viewer *sgroot, int screen_w, int screen_h) { SceneGraphPtr earth; SceneGraphPtr moon; - sgroot->createFromXMLfile(manager, "xml_file/universe.xml"); + sgroot->createFromXMLfile( "xml_file/universe.xml"); // SGList.h にある SceneGraph ID から SceneGraph を生成する - earth = sgroot->createSceneGraph(Earth); + earth = sgroot->createSceneGraph("Earth"); // SceneGraph の move と collision を設定 earth->set_move_collision(earth_move, earth_collision); earth->stack_xyz[0] = 3.0f; earth->stack_xyz[1] = 3.0f; - moon = sgroot->createSceneGraph(Moon); + moon = sgroot->createSceneGraph("Moon"); moon->set_move_collision(moon_move, moon_collision); // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) @@ -65,4 +65,35 @@ // SceneGraphRoot に、使用する SceneGraph を設定する // このとき、ユーザーが記述した SceneGraph の root を渡す。 sgroot->setSceneData(earth); + return sgroot; } + + +extern Application * +application() { + return new universe(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + +/* end */ + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/universe.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/universe.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,12 @@ +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class universe : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/untitled.cc --- a/Renderer/Test/untitled.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/untitled.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,6 +1,6 @@ #include #include "SceneGraphRoot.h" -#include "SGList.h" +#include "untitled.h" #include static void @@ -73,8 +73,8 @@ } -void -untitled_init(TaskManager *manager) +MainLoopPtr +untitled::init(Viewer *sgroot, int screen_w, int screen_h) { SceneGraphPtr test00; SceneGraphPtr test01; @@ -87,7 +87,7 @@ SceneGraphPtr test08; SceneGraphPtr test09; - sgroot->createFromXMLfile(manager, "xml_file/Venus.xml"); + sgroot->createFromXMLfile( "xml_file/Venus.xml"); // SGList.h にある SceneGraph ID から SceneGraph を生成する /* @@ -102,16 +102,16 @@ test08 = sgroot->createSceneGraph(cubetest002); test09 = sgroot->createSceneGraph(cubetest001); */ - test00 = sgroot->createSceneGraph(Venus000); - test01 = sgroot->createSceneGraph(Venus009); - test02 = sgroot->createSceneGraph(Venus008); - test03 = sgroot->createSceneGraph(Venus007); - test04 = sgroot->createSceneGraph(Venus006); - test05 = sgroot->createSceneGraph(Venus005); - test06 = sgroot->createSceneGraph(Venus004); - test07 = sgroot->createSceneGraph(Venus003); - test08 = sgroot->createSceneGraph(Venus002); - test09 = sgroot->createSceneGraph(Venus001); + test00 = sgroot->createSceneGraph("Venus000"); + test01 = sgroot->createSceneGraph("Venus009"); + test02 = sgroot->createSceneGraph("Venus008"); + test03 = sgroot->createSceneGraph("Venus007"); + test04 = sgroot->createSceneGraph("Venus006"); + test05 = sgroot->createSceneGraph("Venus005"); + test06 = sgroot->createSceneGraph("Venus004"); + test07 = sgroot->createSceneGraph("Venus003"); + test08 = sgroot->createSceneGraph("Venus002"); + test09 = sgroot->createSceneGraph("Venus001"); // SceneGraph の move と collision を設定 test00->set_move_collision(cubetest_move, cubetest_collision); @@ -145,5 +145,34 @@ // SceneGraphRoot に、使用する SceneGraph を設定する // このとき、ユーザーが記述した SceneGraph の root を渡す。 sgroot->setSceneData(test00); - + return sgroot; +} + +extern Application * +application() { + return new untitled(); } + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + +/* end */ + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/untitled.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/untitled.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,12 @@ +#include +#include +#include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class untitled : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/vacuum.cc --- a/Renderer/Test/vacuum.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/vacuum.cc Thu Oct 22 23:55:32 2009 +0900 @@ -1,7 +1,6 @@ #include #include "vacuum.h" #include "SceneGraphRoot.h" -#include "SGList.h" #define ENCOUNT 55 using namespace std; @@ -27,6 +26,9 @@ } +int redcube; +int enemy; + void vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree) @@ -35,10 +37,10 @@ if(node->frame%ENCOUNT == ENCOUNT-1) { if(random()%2) { - add_cubecollision_object(REDCUBE,node,screen_w,screen_h); + add_cubecollision_object(redcube,node,screen_w,screen_h); } else { - add_cubecollision_object(ENEMY,node,screen_w,screen_h); + add_cubecollision_object(enemy,node,screen_w,screen_h); } } @@ -60,22 +62,22 @@ lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it) { - SceneGraphPtr enemy; + SceneGraphPtr e; SceneGraphPtr near_enemy = NULL; float dx,dy,r,range = 100; // Pad *pad = sgroot->getController(); - for(;it->hasNext(ENEMY);) { + for(;it->hasNext(enemy);) { - it->next(ENEMY); - enemy = it->get(); - dx = enemy->xyz[0] - node->xyz[0]; - dy = enemy->xyz[1] - node->xyz[1]; + it->next(enemy); + e = it->get(); + dx = e->xyz[0] - node->xyz[0]; + dy = e->xyz[1] - node->xyz[1]; r = sqrt(dx*dx+dy*dy); - if(range > r && enemy->stack_xyz[2] == 0) { + if(range > r && e->stack_xyz[2] == 0) { range = r; - near_enemy = enemy; + near_enemy = e; } } @@ -85,7 +87,7 @@ SceneGraphPtr lockon; // SceneGraphPtr near_enemy_common_move = near_enemy->parent; near_enemy->stack_xyz[2] = 1; - lockon = sgroot->createSceneGraph(LOCK); + lockon = sgroot->createSceneGraph("LOCK"); lockon->set_move_collision(no_move_idle,lockon_collision); //near_enemy_common_move->addChild(lockon); near_enemy->addChild(lockon); @@ -156,19 +158,51 @@ } -void -vacuum_init2(TaskManager *manager, int w, int h) +MainLoopPtr +vacuum::init(Viewer *sgroot, int w, int h) { SceneGraphPtr title; - sgroot->createFromXMLfile(manager, "xml_file/gamecube.xml"); - sgroot->createFromXMLfile(manager, "xml_file/title.xml"); - sgroot->createFromXMLfile(manager, "xml_file/gameover.xml"); + sgroot->createFromXMLfile( "xml_file/gamecube.xml"); + sgroot->createFromXMLfile( "xml_file/title.xml"); + sgroot->createFromXMLfile( "xml_file/gameover.xml"); - title = sgroot->createSceneGraph(TITLE); + title = sgroot->createSceneGraph("TITLE"); title->xyz[0] = w/2; title->xyz[1] = h/2; title->set_move_collision(no_move_idle, title_collision); sgroot->setSceneData(title); + + redcube = sgroot->getSgid("REDCUBE"); + enemy = sgroot->getSgid("ENEMY"); + + return sgroot; } + +extern Application * +application() { + return new vacuum(); +} + +const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; + +extern int init(TaskManager *manager, int argc, char *argv[]); +extern void task_initialize(); +static void TMend(TaskManager *manager); + +int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + task_initialize(); + manager->set_TMend(TMend); + return init(manager, argc, argv); + +} + +void +TMend(TaskManager *manager) +{ + printf("test_nogl end\n"); +} + diff -r 4cff1ffa60db -r 8fca17aa57df Renderer/Test/vacuum.h --- a/Renderer/Test/vacuum.h Tue Oct 20 20:36:13 2009 +0900 +++ b/Renderer/Test/vacuum.h Thu Oct 22 23:55:32 2009 +0900 @@ -1,28 +1,38 @@ #ifndef VACUUM_H #define VACUUM_H -#include "SGList.h" +#include +#include #include "SceneGraphRoot.h" +#include "Application.h" +#include "MainLoop.h" + +class vacuum : public Application { + + MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); + +}; + -void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h); -void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h); -void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h); -void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); -void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); -void cube_split(SceneGraphPtr root,SceneGraphPtr tree); -void vacuum_move(SceneGraphPtr node, int w, int h); -void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree); -void title_idle(SceneGraphPtr node, int screen_w, int screen_h); -void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); -void scene_change(int w,int h,SceneGraphPtr node); -void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h); -void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); -void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node); -void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h); -void gameover_scene(int w,int h, SceneGraphPtr node); -void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h); -void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it); -void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree); -void cube_rotate(SceneGraphPtr node,int w,int h); +extern void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h); +extern void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h); +extern void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h); +extern void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +extern void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +extern void cube_split(SceneGraphPtr root,SceneGraphPtr tree); +extern void vacuum_move(SceneGraphPtr node, int w, int h); +extern void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree); +extern void title_idle(SceneGraphPtr node, int screen_w, int screen_h); +extern void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +extern void scene_change(int w,int h,SceneGraphPtr node); +extern void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h); +extern void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree); +extern void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node); +extern void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h); +extern void gameover_scene(int w,int h, SceneGraphPtr node); +extern void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h); +extern void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it); +extern void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree); +extern void cube_rotate(SceneGraphPtr node,int w,int h); #endif diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/ChangeLog diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/Fifo/FifoDmaManager.h diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/HTask.cc --- a/TaskManager/kernel/ppe/HTask.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Thu Oct 22 23:55:32 2009 +0900 @@ -38,13 +38,15 @@ void HTask::set_cpu(CPU_TYPE type) { -{ mimpl->set_task_cpu(this, type); } void -set_post(PostFunction func,void *read, void *write) +HTask::set_post(PostFunction func,void *arg1, void *arg2) +{ this->post_func = func; - this->post_arg1 = read; - this->post_arg2 = write; + this->post_arg1 = arg1; + this->post_arg2 = arg2; } + +/* end */ diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/HTask.h --- a/TaskManager/kernel/ppe/HTask.h Tue Oct 20 20:36:13 2009 +0900 +++ b/TaskManager/kernel/ppe/HTask.h Thu Oct 22 23:55:32 2009 +0900 @@ -28,7 +28,7 @@ TaskQueueInfo *wait_me; // List of task waiting for me TaskQueueInfo *wait_i; // List of task for which I am waiting - PostFunction func; + PostFunction post_func; void *post_arg1; void *post_arg2; CPU_TYPE cpu_type; diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/HTaskInfo.cc diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/Task.cc diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/Task.h diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/TaskManager.cc diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/TaskManager.h --- a/TaskManager/kernel/ppe/TaskManager.h Tue Oct 20 20:36:13 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.h Thu Oct 22 23:55:32 2009 +0900 @@ -5,6 +5,7 @@ #include "Random.h" #include "MemList.h" #include "Scheduler.h" +#include "HTask.h" class TaskManager { public: diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/TaskManagerImpl.cc --- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Thu Oct 22 23:55:32 2009 +0900 @@ -2,13 +2,15 @@ #include "TaskManagerImpl.h" #include "types.h" #include "error.h" +#include "SchedTask.h" +#include "SchedTaskManager.h" #include "../sys_task/SysTask.h" static HTaskPtr systask_start; static HTaskPtr systask_finish; -void -noaction(SchdTask *s, void *read, void *write) +static void +noaction(SchedTask *s, void *read, void *write) { } diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/ppe/TaskManagerImpl.h --- a/TaskManager/kernel/ppe/TaskManagerImpl.h Tue Oct 20 20:36:13 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Thu Oct 22 23:55:32 2009 +0900 @@ -20,7 +20,7 @@ TaskListInfo *taskListImpl; TaskQueueInfo *taskQueueImpl; HTaskInfo *htaskImpl; - SchedTask *schdTaskManager; + SchedTask *schedTaskManager; /* constructor */ TaskManagerImpl(int num = 1) ; diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/schedule/SchedTask.cc diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/schedule/SchedTask.h diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/schedule/SchedTaskManager.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskManager.cc Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,49 @@ + +#include "TaskManagerImpl.h" +#include "SchedTaskManager.h" + +SchedTaskManager::SchedTaskManager(TaskManagerImpl *m_) +{ + m = m_; +} + +SchedTaskManager::~SchedTaskManager() +{ +} + +HTaskPtr SchedTaskManager::create_task(int cmd) +{ + return m->create_task(cmd); +} + +void SchedTaskManager::set_task_depend(HTaskPtr master, HTaskPtr slave) +{ + m->set_task_depend(master, slave); +} + +void SchedTaskManager::spawn_task(HTaskPtr t) +{ + m->spawn_task(t); +} + +void SchedTaskManager::set_task_cpu(HTaskPtr t, CPU_TYPE cpu) +{ + m->set_task_cpu(t, cpu); +} + +void* SchedTaskManager::allocate(int size) +{ + return m->allocate(size) ; +} + +void* SchedTaskManager::allocate(int size,int align) +{ + return m->allocate(size,align) ; +} + +Scheduler* SchedTaskManager::get_scheduler() +{ + return m->get_scheduler() ; +} + +/* end */ diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/schedule/SchedTaskManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskManager.h Thu Oct 22 23:55:32 2009 +0900 @@ -0,0 +1,36 @@ +#ifndef INCLUDED_SCHED_TASK_MANAGER +#define INCLUDED_SCHED_TASK_MANAGER + +#include +#include +#include "base.h" +#include "SchedTask.h" +#include "TaskManagerImpl.h" + +class SchedTaskManager : public SchedTask { +public: + /* constructor */ + SchedTaskManager(TaskManagerImpl *m); + + virtual ~SchedTaskManager(); + + BASE_NEW_DELETE(SchedTask); + + /* variables */ + + // Task を実行するスケジューラ自身 + TaskManagerImpl *m; + +public: + /* functions */ + + // user + HTaskPtr create_task(int cmd); + void set_task_depend(HTaskPtr master, HTaskPtr slave); + void spawn_task(HTaskPtr); + void set_task_cpu(HTaskPtr, CPU_TYPE); + void* allocate(int size); + void* allocate(int size,int align); + Scheduler* get_scheduler(); +}; +#endif diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/schedule/Scheduler.cc --- a/TaskManager/kernel/schedule/Scheduler.cc Tue Oct 20 20:36:13 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Thu Oct 22 23:55:32 2009 +0900 @@ -364,8 +364,8 @@ static void wait_load(Scheduler *m, int task_id) { +#if 0 MemorySegment *s = task_list[task_id].segment; -#if 0 if (s) fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data); else diff -r 4cff1ffa60db -r 8fca17aa57df TaskManager/kernel/sys_task/SysTask.h diff -r 4cff1ffa60db -r 8fca17aa57df example/basic/main.cc diff -r 4cff1ffa60db -r 8fca17aa57df example/many_task/sort.cc diff -r 4cff1ffa60db -r 8fca17aa57df example/post_function/main.cc diff -r 4cff1ffa60db -r 8fca17aa57df example/renew_task/main.cc diff -r 4cff1ffa60db -r 8fca17aa57df example/renew_task/ppe/Renew1.cc