changeset 1255:39016616cc26 draft

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Nov 2011 16:57:15 +0900
parents 34944900f266 (current diff) bb9c885c1cb5 (diff)
children 880f989ce52a
files Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraphRoot.cc
diffstat 5 files changed, 96 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Fri Nov 18 16:56:11 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Fri Nov 18 16:57:15 2011 +0900
@@ -214,8 +214,13 @@
     if (size % 3 != 0) {
       printf("vertex size is error. size %% 3 = %lld\n", size % 3);
     }
-
+    /*
+     * MAX_SIZE_TRIANGLE:128
+     */
     if (size > 0) {
+      /* size/3 : 三角形の数?
+       * MAX_SIZE_TRIANGLE : 128
+       */
       pp_num = (size/3 + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
       pp = (PolygonPack*)manager->allocate(sizeof(PolygonPack)*pp_num);
     } else {
@@ -229,6 +234,7 @@
 
 }
 
+
 SceneGraph::SceneGraph(TaskManager *manager,const char *font,int pixels,Uint32 color,const char *string_name) {
 
     init();
--- a/Renderer/Engine/SceneGraphRoot.cc	Fri Nov 18 16:56:11 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Fri Nov 18 16:57:15 2011 +0900
@@ -141,14 +141,14 @@
 
 /*文字列の生成*/
 void
-SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root, 
+SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root,
 				 const char *string,int pixels,int screen_w,
 				 int screen_h,Uint32 color)
 {
     SceneGraphPtr text;
   float width_shift = 0;
   int i;
-  int length = strlen(string); 
+  int length = strlen(string);
   for (i = 0; i < length;) {
     int len = 0;
     unsigned char initial = string[i];
@@ -204,7 +204,11 @@
     xmlNodePtr cur;
     SceneGraphPtr tmp;
 
-    /* パース DOM生成 */
+    /* パース DOM生成
+       xmlParseFile:ファイルに含まれるXML文書を分析する
+       xmlDocGetRootElement:ドキュメントルートを指定する。
+       よって、以下のcurにはドキュメントルートの位置が入っている
+     */
     doc = xmlParseFile(xmlfile);
     cur = xmlDocGetRootElement(doc);
 
@@ -213,15 +217,27 @@
 
     /* XMLのノードを一つずつ解析  */
     for (cur=cur->children; cur; cur=cur->next) {
-	/* 扱うのはsurfaceオンリー  */
-	if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
-	    continue;
-	}
+      /*初期化:curをドキュメントルートの一個下に設定
+	継続条件:curが真である
+	再初期化:次のノードへ
+       */
 
-	/* ポリゴン(SceneGraph)生成  */
-	tmp = new SceneGraph(manager, cur);	
+      /* 扱うのはsurfaceオンリーなので、ノードの名前がsurfaceでないなら
+	 以下の処理を行なわずにスキップする
+      */
+      if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
+	continue;
+      }
+      
+      /* ポリゴン(SceneGraph)生成
+	 SceneGraph:SceneGraph.cc、L186
+      */
+	tmp = new SceneGraph(manager, cur);
+	
+	//シーングラフを登録
 	registSceneGraph(tmp);
     }
+    //解放
     xmlFreeDoc(doc);
 }
 
@@ -230,7 +246,7 @@
 {
 	/*make parse dom*/
 	xmlDocPtr doc;
-	xmlNodePtr cur;
+	xmlNodePtr cur,cur_images,cur_effects,cur_geometries,cur_visual_scenes;
 	SceneGraphPtr tmp;
 
 	doc = xmlParseFile(xmlColladafile);
@@ -239,25 +255,30 @@
 	/*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/
 	if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){
 		return ;
-	};
+       };
 
 	/* node analyze */
-	for(cur=cur->children; cur; cur=cur->next){
-
-		if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){
-
-		}
-		if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){
+	for(cur=cur->children; cur_images; cur_images=cur_images->next){
 
-		}
-		if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){
-
-		}
-		if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){
-		}
-
-		tmp = new SceneGraph(manager, cur);
-		registSceneGraph(tmp);
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){
+	    cur_images = cur;
+	    continue;
+	  }
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){
+	    cur_effects = cur;
+	    continue;
+	  }
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){
+	    cur_geometries = cur;
+	    continue;
+	  }
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){
+	    cur_visual_scenes = cur;
+	    continue;
+	  }
+	  
+	  tmp = new SceneGraph(manager, cur);
+	  registSceneGraph(tmp);
 	}
 	xmlFreeDoc(doc);
 }
