Mercurial > hg > Game > Cerium
changeset 865:912586d3c6c3 draft
merge
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Jun 2010 12:09:50 +0900 |
parents | 0172ca0ee53d (current diff) 1cc2b1ae4f05 (diff) |
children | d328690a6f8f |
files | Renderer/Engine/spe/texture.h Renderer/Engine/task/texture.h |
diffstat | 29 files changed, 691 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/Camera.cc Tue Jun 22 12:09:50 2010 +0900 @@ -146,6 +146,14 @@ this->set_move_collision(camera_move, camera_collision, (void *)sgroot); +#if SPE_CREATE_POLYGON + + sg_matrix = (float*)malloc(sizeof(float)*32); + matrix = sg_matrix; + real_matrix = sg_matrix + 16; + +#endif + for(int i = 0; i < 16; i++) { real_matrix[i] = 0; if (i % 5 == 0) { @@ -153,7 +161,6 @@ } } - } Camera::~Camera(void)
--- a/Renderer/Engine/Makefile.def Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/Makefile.def Tue Jun 22 12:09:50 2010 +0900 @@ -5,7 +5,7 @@ ABIBIT = 32 ABI = -m$(ABIBIT) CC = g++ -OPT = -g #-O2 +OPT = -g #-DSPE_CREATE_POLYGON #-O2 CFLAGS = -g -Wall $(ABI) $(OPT) # -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I.
--- a/Renderer/Engine/SceneGraph.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/SceneGraph.cc Tue Jun 22 12:09:50 2010 +0900 @@ -16,7 +16,8 @@ SceneGraphPtr scene_graph_viewer = NULL; static TextureHash texture_hash; -struct texture_list list[TABLE_SIZE]; +texture_list list[TABLE_SIZE]; + extern int decode(char *cont, FILE *outfile); @@ -100,6 +101,14 @@ init(); finalize = &SceneGraph::finalize_copy; +#if SPE_CREATE_POLYGON + + sg_matrix = (float*)malloc(sizeof(float)*32); + matrix = sg_matrix; + real_matrix = sg_matrix + 16; + +#endif + this->name = "NULLPO"; } @@ -138,12 +147,38 @@ size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); name = (char *)xmlGetProp(surface,(xmlChar *)"name"); parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); + //texture_info = (texture_list_ptr)manager->allocate(sizeof(texture_list)); + //data = new float[size*3*3]; - //data = new float[size*3*3]; +#if SPE_CREATE_POLYGON + + /* CreatePolygon を spe 側でやるために。 + size は頂点の数。speに渡す場合には、16の倍数にして + 16Kbyte以上の場合、16Kbyte毎に分割できるようにしなければならない。 + CreatePolygonFromSceneGraphTaskをspeで動かすために、speに渡すのは + TrianglePackでよい。 + polygon_pack 1つには triangle が 128 になってる。polygon_pack の + triangle 数に合わせる方が楽だよね。なんか変な気もするけど、polygon + クラスにもTrianglePackを持たす。SceneGraph は自分の polygon 数が入る + 分だけ、TrianglePackを持つ。CreatePolygonTask にはSceneGraph 側の + TrianglePack を input に、polygon_pack の TriganlePack を output とする + */ + + int tri_pack_size = sizeof(TrianglePack)*(size/3); + tri_pack = (TrianglePackPtr)manager->allocate(tri_pack_size); + texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); + sg_matrix = (float*)manager->allocate(sizeof(float)*32); + matrix = sg_matrix; + real_matrix = sg_matrix + 16; + +#else + coord_xyz = (float*)manager->allocate(sizeof(float)*size*3); coord_tex = (float*)manager->allocate(sizeof(float)*size*3); normal = (float*)manager->allocate(sizeof(float)*size*3); +#endif + get_data(manager, surface->children); finalize = &SceneGraph::finalize_original; @@ -170,10 +205,23 @@ size = 0; //data = NULL; + +#if SPE_CREATE_POLYGON + + //tri_pack = NULL; + //sg_matrix = NULL; + //matrix = NULL; + //real_matrix = NULL; + //texture_info = NULL; + +#else + coord_xyz = NULL; normal = NULL; coord_tex = NULL; +#endif + texture_id = -1; move = no_move; collision = no_collision; @@ -199,9 +247,23 @@ SceneGraph::finalize_original() { //delete [] data; + +#if SPE_CREATE_POLYGON + + free(tri_pack); + free(sg_matrix); + //free(matrix); + //free(real_matrix); + free(texture_info); + +#else + free(coord_xyz); free(coord_tex); free(normal); + +#endif + } /** @@ -497,13 +559,29 @@ 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; + +#if SPE_CREATE_POLYGON + + + 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; + + +#else + + // こんなことすると 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; + +#endif + }
--- a/Renderer/Engine/SceneGraph.h Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/SceneGraph.h Tue Jun 22 12:09:50 2010 +0900 @@ -33,7 +33,7 @@ // Objectのシーケンス番号(Linda) // とりあえず動かしたいので追加 int seq, seq_rd, resend_flag; - + int property_size; void *propertyptr; //void *property;
--- a/Renderer/Engine/polygon.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/polygon.cc Tue Jun 22 12:09:50 2010 +0900 @@ -33,9 +33,15 @@ angle[2] = 0; angle[3] = 1; + +#if !SPE_CREATE_POLYGON + for (int i = 0; i < 16; i++) { matrix[i] = 0; } + +#endif + } void @@ -54,9 +60,15 @@ angle[2] = 0; angle[3] = 1; + +#if !SPE_CREATE_POLYGON + for (int i = 0; i < 16; i++) { matrix[i] = 0; } + +#endif + } #if 0 @@ -177,6 +189,36 @@ void Polygon::pickup_coordinate(char *cont) { + +#if SPE_CREATE_POLYGON + + TrianglePackPtr cur = tri_pack; + + for(int n=0; n<size; n+=3) + { + + cont = pickup_float(cont, &cur->ver1.x); + cont = pickup_float(cont, &cur->ver1.y); + cont = pickup_float(cont, &cur->ver1.z); + + cont = pickup_float(cont, &cur->ver2.x); + cont = pickup_float(cont, &cur->ver2.y); + cont = pickup_float(cont, &cur->ver2.z); + + cont = pickup_float(cont, &cur->ver3.x); + cont = pickup_float(cont, &cur->ver3.y); + cont = pickup_float(cont, &cur->ver3.z); + + cur = cur + 1; + + if (cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + } + +#else + for(int n=0; n<size*3; n+=3) { cont = pickup_float(cont, coord_xyz+n); @@ -188,10 +230,44 @@ cout << "Analyzing obj data failed coordinate\n"; } } + +#endif + } void Polygon::pickup_normal(char *cont) { + +#if SPE_CREATE_POLYGON + + TrianglePackPtr cur = tri_pack; + + for(int n=0; n<size; n+=3) + { + + cont = pickup_float(cont, &cur->normal1.x); + cont = pickup_float(cont, &cur->normal1.y); + cont = pickup_float(cont, &cur->normal1.z); + + cont = pickup_float(cont, &cur->normal2.x); + cont = pickup_float(cont, &cur->normal2.y); + cont = pickup_float(cont, &cur->normal2.z); + + cont = pickup_float(cont, &cur->normal3.x); + cont = pickup_float(cont, &cur->normal3.y); + cont = pickup_float(cont, &cur->normal3.z); + + cur = cur + 1; + + if (cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + } + +#else + + for (int n = 0; n<size*3; n += 3) { cont = pickup_float(cont, normal+n); @@ -203,6 +279,9 @@ cout << "Analyzing obj data failed normal\n"; } } + +#endif + } void Polygon::pickup_model(char *cont) @@ -219,6 +298,33 @@ void Polygon::pickup_texture(char *cont) { + +#if SPE_CREATE_POLYGON + + TrianglePackPtr cur = tri_pack; + + for(int n=0; n<size; n+=3) + { + + cont = pickup_float(cont, &cur->ver1.tex_x); + cont = pickup_float(cont, &cur->ver1.tex_y); + + cont = pickup_float(cont, &cur->ver2.tex_x); + cont = pickup_float(cont, &cur->ver2.tex_y); + + cont = pickup_float(cont, &cur->ver3.tex_x); + cont = pickup_float(cont, &cur->ver3.tex_y); + + cur = cur + 1; + + if (cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + } + +#else + for (int n = 0; n < size*3; n += 3) { cont = pickup_float(cont, coord_tex+n); @@ -230,6 +336,9 @@ cout << "Analyzing obj data failed texture\n"; } } + +#endif + } char *get_pixel(int tx, int ty, SDL_Surface *texture_image)
--- a/Renderer/Engine/polygon.h Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/polygon.h Tue Jun 22 12:09:50 2010 +0900 @@ -14,17 +14,33 @@ const char *parent_name; //float *data; //"vertex" and "normal" and "texture" + int coord_pack_size; + +#if SPE_CREATE_POLYGON + + TrianglePackPtr tri_pack; + float *sg_matrix; + float *matrix; + float *real_matrix; + texture_list *texture_info; + +#else + + float *coord_pack; //coord_xyz(4*3*size), coord_tex(4*3*size), normal(4*3*size), float *coord_xyz; // vertex coordinate array float *coord_tex; // texture coordinate array float *normal; // normal vector array + float matrix[16]; + float real_matrix[16]; + texture_list texture_info; + +#endif + float xyz[4]; // position float angle[4]; // angle float c_xyz[4]; // center of rotation - float matrix[16]; - float real_matrix[16]; float *anim; int texture_id; //texture id number - struct texture_list texture_info; SDL_Surface* texture_image;
--- a/Renderer/Engine/polygon_pack.h Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/polygon_pack.h Tue Jun 22 12:09:50 2010 +0900 @@ -27,25 +27,26 @@ } TriangleTexInfo, *TriangleTexInfoPtr; // 16 typedef struct TrianglePack { - TriTexInfo tex_info; - VertexPack ver1; - VertexPack ver2; - VertexPack ver3; - NormalPack normal1; - NormalPack normal2; - NormalPack normal3; -} TrianglePack, *TrianglePackPtr; + TriTexInfo tex_info; // 16 + VertexPack ver1; // 20 + VertexPack ver2; // 20 + VertexPack ver3; // 20 + NormalPack normal1; // 12 + NormalPack normal2; // 12 + NormalPack normal3; // 12 +} TrianglePack, *TrianglePackPtr; // 112 (16 * 7) typedef struct PolygonPack { + + TrianglePack tri[MAX_SIZE_TRIANGLE]; + struct POLYGON_info { int size; int light_pos[3]; int light_rgb[3]; }info; - TrianglePack tri[MAX_SIZE_TRIANGLE]; - PolygonPack* next; void init(void) { @@ -65,7 +66,7 @@ } this->init(); } -} PolygonPack, *PolygonPackPtr; // 4*7 + 76*128 + 4 = 9760 +} PolygonPack, *PolygonPackPtr; // 4*7 + 76*128 + 4 = 9760 なんやかんやで 14368 みたい。 typedef struct PolygonPackList { int size;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygon.cc Tue Jun 22 12:09:50 2010 +0900 @@ -0,0 +1,150 @@ +#include "CreatePolygon.h" + +SchedDefineTask(CreatePolygon); + +static void +ApplyMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + t[3] = v[3]; + + for (int i = 0; i < 4; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12]; + } +} + +static void +ApplyNormalMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + + for (int i = 0; i < 3; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8]; + } +} + + +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) +{ + + TrianglePack *sg_tri = (TrianglePack*)smanager->get_input(0); + texture_list *sg_texture_info = (texture_list*)smanager->get_input(1); + float *sg_matrix = (float*)smanager->get_input(2); + TrianglePack *pp_tri = (TrianglePack*)smanager->get_output(0); + int *tri_num = (int*)smanager->get_param(0); + + float *matrix = sg_matrix; + float *real_matrix = sg_matrix + 16; + + float xyz1[4], xyz2[4], xyz3[4]; + float normal1[4],normal2[4],normal3[4]; + + for (int i = 0; i < *tri_num; i++) { + + TrianglePack *pp_cur_tri = &pp_tri[i]; + TrianglePack *sg_cur_tri = &sg_tri[i]; + + xyz1[0] = sg_cur_tri->ver1.x; + xyz1[1] = sg_cur_tri->ver1.y; + xyz1[2] = sg_cur_tri->ver1.z*-1.0f; + xyz1[3] = 1.0f; + + xyz2[0] = sg_cur_tri->ver2.x; + xyz2[1] = sg_cur_tri->ver2.y; + xyz2[2] = sg_cur_tri->ver2.z*-1.0f; + xyz2[3] = 1.0f; + + xyz3[0] = sg_cur_tri->ver3.x; + xyz3[1] = sg_cur_tri->ver3.y; + xyz3[2] = sg_cur_tri->ver3.z*-1.0f; + xyz3[3] = 1.0f; + + // matrix = 回転行列*透視変換行列 + ApplyMatrix(xyz1, matrix); + ApplyMatrix(xyz2, matrix); + ApplyMatrix(xyz3, matrix); + + xyz1[0] /= xyz1[2]; + xyz1[1] /= xyz1[2]; + xyz2[0] /= xyz2[2]; + xyz2[1] /= xyz2[2]; + xyz3[0] /= xyz3[2]; + xyz3[1] /= xyz3[2]; + + pp_cur_tri->ver1.x = xyz1[0]; + pp_cur_tri->ver1.y = xyz1[1]; + pp_cur_tri->ver1.z = xyz1[2]; + pp_cur_tri->ver1.tex_x = sg_cur_tri->ver1.tex_x; + pp_cur_tri->ver1.tex_y = sg_cur_tri->ver1.tex_y; + + pp_cur_tri->ver2.x = xyz2[0]; + pp_cur_tri->ver2.y = xyz2[1]; + pp_cur_tri->ver2.z = xyz2[2]; + pp_cur_tri->ver2.tex_x = sg_cur_tri->ver2.tex_x; + pp_cur_tri->ver2.tex_y = sg_cur_tri->ver2.tex_y; + + pp_cur_tri->ver3.x = xyz3[0]; + pp_cur_tri->ver3.y = xyz3[1]; + pp_cur_tri->ver3.z = xyz3[2]; + pp_cur_tri->ver3.tex_x = sg_cur_tri->ver3.tex_x; + pp_cur_tri->ver3.tex_y = sg_cur_tri->ver3.tex_y; + + normal1[0] = sg_cur_tri->normal1.x; + normal1[1] = sg_cur_tri->normal1.y; + normal1[2] = sg_cur_tri->normal1.z*-1.0f; + normal1[3] = 0.0f; + + normal1[0] = sg_cur_tri->normal2.x; + normal1[1] = sg_cur_tri->normal2.y; + normal1[2] = sg_cur_tri->normal2.z*-1.0f; + normal1[3] = 0.0f; + + normal1[0] = sg_cur_tri->normal3.x; + normal1[1] = sg_cur_tri->normal3.y; + normal1[2] = sg_cur_tri->normal3.z*-1.0f; + normal1[3] = 0.0f; + + ApplyNormalMatrix(normal1,real_matrix); + ApplyNormalMatrix(normal2,real_matrix); + ApplyNormalMatrix(normal3,real_matrix); + + normal1[0] /= normal1[2]; + normal1[1] /= normal1[2]; + + normal2[0] /= normal2[2]; + normal2[1] /= normal2[2]; + + normal3[0] /= normal3[2]; + normal3[1] /= normal3[2]; + + pp_cur_tri->normal1.x = normal1[0]; + pp_cur_tri->normal1.y = normal1[1]; + pp_cur_tri->normal1.z = normal1[2]; + + pp_cur_tri->normal2.x = normal2[0]; + pp_cur_tri->normal2.y = normal2[1]; + pp_cur_tri->normal2.z = normal2[2]; + + pp_cur_tri->normal3.x = normal3[0]; + pp_cur_tri->normal3.y = normal3[1]; + pp_cur_tri->normal3.z = normal3[2]; + + pp_cur_tri->tex_info.addr = sg_texture_info->pixels; + pp_cur_tri->tex_info.width = sg_texture_info->t_w; + pp_cur_tri->tex_info.height = sg_texture_info->t_h; + pp_cur_tri->tex_info.scale_max = sg_texture_info->scale_max; + + } + + return 0; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygon.h Tue Jun 22 12:09:50 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_CREATE_SPAN +#define INCLUDED_CREATE_SPAN + +#include "SchedTask.h" +#include "polygon_pack.h" +#include "SpanPack.h" +#include "texture.h" + +#endif
--- a/Renderer/Engine/spe/DrawSpan.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/spe/DrawSpan.cc Tue Jun 22 12:09:50 2010 +0900 @@ -2,7 +2,7 @@ #include <string.h> #include "DrawSpan.h" #include "polygon_pack.h" -#include "texture.h" +#include "task_texture.h" #include "viewer_types.h" #include "Func.h" #include "sys.h"
--- a/Renderer/Engine/spe/Load_Texture.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/spe/Load_Texture.cc Tue Jun 22 12:09:50 2010 +0900 @@ -4,7 +4,7 @@ #include <stdlib.h> #include <string.h> #include "Load_Texture.h" -#include "texture.h" +#include "task_texture.h" #include "Func.h" SchedDefineTask(LoadTexture);
--- a/Renderer/Engine/spe/Makefile Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/spe/Makefile Tue Jun 22 12:09:50 2010 +0900 @@ -5,7 +5,7 @@ TOP = ../$(CERIUM) SRCS_TMP = $(wildcard *.cc) -SRCS_EXCLUDE = CreatePolygon.cc +#SRCS_EXCLUDE = CreatePolygon.cc SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o)
--- a/Renderer/Engine/spe/spe-main.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/spe/spe-main.cc Tue Jun 22 12:09:50 2010 +0900 @@ -14,6 +14,7 @@ SchedExternTask(ChainInit); SchedExternTask(CreateSpan); +SchedExternTask(CreatePolygon); //SchedExternTask(CreatePolygonFromSceneGraph); SchedExternTask(ShowTime); @@ -40,6 +41,7 @@ SchedRegister( DrawBack); SchedRegister( CreateSpan); + SchedRegister( CreatePolygon); //SchedRegister( CreatePolygonFromSceneGraph); SchedRegister( ShowTime);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/task_texture.h Tue Jun 22 12:09:50 2010 +0900 @@ -0,0 +1,2 @@ +#define MAX_LOAD_SIZE 16384 +#define TEXTURE_ID 13
--- a/Renderer/Engine/spe/texture.h Tue Jun 22 12:08:14 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -#define MAX_LOAD_SIZE 16384 -#define TEXTURE_ID 13
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/CreatePolygon.cc Tue Jun 22 12:09:50 2010 +0900 @@ -0,0 +1,150 @@ +#include "CreatePolygon.h" + +SchedDefineTask(CreatePolygon); + +static void +ApplyMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + t[3] = v[3]; + + for (int i = 0; i < 4; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12]; + } +} + +static void +ApplyNormalMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + + for (int i = 0; i < 3; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8]; + } +} + + +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) +{ + + TrianglePack *sg_tri = (TrianglePack*)smanager->get_input(0); + texture_list *sg_texture_info = (texture_list*)smanager->get_input(1); + float *sg_matrix = (float*)smanager->get_input(2); + TrianglePack *pp_tri = (TrianglePack*)smanager->get_output(0); + int *tri_num = (int*)smanager->get_param(0); + + float *matrix = sg_matrix; + float *real_matrix = sg_matrix + 16; + + float xyz1[4], xyz2[4], xyz3[4]; + float normal1[4],normal2[4],normal3[4]; + + for (int i = 0; i < *tri_num; i++) { + + TrianglePack *pp_cur_tri = &pp_tri[i]; + TrianglePack *sg_cur_tri = &sg_tri[i]; + + xyz1[0] = sg_cur_tri->ver1.x; + xyz1[1] = sg_cur_tri->ver1.y; + xyz1[2] = sg_cur_tri->ver1.z*-1.0f; + xyz1[3] = 1.0f; + + xyz2[0] = sg_cur_tri->ver2.x; + xyz2[1] = sg_cur_tri->ver2.y; + xyz2[2] = sg_cur_tri->ver2.z*-1.0f; + xyz2[3] = 1.0f; + + xyz3[0] = sg_cur_tri->ver3.x; + xyz3[1] = sg_cur_tri->ver3.y; + xyz3[2] = sg_cur_tri->ver3.z*-1.0f; + xyz3[3] = 1.0f; + + // matrix = 回転行列*透視変換行列 + ApplyMatrix(xyz1, matrix); + ApplyMatrix(xyz2, matrix); + ApplyMatrix(xyz3, matrix); + + xyz1[0] /= xyz1[2]; + xyz1[1] /= xyz1[2]; + xyz2[0] /= xyz2[2]; + xyz2[1] /= xyz2[2]; + xyz3[0] /= xyz3[2]; + xyz3[1] /= xyz3[2]; + + pp_cur_tri->ver1.x = xyz1[0]; + pp_cur_tri->ver1.y = xyz1[1]; + pp_cur_tri->ver1.z = xyz1[2]; + pp_cur_tri->ver1.tex_x = sg_cur_tri->ver1.tex_x; + pp_cur_tri->ver1.tex_y = sg_cur_tri->ver1.tex_y; + + pp_cur_tri->ver2.x = xyz2[0]; + pp_cur_tri->ver2.y = xyz2[1]; + pp_cur_tri->ver2.z = xyz2[2]; + pp_cur_tri->ver2.tex_x = sg_cur_tri->ver2.tex_x; + pp_cur_tri->ver2.tex_y = sg_cur_tri->ver2.tex_y; + + pp_cur_tri->ver3.x = xyz3[0]; + pp_cur_tri->ver3.y = xyz3[1]; + pp_cur_tri->ver3.z = xyz3[2]; + pp_cur_tri->ver3.tex_x = sg_cur_tri->ver3.tex_x; + pp_cur_tri->ver3.tex_y = sg_cur_tri->ver3.tex_y; + + normal1[0] = sg_cur_tri->normal1.x; + normal1[1] = sg_cur_tri->normal1.y; + normal1[2] = sg_cur_tri->normal1.z*-1.0f; + normal1[3] = 0.0f; + + normal1[0] = sg_cur_tri->normal2.x; + normal1[1] = sg_cur_tri->normal2.y; + normal1[2] = sg_cur_tri->normal2.z*-1.0f; + normal1[3] = 0.0f; + + normal1[0] = sg_cur_tri->normal3.x; + normal1[1] = sg_cur_tri->normal3.y; + normal1[2] = sg_cur_tri->normal3.z*-1.0f; + normal1[3] = 0.0f; + + ApplyNormalMatrix(normal1,real_matrix); + ApplyNormalMatrix(normal2,real_matrix); + ApplyNormalMatrix(normal3,real_matrix); + + normal1[0] /= normal1[2]; + normal1[1] /= normal1[2]; + + normal2[0] /= normal2[2]; + normal2[1] /= normal2[2]; + + normal3[0] /= normal3[2]; + normal3[1] /= normal3[2]; + + pp_cur_tri->normal1.x = normal1[0]; + pp_cur_tri->normal1.y = normal1[1]; + pp_cur_tri->normal1.z = normal1[2]; + + pp_cur_tri->normal2.x = normal2[0]; + pp_cur_tri->normal2.y = normal2[1]; + pp_cur_tri->normal2.z = normal2[2]; + + pp_cur_tri->normal3.x = normal3[0]; + pp_cur_tri->normal3.y = normal3[1]; + pp_cur_tri->normal3.z = normal3[2]; + + pp_cur_tri->tex_info.addr = sg_texture_info->pixels; + pp_cur_tri->tex_info.width = sg_texture_info->t_w; + pp_cur_tri->tex_info.height = sg_texture_info->t_h; + pp_cur_tri->tex_info.scale_max = sg_texture_info->scale_max; + + } + + return 0; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/CreatePolygon.h Tue Jun 22 12:09:50 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_CREATE_SPAN +#define INCLUDED_CREATE_SPAN + +#include "SchedTask.h" +#include "polygon_pack.h" +#include "SpanPack.h" +#include "texture.h" + +#endif
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Tue Jun 22 12:09:50 2010 +0900 @@ -73,6 +73,9 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf) { + +#if !SPE_CREATE_POLYGON + float xyz1[4], xyz2[4], xyz3[4]; float normal1[4],normal2[4],normal3[4]; @@ -245,4 +248,7 @@ free(send_pp); return 0; + +#endif + }
--- a/Renderer/Engine/task/DrawSpan.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Tue Jun 22 12:09:50 2010 +0900 @@ -2,7 +2,7 @@ #include <string.h> #include "DrawSpan.h" #include "polygon_pack.h" -#include "texture.h" +#include "task_texture.h" #include "viewer_types.h" #include "Func.h" #include "sys.h"
--- a/Renderer/Engine/task/Load_Texture.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/task/Load_Texture.cc Tue Jun 22 12:09:50 2010 +0900 @@ -1,7 +1,7 @@ #include <stdlib.h> #include <string.h> #include "Load_Texture.h" -#include "texture.h" +#include "task_texture.h" #include "Func.h" #include "Tapestry.h"
--- a/Renderer/Engine/task/create_sgp.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/task/create_sgp.cc Tue Jun 22 12:09:50 2010 +0900 @@ -17,6 +17,9 @@ //create_sgp(Polygon *sg, SceneGraphPack *sgp) run(SchedTask *smanager, void *rbuf, void *wbuf) { + +#if !SPE_CREATE_POLYGON + //SceneGraph *sg = (SceneGraph*)smanager->get_input(rbuf, 0); SceneGraph *sg = (SceneGraph*)smanager->get_param(0); SceneGraphPack *sgp = (SceneGraphPack*)smanager->get_param(0); @@ -125,5 +128,7 @@ } sgp->info.size = curNumber; +#endif + return 0; }
--- a/Renderer/Engine/task/task_init.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/task/task_init.cc Tue Jun 22 12:09:50 2010 +0900 @@ -6,6 +6,7 @@ SchedExternTask(Create_SGP); SchedExternTask(Update_SGP); +SchedExternTask(CreatePolygon); SchedExternTask(CreatePolygonFromSceneGraph); SchedExternTask(CreateSpan); @@ -46,6 +47,7 @@ SchedRegister( Create_SGP); SchedRegister( Update_SGP); SchedRegister(CreatePolygonFromSceneGraph); + SchedRegister(CreatePolygon); SchedRegister( CreateSpan); SchedRegister( DrawSpan);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/task_texture.h Tue Jun 22 12:09:50 2010 +0900 @@ -0,0 +1,2 @@ +#define MAX_LOAD_SIZE 16384 +#define TEXTURE_ID 13
--- a/Renderer/Engine/task/texture.h Tue Jun 22 12:08:14 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -#define MAX_LOAD_SIZE 16384 -#define TEXTURE_ID 13
--- a/Renderer/Engine/texture.h Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/texture.h Tue Jun 22 12:09:50 2010 +0900 @@ -7,11 +7,14 @@ GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) #endif -struct texture_list { - int t_w, t_h; - Uint32 *pixels_orig; - Uint32 *pixels; +typedef struct texture_list { + int t_w; + int t_h; + uint32 *pixels_orig; + uint32 *pixels; int scale_max; -}; + int pad[3]; // 12 + +} texture_list, *texture_list_ptr ; // 20 + pad(12) = 32 #endif
--- a/Renderer/Engine/viewer.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/viewer.cc Tue Jun 22 12:09:50 2010 +0900 @@ -436,9 +436,103 @@ frames++; } +#if SPE_CREATE_POLYGON + +void +Viewer::create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait, + int &pp_index, int &sg_index, int tri_num) +{ + + HTaskPtr create_pp = manager->create_task(CreatePolygon); + create_pp->set_inData(0, &sg->tri_pack[sg_index], sizeof(TrianglePack)*tri_num); + create_pp->set_inData(1, sg->texture_info, sizeof(texture_list)); + create_pp->set_inData(2, sg->sg_matrix, sizeof(float)*32); //わーい、マジックナンバー + create_pp->set_outData(0, &pp_cur->tri[pp_index], sizeof(TrianglePack)*tri_num); + create_pp->set_param(0, (memaddr)tri_num); + //create_pp->set_cpu(SPE_ANY); + create_pp_wait->wait_for(create_pp); + create_pp->spawn(); + + pp_index += tri_num; + sg_index += tri_num; +} + +#endif + void Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot) { + +#if SPE_CREATE_POLYGON + + SceneGraphPtr sg = sgroot->getDrawSceneGraph(); + PolygonPackPtr pp_cur = ppack; + HTaskPtr create_pp_wait = manager->create_task(Dummy); + int pp_index = 0; + + while (sg) { + + if (sg->flag_drawable) { + + int sum_size = sg->size; + int tri_cur_num = MAX_SIZE_TRIANGLE; + int sg_index = 0; + + while (sum_size) { + + tri_cur_num -= sg->size/3; + + if (tri_cur_num < 0) { + + tri_cur_num = MAX_SIZE_TRIANGLE; + create_pp_task(sg, pp_cur, create_pp_wait, + pp_index, sg_index, tri_cur_num); + + PolygonPackPtr next = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack)); + + pp_cur->next = next; + pp_cur = next; + pp_index = 0; + + } else { + + create_pp_task(sg, pp_cur, create_pp_wait, + pp_index, sg_index, tri_cur_num); + + } + + sum_size -= tri_cur_num*3; + + } + + + } + + + + if (sg->children != NULL) { + sg = sg->children; + } else if (sg->brother != NULL) { + sg = sg->brother; + } else { + while (sg) { + if (sg->brother != NULL) { + sg = sg->brother; + break; + } else { + if (sg->parent == NULL) { + sg = NULL; + break; + } else { + sg = sg->parent; + } + } + } + } + } + +#else + HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); // SceneGraph(木構造) -> PolygonPack @@ -487,8 +581,10 @@ task_create_sp->spawn(); } + task_create_pp->spawn(); - task_create_pp->spawn(); +#endif + } HTaskPtr @@ -568,7 +664,7 @@ int rangey = (starty + split_screen_h - 1 > this->height) ? this->height - starty + 1 : split_screen_h; -#if 1 +#if 0 if(spack->info.size > 0) {
--- a/Renderer/Engine/viewer.h Tue Jun 22 12:08:14 2010 +0900 +++ b/Renderer/Engine/viewer.h Tue Jun 22 12:09:50 2010 +0900 @@ -69,6 +69,8 @@ void run_collision(); void rendering(HTaskPtr task_next); void common_draw(HTaskPtr task_next); + void create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait, + int &pp_index, int &sg_index, int tri_num); void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot); void spe_rendering(HTaskPtr task_next);
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Tue Jun 22 12:08:14 2010 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Tue Jun 22 12:09:50 2010 +0900 @@ -172,6 +172,9 @@ TaskListPtr list = (TaskListPtr)data; check_task_list_finish(schedTaskManager, list, waitTaskQueue); #else + + printf("hoge\n"); + // 終了したタスク(PPEにあるのでアドレス) HTaskPtr task = (HTaskPtr)data; task->post_func(schedTaskManager, task->post_arg1, task->post_arg2);