changeset 349:51ffd144f62c

fix hash_regist
author admin@mcbk.cr.ie.u-ryukyu.ac.jp
date Fri, 10 Jul 2009 16:06:15 +0900
parents d6338bb6db87
children dd3888980738
files TaskManager/Test/test_render/SceneGraph.cpp TaskManager/Test/test_render/SceneGraph.h TaskManager/Test/test_render/TextureHash.cpp TaskManager/Test/test_render/TextureHash.h TaskManager/Test/test_render/polygon.cpp TaskManager/Test/test_render/polygon.h
diffstat 6 files changed, 360 insertions(+), 362 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/SceneGraph.cpp	Thu Jul 09 17:59:44 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraph.cpp	Fri Jul 10 16:06:15 2009 +0900
@@ -18,9 +18,6 @@
 static TextureHash texture_hash;
 struct texture_list list[TABLE_SIZE];
 
-// TextureHash.cpp
-extern int id_count;
-
 extern int decode(char *cont, FILE *outfile);
 
 static void
@@ -28,7 +25,7 @@
 
 static void
 no_collision(SceneGraphPtr self, int screen_w, int screen_h,
-	     SceneGraphPtr tree) {}
+             SceneGraphPtr tree) {}
 
 /**
  * 事前に計算したテクスチャの最大縮小率 scale まで、
@@ -64,33 +61,33 @@
  */
 static uint32*
 makeTapestry(int tex_w, int tex_h, uint32 *tex_src,
-	     int all_pixel_num, int scale_cnt)
+             int all_pixel_num, int scale_cnt)
 {
     uint32 *tex_dest;
 
     int t = 0;
     int diff = TEXTURE_SPLIT_PIXEL;
     int p_diff = 1;
-	
+
     tex_dest = (uint32*)manager->allocate(sizeof(int)*all_pixel_num);
 
     while (scale_cnt) {
-	for (int y = 0; y < tex_h; y += diff) {
-	    for (int x = 0; x < tex_w; x += diff) {
-		for (int j = 0; j < diff; j += p_diff) {
-		    for (int i = 0; i < diff; i += p_diff) {
-			tex_dest[t++]
-			    = tex_src[(x+i) + tex_w*(y+j)];
-		    }
-		}
-	    }
-	}
-			
-	diff <<= 1;
-	p_diff <<= 1;
-	scale_cnt >>= 1;
+        for (int y = 0; y < tex_h; y += diff) {
+            for (int x = 0; x < tex_w; x += diff) {
+                for (int j = 0; j < diff; j += p_diff) {
+                    for (int i = 0; i < diff; i += p_diff) {
+                        tex_dest[t++]
+                            = tex_src[(x+i) + tex_w*(y+j)];
+                    }
+                }
+            }
+        }
+
+        diff <<= 1;
+        p_diff <<= 1;
+        scale_cnt >>= 1;
     }
-    
+
     return tex_dest;
 }
 
@@ -130,7 +127,7 @@
     finalize = &SceneGraph::finalize_copy;
 
 
-    frame = 0;    
+    frame = 0;
 }
 
 
@@ -229,14 +226,14 @@
 {
     /* childrenのリストの最後に加える (brother として)*/
     if (this->lastChild != NULL) {
-	SceneGraphPtr last = this->lastChild;
-	last->brother = child;
+        SceneGraphPtr last = this->lastChild;
+        last->brother = child;
     }
 
     this->lastChild = child;
 
     if (this->children == NULL) {
-	this->children = child;
+        this->children = child;
     }
 
     child->parent = this;
@@ -255,10 +252,10 @@
 SceneGraph::addBrother(SceneGraphPtr bro)
 {
     if (this->parent) {
-	parent->addChild(bro);
+        parent->addChild(bro);
     } else {
-	fprintf(stderr, "error : SceneGraph::%s : %s doesn't have parent\n",
-		__FUNCTION__, this->name);
+        fprintf(stderr, "error : SceneGraph::%s : %s doesn't have parent\n",
+                __FUNCTION__, this->name);
     }
 
     return bro;
@@ -276,8 +273,8 @@
 
     /* 子供から再帰的に探す  */
     for(tmp = this->children; tmp; tmp = tmp->next) {
-	if ((result=tmp->searchSceneGraph(name)) != NULL)
-	    return result;
+        if ((result=tmp->searchSceneGraph(name)) != NULL)
+            return result;
     }
 
     /* 無かったら NULL.  */
@@ -291,37 +288,37 @@
 
     while(t)
     {
-	cout << "my_name : " << t->name << endl;
-	if(t->children != NULL)
-	{
-	    cout << "--move children : " << t->children->name << endl;
-	    t = t->children;
-	}
-	else if(t->brother != NULL)
-	{
-	    cout << "--move brother : " << t->brother->name << endl;
-	    t = t->brother;
-	}
-	else
-	{
-	    while(t)
-	    {
-		if(t->brother != NULL)
-		{
-		    cout << "--move brother : " << t->brother->name << endl;
-		    t = t->brother;
-		    break;
-		}
-		else
-		{
-		    if(t->parent)
-		    {
-			cout << "--move parent : " << t->parent->name << endl;
-		    }
-		    t = t->parent;
-		}
-	    }
-	}
+        cout << "my_name : " << t->name << endl;
+        if(t->children != NULL)
+        {
+            cout << "--move children : " << t->children->name << endl;
+            t = t->children;
+        }
+        else if(t->brother != NULL)
+        {
+            cout << "--move brother : " << t->brother->name << endl;
+            t = t->brother;
+        }
+        else
+        {
+            while(t)
+            {
+                if(t->brother != NULL)
+                {
+                    cout << "--move brother : " << t->brother->name << endl;
+                    t = t->brother;
+                    break;
+                }
+                else
+                {
+                    if(t->parent)
+                    {
+                        cout << "--move parent : " << t->parent->name << endl;
+                    }
+                    t = t->parent;
+                }
+            }
+        }
     }
 }
 
@@ -334,11 +331,11 @@
     cout << "parent_name = " << parent_name << endl;
 
     if (parent != NULL) {
-	cout << "parent->name = " << parent->name << endl;
+        cout << "parent->name = " << parent->name << endl;
     }
 
     if (children != NULL) {
-	cout << "children->name = " << children->name << endl;
+        cout << "children->name = " << children->name << endl;
     }
 }
 
