annotate Renderer/Engine/SceneGraph.cc @ 1254:34944900f266 draft

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Nov 2011 16:56:11 +0900
parents 636dfdc30176
children 39016616cc26
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 <libxml/parser.h>
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
6 #include <string.h>
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "SceneGraph.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "xml.h"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1049
diff changeset
9 #include "matrix_calc.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "TextureHash.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "texture.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "TaskManager.h"
1125
b733c7903d07 remove old code
yutaka@localhost.localdomain
parents: 1123
diff changeset
13 #include "polygon_pack.h"
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
14 #include <ft2build.h>
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
15 #include <freetype/freetype.h>
539
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 using namespace std;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 SceneGraphPtr scene_graph = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 SceneGraphPtr scene_graph_viewer = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 static TextureHash texture_hash;
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
23 texture_list list[TABLE_SIZE];
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
24
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 extern int decode(char *cont, FILE *outfile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 static void
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
28 no_move(SceneGraphPtr self, void *sgroot_, int screen_w, int screen_h) {}
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 static void
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
31 no_collision(SceneGraphPtr self, void *sgroot_, int screen_w, int screen_h,
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 SceneGraphPtr tree) {}
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 * 事前に計算したテクスチャの最大縮小率 scale まで、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 * テクスチャを 1/2 縮小していく。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 * このとき、テクスチャは TEXTURE_SPLIT_PIXELx2 のブロック (Tile) で分割し、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 * これらを連続したメモリ領域に格納していく。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 * 以下の (1), (2), (3) を Tapestry と呼ぶ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 * 例 scale = 4 の場合
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 * Tapestry(1) 1/1
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 * +---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 * | 0 | 1 | 2 | 3 |
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 * | 4 | 5 | 6 | 7 | (2) 1/2
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 * | 8 | 9 | 10| 11| | 16| 17| (3) 1/4
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 * | 12| 13| 14| 15| | 18| 19| | 20|
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 * +---+---+---+---+ +---+---+ +---|
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 * (1) (2) (3)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | * | * | 14| 15| 16| 17| 18| 19| 20|
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 * @param[in] tex_w Width of orignal texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 * @param[in] tex_h Height of orignal texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 * @param[in] tex_src Original texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 * @param[in] all_pixel_num Tapestry の合計 pixel 数
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 * @param[in] scale テクスチャの最大縮小率 (= 2^n)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 * @return (1) のアドレス
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 */
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
66
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
67
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
68 uint32 white[256] __attribute__((aligned(16)));
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
69
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 static uint32*
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
71 makeTapestry(TaskManager *manager, uint32 tex_w, uint32 tex_h, uint32 *tex_src,
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 int all_pixel_num, int scale_cnt)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 {
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
74 if (tex_w==0 && tex_h==0) {
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
75 // non texture case
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
76 uint32 pattern = SDL_BYTEORDER == SDL_LIL_ENDIAN? 0x00ffffff : 0xffffff00; /* OpenGL RGBA masks */
1053
root@localhost.localdomain
parents: 1050
diff changeset
77 if (white[0]!=pattern) { // dumb!
root@localhost.localdomain
parents: 1050
diff changeset
78 #if 1
root@localhost.localdomain
parents: 1050
diff changeset
79 for(int i=0;i<256;i++)
root@localhost.localdomain
parents: 1050
diff changeset
80 white[i] = pattern;
root@localhost.localdomain
parents: 1050
diff changeset
81 #else
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
82 memset_pattern4(white,&pattern,256);
1053
root@localhost.localdomain
parents: 1050
diff changeset
83 #endif
root@localhost.localdomain
parents: 1050
diff changeset
84 }
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
85 return white;
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
86 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
88 uint32 t = 0;
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
89 uint32 diff = TEXTURE_SPLIT_PIXEL;
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
90 uint32 p_diff = 1;
539
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 uint32 *tex_dest = (uint32*)manager->allocate(sizeof(int)*all_pixel_num);
1092
b99abedb5523 fix h w in makeTapestry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1053
diff changeset
93 // uint32 *tex_src_max = (uint32*)( tex_src + tex_h*tex_w);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
1092
b99abedb5523 fix h w in makeTapestry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1053
diff changeset
95 // uint32 alpha = SDL_BYTEORDER == SDL_LIL_ENDIAN? 0xff000000 : 0xff; /* OpenGL RGBA masks */
b99abedb5523 fix h w in makeTapestry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1053
diff changeset
96 uint32 alpha = tex_src[0];
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
97
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 while (scale_cnt) {
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
99 // we should use average, except clear one
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
100 for (uint32 y = 0; y < align(tex_h,diff); y += diff) {
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
101 for (uint32 x = 0; x < align(tex_w,diff); x += diff) {
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
102 for (uint32 j = 0; j < diff; j += p_diff) {
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
103 for (uint32 i = 0; i < diff; i += p_diff) {
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
104 tex_dest[t++] =
1092
b99abedb5523 fix h w in makeTapestry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1053
diff changeset
105 (x+i<tex_w && y+j<tex_h) ? tex_src[(x+i) + tex_w*(y+j)]: alpha;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
1092
b99abedb5523 fix h w in makeTapestry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1053
diff changeset
111 diff <<= 1; p_diff <<= 1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 scale_cnt >>= 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 return tex_dest;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 * 何の情報も持ってない SceneGraph の生成
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 * 今のところ、とりあえず木構造の繋がりに使うぐらい
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 */
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
123 SceneGraph::SceneGraph(TaskManager *manager)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 {
1129
a8bffdb5d2e3 bus error
yutaka@localhost.localdomain
parents: 1128
diff changeset
125
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 init();
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
127
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
128 matrix = (float*)manager->allocate(sizeof(float)*16);
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
129 real_matrix = (float*)manager->allocate(sizeof(float)*16);
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
130 texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
131
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
132 texture_info->texture_id = -1;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
133
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
134 for (int i = 0; i < 16; i++) {
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
135 matrix[i] = 0;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
136 real_matrix[i] = 0;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
137 }
1254
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
138 for (int i = 0; i < 4; i++) {
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
139 matrix[i*4+i] = 1;
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
140 real_matrix[i*4+i] = 1;
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
141 }
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
142
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
143
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 finalize = &SceneGraph::finalize_copy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 this->name = "NULLPO";
1141
bc2dea061cb1 minor fix
Yutaka_Kinjyo
parents: 1140
diff changeset
147
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
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 * orig のコピーとして SceneGraph を生成する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 */
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
153 SceneGraph::SceneGraph( TaskManager *manager, SceneGraphPtr orig)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 {
908
Yutaka_Kinjyo
parents: 906
diff changeset
155
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 init();
1129
a8bffdb5d2e3 bus error
yutaka@localhost.localdomain
parents: 1128
diff changeset
157
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 memcpy(this, orig, sizeof(SceneGraph));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
160 matrix = (float*)manager->allocate(sizeof(float)*16);
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
161 real_matrix = (float*)manager->allocate(sizeof(float)*16);
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
162 texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
163
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
164 for (int i = 0; i < 16; i++) {
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
165 matrix[i] = orig->matrix[i];
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
166 real_matrix[i] = orig->real_matrix[i];
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
167 }
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
168
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
169 memcpy(texture_info, orig->texture_info, sizeof(texture_list));
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
170
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 // コピーしない
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 //flag_remove = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 //flag_drawable = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 next = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 prev = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 last = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 parent = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 brother = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 children = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 lastChild = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 finalize = &SceneGraph::finalize_copy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 frame = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 /* construct polygon from xmlNode. */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 SceneGraph::SceneGraph(TaskManager *manager, xmlNodePtr surface)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 {
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
192
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 init();
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
194
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
195 matrix = (float*)manager->allocate(sizeof(float)*16*2);
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
196 real_matrix = matrix+16;
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
197 texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1142
diff changeset
198 texture_info->texture_id = -1;
1125
b733c7903d07 remove old code
yutaka@localhost.localdomain
parents: 1123
diff changeset
199
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
200 //size : 頂点の数かな
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size"));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 name = (char *)xmlGetProp(surface,(xmlChar *)"name");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204
908
Yutaka_Kinjyo
parents: 906
diff changeset
205 for (int i = 0; i < 16; i++) {
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
206 matrix[i] = 0;
908
Yutaka_Kinjyo
parents: 906
diff changeset
207 real_matrix[i] = 0;
Yutaka_Kinjyo
parents: 906
diff changeset
208 }
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
209 for (int i = 0; i < 4; i++) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
210 matrix[i*4+i] = 1;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
211 real_matrix[i*4+i] = 1;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
212 }
908
Yutaka_Kinjyo
parents: 906
diff changeset
213
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
214 if (size % 3 != 0) {
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
215 printf("vertex size is error. size %% 3 = %lld\n", size % 3);
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
216 }
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
217
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
218 if (size > 0) {
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
219 pp_num = (size/3 + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
220 pp = (PolygonPack*)manager->allocate(sizeof(PolygonPack)*pp_num);
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
221 } else {
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
222 pp_num = 0;
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
223 pp = NULL;
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
224 }
906
becd6fad3ae0 coord_pack is stuffed with infomation of create polygon at spe.
Yutaka_Kinjyo
parents: 891
diff changeset
225
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 get_data(manager, surface->children);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 finalize = &SceneGraph::finalize_original;
1108
cbfedf774354 getSgid was made hash.
tkaito
parents: 1092
diff changeset
229
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
232 SceneGraph::SceneGraph(TaskManager *manager,const char *font,int pixels,Uint32 color,const char *string_name) {
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
233
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
234 init();
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
235
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
236 this->matrix = (float*)manager->allocate(sizeof(float)*16);
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
237 this->real_matrix = this->matrix+16;
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
238 this->texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
239 texture_info->texture_id = -1;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
240
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
241 //size : 頂点の数かな
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
242 size = 6;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
243 parent_name = NULL;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
244 name = string_name;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
245 for (int i = 0; i < 16; i++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
246 matrix[i] = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
247 real_matrix[i] = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
248 }
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
249 for (int i = 0; i < 4; i++) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
250 matrix[i*4+i] = 1;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
251 real_matrix[i*4+i] = 1;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
252 }
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
253
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
254 if (size % 3 != 0) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
255 printf("vertex size is error. size %% 3 = %lld\n", size % 3);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
256 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
257
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
258 if (size > 0) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
259 pp_num = (size/3 + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
260 pp = (PolygonPack*)manager->allocate(sizeof(PolygonPack)*pp_num);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
261 } else {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
262 pp_num = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
263 pp = NULL;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
264 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
265
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
266 create_font_data(manager, font, pixels, color, string_name);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
267
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
268 finalize = &SceneGraph::finalize_original;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
269 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
270
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
271 void
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
272 SceneGraph::create_font_data(TaskManager *manager,const char *font ,int pixels, Uint32 color, const char *string_name)
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
273 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
274 //font_coordinate(pixels/2,pixels);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
275 font_normal();
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
276 font_model();
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
277 //font_texture();
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
278
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
279 get_font_image(manager, font, pixels, color, string_name);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
280 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
281
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
282 void
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
283 SceneGraph::get_font_image(TaskManager *manager,const char *font ,int pixels ,Uint32 color, const char *string_name)
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
284 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
285 int tex_id;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
286 if (texture_hash.hash_regist(string_name, tex_id)) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
287 SDL_Surface *texture_image = load_font_image(font,pixels,color,string_name);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
288 if(!texture_image){
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
289 printf("Can't load image %s\n",string_name);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
290 exit(0);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
291 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
292 texture_info->texture_id = makeTapestries(manager, texture_image,tex_id);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
293 printf("%d\n",texture_info->texture_id);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
294 tex_id = texture_info->texture_id;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
295
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
296 } else {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
297 texture_info->texture_id = tex_id;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
298 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
299
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
300 texture_info->t_w = list[tex_id].t_w;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
301 texture_info->t_h = list[tex_id].t_h;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
302 texture_info->pixels_orig = list[tex_id].pixels_orig;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
303 texture_info->pixels = list[tex_id].pixels;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
304 texture_info->scale_max = list[tex_id].scale_max;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
305 texture_info->texture_image = list[tex_id].texture_image;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
306 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
307
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
308 SDL_Surface*
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
309 SceneGraph::load_font_image(const char *font ,int pixel,Uint32 color , const char *string_name)
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
310 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
311 //printf("laod_font_iamge");
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
312 FT_Library library;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
313 FT_Error err;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
314 err = FT_Init_FreeType(&library);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
315 if(err){
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
316 exit(1);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
317 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
318 FT_Face face;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
319 err = FT_New_Face(library,font,0,&face);//font:フォントファイルのパス
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
320 if(err){
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
321 exit(1);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
322 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
323
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
324 err = FT_Set_Pixel_Sizes(face,pixel,pixel);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
325 if(err){
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
326 exit(1);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
327 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
328
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
329 u_int32_t changecode[256] = {0};
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
330
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
331 conv(string_name+5,strlen(string_name+5),changecode);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
332
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
333 unsigned int characode = changecode[0];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
334
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
335 err = FT_Load_Char(face,characode,0);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
336 if(err){
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
337 exit(1);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
338 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
339
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
340 err = FT_Render_Glyph(face->glyph,FT_RENDER_MODE_MONO);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
341 if(err){
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
342 exit(1);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
343 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
344
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
345 FT_Bitmap *bm = &face->glyph->bitmap;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
346
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
347 //baseline計算 y_ppem(nominal height) - bitmap_top(topからのbaseline)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
348 float baseline = face->size->metrics.y_ppem - face->glyph->bitmap_top;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
349
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
350 float row = 1;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
351 float width = 1;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
352
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
353 font_coordinate(baseline,face->glyph->bitmap.rows,face->glyph->bitmap.width);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
354 this->seq = face->glyph->bitmap.width;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
355 font_texture(row,width);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
356
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
357 int index = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
358 Uint32 *pixels = (Uint32*)malloc(bm->rows*bm->pitch*8*4);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
359
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
360 for (int row = 0; row < bm->rows; row ++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
361 for (int col = 0; col < bm->pitch; col ++) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
362 int c = bm->buffer[bm->pitch * row + col];
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
363 for (int bit = 7; bit >= 0; bit --) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
364
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
365 if (((c >> bit) & 1) == 0) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
366 //printf(" ");
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
367 pixels[index++] = 0x0000000;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
368 } else {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
369 //printf("##");
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
370 //pixels[index++] = 0x00ffffff;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
371 pixels[index++] = color;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
372
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
373 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
374
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
375 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
376 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
377
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
378 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
379
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
380 SDL_Surface *texture_image = SDL_CreateRGBSurfaceFrom(pixels, bm->pitch*8, bm->rows,
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
381 32, bm->pitch*8*4, redMask,
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
382 greenMask, blueMask, alphaMask);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
383
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
384
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
385
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
386 if (!texture_image) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
387 printf("error\n");
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
388 return 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
389 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
390 SDL_Surface *tmpImage
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
391 = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
392 texture_image->h, 32, redMask,
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
393 greenMask, blueMask, alphaMask);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
394
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
395
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
396 SDL_Surface *converted;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
397 converted = SDL_ConvertSurface(texture_image, tmpImage->format,
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
398 SDL_HWSURFACE);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
399 if (converted != NULL) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
400 SDL_FreeSurface(texture_image);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
401 texture_image = converted;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
402 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
403
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
404 return texture_image;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
405 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
406
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
407 void
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
408 SceneGraph::conv(const char *str, int length, u_int32_t *out) {
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
409 int oindex = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
410 int i = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
411 while (i < length) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
412 out[oindex] = str[i++] & 0xff;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
413 int len = 0;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
414 u_int32_t mask;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
415 for (mask = 0x80; out[oindex] & mask; mask >>= 1) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
416 out[oindex] -= mask;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
417 len++;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
418 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
419 int j;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
420 for (j = 1; j < len; j++)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
421 out[oindex] = (out[oindex] << 6) | (str[i++] & 0x3f);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
422 oindex++;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
423 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
424 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
425
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
426 /*文字のSceneGraphを生成する*/
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1184
diff changeset
427
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
429 SceneGraph::init()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 next = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 prev = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 last = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 parent = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 brother = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 children = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 lastChild = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 stack_xyz[0] = 0.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 stack_xyz[2] = 0.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 stack_xyz[1] = 0.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 stack_angle[0] = 0.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 stack_angle[1] = 0.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 stack_angle[2] = 0.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 size = 0;
1141
bc2dea061cb1 minor fix
Yutaka_Kinjyo
parents: 1140
diff changeset
448 pp_num = 0;
bc2dea061cb1 minor fix
Yutaka_Kinjyo
parents: 1140
diff changeset
449
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 //data = NULL;
1128
293b36802714 code cleanup
Yutaka_Kinjyo
parents: 1127
diff changeset
451
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 move = no_move;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 collision = no_collision;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 flag_remove = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 flag_drawable = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 sgid = -1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 gid = -1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 frame = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
463 SceneGraph::~SceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 (this->*finalize)();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 * xml ファイルから生成されたオリジナル SceneGraph なので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 * polygon data を削除
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
473 SceneGraph::finalize_original()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 //delete [] data;
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
476
1126
6043da6e48f1 complete compile but not work yet.
yutaka@localhost.localdomain
parents: 1125
diff changeset
477 free(pp);
1142
801d57ae1e29 cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents: 1141
diff changeset
478 free(matrix);
801d57ae1e29 cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents: 1141
diff changeset
479 free(real_matrix);
801d57ae1e29 cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents: 1141
diff changeset
480 free(texture_info);
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
481
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 * SceneGraph ID から生成された、コピー SceneGraph なので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 * polygon data は削除しない。オリジナルの方で削除する。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
489 SceneGraph::finalize_copy()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 {
1142
801d57ae1e29 cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents: 1141
diff changeset
491
801d57ae1e29 cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents: 1141
diff changeset
492 free(matrix);
801d57ae1e29 cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents: 1141
diff changeset
493 free(real_matrix);
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
494 free(texture_info);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
496
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
497
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 * add Children
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 * 親の登録と、brother のリストへ加える
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 * @param child new child
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 SceneGraph::addChild(SceneGraphPtr child)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 /* childrenのリストの最後に加える (brother として)*/
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 if (this->lastChild != NULL) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 SceneGraphPtr last = this->lastChild;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 last->brother = child;
850
tkaito
parents: 848
diff changeset
511 //child->parent = this;
tkaito
parents: 848
diff changeset
512 //return child;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 }
891
Yutaka_Kinjyo
parents: 885
diff changeset
514
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 this->lastChild = child;
891
Yutaka_Kinjyo
parents: 885
diff changeset
516
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 if (this->children == NULL) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 this->children = child;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 }
891
Yutaka_Kinjyo
parents: 885
diff changeset
520
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 child->parent = this;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
522
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 return child;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
525
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
526
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 * add Brother
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 * addChild() でも brother の操作をしないといけないので、そっちに回す
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 * @param bro new Brother
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 SceneGraph::addBrother(SceneGraphPtr bro)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 if (this->parent) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 parent->addChild(bro);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 fprintf(stderr, "error : SceneGraph::%s : %s doesn't have parent\n",
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 __FUNCTION__, this->name);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
542
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 return bro;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 /* thisの子や子孫にnameのものが存在すればそいつを返す なければNULL. */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 SceneGraph::searchSceneGraph(const char *name)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 SceneGraphPtr tmp;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 SceneGraphPtr result;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
552
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 /* 本人か */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 if( 0==strcmp(this->name, name) ) return this;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 /* 子供から再帰的に探す */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 for(tmp = this->children; tmp; tmp = tmp->next) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 if ((result=tmp->searchSceneGraph(name)) != NULL)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 return result;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 /* 無かったら NULL. */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 return NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
567 SceneGraph::tree_check()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 SceneGraphPtr t = this;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 while(t)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 cout << "my_name : " << t->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 if(t->children != NULL)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 cout << "--move children : " << t->children->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 t = t->children;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 else if(t->brother != NULL)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 cout << "--move brother : " << t->brother->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 t = t->brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 else
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 while(t)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 if(t->brother != NULL)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 cout << "--move brother : " << t->brother->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 t = t->brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 break;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 else
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 if(t->parent)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 cout << "--move parent : " << t->parent->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 t = t->parent;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
606
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
607
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
609 SceneGraph::print_member()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 cout << "size = " << size << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 cout << "name = " << name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 cout << "parent_name = " << parent_name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
614
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 if (parent != NULL) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 cout << "parent->name = " << parent->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
618
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 if (children != NULL) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 cout << "children->name = " << children->name << endl;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
624
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 /*
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 * surface nodeからポリゴンの情報を読み出す 再帰しない
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 SceneGraph::get_data(TaskManager *manager, xmlNodePtr cur)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 //char *image_name;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
632
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 for(;cur;cur=cur->next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 if(!xmlStrcmp(cur->name,(xmlChar*)"coordinate"))
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 char *cont = (char *)xmlNodeGetContent(cur);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 pickup_coordinate(cont);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 else if(!xmlStrcmp(cur->name,(xmlChar*)"normal"))
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 char *cont = (char *)xmlNodeGetContent(cur);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 pickup_normal(cont);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 else if(!xmlStrcmp(cur->name,(xmlChar*)"model"))
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 char *cont = (char *)xmlNodeGetContent(cur);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 pickup_model(cont);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 else if(!xmlStrcmp(cur->name,(xmlChar*)"texture"))
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 char *cont = (char *)xmlNodeGetContent(cur);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 pickup_texture(cont);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 else if(!xmlStrcmp(cur->name,(xmlChar*)"imageflag"))
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 int id;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 texture_hash.hash_regist(filename, id);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 else if(!xmlStrcmp(cur->name,(xmlChar*)"image"))
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 get_image(manager, cur);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
667
1166
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
668 static int
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
669 is_bmp(const char *name) {
1166
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
670 int bmp = 0;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
671
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
672 while(*name) {
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
673 if (bmp==0 && *name=='.') bmp = 1;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
674 else if (bmp==1 && (*name=='b' || *name=='B')) bmp = 2;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
675 else if (bmp==2 && (*name=='m' || *name=='M')) bmp = 3;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
676 else if (bmp==3 && (*name=='p' || *name=='P')) bmp = 4;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
677 else bmp = 0;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
678 name++;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
679 }
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
680 return bmp==4;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
681 }
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
682
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
683 #if (__LITTLE_ENDIAN__)
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
684 #define LITTLEENDIAN 1
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
685 #else
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
686 #define LITTLEENDIAN 0
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
687 #endif
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
688
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
689 static void
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
690 make_black_alpha(SDL_Surface *texture_image)
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
691 {
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
692 int tex_w = texture_image->w;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
693 int tex_h = texture_image->h;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
694 #if LITTLEENDIAN
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
695 uint32 alpha = 0x000000ff;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
696 #else
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
697 uint32 alpha = 0xff000000;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
698 #endif
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
699
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
700 uint32 *pixels = (uint32*)texture_image->pixels;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
701 int i;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
702 for(i=0;i<tex_w*tex_h;i++) {
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
703 uint32 pixel = pixels[i] & ~alpha;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
704 if (pixel==0) {
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
705 pixels[i] = 0;
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
706 }
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
707 }
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
708 }
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
709
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 SDL_Surface*
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
711 SceneGraph::load_decode_image(const char *file_name, const char *image_name, xmlNodePtr cur)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 {
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1210
diff changeset
713 int fd = mkstemp((char *)image_name);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 FILE *outfile = fdopen(fd, "wb");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
715
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 if (NULL == outfile) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 cout << "error open file\n";
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 return 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
720
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 char *cont = (char *)xmlNodeGetContent(cur);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 //decode(cont, image_name);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 decode(cont, outfile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 fclose(outfile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
725
1166
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
726 int alpha_black = is_bmp(file_name);
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
727
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
728
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
729 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 * image を 32bit(RGBA) に変換する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 SDL_Surface *texture_image = IMG_Load(image_name);
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
733 if (!texture_image) return 0;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 SDL_Surface *tmpImage
1123
2a63ba2c9506 bug fix.
yutaka@localhost.localdomain
parents: 1108
diff changeset
735 = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
996
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
736 texture_image->h, 32, redMask,
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
737 greenMask, blueMask, alphaMask);
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
738
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
739 //= SDL_CreateRGBSurface(SDL_HWSURFACE, 0,
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
740 // 0, 32, redMask,
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
741 // greenMask, blueMask, alphaMask);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 SDL_Surface *converted;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 converted = SDL_ConvertSurface(texture_image, tmpImage->format,
996
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
744 SDL_HWSURFACE);
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
745
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
746 //SDL_SetAlpha(converted, 0, 0);
bac3b0afc3e8 add sdl_test file
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 994
diff changeset
747
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 if (converted != NULL) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 SDL_FreeSurface(texture_image);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 texture_image = converted;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
752
1166
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
753 if (alpha_black) {
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
754 make_black_alpha(texture_image);
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
755 }
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
756
942
27df980045b5 FB mode is working again on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 930
diff changeset
757 // this->gl_tex = SDL_GL_LoadTexture(texture_image);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 return texture_image;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
760
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 SceneGraph::makeTapestries(TaskManager *manager, SDL_Surface *texture_image, int id) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 uint32 *tapestry;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 int scale = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 int tex_w = texture_image->w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 int tex_h = texture_image->h;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 int all_pixel_num = 0;
1047
f87218eed9fc broken texure ( h/w != 2^n ) protection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
768 int nw = tex_w;
f87218eed9fc broken texure ( h/w != 2^n ) protection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
769 int nh = tex_h;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
770
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 * テクスチャの w or h が 8 pixel で分割できる間、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 * 1/2 の縮小画像を作る。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 * ここでは、最大の scale (1/scale) を見つける
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 * (ex)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 * (128,128) => 64,64 : 32,32: 16,16 : 8,8
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 * scale = 16
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 * (128, 64) => 64,32 : 32,16: 16,8
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 * scale = 8
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
781 * 8 pixcel align してない場合は、透明に 8 pixcel に拡張する
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
782 * (200, 57) => 200,64 : 100,32 : 56,16: 32,8 (16,1 : 8,1 まで落すべき? 32byte)
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
783 * scale = 32
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 */
1047
f87218eed9fc broken texure ( h/w != 2^n ) protection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
785
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
786 do {
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
787 tex_w = align(tex_w,8);
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
788 tex_h = align(tex_h,8);
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
789 all_pixel_num += tex_w * tex_h;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 tex_w >>= 1; /* tex_w /= 2 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 tex_h >>= 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 scale <<= 1; /* scale *= 2 */
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
793 } while( tex_w >8 || tex_h > 8 );
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
794
1049
91500a6c4def non 2^n texture tapestry generation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
795 scale >>= 1; // 必ず 1 以上になる
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
796
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 tapestry = makeTapestry(manager, texture_image->w, texture_image->h,
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 (uint32*)texture_image->pixels,
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 all_pixel_num, scale);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
800
1047
f87218eed9fc broken texure ( h/w != 2^n ) protection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
801 list[id].t_w = nw;
f87218eed9fc broken texure ( h/w != 2^n ) protection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
802 list[id].t_h = nh;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 list[id].pixels_orig = (Uint32*)texture_image->pixels;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 list[id].pixels = tapestry;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 list[id].scale_max = scale;
942
27df980045b5 FB mode is working again on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 930
diff changeset
806 list[id].texture_image = texture_image;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
807
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
808 return id;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
810
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
811 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 SceneGraph::get_image(TaskManager *manager, xmlNodePtr cur)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 char image_name[20] = "/tmp/image_XXXXXX";
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
816
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 if (filename == NULL || filename[0] == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 return;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
820
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 * image_name を既に Load していれば何もしない
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 int tex_id;
1184
5abf0ce8c71c texture hash fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1169
diff changeset
825 if (texture_hash.sg_hash_regist(filename, tex_id) == -1) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
826
1166
38111db531e0 bmp's black has 0 alpha value for compatibility
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
827 SDL_Surface *texture_image = load_decode_image(filename, image_name, cur);
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
828 if (texture_image==0) {
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
829 printf("Can't load image %s\n",filename);
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
830 exit(0);
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
831 }
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
832 texture_info->texture_id = makeTapestries(manager, texture_image, tex_id);
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
833 tex_id = texture_info->texture_id;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
834
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 if (unlink(image_name)) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 cout << "unlink error\n";
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
838 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 * 以前に Load されている Texture を共用
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 */
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
842 texture_info->texture_id = tex_id;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
844
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
845 // こんなことすると list[] のいみあるのかなーと
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
846 // 微妙に思う、自分で書き換えた感想 by gongo
1130
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
847 texture_info->t_w = list[tex_id].t_w;
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
848 texture_info->t_h = list[tex_id].t_h;;
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
849 texture_info->pixels_orig = list[tex_id].pixels_orig;
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
850 texture_info->pixels = list[tex_id].pixels;
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
851 texture_info->scale_max = list[tex_id].scale_max;
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents: 1129
diff changeset
852 texture_info->texture_image = list[tex_id].texture_image;
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 850
diff changeset
853
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
855
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
856
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
858 SceneGraph::delete_data()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 SceneGraphPtr n = this->next, m;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
861
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 //n = this;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 //delete [] n->data;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
864
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 if (next) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 while (n) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 m = n->next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 delete n;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 n = m;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
873
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
874 /* move_func 実行 sgroot 渡す */
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 SceneGraph::move_execute(int w, int h)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 {
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
878 (*move)(this, this->sgroot, w, h);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
880
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 SceneGraph::collision_check(int w, int h, SceneGraphPtr tree)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 {
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
884 (*collision)(this, this->sgroot, w, h, tree);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
886
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
887 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
888 SceneGraph::create_sg_execute()
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
889 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
890 (*create_sg)(this->sgroot, property, update_property);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
891 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
892
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
893 void
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
894 SceneGraph::set_move_collision(move_func new_move)
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
895 {
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
896 this->move = new_move;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
897 }
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
898
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
899 void
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
900 SceneGraph::set_move_collision(collision_func new_collision)
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
901 {
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
902 this->collision = new_collision;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 996
diff changeset
903 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
904
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 SceneGraph::set_move_collision(move_func new_move,
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 collision_func new_collision)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 this->move = new_move;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 this->collision = new_collision;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
911 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
912
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
913
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
914 void
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
915 SceneGraph::set_move_collision(move_func new_move,
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
916 collision_func new_collision, void *sgroot_)
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
917 {
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
918 this->move = new_move;
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
919 this->collision = new_collision;
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
920 // add
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
921 this->sgroot = sgroot_;
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
922 }
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 580
diff changeset
923
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 void
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
925 SceneGraph::set_move_collision(move_func new_move,
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
926 collision_func new_collision, create_sg_func new_create_sg)
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
927 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
928 this->move = new_move;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
929 this->collision = new_collision;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
930 this->create_sg = new_create_sg;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
931 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
932
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 724
diff changeset
933 void
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 SceneGraph::add_next(SceneGraphPtr next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
935 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 /* next のリストの最後に加える */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 if (this->next != NULL) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 SceneGraphPtr tmp = this->last;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
939 tmp->next = next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
940 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 this->next = next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
943
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 this->last = next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
945 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
946
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 * SceneGraph の clone
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 * @return clone SceneGraph
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 SceneGraphPtr
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
952 SceneGraph::clone(TaskManager *manager) {
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
953
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
954 SceneGraphPtr p = new SceneGraph(manager, this);
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1130
diff changeset
955
1140
3975c384ff93 SceneGraph initalize... can worked on Mac OS X. not check Cell arch.
Yutaka_Kinjyo
parents: 1136
diff changeset
956
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
957 return p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
959
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 * SceneGraph の clone
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 * 予め allocate されてる領域への placement new を行う
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 * @param buf clone 領域
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 * @return clone SceneGraph
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 */
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
967
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 SceneGraphPtr
1169
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
969 SceneGraph::clone(TaskManager *manager, void *buf) {
b93ff55ba015 free TaskArray rbuf
Yutaka_Kinjyo
parents: 1166
diff changeset
970 SceneGraphPtr p = new(buf) SceneGraph(manager, this);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 return p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
973
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 void
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
975 SceneGraph::remove()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 this->flag_remove = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
979
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 * tree から node を削除する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 * @param tree SceneGraphTree
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 * @return node削除後の SceneGraphTree
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 SceneGraph::realRemoveFromTree(SceneGraphPtr tree)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 SceneGraphPtr node = this;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 SceneGraphPtr parent = node->parent;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 SceneGraphPtr ret = tree;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
992
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 if (parent) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 SceneGraphPtr brother = parent->children;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 SceneGraphPtr p, p1 = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
996
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 p = brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 if (p) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 if (p == node) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 parent->children = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 parent->lastChild = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 p1 = p->brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 while (p1 && p1 != node) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 p1 = p1->brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 p = p->brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010 if (p1) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 p->brother = p1->brother;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013 // node が最後尾なら、lastChild を変更
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 if (parent->lastChild == p1) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 parent->lastChild = p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 // Can't find remove node
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 // 親が居ない = tree root なので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 // NULL を返す
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 ret = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 return ret;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 * list から node を削除する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 * @param list SceneGraphList
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 * @return node削除後の SceneGraphList
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 SceneGraph::realRemoveFromList(SceneGraphPtr list)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 SceneGraphPtr node = this;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 SceneGraphPtr prev = node->prev;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 SceneGraphPtr next = node->next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 SceneGraphPtr ret = list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 if (prev) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 prev->next = next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 ret = next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 if (next) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 next->prev = prev;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 return ret;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 int
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
1059 SceneGraph::isRemoved()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 return flag_remove;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 * 平行移動
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 * @param x Ttranslate in the x direction
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 * @param y Ttranslate in the y direction
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 * @param z Ttranslate in the z direction
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 SceneGraph::translate(float x, float y, float z)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 {
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1074 this->matrix[3] += x;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1075 this->matrix[4+3] += y;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1076 this->matrix[8+3] += z;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 * x 軸方向への平行移動
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 * @param x Ttranslate in the x direction
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 SceneGraph::translateX(float x)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 {
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1087 this->matrix[3] += x;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 * y 軸方向への平行移動
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 * @param y Ttranslate in the y direction
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 SceneGraph::translateY(float y)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 {
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1098 this->matrix[4+3] += y;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 * z 軸方向への平行移動
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 * @param z Ttranslate in the z direction
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 SceneGraph::translateZ(float z)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 {
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1109 this->matrix[8+3] += z;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1110 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1111
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1112 void
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1113 SceneGraph::angleIt(float *angle)
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1114 {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1115 float m[16];
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1116 float t[4] = {0,0,0,0};
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1117 for(int i=0;i<16;i++) m[i] = matrix[i];
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1118 get_matrix(matrix, angle, t, m);
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1119 get_matrix(real_matrix, angle, t, m);
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1120 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1121
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1122 void
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1123 SceneGraph::scaleIt(float *scale)
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1124 {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1125 for(int i=0;i<4;i++) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1126 for(int j=0;i<3;j++) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1127 matrix[i*4+j] = matrix[i*4+j]*scale[i];
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1128 real_matrix[i*4+j] = real_matrix[i*4+j]*scale[i];
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1129 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
1130 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 }
724
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
1132
6e9e4726113e Small clean up of Rendering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 653
diff changeset
1133 /* end */