35
|
1 #include <iostream>
|
|
2 #include "polygon_pack.h"
|
|
3 #include "scene_graph_pack.h"
|
|
4 #include "sys.h"
|
|
5 using namespace std;
|
|
6
|
49
|
7 #include "error.h"
|
35
|
8
|
49
|
9 int
|
|
10 create_pp(SceneGraphPack *sgp, PolygonPack *pp)
|
35
|
11 {
|
49
|
12 float xyz1[4],xyz2[4],xyz3[4];
|
35
|
13
|
49
|
14 __debug("[%s] sgp = 0x%x, pp = 0x%x\n", __FUNCTION__,
|
|
15 (unsigned int)sgp,(unsigned int)pp);
|
35
|
16
|
49
|
17 for (int i = 0; i < sgp->info.size; i++) {
|
|
18 SceneGraphNodePtr node = &sgp->node[i];
|
|
19
|
|
20 int n,nt,pt;
|
|
21 for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) {
|
|
22 xyz1[0] = node->vertex[n];
|
|
23 xyz1[1] = node->vertex[n+1];
|
|
24 xyz1[2] = node->vertex[n+2]*-1;
|
|
25 xyz1[3] = 1;
|
|
26 xyz2[0] = node->vertex[n+3];
|
|
27 xyz2[1] = node->vertex[n+3+1];
|
|
28 xyz2[2] = node->vertex[n+3+2]*-1;
|
|
29 xyz2[3] = 1;
|
|
30 xyz3[0] = node->vertex[n+6];
|
|
31 xyz3[1] = node->vertex[n+6+1];
|
|
32 xyz3[2] = node->vertex[n+6+2]*-1;
|
|
33 xyz3[3] = 1;
|
35
|
34
|
49
|
35 rotate(xyz1, node->translation);
|
|
36 rotate(xyz2, node->translation);
|
|
37 rotate(xyz3, node->translation);
|
35
|
38
|
49
|
39 pp->tri[pt].x1 = xyz1[0];
|
|
40 pp->tri[pt].y1 = xyz1[1];
|
|
41 pp->tri[pt].z1 = xyz1[2];
|
|
42 pp->tri[pt].tex_x1 = node->texture[nt];
|
|
43 pp->tri[pt].tex_y1 = node->texture[nt+1];
|
35
|
44
|
49
|
45 pp->tri[pt].x2 = xyz2[0];
|
|
46 pp->tri[pt].y2 = xyz2[1];
|
|
47 pp->tri[pt].z2 = xyz2[2];
|
|
48 pp->tri[pt].tex_x2 = node->texture[nt+2];
|
|
49 pp->tri[pt].tex_y2 = node->texture[nt+2+1];
|
35
|
50
|
49
|
51 pp->tri[pt].x3 = xyz3[0];
|
|
52 pp->tri[pt].y3 = xyz3[1];
|
|
53 pp->tri[pt].z3 = xyz3[2];
|
|
54 pp->tri[pt].tex_x3 = node->texture[nt+4];
|
|
55 pp->tri[pt].tex_y3 = node->texture[nt+4+1];
|
35
|
56
|
49
|
57 }
|
|
58 pp->info.size = pt;
|
35
|
59 }
|
|
60
|
49
|
61 return sizeof(PolygonPack);
|
35
|
62 }
|