changeset 453:dc50a62ffd96

Chain extends Application. add Application to Viewer.
author kazz@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 25 Sep 2009 23:51:55 +0900
parents 1f35fc0a3472
children 8c2e255f7a6c
files TaskManager/Test/test_render/Application.cc TaskManager/Test/test_render/Application.h TaskManager/Test/test_render/Application/Chain.h TaskManager/Test/test_render/Application/chain.cc TaskManager/Test/test_render/polygon.h TaskManager/Test/test_render/spe/ChainCal.cc TaskManager/Test/test_render/viewer.cc TaskManager/Test/test_render/viewer.h
diffstat 8 files changed, 59 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Application.cc	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/Application.cc	Fri Sep 25 23:51:55 2009 +0900
@@ -1,5 +1,4 @@
 #include "Application.h"
-#include "SceneGraph.h"
 
 // void
 // Application::set_move_func(move_func new_move)
@@ -80,6 +79,6 @@
 }
 
 int Application::move_task_id() {
-    return 0;
+    return move_task_id_;
 }
 
--- a/TaskManager/Test/test_render/Application.h	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/Application.h	Fri Sep 25 23:51:55 2009 +0900
@@ -1,6 +1,3 @@
-class Application;
-typedef Application *ApplicationPtr;
-
 #ifndef INCLUDED_APPLICATION
 #define INCLUDED_APPLICATION
 
@@ -16,17 +13,15 @@
     
     void *propertyPtr;
     int property_size;
+	int move_task_id_;
+
+    int move_task_id();
     void set_move_func(move_func move);
     void set_coll_func(coll_func coll);
-    //void set_move_taskid(int id);
-    //SceneGraphPtr scenegraph_factory(PropertyPtr p);
-    //SceneGraphPtr scenegraph_connector(PropertyPtr p,SceneGraphPtr s);
     SceneGraphPtr scenegraph_factory(void *p, int size);
     SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list);
     virtual void init(TaskManager *manager, int w, int h) ;
 
-    virtual int move_task_id() ;
-
 };
 
 #endif
--- a/TaskManager/Test/test_render/Application/Chain.h	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/Application/Chain.h	Fri Sep 25 23:51:55 2009 +0900
@@ -13,15 +13,11 @@
 
 class Chain : public Application {
 public:
-    Chain(){}    
+    Chain(){}
 
     SceneGraphPtr scenegraph_factory(void *p, int size);
     SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list);
-    void init(TaskManager *manager, int w, int h);
-    
-    virtual int move_task_id();
-    int move_task_id_;
-
+	void init(TaskManager *manager, int w, int h);
     void init_chain_vars(ChainPropertyPtr cv);
     void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h);
     void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg);
--- a/TaskManager/Test/test_render/Application/chain.cc	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/Application/chain.cc	Fri Sep 25 23:51:55 2009 +0900
@@ -5,40 +5,31 @@
 #include "SGList.h"
 #include "TaskManager.h"
 #include "Func.h"
-
+#include "Chain.h"
 #define FALSE 0
 #define TRUE !FALSE
 #define CHAIN_LEN 50
 
 static double chain_width = 10;
 
-typedef struct {
-    double x, y, next_x, next_y;
-    double vx, vy, next_vx, next_vy;
-    double angle[3];
-    int can_move;
-    SceneGraphPtr parent;
-    int id;
-    //int parent;
-} CHAIN_VARS;
 
 /* SceneGraph の property */
-CHAIN_VARS* properties[2];
-CHAIN_VARS* property;
+ChainPropertyPtr properties[2];
+ChainPropertyPtr property;
 
 
-//void createSceneGraphFromProperty(CHAIN_VARS* p) ;
+//void createSceneGraphFromProperty(ChainPropertyPtr p) ;
 void createSceneGraphFromProperty(void* p) ;
 
 void