@@ -348,40 +345,41 @@
  */
 void
 SceneGraph::get_data(xmlNodePtr cur)
-{    
+{
     //char *image_name;
 
     for(;cur;cur=cur->next)
     {
-	if(!xmlStrcmp(cur->name,(xmlChar*)"coordinate"))
+        if(!xmlStrcmp(cur->name,(xmlChar*)"coordinate"))
         {
-	    char *cont = (char *)xmlNodeGetContent(cur);
-	    pickup_coordinate(cont);
+            char *cont = (char *)xmlNodeGetContent(cur);
+            pickup_coordinate(cont);
         }
-	else if(!xmlStrcmp(cur->name,(xmlChar*)"normal"))
+        else if(!xmlStrcmp(cur->name,(xmlChar*)"normal"))
         {
-	    char *cont = (char *)xmlNodeGetContent(cur);
-	    pickup_normal(cont);
+            char *cont = (char *)xmlNodeGetContent(cur);
+            pickup_normal(cont);
         }
-	else if(!xmlStrcmp(cur->name,(xmlChar*)"model"))
+        else if(!xmlStrcmp(cur->name,(xmlChar*)"model"))
         {
-	    char *cont = (char *)xmlNodeGetContent(cur);
-	    pickup_model(cont);
+            char *cont = (char *)xmlNodeGetContent(cur);
+            pickup_model(cont);
         }
-	else if(!xmlStrcmp(cur->name,(xmlChar*)"texture"))
+        else if(!xmlStrcmp(cur->name,(xmlChar*)"texture"))
         {
-	    char *cont = (char *)xmlNodeGetContent(cur);
-	    pickup_texture(cont);
-	}
-	else if(!xmlStrcmp(cur->name,(xmlChar*)"imageflag"))
+            char *cont = (char *)xmlNodeGetContent(cur);
+            pickup_texture(cont);
+        }
+        else if(!xmlStrcmp(cur->name,(xmlChar*)"imageflag"))
         {
-	    char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
-	    texture_hash.hash_regist(filename);
-	}
-	else if(!xmlStrcmp(cur->name,(xmlChar*)"image"))
+            int id;
+            char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
+            texture_hash.hash_regist(filename, id);
+        }
+        else if(!xmlStrcmp(cur->name,(xmlChar*)"image"))
         {
-	    get_image(cur);	    
-	}
+            get_image(cur);
+        }
     }
 }
 
@@ -390,77 +388,77 @@
 {
     int fd = mkstemp(image_name);
     FILE *outfile = fdopen(fd, "wb");
-    
+
     if (NULL == outfile) {
-	    cout << "error open file\n";
-	    return 0;
+            cout << "error open file\n";
+            return 0;
     }
-    
+
     char *cont = (char *)xmlNodeGetContent(cur);
     //decode(cont, image_name);
     decode(cont, outfile);
     fclose(outfile);
-    
+
 
 /**
  * image を 32bit(RGBA) に変換する
  */
     SDL_Surface *texture_image = IMG_Load(image_name);
     SDL_Surface *tmpImage
-	= SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
-			       texture_image->h, 32, redMask,
-			       greenMask, blueMask, alphaMask);
+        = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
+                               texture_image->h, 32, redMask,
+                               greenMask, blueMask, alphaMask);
     SDL_Surface *converted;
     converted = SDL_ConvertSurface(texture_image, tmpImage->format,
-				   SDL_HWSURFACE);
+                                   SDL_HWSURFACE);
     if (converted != NULL) {
-	SDL_FreeSurface(texture_image);
-	texture_image = converted;
+        SDL_FreeSurface(texture_image);
+        texture_image = converted;
     }
