diff TaskManager/Test/test_render/chain.cpp @ 396:0b623693e6ec draft

don't move. separate allExecute from run_loop
author game@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 18 Sep 2009 18:28:56 +0900
parents 208ba3551474
children ce86b0186a4a
line wrap: on
line diff
--- a/TaskManager/Test/test_render/chain.cpp	Thu Sep 17 16:55:18 2009 +0900
+++ b/TaskManager/Test/test_render/chain.cpp	Fri Sep 18 18:28:56 2009 +0900
@@ -23,11 +23,12 @@
 } CHAIN_VARS;
 
 /* SceneGraph の property */
+CHAIN_VARS* properties[2];
 CHAIN_VARS* property;
 
-CHAIN_VARS cv[CHAIN_LEN];
 
-void createSceneGraphFromProperty(CHAIN_VARS* p) ;
+//void createSceneGraphFromProperty(CHAIN_VARS* p) ;
+void createSceneGraphFromProperty(void* p) ;
 
 void
 init_chain_vars(CHAIN_VARS *cv) {
@@ -74,17 +75,25 @@
 chain_move(SceneGraphPtr sg, int w, int h)
 {
     int id = sg->id;
-    CHAIN_VARS* p = (CHAIN_VARS*)sg->propertyptr;
-    if(id == 0) {
-	HTaskPtr chain_cal;
-	chain_cal = manager->create_task(CHAINCAL_TASK);
-	chain_cal->add_inData(&property[CHAIN_LEN-1], sizeof(CHAIN_VARS));
-	chain_cal->add_param(id);
-	chain_cal->add_outData(property, sizeof(CHAIN_VARS)*CHAIN_LEN);
-	chain_cal->spawn();
-	createSceneGraphFromProperty(p);
+    //CHAIN_VARS* p = (CHAIN_VARS*)sg->propertyptr;
+    HTaskPtr chain_cal;
+    CHAIN_VARS* output;
+
+    // SceneGraph の切り替えもここでやる
+    if (property == properties[0]) {
+      property = properties[1];
+      output   = properties[0];
+    }else{
+      property = properties[0];
+      output   = properties[1];
     }
-    
+    chain_cal = manager->create_task(CHAINCAL_TASK);
+    chain_cal->add_inData(property, sizeof(CHAIN_VARS)*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->spawn();
+
 }
 
 void
@@ -94,13 +103,14 @@
 }
 
 void 
-createSceneGraphFromProperty(CHAIN_VARS* p) 
+createSceneGraphFromProperty(void* p) 
 {
-    SceneGraphPtr chain_copy;
-    chain_copy = sgroot->createSceneGraph(CHAIN);
-    chain_copy->propertyptr = (void*)p;
-    set_vector(p, chain_copy);
-    p->parent->addChild(chain_copy);
+    CHAIN_VARS* chain_p = (CHAIN_VARS*)p;
+    SceneGraphPtr chain_copy = sgroot->createSceneGraph(CHAIN);
+    chain_copy->propertyptr = (void*)chain_p;
+    chain_copy->property_size = sizeof(CHAIN_VARS);
+    set_vector(chain_p, chain_copy);
+    chain_p->parent->addChild(chain_copy);
 }
 
 void
@@ -111,12 +121,16 @@
 
     HTaskPtr chain_init;
     
+    
     sgroot->createFromXMLfile("xml_file/chain.xml");
 
     /* SPE に送る property の配列の領域確保 */
-    property = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*CHAIN_LEN);
+    properties[0] = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*CHAIN_LEN);
+    properties[1] = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*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;
@@ -135,19 +149,21 @@
         property[i].y = chain_width * i;
         set_vector(&property[i], chain);
         property->angle[1] = -90 * (i % 2);
-        chain->set_move_collision(chain_move, chain_collision);
-
+        //chain->set_move_collision(chain_move, chain_collision);
+	chain->propertyptr = &property[i];
+	chain->property_size = sizeof(CHAIN_VARS);
         root_chain->addChild(chain);
 	property[i].parent = root_chain;
     }
-    cv[0].can_move = FALSE;
+    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_param(CHAIN_LEN);
     chain_init->set_cpu(SPE_0);
-
+    chain_init->set_post(createSceneGraphFromProperty, (void*)property);
+    chain_init->spawn();
 
     sgroot->setSceneData(root_chain);
 }