-init_chain_vars(CHAIN_VARS *cv) {
+Chain::init_chain_vars(ChainPropertyPtr cv) {
     cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0;
     cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0;
     cv->can_move = TRUE;
 }
 
 void
-set_vector(CHAIN_VARS *p, SceneGraphPtr sg) {
+set_vector(ChainPropertyPtr p, SceneGraphPtr sg) {
     sg->xyz[0] = p->next_x;
     sg->xyz[1] = p->next_y;
     sg->xyz[2] = 0.0f;
@@ -72,12 +63,12 @@
 }
 
 void
-chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h)
+Chain::chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h)
 {
     int id = sg->id;
-    //CHAIN_VARS* p = (CHAIN_VARS*)sg->propertyptr;
+    //ChainPropertyPtr p = (ChainPropertyPtr)sg->propertyptr;
     HTaskPtr chain_cal;
-    CHAIN_VARS* output;
+    ChainPropertyPtr output;
 
     // SceneGraph の切り替えもここでやる
     if (property == properties[0]) {
@@ -88,58 +79,59 @@
       output   = properties[1];
     }
     chain_cal = manager->create_task(CHAINCAL_TASK);
-    chain_cal->add_inData(property, sizeof(CHAIN_VARS)*CHAIN_LEN);
+    chain_cal->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN);
     chain_cal->add_param(id);
-    chain_cal->add_outData(output, sizeof(CHAIN_VARS)*CHAIN_LEN);
-    chain_cal->set_post(createSceneGraphFromProperty, (void*)id);	
+    chain_cal->add_outData(output, sizeof(ChainProperty)*CHAIN_LEN);
+    chain_cal->set_post(createSceneGraphFromProperty, (void*)id);
     chain_cal->spawn();
 
 }
 
 void
-chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg)
+Chain::chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg)
 {
 
 }
 
 void 
-createSceneGraphFromProperty(void* p) 
+createSceneGraphFromProperty(void* p)
 {
-    CHAIN_VARS* chain_p = (CHAIN_VARS*)p;
+    ChainPropertyPtr chain_p = (ChainPropertyPtr)p;
     SceneGraphPtr chain_copy = sgroot->createSceneGraph(CHAIN);
     chain_copy->propertyptr = (void*)chain_p;
-    chain_copy->property_size = sizeof(CHAIN_VARS);
+    chain_copy->property_size = sizeof(ChainProperty);
     set_vector(chain_p, chain_copy);
     chain_p->parent->addChild(chain_copy);
 }
 
 void
-chain_init(TaskManager *manager, int w, int h)
+Chain::init(TaskManager *manager, int w, int h)
 {
     SceneGraphPtr root_chain, chain;
-    CHAIN_VARS rcv;
+    ChainPropertyPtr rcv;
+	ChainProperty r;
+    HTaskPtr chain_init;
 
-    HTaskPtr chain_init;
-    
+	rcv = &r;    
     
     sgroot->createFromXMLfile(manager, "xml_file/chain.xml");
 
     /* SPE に送る property の配列の領域確保 */
-    properties[0] = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*CHAIN_LEN);
-    properties[1] = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*CHAIN_LEN);
+    properties[0] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN);
+    properties[1] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN);
     property = properties[0];
 
     root_chain = sgroot->createSceneGraph(CHAIN);
     // set_move_collision()ではだめ
-    root_chain->set_move_collision(chain_move_ope, chain_collision);
-    init_chain_vars(&rcv);
-    rcv.next_x = w / 2;
-    rcv.next_y = 0.0;
-    rcv.angle[0] = 0;
-    rcv.angle[1] = 0;
-    rcv.angle[2] = 0;
+//    root_chain->set_move_collision(chain_move_ope, chain_collision);
+	init_chain_vars(rcv);
+    rcv->next_x = w / 2;
+    rcv->next_y = 0.0;
+    rcv->angle[0] = 0;
+    rcv->angle[1] = 0;
+    rcv->angle[2] = 0;
 
-    set_vector(&rcv, root_chain);
+    set_vector(rcv, root_chain);
 
     for(int i = 0; i < CHAIN_LEN; i++) {
         chain = sgroot->createSceneGraph(CHAIN);
@@ -150,16 +142,16 @@
         set_vector(&property[i], chain);
         property->angle[1] = -90 * (i % 2);
         //chain->set_move_collision(chain_move, chain_collision);
-	chain->propertyptr = &property[i];
-	chain->property_size = sizeof(CHAIN_VARS);
+		chain->propertyptr = &property[i];
+		chain->property_size = sizeof(ChainProperty);
         root_chain->addChild(chain);
-	property[i].parent = root_chain;
+		property[i].parent = root_chain;
     }
     property[0].can_move = FALSE;
 
     // property を SPU の共有領域へコピーする
     chain_init = manager->create_task(CHAININIT_TASK);
