53
|
1 #include <iostream>
|
|
2 #include "polygon_pack.h"
|
|
3 #include "scene_graph_pack.h"
|
|
4 #include "sys.h"
|
|
5 using namespace std;
|
|
6
|
68
|
7 #include "error.h"
|
53
|
8
|
68
|
9 int
|
|
10 create_pp(SceneGraphPack *sgp, PolygonPack *pp)
|
53
|
11 {
|
68
|
12 float xyz1[4],xyz2[4],xyz3[4];
|
53
|
13
|
68
|
14 __debug("[%s] sgp = 0x%x, pp = 0x%x\n", __FUNCTION__,
|
|
15 (unsigned int)sgp,(unsigned int)pp);
|
53
|
16
|
68
|
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;
|
53
|
34
|
68
|
35 rotate(xyz1, node->translation);
|
|
36 rotate(xyz2, node->translation);
|
|
37 rotate(xyz3, node->translation);
|
53
|
38
|
68
|
39 pp->tri[pt].ver1.x = xyz1[0];
|
|
40 pp->tri[pt].ver1.y = xyz1[1];
|
|
41 pp->tri[pt].ver1.z = xyz1[2];
|
|
42 pp->tri[pt].ver1.tex_x = node->texture[nt];
|
|
43 pp->tri[pt].ver1.tex_y = node->texture[nt+1];
|
|
44
|
|
45 pp->tri[pt].ver2.x = xyz2[0];
|
|
46 pp->tri[pt].ver2.y = xyz2[1];
|
|
47 pp->tri[pt].ver2.z = xyz2[2];
|
|
48 pp->tri[pt].ver2.tex_x = node->texture[nt+2];
|
|
49 pp->tri[pt].ver2.tex_y = node->texture[nt+2+1];
|
53
|
50
|
68
|
51 pp->tri[pt].ver3.x = xyz3[0];
|
|
52 pp->tri[pt].ver3.y = xyz3[1];
|
|
53 pp->tri[pt].ver3.z = xyz3[2];
|
|
54 pp->tri[pt].ver3.tex_x = node->texture[nt+4];
|
|
55 pp->tri[pt].ver3.tex_y = node->texture[nt+4+1];
|
53
|
56
|
68
|
57 //pp->tri[pt].tex_addr = node->tex_addr;
|
|
58 pp->tri[pt].tex_width = node->tex_width;
|
|
59 pp->tri[pt].tex_height = node->tex_height;
|
53
|
60
|
68
|
61 }
|
|
62 pp->info.size = pt;
|
53
|
63 }
|
68
|
64 return sizeof(PolygonPack);
|
53
|
65 }
|