- 
+
     return texture_image;
 }
 
 int
-SceneGraph::makeTapestries(SDL_Surface *texture_image) {
-		uint32 *tapestry;
-		int scale = 1;
-		int tex_w = texture_image->w;
-		int tex_h = texture_image->h;
-		int all_pixel_num = 0;
+SceneGraph::makeTapestries(SDL_Surface *texture_image, int id) {
+                uint32 *tapestry;
+                int scale = 1;
+                int tex_w = texture_image->w;
+                int tex_h = texture_image->h;
+                int all_pixel_num = 0;
 
-		/**
-		 * テクスチャの w or h が 8 pixel で分割できる間、
-		 * 1/2 の縮小画像を作る。
-		 * ここでは、最大の scale (1/scale) を見つける
-		 *
-		 * (ex)
-		 *  (128,128) => 64,64 : 32,32: 16,16 : 8,8
-		 *     scale = 16
-		 *  (128, 64) => 64,32 : 32,16: 16,8
-		 *     scale = 8
-		 */
-		while (tex_w % TEXTURE_SPLIT_PIXEL == 0 && 
-		       tex_h % TEXTURE_SPLIT_PIXEL == 0) {
-		    all_pixel_num += tex_w*tex_h;
-		    tex_w >>= 1; /* tex_w /= 2 */
-		    tex_h >>= 1;
-		    scale <<= 1; /* scale *= 2 */
-		}
+                /**
+                 * テクスチャの w or h が 8 pixel で分割できる間、
+                 * 1/2 の縮小画像を作る。
+                 * ここでは、最大の scale (1/scale) を見つける
+                 *
+                 * (ex)
+                 *  (128,128) => 64,64 : 32,32: 16,16 : 8,8
+                 *     scale = 16
+                 *  (128, 64) => 64,32 : 32,16: 16,8
+                 *     scale = 8
+                 */
+                while (tex_w % TEXTURE_SPLIT_PIXEL == 0 &&
+                       tex_h % TEXTURE_SPLIT_PIXEL == 0) {
+                    all_pixel_num += tex_w*tex_h;
+                    tex_w >>= 1; /* tex_w /= 2 */
+                    tex_h >>= 1;
+                    scale <<= 1; /* scale *= 2 */
+                }
 
-		scale >>= 1;
+                scale >>= 1;
 
-		tapestry = makeTapestry(texture_image->w, texture_image->h,
-					(uint32*)texture_image->pixels,
-					all_pixel_num, scale);
+                tapestry = makeTapestry(texture_image->w, texture_image->h,
+                                        (uint32*)texture_image->pixels,
+                                        all_pixel_num, scale);
 
-		list[id_count-1].t_w = texture_image->w;
-		list[id_count-1].t_h = texture_image->h;
-		list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels;
-		list[id_count-1].pixels = tapestry;
-		list[id_count-1].scale_max = scale;
-		
-		return id_count-1;
+                list[id].t_w = texture_image->w;
+                list[id].t_h = texture_image->h;
+                list[id].pixels_orig = (Uint32*)texture_image->pixels;
+                list[id].pixels = tapestry;
+                list[id].scale_max = scale;
+
+                return id;
     }
 
 void
@@ -470,36 +468,36 @@
     char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
 
     if (filename == NULL || filename[0] == 0) {
-	return;
+        return;
     }
 
     /**
      * image_name を既に Load していれば何もしない
      */
-    int tex_id = texture_hash.hash_regist(filename);
-    if (tex_id < 0) {       
+    int tex_id;
+    if (!texture_hash.hash_regist(filename, tex_id)) {
+
+        SDL_Surface *texture_image = load_decode_image(image_name, cur);
 
-	SDL_Surface *texture_image = load_decode_image(image_name, cur);
-			        		
-	texture_id = makeTapestries(texture_image);
-		
-	if (unlink(image_name)) {
-	    cout << "unlink error\n";
-	}
+        texture_id = makeTapestries(texture_image, tex_id);
+
+        if (unlink(image_name)) {
+            cout << "unlink error\n";
+        }
     } else {
-	/**
-	 * 以前に Load されている Texture を共用
-	 */
-	texture_id = tex_id;
+        /**
+         * 以前に Load されている Texture を共用
+         */
+        texture_id = tex_id;
     }
- 
-	    // こんなことすると list[] のいみあるのかなーと
-	    // 微妙に思う、自分で書き換えた感想 by gongo
-	    texture_info.t_w = list[texture_id].t_w;
-	    texture_info.t_h = list[texture_id].t_h;;
-	    texture_info.pixels_orig = list[texture_id].pixels_orig;
-	    texture_info.pixels = list[texture_id].pixels;
-	    texture_info.scale_max = list[texture_id].scale_max;
+
+            // こんなことすると list[] のいみあるのかなーと
+            // 微妙に思う、自分で書き換えた感想 by gongo
+            texture_info.t_w = list[texture_id].t_w;
+            texture_info.t_h = list[texture_id].t_h;;
+            texture_info.pixels_orig = list[texture_id].pixels_orig;
+            texture_info.pixels = list[texture_id].pixels;
+            texture_info.scale_max = list[texture_id].scale_max;
 }
 
 
@@ -512,11 +510,11 @@
     //delete [] n->data;
 
     if (next) {
-	while (n) {
-	    m = n->next;
-	    delete n;
-	    n = m;
-	}
+        while (n) {
+            m = n->next;
+            delete n;
+            n = m;
+        }
     }
 }
 
