Mercurial > hg > Members > kono > Cerium
comparison old/simple_render/spe/CreatePolygonPack.cpp @ 507:735f76483bb2
Reorganization..
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 12 Oct 2009 09:39:35 +0900 |
parents | TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp@f64d75473f95 |
children |
comparison
equal
deleted
inserted
replaced
506:1d4a8a86f26b | 507:735f76483bb2 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <malloc.h> | |
4 #include "CreatePolygonPack.h" | |
5 #include "polygon_pack.h" | |
6 #include "scene_graph_pack.h" | |
7 | |
8 | |
9 void | |
10 CreatePolygonPack::read(void) | |
11 { | |
12 SchedTask::read(); | |
13 } | |
14 | |
15 int | |
16 CreatePolygonPack::run(void *rbuf, void *wbuf) | |
17 { | |
18 SceneGraphPack *sgp = (SceneGraphPack*)rbuf; | |
19 PolygonPack *pp = (PolygonPack*)wbuf; | |
20 | |
21 float xyz1[4],xyz2[4],xyz3[4]; | |
22 | |
23 for (int i = 0; i < sgp->info.size; i++) { | |
24 SceneGraphNodePtr node = &sgp->node[i]; | |
25 | |
26 int n,nt,pt; | |
27 for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) { | |
28 xyz1[0] = node->vertex[n]; | |
29 xyz1[1] = node->vertex[n+1]; | |
30 xyz1[2] = node->vertex[n+2]*-1; | |
31 xyz1[3] = 1; | |
32 xyz2[0] = node->vertex[n+3]; | |
33 xyz2[1] = node->vertex[n+3+1]; | |
34 xyz2[2] = node->vertex[n+3+2]*-1; | |
35 xyz2[3] = 1; | |
36 xyz3[0] = node->vertex[n+6]; | |
37 xyz3[1] = node->vertex[n+6+1]; | |
38 xyz3[2] = node->vertex[n+6+2]*-1; | |
39 xyz3[3] = 1; | |
40 | |
41 rotate(xyz1, node->translation); | |
42 rotate(xyz2, node->translation); | |
43 rotate(xyz3, node->translation); | |
44 | |
45 pp->tri[pt].ver1.x = xyz1[0]; | |
46 pp->tri[pt].ver1.y = xyz1[1]; | |
47 pp->tri[pt].ver1.z = xyz1[2]; | |
48 pp->tri[pt].ver1.tex_x = node->texture[nt]; | |
49 pp->tri[pt].ver1.tex_y = node->texture[nt+1]; | |
50 | |
51 pp->tri[pt].ver2.x = xyz2[0]; | |
52 pp->tri[pt].ver2.y = xyz2[1]; | |
53 pp->tri[pt].ver2.z = xyz2[2]; | |
54 pp->tri[pt].ver2.tex_x = node->texture[nt+2]; | |
55 pp->tri[pt].ver2.tex_y = node->texture[nt+2+1]; | |
56 | |
57 pp->tri[pt].ver3.x = xyz3[0]; | |
58 pp->tri[pt].ver3.y = xyz3[1]; | |
59 pp->tri[pt].ver3.z = xyz3[2]; | |
60 pp->tri[pt].ver3.tex_x = node->texture[nt+4]; | |
61 pp->tri[pt].ver3.tex_y = node->texture[nt+4+1]; | |
62 | |
63 pp->tri[pt].tex_width = node->tex_width; | |
64 pp->tri[pt].tex_height = node->tex_height; | |
65 } | |
66 pp->info.size = pt; | |
67 pp->ssl = sgp->ssl; | |
68 } | |
69 | |
70 return sizeof(PolygonPack); | |
71 } | |
72 | |
73 void | |
74 CreatePolygonPack::write(void) | |
75 { | |
76 SchedTask::write(); | |
77 | |
78 free(readbuf); | |
79 free(writebuf); | |
80 } | |
81 | |
82 void | |
83 CreatePolygonPack::rotate(float *xyz, float *matrix) | |
84 { | |
85 float abc[4]; | |
86 | |
87 abc[0] = xyz[0]; | |
88 abc[1] = xyz[1]; | |
89 abc[2] = xyz[2]; | |
90 abc[3] = xyz[3]; | |
91 | |
92 // SIMD 使えるよね | |
93 for (int i=0; i<4; i++) | |
94 { | |
95 xyz[i] = abc[0]*matrix[i] + abc[1]*matrix[i+4] | |
96 + abc[2]*matrix[i+8] + abc[3]*matrix[i+12]; | |
97 } | |
98 } | |
99 | |
100 SchedTask* | |
101 createTask_createPolygonPack(TaskListPtr _taskList, TaskPtr _task, | |
102 void *rbuff, void *wbuff, DmaManager *dma) | |
103 { | |
104 rbuff = memalign(16, sizeof(SceneGraphPack)); | |
105 wbuff = memalign(16, sizeof(PolygonPack)); | |
106 | |
107 return new CreatePolygonPack(_taskList, _task, rbuff, wbuff, dma); | |
108 } |