annotate Renderer/Engine/polygon.cc @ 1319:31455d34e502 draft

collada file reader minor changes.
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Sun, 18 Dec 2011 09:39:14 +0900
parents bb9c885c1cb5
children 3f95f61faef6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <iostream>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <SDL.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <SDL_opengl.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <SDL_image.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "polygon.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "xml.h"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
7 #include "matrix_calc.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "triangle.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "vertex.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "Span.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "SpanC.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "scene_graph_pack.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "error.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "viewer_types.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 using namespace std;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
18
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
19
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
20 Polygon::Polygon()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 {
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
22 position_init();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 Polygon::position_init(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 {
1129
a8bffdb5d2e3 bus error
yutaka@localhost.localdomain
parents: 1128
diff changeset
28
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 xyz[0] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 xyz[1] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 xyz[2] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 xyz[3] = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 c_xyz[0] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 c_xyz[1] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 c_xyz[2] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 c_xyz[3] = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 angle[0] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 angle[1] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 angle[2] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 angle[3] = 1;
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
41 scale[0] = 1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
42 scale[1] = 1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
43 scale[2] = 1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
861
fda7b71c3cc6 Still on the way
yutaka@localhost.localdomain
parents: 860
diff changeset
45
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 void Polygon::pickup_coordinate(char *cont)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 {
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 539
diff changeset
50
1128
293b36802714 code cleanup
Yutaka_Kinjyo
parents: 1127
diff changeset
51 // size は頂点の数, count は面の数
906
becd6fad3ae0 coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents: 861
diff changeset
52 char *tmp_cont = cont;
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
53 int count = size / 3;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
54
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
55 for (int i = 0; i < pp_num; i++) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
56
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
57 TrianglePackPtr tri = pp[i].tri;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
58 // TrianglePack の size のチェック
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
59
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
60 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
61
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
62 //それを構造体に登録
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
63 pp[i].info.size = tri_size;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
64
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
65
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
66 for (int j = 0; j < tri_size; j++) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
67
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
68 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
69 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.y));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
70 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.z));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
71
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
72 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
73 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.y));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
74 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.z));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
75
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
76 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
77 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.y));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
78 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.z));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
79
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
80 if (tmp_cont == NULL)
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
81 {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
82 cout << "Analyzing obj data failed coordinate\n";
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
83 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
84
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
85 count -= 1;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
86
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
87 }
1128
293b36802714 code cleanup
Yutaka_Kinjyo
parents: 1127
diff changeset
88
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
89 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
90
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
91 if (count != 0) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
92 printf("miss pickup_coordinate size. diff size = %d\n", count);
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
93 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
94
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 void Polygon::pickup_normal(char *cont)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 {
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 539
diff changeset
99
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 539
diff changeset
100
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
101 // size は頂点の数, count は面の数
1128
293b36802714 code cleanup
Yutaka_Kinjyo
parents: 1127
diff changeset
102 char *tmp_cont = cont;
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
103 int count = size / 3;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
104
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
105 for (int i = 0; i < pp_num; i++) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
106
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
107 TrianglePackPtr tri = pp[i].tri;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
108 // TrianglePack の size のチェック
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
109 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
110 pp[i].info.size = tri_size;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
111
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
112 for (int j = 0; j < tri_size; j++) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
113
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
114 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
115 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.y));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
116 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.z));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
117
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
118 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
119 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.y));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
120 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.z));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
121
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
122 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
123 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.y));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
124 tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.z));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
125
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
127 if (tmp_cont == NULL)
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
128 {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
129 cout << "Analyzing obj data failed coordinate\n";
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
130 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
131
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
132 count -= 1;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
133
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
134 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
135
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
136
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
137 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
138
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
139 if (count != 0) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
140 printf("miss pickup_normal size. diff size = %d\n", count);
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
141 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
142
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 void Polygon::pickup_model(char *cont)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 cont = pickup_float(cont,c_xyz);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 cont = pickup_float(cont,c_xyz+1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 cont = pickup_float(cont,c_xyz+2);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 if (cont == NULL)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 cout << "Analyzing obj data failed model\n";
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 void Polygon::pickup_texture(char *cont)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 {
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 539
diff changeset
159
906
becd6fad3ae0 coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents: 861
diff changeset
160 char *tmp_cont = cont;
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
161 int count = size / 3;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
162
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
163 for (int i = 0; i < pp_num; i++) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
164
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
165 TrianglePackPtr tri = pp[i].tri;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
166 // TrianglePack の size のチェック
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
167 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
168 pp[i].info.size = tri_size;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
169
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
170 for (int j = 0; j < tri_size; j++) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
171
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
172 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.tex_x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
173 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.tex_y));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
174
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
175 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
176 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_y));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
177
1127
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
178 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_x));
c4287bf771a0 CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents: 1126
diff changeset
179 tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_y));
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
180
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
181
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
182 if (tmp_cont == NULL)
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
183 {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
184 cout << "Analyzing obj data failed coordinate\n";
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
185 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
186
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
187 count -= 1;
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
188
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
189 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
190
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
191
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
192 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
193
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
194 if (count != 0) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
195 printf("miss pickup_texture size. diff size = %d\n", count);
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
196 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
197
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
198
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
199
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 char *get_pixel(int tx, int ty, SDL_Surface *texture_image)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 return (char*)texture_image->pixels+(texture_image->format->BytesPerPixel*((texture_image->w)*ty+tx));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 unsigned my_ntohl(unsigned u) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 // rr gg bb 00
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 // rr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 // bb gg rr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 //unsigned u1 = ((u&0xff)<<24) +
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 // ((u&0xff00)<<8) +
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 // ((u&0xff0000)>>8) +
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 // ((u&0xff000000)>>24);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 unsigned u1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 unsigned b = (u&0xff000000)>>24;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 unsigned g = (u&0xff0000)>>16;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 unsigned r = (u&0xff00)>>8;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 u1 = r + (g<<8) + (b<<16);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 //printf("pixel %x->%x\n",u,u1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 return u1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 Uint32 Polygon::get_rgb(int tx, int ty)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 SDL_PixelFormat *fmt;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 //Uint32 temp, pixel;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 Uint8 red, green, blue;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
230 fmt = texture_info->texture_image->format;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 if (tx<0) tx = 0;
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
233 if (texture_info->texture_image->w-1< tx) tx = texture_info->texture_image->w-1 ;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 if (ty<0) ty = 0;
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
235 if (texture_info->texture_image->h-1< ty) ty = texture_info->texture_image->h-1 ;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 //SDL_LockSurface(texture_image);
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
239 char *p = get_pixel(tx,ty,texture_info->texture_image);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 blue = (Uint8) p[0];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 green = (Uint8) p[1];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 red = (Uint8) p[2];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 //printf("tx = %d ty = %d ", tx,ty);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 //printf("pixel color => R: %d, G: %d, B: %d\n", red, green, blue);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 SDL_PixelFormat *pf = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 //pf = viewer->screen->format;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 //cout << SDL_MapRGB(pf, red, green, blue) << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 return SDL_MapRGB(pf, red, green, blue);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 }
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
253
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
254 void Polygon::font_coordinate(int baseline, int row,int width)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
255 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
256
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
257 //int count = size / 3;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
258
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
259 for (int i = 0; i < pp_num; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
260
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
261 TrianglePackPtr tri = pp[i].tri;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
262 // TrianglePack の size のチェック
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
263 int tri_size = 2;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
264 pp[i].info.size = tri_size;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
265
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
266 for (int j = 0; j < tri_size; j++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
267
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
268 tri[j].ver1.x = 0.0 ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
269 tri[j].ver1.y = 0.0 + baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
270 //tri[j].ver1.y = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
271 tri[j].ver1.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
272
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
273 if(j < 1)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
274 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
275 tri[j].ver2.x = 0.0 ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
276 tri[j].ver2.y = row +baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
277 //tri[j].ver2.y = row;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
278 tri[j].ver2.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
279 }else{
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
280 tri[j].ver2.x = width ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
281 tri[j].ver2.y = 0.0 +baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
282 //tri[j].ver2.y = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
283 tri[j].ver2.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
284 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
285 tri[j].ver3.x = width ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
286 tri[j].ver3.y =row +baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
287 //tri[j].ver3.y =row;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
288 tri[j].ver3.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
289
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
290 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
291
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
292 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
293 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
294
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
295 void Polygon::font_normal()
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
296 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
297
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
298 //テスト用
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
299 float polygon_point[2][9] = { {0,0,1, 0,0,1, 0,0,1},
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
300 {0,0,1, 0,0,1, 0,0,1} };
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
301
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
302 //int count = size / 3;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
303
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
304 for (int i = 0; i < pp_num; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
305
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
306 TrianglePackPtr tri = pp[i].tri;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
307 // TrianglePack の size のチェック
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
308 int tri_size = 2;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
309 pp[i].info.size = tri_size;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
310
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
311 for (int j = 0; j < tri_size; j++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
312
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
313 tri[j].normal1.x = polygon_point[j][0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
314 tri[j].normal1.y = polygon_point[j][1];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
315 tri[j].normal1.z = polygon_point[j][2];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
316
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
317 tri[j].normal2.x = polygon_point[j][3];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
318 tri[j].normal2.y = polygon_point[j][4];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
319 tri[j].normal2.z = polygon_point[j][5];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
320
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
321 tri[j].normal3.x = polygon_point[j][6];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
322 tri[j].normal3.y = polygon_point[j][7];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
323 tri[j].normal3.z = polygon_point[j][8];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
324
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
325 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
326
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
327 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
328
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
329 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
330
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
331 void Polygon::font_model()
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
332 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
333 //テスト用
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
334 float polygon_point[3] = {0,0,0};
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
335
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
336 c_xyz[0] = polygon_point[0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
337 c_xyz[1] = polygon_point[1];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
338 c_xyz[2] = polygon_point[2];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
339
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
340 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
341
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
342
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
343 void Polygon::font_texture(float row,float width)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
344 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
345 float texture_point[2][7] = { {0,0, 0,1, 1,1},
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
346 {0,0, 1,0, 1,1} };
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
347
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
348 for (int i = 0; i < pp_num; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
349
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
350 TrianglePackPtr tri = pp[i].tri;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
351 // TrianglePack の size のチェック
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
352 int tri_size = 2;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
353 pp[i].info.size = tri_size;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
354
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
355 for (int j = 0; j < tri_size; j++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
356
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
357 tri[j].ver1.tex_x = texture_point[j][0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
358 tri[j].ver1.tex_y = texture_point[j][1];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
359
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
360 tri[j].ver2.tex_x = texture_point[j][2];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
361 tri[j].ver2.tex_y = texture_point[j][3];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
362
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
363 tri[j].ver3.tex_x = texture_point[j][4];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
364 tri[j].ver3.tex_y = texture_point[j][5];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
365
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
366
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
367 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
368
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
369
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
370 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
371
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
372 /*if (count != 0) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
373 printf("miss pickup_texture size. diff size = %d\n", count);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
374 }*/
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
375
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
376 }