@@ -539,42 +537,42 @@
     SceneGraphPtr t = top;
 
     while (t) {
-	t->move_execute(screen_w, screen_h);
-	t->collision_check(screen_w, screen_h, top);
+        t->move_execute(screen_w, screen_h);
+        t->collision_check(screen_w, screen_h, top);
 
-	t->frame++;
+        t->frame++;
 
-	if (t->parent != NULL) {
-	    get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix);
-	} else {
-	    get_matrix(t->matrix, t->angle, t->xyz, NULL);
-	}
+        if (t->parent != NULL) {
+            get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix);
+        } else {
+            get_matrix(t->matrix, t->angle, t->xyz, NULL);
+        }
 
-	if (t->children != NULL) {
-	    t = t->children;
-	} else if (t->brother != NULL) {
-	    t = t->brother;
-	} else {
-	    while (t) {
-		if (t->brother != NULL) {
-		    t = t->brother;
-		    break;
-		} else {
-		    if (t->parent == NULL) {
-			t = NULL;
-			break;
-		    } else {
-			t = t->parent;
-		    }
-		}
-	    }
-	}
+        if (t->children != NULL) {
+            t = t->children;
+        } else if (t->brother != NULL) {
+            t = t->brother;
+        } else {
+            while (t) {
+                if (t->brother != NULL) {
+                    t = t->brother;
+                    break;
+                } else {
+                    if (t->parent == NULL) {
+                        t = NULL;
+                        break;
+                    } else {
+                        t = t->parent;
+                    }
+                }
+            }
+        }
     }
 }
 
 void
 SceneGraph::set_move_collision(SceneGraphPtr node, move_func new_move,
-			       collision_func new_collision)
+                               collision_func new_collision)
 {
     node->move = new_move;
     node->collision = new_collision;
@@ -582,7 +580,7 @@
 
 void
 SceneGraph::set_move_collision(move_func new_move,
-			       collision_func new_collision)
+                               collision_func new_collision)
 {
     this->move = new_move;
     this->collision = new_collision;
@@ -593,10 +591,10 @@
 {
     /* next のリストの最後に加える */
     if (this->next != NULL) {
-	SceneGraphPtr tmp = this->last;
-	tmp->next = next;
+        SceneGraphPtr tmp = this->last;
+        tmp->next = next;
     } else {
-	this->next = next;
+        this->next = next;
     }
 
     this->last = next;
@@ -633,7 +631,7 @@
 
 /**
  * tree から node を削除する
- * 
+ *
  * @param tree SceneGraphTree
  * @return node削除後の SceneGraphTree
  */
@@ -645,38 +643,38 @@
     SceneGraphPtr ret = tree;
 
     if (parent) {
-	SceneGraphPtr brother = parent->children;
-	SceneGraphPtr p, p1 = NULL;
+        SceneGraphPtr brother = parent->children;
+        SceneGraphPtr p, p1 = NULL;
 
-	p = brother;
-	if (p) {
-	    if (p == node) {
-		parent->children = NULL;
-		parent->lastChild = NULL;
-	    } else {
-		p1 = p->brother;
+        p = brother;
+        if (p) {
+            if (p == node) {
+                parent->children = NULL;
+                parent->lastChild = NULL;
+            } else {
+                p1 = p->brother;
+
+                while (p1 && p1 != node) {
+                    p1 = p1->brother;
+                    p = p->brother;
+                }
 
-		while (p1 && p1 != node) {
-		    p1 = p1->brother;
-		    p = p->brother;
-		}
-	    
-		if (p1) {
-		    p->brother = p1->brother;
+                if (p1) {
+                    p->brother = p1->brother;
 
-		    // node が最後尾なら、lastChild を変更
-		    if (parent->lastChild == p1) {
-			parent->lastChild = p;
-		    }
-		} else {
-		    // Can't find remove node
-		}
-	    }
-	}
+                    // node が最後尾なら、lastChild を変更
+                    if (parent->lastChild == p1) {
+                        parent->lastChild = p;
+                    }
+                } else {
+                    // Can't find remove node
+                }
+            }
+        }
     } else {
-	// 親が居ない = tree root なので
-	// NULL を返す
-	ret = NULL;
+        // 親が居ない = tree root なので
+        // NULL を返す
+        ret = NULL;
     }
 
     return ret;
@@ -684,7 +682,7 @@
 
 /**
  * list から node を削除する
- * 
+ *
  * @param list SceneGraphList
  * @return node削除後の SceneGraphList
  */
@@ -695,15 +693,15 @@
     SceneGraphPtr prev = node->prev;
     SceneGraphPtr next = node->next;
     SceneGraphPtr ret = list;
-    
+
     if (prev) {
-	prev->next = next;
+        prev->next = next;
     } else {
-	ret = next;
+        ret = next;
     }
 
     if (next) {
-	next->prev = prev;
+        next->prev = prev;
     }
 
     return ret;
--- a/TaskManager/Test/test_render/SceneGraph.h	Thu Jul 09 17:59:44 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraph.h	Fri Jul 10 16:06:15 2009 +0900
@@ -13,7 +13,7 @@
 
 typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h);
 typedef void (*collision_func)(SceneGraph* node, int screen_w, int screen_h,
-			       SceneGraph* tree);
+                               SceneGraph* tree);
 typedef SceneGraph* SceneGraphPtr;
 
 class SceneGraph : public Polygon {
@@ -75,13 +75,13 @@
     SceneGraphPtr clone(void *buf);
     SceneGraphPtr searchSceneGraph(const char *name);
     void set_move_collision(SceneGraphPtr node,
-			    move_func new_move, collision_func new_collision);
+                            move_func new_move, collision_func new_collision);
     void set_move_collision(move_func new_move, collision_func new_collision);
     void remove(void);
     SceneGraphPtr realRemoveFromTree(SceneGraphPtr tree);
     SceneGraphPtr realRemoveFromList(SceneGraphPtr list);
     int isRemoved(void);