@@ -267,7 +288,7 @@
 {
     xmlDocPtr doc;
     xmlNodePtr cur;
-    
+
     // size は取れるはず、テスト用に mmap したデータを使う
     /* パース DOM生成 */
 
@@ -284,7 +305,7 @@
 	    continue;
 	}
 	/* ポリゴン(SceneGraph)生成  */
-	SceneGraphPtr original = new SceneGraph(manager, cur);	
+	SceneGraphPtr original = new SceneGraph(manager, cur);
 	registSceneGraph(original);
 	SceneGraphPtr clone = createSceneGraph(original->sgid);
 	node->addChild(clone);
@@ -331,13 +352,13 @@
 	printf("error: createSceneGraph(name): name object not found.\n");
 	return NULL;
     }
-    
+
     /* オリジナルの SceneGraph */
     src = sg_src[id];
 
     /* ユーザーにはオリジナルの clone を返す */
     p = src->clone(this->tmanager);
-    
+
     /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
     p->sgroot = (void *)this;
 
@@ -349,7 +370,7 @@
 int
 SceneGraphRoot::getSgid(const char *name)
 {
-  return sgid_hash.get_sgid(name);    
+  return sgid_hash.get_sgid(name);
 }
 
 int
@@ -386,14 +407,14 @@
     for (int i = 0; i < light_num; i++) {
 
 	get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
-      
+
 	light_vector[i*4] = 0.0f;
 	light_vector[i*4+1] = 0.0f;
 	light_vector[i*4+2] = 0.0f;
 	light_vector[i*4+3] = 1.0f;
 
 	ApplyMatrix(&light_vector[i*4], light[i]->matrix);
-      
+
 	light_vector[i*4] /= light_vector[i*4+2];
 	light_vector[i*4+1] /= light_vector[i*4+2];
 
@@ -437,11 +458,11 @@
     while (list) {
 
         list->move_execute(screen_w, screen_h);
-        list->collision_check(screen_w, screen_h, list);	
-        
-	list->frame++; 
+        list->collision_check(screen_w, screen_h, list);
+
+	list->frame++;
         list = list->next;
-    }    
+    }
 
     lightCalc();
 
@@ -461,7 +482,7 @@
 
     sg_exec_tree = camera->children;
 }
-   
+
 void
 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent)
 {
@@ -481,8 +502,8 @@
 	    // get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
 	    //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
 
-	} 
-	
+	}
+
 	if (t->children != NULL && c != NULL) {
 	    cur_parent = c;
 	    t = t->children;
@@ -502,7 +523,7 @@
                         t = t->parent;
 		    }
 		}
-	    }	    
+	    }
 	}
     }
 
@@ -534,7 +555,6 @@
 	    /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
 	    // matrix4x4(t->real_matrix,t->real_matrix,cur_parent->real_matrix);
 	} 
-	
 	if (t->children != NULL && c != NULL) {
 	    cur_parent = t;
 	    t = t->children;
@@ -554,7 +574,7 @@
                         t = t->parent;
 		    }
 		}
-	    }	    
+	    }
 	}
     }
 
@@ -565,31 +585,31 @@
 */
 void
 SceneGraphRoot::move_finish()
