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
|
92
|
14 __debug("[%s]\n", __FUNCTION__);
|
35
|
15
|
49
|
16 for (int i = 0; i < sgp->info.size; i++) {
|
|
17 SceneGraphNodePtr node = &sgp->node[i];
|
|
18
|
92
|
19 int n, nt , pt;
|
|
20 for (n = 0, nt = 0, pt = 0; n < node->size*3; n+=9, nt+=6, pt++) {
|
49
|
21 xyz1[0] = node->vertex[n];
|
|
22 xyz1[1] = node->vertex[n+1];
|
|
23 xyz1[2] = node->vertex[n+2]*-1;
|
|
24 xyz1[3] = 1;
|
|
25 xyz2[0] = node->vertex[n+3];
|
|
26 xyz2[1] = node->vertex[n+3+1];
|
|
27 xyz2[2] = node->vertex[n+3+2]*-1;
|
|
28 xyz2[3] = 1;
|
|
29 xyz3[0] = node->vertex[n+6];
|
|
30 xyz3[1] = node->vertex[n+6+1];
|
|
31 xyz3[2] = node->vertex[n+6+2]*-1;
|
|
32 xyz3[3] = 1;
|
35
|
33
|
49
|
34 rotate(xyz1, node->translation);
|
|
35 rotate(xyz2, node->translation);
|
|
36 rotate(xyz3, node->translation);
|
35
|
37
|
85
|
38 pp->tri[pt].ver1.x = xyz1[0];
|
|
39 pp->tri[pt].ver1.y = xyz1[1];
|
|
40 pp->tri[pt].ver1.z = xyz1[2];
|
|
41 pp->tri[pt].ver1.tex_x = node->texture[nt];
|
|
42 pp->tri[pt].ver1.tex_y = node->texture[nt+1];
|
35
|
43
|
85
|
44 pp->tri[pt].ver2.x = xyz2[0];
|
|
45 pp->tri[pt].ver2.y = xyz2[1];
|
|
46 pp->tri[pt].ver2.z = xyz2[2];
|
|
47 pp->tri[pt].ver2.tex_x = node->texture[nt+2];
|
|
48 pp->tri[pt].ver2.tex_y = node->texture[nt+2+1];
|
35
|
49
|
85
|
50 pp->tri[pt].ver3.x = xyz3[0];
|
|
51 pp->tri[pt].ver3.y = xyz3[1];
|
|
52 pp->tri[pt].ver3.z = xyz3[2];
|
|
53 pp->tri[pt].ver3.tex_x = node->texture[nt+4];
|
|
54 pp->tri[pt].ver3.tex_y = node->texture[nt+4+1];
|
|
55
|
92
|
56 pp->tri[pt].tex_addr = node->tex_addr;
|
85
|
57 pp->tri[pt].tex_width = node->tex_width;
|
|
58 pp->tri[pt].tex_height = node->tex_height;
|
35
|
59
|
49
|
60 }
|
|
61 pp->info.size = pt;
|
85
|
62 pp->ssl = sgp->ssl;
|
35
|
63 }
|
49
|
64 return sizeof(PolygonPack);
|
35
|
65 }
|