-  
+
     static SceneGraphPtr createSceneGraph(int id);
 
     void translate(float x, float y, float z);
@@ -96,7 +96,7 @@
     void delete_data(void);
 
     SDL_Surface* load_decode_image(char *image_name, xmlNodePtr cur);
-    int makeTapestries(SDL_Surface *texture_image);
+    int makeTapestries(SDL_Surface *texture_image, int id);
     void get_image(xmlNodePtr cur);
 };
 
--- a/TaskManager/Test/test_render/TextureHash.cpp	Thu Jul 09 17:59:44 2009 +0900
+++ b/TaskManager/Test/test_render/TextureHash.cpp	Fri Jul 10 16:06:15 2009 +0900
@@ -2,15 +2,15 @@
 #include <stdlib.h>
 #include "TextureHash.h"
 
-int id_count;
+static int id_count;
 
 TextureHash::TextureHash(void)
 {
     table = (hashtable*)malloc(sizeof(hashtable)*TABLE_SIZE);
 
     for (int i = 0; i < TABLE_SIZE; i++) {
-	table[i].tx_id = -1;
-	table[i].key = NULL;
+        table[i].tx_id = -1;
+        table[i].key = NULL;
     }
 }
 
@@ -26,26 +26,28 @@
     int value = 0;
 
     for (int i = 0; key[i]; i++) {
-	value += key[i]*(i+1)*17+1;
+        value += key[i]*(i+1)*17+1;
     }
 
     return value%TABLE_SIZE;
 }
 
 int
-TextureHash::hash_regist(const char* key)
+TextureHash::hash_regist(const char* key, int &id)
 {
     int hash = hash_function(key);
-    
+
     for (int i = 0; ; i++) {
-	if (table[hash].tx_id == -1) {
-	    table[hash].key   = (char*)key;
-	    table[hash].tx_id = id_count++;
-	    return -1;
-	} else if (strcmp(key, table[hash].key) == 0
-		   && table[hash].tx_id != -1){
-	    return table[hash].tx_id;
-	}
-	hash = ((37*hash)^(11*i)) % TABLE_SIZE;
+        if (table[hash].tx_id == -1) {
+            table[hash].key   = (char*)key;
+            id = id_count++;
+            return 0;
+
+        } else if (strcmp(key, table[hash].key) == 0
+                   && table[hash].tx_id != -1){
+            id = table[hash].tx_id;
+            return 1;
+        }
+        hash = ((37*hash)^(11*i)) % TABLE_SIZE;
     }
 }