-{    
-    list->collision_check(screen_w, screen_h, list);	
+{
+    list->collision_check(screen_w, screen_h, list);
 
-    list->frame++; 
+    list->frame++;
     //list = list->next;
 
     int light_num = 4;
     for (int i = 0; i < light_num; i++) {
 
 	get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
-      
+
 	light_vector[i*4] = 0.0f;
 	light_vector[i*4+1] = 0.0f;
 	light_vector[i*4+2] = 0.0f;
 	light_vector[i*4+3] = 1.0f;
 
 	ApplyMatrix(&light_vector[i*4], light[i]->matrix);
-      
+
 	light_vector[i*4] /= light_vector[i*4+2];
 	light_vector[i*4+1] /= light_vector[i*4+2];
 
 	light_vector[i*4+2] *= -1;
 	light_vector[i*4+3] *= -1;
-    }    
-    
+    }
+
     //sgchange->viewer->light_xyz_stock = getLightVector();
 }
 
@@ -610,7 +630,7 @@
 SceneGraphRoot::allRemove(SceneGraphPtr list)
 {
     SceneGraphPtr p = list;
-    
+
     while (p) {
 	SceneGraphPtr p1 = p->next;
 	delete p;
@@ -624,7 +644,7 @@
 {
     SceneGraphPtr p = sg_available_list;
     SceneGraphPtr p1;
-    
+
     while (p) {
 	p1 = p->next;
 	if (p->isRemoved()) {
@@ -650,7 +670,7 @@
 	if (!t->isRemoved()) {
 	    if (t->name) printf("name: %s ",t->name);
 	    printf("x=%g y=%g z=%g\n",t->xyz[0],t->xyz[1],t->xyz[2]);
-	} 
+	}
 	if (t->children != NULL) {
 	    t = t->children;
 	} else if (t->brother != NULL) {
@@ -668,7 +688,7 @@
                         t = t->parent;
 		    }
 		}
-	    }	    
+	    }
 	}
     }
 }
--- a/Renderer/Engine/polygon.cc	Fri Nov 18 16:56:11 2011 +0900
+++ b/Renderer/Engine/polygon.cc	Fri Nov 18 16:57:15 2011 +0900
@@ -56,8 +56,12 @@
 
       TrianglePackPtr tri =  pp[i].tri;
       // TrianglePack の size のチェック
+      
       int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
+      
+      //それを構造体に登録
       pp[i].info.size = tri_size;
+      
 
       for (int j = 0; j < tri_size; j++) {
 
--- a/Renderer/Test/xml_file/Ball.xml	Fri Nov 18 16:56:11 2011 +0900
+++ b/Renderer/Test/xml_file/Ball.xml	Fri Nov 18 16:57:15 2011 +0900
@@ -4345,4 +4345,4 @@
 			vLPuT//Z
 		</image>
 	</surface>
-</OBJECT-3D>
\ No newline at end of file
+</OBJECT-3D>
--- a/example/Prime/ppe/Prime.cc	Fri Nov 18 16:56:11 2011 +0900
+++ b/example/Prime/ppe/Prime.cc	Fri Nov 18 16:57:15 2011 +0900
@@ -11,7 +11,11 @@
 {
 	long start = (long)smanager->get_param(0);	/* 素数判定の開始地点 */
 	long end   = (long)smanager->get_param(1);	/* 素数判定の終了地点 */
+<<<<<<< local
+	long range = end - start;		        /* 判定する範囲	      */
+=======
 	long range = end - start;					/* 判定する範囲		  */
+>>>>>>> other
 
 	/* 判定結果を収める配列を受け取る */
 	bool *output = (bool*)smanager->get_output(wbuf, 0);
@@ -22,10 +26,16 @@
 	}
 
 
+<<<<<<< local
+ 	for (int i = start, index = 0; i < end; i++, index++) {
+ 		int limit = (int)sqrt((double) i);	       /* 割る数の最大値を求める */
+		for (int j = 2; j <= limit; j++) {
+=======
 
 	for (long i = start, index = 0; i < end; i++, index++) {
 		long limit = (long)sqrt((double) i);		/* 割る数の最大値を求める */
 		for (long j = 2; j <= limit; j++) {
+>>>>>>> other
 			/* 割り切れた場合、0を代入し素数じゃないという判定を下す */
 			if (i % j == 0) {
 				output[index] = false;