-    chain_init->add_inData(property, sizeof(CHAIN_VARS)*CHAIN_LEN);
+    chain_init->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN);
     chain_init->add_param(CHAIN_LEN);
     chain_init->set_cpu(SPE_0);
     chain_init->set_post(createSceneGraphFromProperty, (void*)property);
--- a/TaskManager/Test/test_render/polygon.h	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/polygon.h	Fri Sep 25 23:51:55 2009 +0900
@@ -1,7 +1,7 @@
 #ifndef INCLUDED_POLYGON
 #define INCLUDED_POLYGON
 
-#include "viewer.h"
+#include <SDL.h>
 #include <libxml/parser.h>
 #include "polygon_pack.h"
 #include "SpanPack.h"
--- a/TaskManager/Test/test_render/spe/ChainCal.cc	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/spe/ChainCal.cc	Fri Sep 25 23:51:55 2009 +0900
@@ -1,10 +1,9 @@
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include "ChainCal.h"
 #include "Func.h"
 #include "types.h"
-#include <math.h>
-
 
 /* これは必須 */
 SchedDefineTask(ChainCal);
@@ -26,15 +25,18 @@
     uint32 parent;
     int id;
     //int parent;
-} CHAIN_VARS;
+} ChainProperty, *ChainPropertyPtr;
 
 int
 ChainCal::run(void *rbuf, void *wbuf)
 {
-    CHAIN_VARS* property = (CHAIN_VARS*)rbuf;
-    int id = get_param(0);
+	ChainPropertyPtr property = (ChainPropertyPtr)get_input(rbuf, 0);
+    ChainPropertyPtr update_property = (ChainPropertyPtr)get_output(wbuf, 0);
+
+//    ChainPropertyPtr property = (ChainPropertyPtr)rbuf;
+//    int id = get_param(0);
     
-    //CHAIN_VARS* o_property = (CHAIN_VARS*)wbuf;
+    //ChainPropertyPtr o_property = (ChainPropertyPtr)wbuf;
     
     for(int cnt = 0; cnt < 600; cnt++) {
 		for(int i = 0; i < CHAIN_LEN; i++) {
@@ -75,7 +77,7 @@
 	
     for (int j = 0; j < CHAIN_LEN; j++) {
 		int p, n;
-		id = property[j].id;
+		int id = property[j].id;
 		p = n = id;
 		if(p != 0) {
 			p--;
@@ -86,6 +88,6 @@
 		property[j].angle[2-(id%2)*2]
 			= 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI;
     }
-    
+    memcpy((void*)update_property, (void*)property, sizeof(ChainProperty) * CHAIN_LEN);    
     return 0;
 }
--- a/TaskManager/Test/test_render/viewer.cc	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.cc	Fri Sep 25 23:51:55 2009 +0900
@@ -162,7 +162,8 @@
 		vacuum_init2(manager, this->width, this->height);
         break;
     case 16:
-        chain_init(manager, this->width, this-> height);
+		app = new Chain();
+        app->init(manager, this->width, this-> height);
 		speLoop();
 		return;
         break;
--- a/TaskManager/Test/test_render/viewer.h	Fri Sep 25 22:51:39 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.h	Fri Sep 25 23:51:55 2009 +0900
@@ -7,6 +7,10 @@
 #include "TaskManager.h"
 #include "KeyStat.h"
 
+#include "Application.h"
+#include "Application/Chain.h"
+
+
 class Viewer {
 public:
     //Viewer(TaskManager *manager, int bpp, int width, int height, int spenum);
@@ -14,7 +18,7 @@
 
     virtual ~Viewer(void) {}
 
-    //Application *application;
+    Application *app;
 
     TaskManager *manager;
     key_stat *keyPtr;