changeset 427:b48df6332eb8

add Application.{cc, h}
author game@henri.cr.ie.u-ryukyu.ac.jp
date Thu, 24 Sep 2009 17:44:09 +0900
parents afb717c43a3c
children e82be8759036
files TaskManager/Test/test_render/Application.cc TaskManager/Test/test_render/Application.h TaskManager/Test/test_render/SceneGraphRoot.cc TaskManager/Test/test_render/viewer.cc
diffstat 4 files changed, 113 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Test/test_render/Application.cc	Thu Sep 24 17:44:09 2009 +0900
@@ -0,0 +1,75 @@
+#include "Application.h"
+#include "SceneGraph.h"
+
+void
+Application::set_move_func(move_func new_move)
+{
+    this->move = new_move;
+}
+
+void
+Application::set_move_coll(coll_func new_coll)
+{
+    this->coll = new_coll;
+}
+
+void
+Application::apply_property(PropertyPtr p, SceneGraphPtr sgptr)
+{
+    sgptr->xyz[0] = p->xyz[0];
+    sgptr->xyz[1] = p->xyz[1];
+    sgptr->xyz[2] = p->xyz[2];
+
+    sgptr->angle[0] = p->angle[0];
+    sgptr->angle[1] = p->angle[1];
+    sgptr->angle[2] = p->angle[2];
+
+    sgptr->frame++;
+
+}
+
+SceneGraphPtr 
+Application::scenegraph_factory(PropertyPtr p)
+{
+    SceneGraphPtr sgptr =  p->scenegraph;
+    apply_property(p, sgptr);
+
+    return sgptr;
+}
+
+SceneGraphPtr 
+Application::scenegraph_connector(PropertyPtr p, SceneGraphPtr sg,
+				  SceneGraphPtr sg_available_list)
+{
+    SceneGraphPtr last = sg_available_list;
+
+    if (!last) {
+	sg_available_list = sg;
+    } else {
+	while (last->next) {
+	    last = last->next;
+	}
+	last->next = sg;
+	sg->prev = last;
+    }
+
+    PropertyPtr p_curent = (PropertyPtr)sg->propertyPtr;
+    PropertyPtr p_parent = p[p_curent->parent_id];
+    SceneGraphPtr s_parent = p_parent->scenegraph;
+
+    /* childrenのリストの最後に加える (brother として)*/
+    if (s_parent->lastChild != NULL) {
+        SceneGraphPtr last = s_parent->lastChild;
+        last->brother = sg;
+    }
+
+    s_parent->lastChild = sg;
+
+    if (s_parent->children == NULL) {
+        s_parent->children = sg;
+    }
+
+    sg->parent = s_parent;
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Test/test_render/Application.h	Thu Sep 24 17:44:09 2009 +0900
@@ -0,0 +1,25 @@
+#ifndef INCLUDED_APPLICATION
+#define INCLUDED_APPLICATION
+
+typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h);
+typedef void (*coll_func)(SceneGraph* node, int screen_w, int screen_h);
+
+class Application {
+public:
+    Application();
+    ~Application();
+    
+    void* propertyPtr;
+
+    void set_move_func(move_func move);
+    void set_coll_func(coll_func coll);
+    SceneGraphPtr scenegraph_factory(PropertyPtr p);
+    SceneGraphPtr scenegraph_connector(PropertyPtr p,SceneGraphPtr s);
+
+    move_func move;
+    coll_func coll;
+};
+
+typedef Application *Application;
+
+#endif
--- a/TaskManager/Test/test_render/SceneGraphRoot.cc	Thu Sep 24 15:26:58 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraphRoot.cc	Thu Sep 24 17:44:09 2009 +0900
@@ -77,7 +77,7 @@
 void
 SceneGraphRoot::addNext(SceneGraphPtr sg)
 {
-    SceneGraphPtr last = sg_available_list;
+     SceneGraphPtr last = sg_available_list;
 
     if (!last) {
 	sg_available_list = sg;
@@ -160,13 +160,13 @@
 }
 
 void
-SceneGraphRoot::speExecute(int screen_w, int screen_h)
+SceneGraphRoot::speExecute(Application application, int screen_w, int screen_h)
 {
-
+    
     SceneGraphPtr list = sg_available_list;
     SceneGraphPtr t = sg_exec_tree;
     SceneGraphPtr cur_parent = camera;
-
+    
     // 前フレームで描画した SceneGraph は削除
     allRemove(sg_remove_list);
 
@@ -185,11 +185,11 @@
     camera->children = NULL;
     camera->lastChild = NULL;
     
-    list->move_execute(screen_w, screen_h);
-    list->collision_check(screen_w, screen_h, list);	
+    void *property = application->move_execute(screen_w, screen_h);
+    application->collision_check(screen_w, screen_h, list);	
     
-    list->frame++; 
-    list = list->next;
+    //list->frame++; 
+    //list = list->next;
 
     if(sg_exec_tree != NULL) {
       return;
@@ -197,24 +197,15 @@
 
     /*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 する
+	application->scenegraph_connector(property[0], s, sg_available_list); // add する
     }
-    */
-
-      
-
+        
     // 現在、allExecute が終わった時点では
     // camera->children が User SceneGraph の root になる
-
-    /**
-     * NULL じゃなかったら、setSceneData が呼ばれてるから
-     * そっちを次の Scene にする
-     */
-
     sg_exec_tree = camera->children;
 }
 
--- a/TaskManager/Test/test_render/viewer.cc	Thu Sep 24 15:26:58 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.cc	Thu Sep 24 17:44:09 2009 +0900
@@ -10,6 +10,7 @@
 #include "TaskManager.h"
 #include <wchar.h>
 #include "Pad.h"
+#include "Application.h"
 
 static void post2runLoop(void *viewer);
 static void post2runDraw(void *viewer);
@@ -108,6 +109,7 @@
 void
 Viewer::run_init(TaskManager *manager, const char *xml, int sg_number)
 {
+    Application application = new Application();
     this->manager = manager;
 
     start_time = get_ticks();