--- a/TaskManager/Test/test_render/TextureHash.h	Thu Jul 09 17:59:44 2009 +0900
+++ b/TaskManager/Test/test_render/TextureHash.h	Fri Jul 10 16:06:15 2009 +0900
@@ -14,8 +14,8 @@
 
     TextureHash(void);
     ~TextureHash(void);
-    int hash_function(const char*);
-    int hash_regist(const char*);
+    int hash_function(const char* image_name);
+    int hash_regist(const char* image_name, int &tx_id);
 };
 
 #endif
--- a/TaskManager/Test/test_render/polygon.cpp	Thu Jul 09 17:59:44 2009 +0900
+++ b/TaskManager/Test/test_render/polygon.cpp	Fri Jul 10 16:06:15 2009 +0900
@@ -18,8 +18,6 @@
 extern int decode(char *cont, FILE *outfile);
 
 
-//SDL_Surface* Polygon::texture_image;
-
 Polygon::Polygon(void)
 {
     xyz[0] = 0;
@@ -36,7 +34,7 @@
     angle[3] = 1;
 
     for (int i = 0; i < 16; i++) {
-	matrix[i] = 0;
+        matrix[i] = 0;
     }
 }
 
@@ -57,7 +55,7 @@
     angle[3] = 1;
 
     for (int i = 0; i < 16; i++) {
-	matrix[i] = 0;
+        matrix[i] = 0;
     }
 }
 
@@ -69,43 +67,43 @@
     /***SceneGraphUpdate***/
     //sgp_update();
     for (int i = 0; i < sgp->info.size; i++) {
-	SceneGraphNode node = sgp->node[i];
+        SceneGraphNode node = sgp->node[i];
 
-	/***draw***/
-	int n,nt;
-	for(n=0,nt=0; n<node.size*3; n+=9,nt+=6) {
-	    xyz1[0] = node.vertex[n];
-	    xyz1[1] = node.vertex[n+1];
-	    xyz1[2] = node.vertex[n+2]*-1;
-	    xyz1[3] = 1;
-	    xyz2[0] = node.vertex[n+3];
-	    xyz2[1] = node.vertex[n+3+1];
-	    xyz2[2] = node.vertex[n+3+2]*-1;
-	    xyz2[3] = 1;
-	    xyz3[0] = node.vertex[n+6];
-	    xyz3[1] = node.vertex[n+6+1];
-	    xyz3[2] = node.vertex[n+6+2]*-1;
-	    xyz3[3] = 1;
+        /***draw***/
+        int n,nt;
+        for(n=0,nt=0; n<node.size*3; n+=9,nt+=6) {
+            xyz1[0] = node.vertex[n];
+            xyz1[1] = node.vertex[n+1];
+            xyz1[2] = node.vertex[n+2]*-1;
+            xyz1[3] = 1;
+            xyz2[0] = node.vertex[n+3];
+            xyz2[1] = node.vertex[n+3+1];
+            xyz2[2] = node.vertex[n+3+2]*-1;
+            xyz2[3] = 1;
+            xyz3[0] = node.vertex[n+6];
+            xyz3[1] = node.vertex[n+6+1];
+            xyz3[2] = node.vertex[n+6+2]*-1;
+            xyz3[3] = 1;
 
-	    rotate(xyz1, node.translation);
-	    rotate(xyz2, node.translation);
-	    rotate(xyz3, node.translation);
+            rotate(xyz1, node.translation);
+            rotate(xyz2, node.translation);
+            rotate(xyz3, node.translation);
 
-	    Vertex *ver1 = new Vertex(xyz1[0],xyz1[1],xyz1[2],node.texture[nt],node.texture[nt+1]);
-	    Vertex *ver2 = new Vertex(xyz2[0],xyz2[1],xyz2[2],node.texture[nt+2],node.texture[nt+2+1]);
-	    Vertex *ver3 = new Vertex(xyz3[0],xyz3[1],xyz3[2],node.texture[nt+4],node.texture[nt+4+1]);
+            Vertex *ver1 = new Vertex(xyz1[0],xyz1[1],xyz1[2],node.texture[nt],node.texture[nt+1]);
+            Vertex *ver2 = new Vertex(xyz2[0],xyz2[1],xyz2[2],node.texture[nt+2],node.texture[nt+2+1]);
+            Vertex *ver3 = new Vertex(xyz3[0],xyz3[1],xyz3[2],node.texture[nt+4],node.texture[nt+4+1]);
 
-	    Triangle *tri = new Triangle(ver1,ver2,ver3);
-	    Span_c *span = new Span_c();
-	    span->viewer = viewer;
-	    span->p = this;
-	    span->create_span(tri,texture_image);
-	    delete ver1;
-	    delete ver2;
-	    delete ver3;
-	    delete tri;
-	    delete span;
-	}
+            Triangle *tri = new Triangle(ver1,ver2,ver3);
+            Span_c *span = new Span_c();
+            span->viewer = viewer;
+            span->p = this;
+            span->create_span(tri,texture_image);
+            delete ver1;
+            delete ver2;
+            delete ver3;
+            delete tri;
+            delete span;
+        }
     }
 }
 
