annotate Renderer/Engine/polygon.cc @ 1379:13065ad17328 draft

collada moved but only my mac.
author e095732 <e095732@ie.u-ryukyu.ac.jp>
date Thu, 26 Jan 2012 21:56:32 +0900
parents 3f95f61faef6
children
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"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
6 #include "matrix_calc.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "triangle.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "vertex.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "Span.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "SpanC.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "scene_graph_pack.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "error.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "viewer_types.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 using namespace std;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
17
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 Polygon::Polygon()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 {
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
21 position_init();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 }
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 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 Polygon::position_init(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 {
1129
a8bffdb5d2e3 bus error
yutaka@localhost.localdomain
parents: 1128
diff changeset
27
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 xyz[0] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 xyz[1] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 xyz[2] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 xyz[3] = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 c_xyz[0] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 c_xyz[1] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 c_xyz[2] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 c_xyz[3] = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 angle[0] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 angle[1] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 angle[2] = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 angle[3] = 1;
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
40 scale[0] = 1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
41 scale[1] = 1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
42 scale[2] = 1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
861
fda7b71c3cc6 Still on the way
yutaka@localhost.localdomain
parents: 860
diff changeset
44
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }
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 char *get_pixel(int tx, int ty, SDL_Surface *texture_image)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 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
50 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 unsigned my_ntohl(unsigned u) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 // rr gg bb 00
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 // rr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 // bb gg rr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 //unsigned u1 = ((u&0xff)<<24) +
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 // ((u&0xff00)<<8) +
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 // ((u&0xff0000)>>8) +
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 // ((u&0xff000000)>>24);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 unsigned u1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 unsigned b = (u&0xff000000)>>24;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 unsigned g = (u&0xff0000)>>16;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 unsigned r = (u&0xff00)>>8;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 u1 = r + (g<<8) + (b<<16);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 //printf("pixel %x->%x\n",u,u1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 return u1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 Uint32 Polygon::get_rgb(int tx, int ty)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 SDL_PixelFormat *fmt;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 //Uint32 temp, pixel;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 Uint8 red, green, blue;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
75 fmt = texture_info->texture_image->format;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 if (tx<0) tx = 0;
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
78 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
79 if (ty<0) ty = 0;
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
80 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
81
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 //SDL_LockSurface(texture_image);
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
84 char *p = get_pixel(tx,ty,texture_info->texture_image);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 blue = (Uint8) p[0];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 green = (Uint8) p[1];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 red = (Uint8) p[2];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 //printf("tx = %d ty = %d ", tx,ty);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 //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
91
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 SDL_PixelFormat *pf = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 //pf = viewer->screen->format;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 //cout << SDL_MapRGB(pf, red, green, blue) << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 return SDL_MapRGB(pf, red, green, blue);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 }
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
98
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
99 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
100 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
101
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
102 //int count = size / 3;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
103
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
104 for (int i = 0; i < pp_num; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
105
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
106 TrianglePackPtr tri = pp[i].tri;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
107 // TrianglePack の size のチェック
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
108 int tri_size = 2;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
109 pp[i].info.size = tri_size;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
110
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
111 for (int j = 0; j < tri_size; j++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
112
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
113 tri[j].ver1.x = 0.0 ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
114 tri[j].ver1.y = 0.0 + baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
115 //tri[j].ver1.y = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
116 tri[j].ver1.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
117
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
118 if(j < 1)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
119 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
120 tri[j].ver2.x = 0.0 ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
121 tri[j].ver2.y = row +baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
122 //tri[j].ver2.y = row;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
123 tri[j].ver2.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
124 }else{
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
125 tri[j].ver2.x = width ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
126 tri[j].ver2.y = 0.0 +baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
127 //tri[j].ver2.y = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
128 tri[j].ver2.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
129 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
130 tri[j].ver3.x = width ;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
131 tri[j].ver3.y =row +baseline;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
132 //tri[j].ver3.y =row;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
133 tri[j].ver3.z = 0.0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
134
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
135 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
136
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
137 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
138 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
139
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
140 void Polygon::font_normal()
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
141 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
142
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
143 //テスト用
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
144 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
145 {0,0,1, 0,0,1, 0,0,1} };
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
146
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
147 //int count = size / 3;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
148
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
149 for (int i = 0; i < pp_num; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
150
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
151 TrianglePackPtr tri = pp[i].tri;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
152 // TrianglePack の size のチェック
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
153 int tri_size = 2;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
154 pp[i].info.size = tri_size;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
155
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
156 for (int j = 0; j < tri_size; j++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
157
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
158 tri[j].normal1.x = polygon_point[j][0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
159 tri[j].normal1.y = polygon_point[j][1];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
160 tri[j].normal1.z = polygon_point[j][2];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
161
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
162 tri[j].normal2.x = polygon_point[j][3];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
163 tri[j].normal2.y = polygon_point[j][4];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
164 tri[j].normal2.z = polygon_point[j][5];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
165
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
166 tri[j].normal3.x = polygon_point[j][6];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
167 tri[j].normal3.y = polygon_point[j][7];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
168 tri[j].normal3.z = polygon_point[j][8];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
169
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
170 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
171
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
172 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
173
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
174 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
175
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
176 void Polygon::font_model()
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
177 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
178 //テスト用
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
179 float polygon_point[3] = {0,0,0};
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
180
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
181 c_xyz[0] = polygon_point[0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
182 c_xyz[1] = polygon_point[1];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
183 c_xyz[2] = polygon_point[2];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
184
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
185 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
186
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
187
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
188 void Polygon::font_texture(float row,float width)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
189 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
190 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
191 {0,0, 1,0, 1,1} };
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
192
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
193 for (int i = 0; i < pp_num; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
194
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
195 TrianglePackPtr tri = pp[i].tri;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
196 // TrianglePack の size のチェック
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
197 int tri_size = 2;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
198 pp[i].info.size = tri_size;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
199
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
200 for (int j = 0; j < tri_size; j++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
201
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
202 tri[j].ver1.tex_x = texture_point[j][0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
203 tri[j].ver1.tex_y = texture_point[j][1];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
204
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
205 tri[j].ver2.tex_x = texture_point[j][2];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
206 tri[j].ver2.tex_y = texture_point[j][3];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
207
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
208 tri[j].ver3.tex_x = texture_point[j][4];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
209 tri[j].ver3.tex_y = texture_point[j][5];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
210
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
211
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
212 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
213
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
214
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
215 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
216
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
217 /*if (count != 0) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
218 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
219 }*/
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
220
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
221 }