@@ -114,20 +112,20 @@
 {
     for(int n=0; n<pp->info.size; n++)
     {
-	Vertex *ver1 = new Vertex(pp->tri[n].ver1.x,pp->tri[n].ver1.y,pp->tri[n].ver1.z,pp->tri[n].ver1.tex_x,pp->tri[n].ver1.tex_y);
-	Vertex *ver2 = new Vertex(pp->tri[n].ver2.x,pp->tri[n].ver2.y,pp->tri[n].ver2.z,pp->tri[n].ver2.tex_x,pp->tri[n].ver2.tex_y);
-	Vertex *ver3 = new Vertex(pp->tri[n].ver3.x,pp->tri[n].ver3.y,pp->tri[n].ver3.z,pp->tri[n].ver3.tex_x,pp->tri[n].ver3.tex_y);
+        Vertex *ver1 = new Vertex(pp->tri[n].ver1.x,pp->tri[n].ver1.y,pp->tri[n].ver1.z,pp->tri[n].ver1.tex_x,pp->tri[n].ver1.tex_y);
+        Vertex *ver2 = new Vertex(pp->tri[n].ver2.x,pp->tri[n].ver2.y,pp->tri[n].ver2.z,pp->tri[n].ver2.tex_x,pp->tri[n].ver2.tex_y);
+        Vertex *ver3 = new Vertex(pp->tri[n].ver3.x,pp->tri[n].ver3.y,pp->tri[n].ver3.z,pp->tri[n].ver3.tex_x,pp->tri[n].ver3.tex_y);
 
-	Triangle *tri = new Triangle(ver1,ver2,ver3);
-	Span_c *span = new Span_c();
-	span->viewer = viewer;
-	span->p = this;
-	span->create_span(tri,texture_image);
-	delete ver1;
-	delete ver2;
-	delete ver3;
-	delete tri;
-	delete span;
+        Triangle *tri = new Triangle(ver1,ver2,ver3);
+        Span_c *span = new Span_c();
+        span->viewer = viewer;
+        span->p = this;
+        span->create_span(tri,texture_image);
+        delete ver1;
+        delete ver2;
+        delete ver3;
+        delete tri;
+        delete span;
     }
 }
 
@@ -136,42 +134,42 @@
     Span *span;
 
     for (int n = 0; n < sp->info.size; n++) {
-	span = &sp->span[n];
+        span = &sp->span[n];
 
-	//int x = span->x;
-	//int y = span->y;
-	float z = span->start_z;
-	int end = span->length_x;
-	float zpos = span->end_z;
-	float tex1 = span->tex_x1;
-	float tex2 = span->tex_x2;
-	float tey1 = span->tex_y1;
-	float tey2 = span->tex_y2;
-	Uint32 rgb;
-	int tex_xpos;
-	int tex_ypos;
-	int tex_zpos;
-	float tex_x, tex_y, tex_z;
+        //int x = span->x;
+        //int y = span->y;
+        float z = span->start_z;
+        int end = span->length_x;
+        float zpos = span->end_z;
+        float tex1 = span->tex_x1;
+        float tex2 = span->tex_x2;
+        float tey1 = span->tex_y1;
+        float tey2 = span->tex_y2;
+        Uint32 rgb;
+        int tex_xpos;
+        int tex_ypos;
+        int tex_zpos;
+        float tex_x, tex_y, tex_z;
 
-	if (end == 1) {
-	    tex_xpos = (int)((span->tex_height-1) * tex1);
-	    tex_ypos = (int)((span->tex_width-1) * tey1);
-	    tex_zpos = (int)z;
-	    rgb = get_rgb(tex_xpos, tex_ypos);
-	    //viewer->write_pixel(x, y, zpos, rgb);
-	} else {
-	    for (int j = 0; j < end; j++) {
-		tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1);
-		tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1);
-		tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1);
-		if (tex_x > 1) tex_x = 1;
-		if (tex_y > 1) tex_y = 1;
-		tex_xpos = (int)((span->tex_height-1) * tex_x);
-		tex_ypos = (int)((span->tex_width-1) * tex_y);
-		rgb = get_rgb(tex_xpos,tex_ypos);
-		//viewer->write_pixel(j + x, y, tex_z, rgb);
-	    }
-	}
+        if (end == 1) {
+            tex_xpos = (int)((span->tex_height-1) * tex1);
+            tex_ypos = (int)((span->tex_width-1) * tey1);
+            tex_zpos = (int)z;
+            rgb = get_rgb(tex_xpos, tex_ypos);
+            //viewer->write_pixel(x, y, zpos, rgb);
+        } else {
+            for (int j = 0; j < end; j++) {
+                tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1);
+                tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1);
+                tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1);
+                if (tex_x > 1) tex_x = 1;
+                if (tex_y > 1) tex_y = 1;
+                tex_xpos = (int)((span->tex_height-1) * tex_x);
+                tex_ypos = (int)((span->tex_width-1) * tex_y);
+                rgb = get_rgb(tex_xpos,tex_ypos);
+                //viewer->write_pixel(j + x, y, tex_z, rgb);
+            }
+        }
     }
 }
 
@@ -181,14 +179,14 @@
 {
     for(int n=0; n<size*3; n+=3)
     {
-	cont = pickup_float(cont, coord_xyz+n);
-	cont = pickup_float(cont, coord_xyz+n+1);
-	cont = pickup_float(cont, coord_xyz+n+2);
-      
-	if (cont == NULL)
-	{
-	    cout << "Analyzing obj data failed coordinate\n";
-	}
+        cont = pickup_float(cont, coord_xyz+n);
+        cont = pickup_float(cont, coord_xyz+n+1);
+        cont = pickup_float(cont, coord_xyz+n+2);
+
+        if (cont == NULL)
+        {
+            cout << "Analyzing obj data failed coordinate\n";
+        }
     }
 }
 
@@ -196,14 +194,14 @@
 {
     for (int n = 0; n<size*3; n += 3)
     {
-	cont = pickup_float(cont, normal+n);
-	cont = pickup_float(cont, normal+n+1);
-	cont = pickup_float(cont, normal+n+2);
-      
-	if (cont == NULL)
-	{
-	    cout << "Analyzing obj data failed normal\n";
-	}
+        cont = pickup_float(cont, normal+n);
+        cont = pickup_float(cont, normal+n+1);
+        cont = pickup_float(cont, normal+n+2);
+
+        if (cont == NULL)
+        {
+            cout << "Analyzing obj data failed normal\n";
+        }
     }
 }
 
@@ -212,10 +210,10 @@
     cont = pickup_float(cont,c_xyz);
     cont = pickup_float(cont,c_xyz+1);
     cont = pickup_float(cont,c_xyz+2);
-  
+
     if (cont == NULL)
     {
-	cout << "Analyzing obj data failed model\n";
+        cout << "Analyzing obj data failed model\n";
     }
 }
 
@@ -223,14 +221,14 @@
 {
     for (int n = 0; n < size*3; n += 3)
     {
-	cont = pickup_float(cont, coord_tex+n);
-	cont = pickup_float(cont, coord_tex+n+1);
-	coord_tex[n+2] = 1.0;
-      
-	if (cont == NULL)
-	{
-	    cout << "Analyzing obj data failed texture\n";
-	}
+        cont = pickup_float(cont, coord_tex+n);
+        cont = pickup_float(cont, coord_tex+n+1);
+        coord_tex[n+2] = 1.0;
+
+        if (cont == NULL)
+        {
+            cout << "Analyzing obj data failed texture\n";
+        }
     }
 }
 
@@ -261,7 +259,7 @@
     SDL_PixelFormat *fmt;
     //Uint32 temp, pixel;
     Uint8 red, green, blue;
-  
+
     fmt = texture_image->format;
 
     if (tx<0) tx = 0;
@@ -278,17 +276,17 @@
     //printf("pixel = %d\n", pixel);
     //printf("pixel %x bpp = %d ",p, fmt->BytesPerPixel);
     //SDL_UnlockSurface(texture_image);
-  
+
     temp = pixel&fmt->Rmask;
     temp = temp>>fmt->Rshift;
     temp = temp<<fmt->Rloss;
     red = (Uint8)temp;
-  
+
     temp = pixel&fmt->Gmask;
     temp = temp>>fmt->Gshift;
     temp = temp<<fmt->Gloss;
     green = (Uint8)temp;
-  
+
     temp = pixel&fmt->Bmask;
     temp = temp>>fmt->Bshift;
     temp = temp<<fmt->Bloss;
@@ -297,8 +295,8 @@
     blue  = (Uint8) p[0];
     green = (Uint8) p[1];
     red   = (Uint8) p[2];
-	  
-    //printf("tx = %d ty = %d ", tx,ty); 
+
+    //printf("tx = %d ty = %d ", tx,ty);
     //printf("pixel color =>  R: %d,  G: %d,  B: %d\n", red, green, blue);
 
     SDL_PixelFormat *pf = NULL;
--- a/TaskManager/Test/test_render/polygon.h	Thu Jul 09 17:59:44 2009 +0900
+++ b/TaskManager/Test/test_render/polygon.h	Fri Jul 10 16:06:15 2009 +0900
@@ -36,7 +36,7 @@
     float *anim;
     int texture_id; //texture id number
     struct texture_list texture_info;
-    
+
     SDL_Surface* texture_image;
 
     Polygon(void);