annotate TaskManager/Test/test_render/SceneGraph.cpp @ 238:443c7ae1c7a7 draft

warning clean
author admin@mcbk.cr.ie.u-ryukyu.ac.jp
date Fri, 29 May 2009 13:43:52 +0900
parents a314d8cd2082
children c4918a1fb6c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <iostream>
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include <SDL.h>
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 #include <SDL_opengl.h>
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 #include <SDL_image.h>
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 #include <libxml/parser.h>
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 #include "SceneGraph.h"
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7 #include "xml.h"
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8 #include "sys.h"
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
9 #include "TextureHash.h"
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
10 #include "texture.h"
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 142
diff changeset
11 #include "TaskManager.h"
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 using namespace std;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
15 SceneGraphPtr scene_graph = NULL;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
16 SceneGraphPtr scene_graph_viewer = NULL;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
17
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
18 static TextureHash texture_hash;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
19 struct texture_list list[TABLE_SIZE];
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
20
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
21 // TextureHash.cpp
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
22 extern int id_count;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
23
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 extern int decode(char *cont, FILE *outfile);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 static void
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
27 no_move(SceneGraphPtr self, int screen_w, int screen_h) {}
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 static void
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
30 no_collision(SceneGraphPtr self, int screen_w, int screen_h,
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
31 SceneGraphPtr tree) {}
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
33 /**
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
34 * 事前に計算したテクスチャの最大縮小率 scale まで、
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
35 * テクスチャを 1/2 縮小していく。
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
36 * このとき、テクスチャは TEXTURE_SPLIT_PIXELx2 のブロック (Tile) で分割し、
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
37 * これらを連続したメモリ領域に格納していく。
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
38 * 以下の (1), (2), (3) を Tapestry と呼ぶ
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
39 *
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
40 * 例 scale = 4 の場合
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
41 *
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
42 * Tapestry(1) 1/1
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
43 * +---+---+---+---+
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
44 * | 0 | 1 | 2 | 3 |
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
45 * +---+---+---+---+
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
46 * | 4 | 5 | 6 | 7 | (2) 1/2
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
47 * +---+---+---+---+ +---+---+
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
48 * | 8 | 9 | 10| 11| | 16| 17| (3) 1/4
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
49 * +---+---+---+---+ +---+---+ +---+
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
50 * | 12| 13| 14| 15| | 18| 19| | 20|
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
51 * +---+---+---+---+ +---+---+ +---|
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
52 *
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
53 * (1) (2) (3)
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
54 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
55 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | * | * | 14| 15| 16| 17| 18| 19| 20|
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
56 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
57 *
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
58 * @param[in] tex_w Width of orignal texture
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
59 * @param[in] tex_h Height of orignal texture
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
60 * @param[in] tex_src Original texture
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
61 * @param[in] all_pixel_num Tapestry の合計 pixel 数
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
62 * @param[in] scale テクスチャの最大縮小率 (= 2^n)
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
63 * @return (1) のアドレス
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
64 */
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
65 static uint32*
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
66 makeTapestry(int tex_w, int tex_h, uint32 *tex_src,
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
67 int all_pixel_num, int scale_cnt)
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
68 {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
69 uint32 *tex_dest;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
70
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
71 int t = 0;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
72 int diff = TEXTURE_SPLIT_PIXEL;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
73 int p_diff = 1;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
74
217
gongo@localhost.localdomain
parents: 212
diff changeset
75 tex_dest = (uint32*)manager->allocate(sizeof(int)*all_pixel_num);
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
76
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
77 while (scale_cnt) {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
78 for (int y = 0; y < tex_h; y += diff) {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
79 for (int x = 0; x < tex_w; x += diff) {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
80 for (int j = 0; j < diff; j += p_diff) {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
81 for (int i = 0; i < diff; i += p_diff) {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
82 tex_dest[t++]
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
83 = tex_src[(x+i) + tex_w*(y+j)];
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
84 }
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
85 }
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
86 }
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
87 }
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
88
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
89 diff <<= 1;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
90 p_diff <<= 1;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
91 scale_cnt >>= 1;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
92 }
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
93
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
94 return tex_dest;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
95 }
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
96
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
97
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
98 /**
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
99 * 何の情報も持ってない SceneGraph の生成
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
100 * 今のところ、とりあえず木構造の繋がりに使うぐらい
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
101 */
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
102 SceneGraph::SceneGraph(void)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
103 {
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
104 init();
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
105 finalize = &SceneGraph::finalize_copy;
219
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
106
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
107 this->name = "NULLPO";
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
108 }
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
109
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
110 /**
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
111 * orig のコピーとして SceneGraph を生成する
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
112 */
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
113 SceneGraph::SceneGraph(SceneGraphPtr orig)
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
114 {
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
115 init();
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
116 memcpy(this, orig, sizeof(SceneGraph));
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
117
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
118 // コピーしない
219
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
119 //flag_remove = 0;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
120 //flag_drawable = 1;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
121 next = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
122 prev = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
123 last = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
124
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
125 parent = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
126 brother = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
127 children = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
128 lastChild = NULL;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
129
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
130 finalize = &SceneGraph::finalize_copy;
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
131
335ea3665fcd allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents: 218
diff changeset
132
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
133 frame = 0;
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
134 }
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
135
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
136
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
137 /* construct polygon from xmlNode. */
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
138 SceneGraph::SceneGraph(xmlNodePtr surface)
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
139 {
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
140 init();
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
141
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
142 size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size"));
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
143 name = (char *)xmlGetProp(surface,(xmlChar *)"name");
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
144 parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent");
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
145
228
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
146 //data = new float[size*3*3];
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
147 coord_xyz = (float*)manager->allocate(sizeof(float)*size*3);
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
148 coord_tex = (float*)manager->allocate(sizeof(float)*size*3);
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
149 normal = (float*)manager->allocate(sizeof(float)*size*3);
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
150
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
151 get_data(surface->children);
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
152
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
153 finalize = &SceneGraph::finalize_original;
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
154 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
155
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
156 void
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
157 SceneGraph::init(void)
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
158 {
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
159 next = NULL;
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
160 prev = NULL;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
161 last = NULL;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
162
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
163 parent = NULL;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
164 brother = NULL;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
165 children = NULL;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
166 lastChild = NULL;
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
167
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
168 stack_xyz[0] = 0.0f;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
169 stack_xyz[2] = 0.0f;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
170 stack_xyz[1] = 0.0f;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
171 stack_angle[0] = 0.0f;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
172 stack_angle[1] = 0.0f;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
173 stack_angle[2] = 0.0f;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
174
203
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
175 size = 0;
228
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
176 //data = NULL;
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
177 coord_xyz = NULL;
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
178 normal = NULL;
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
179 coord_tex = NULL;
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
180
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
181 texture_id = -1;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
182 move = no_move;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
183 collision = no_collision;
142
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
184
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
185 flag_remove = 0;
202
76bf19f9e305 fix SceneGraphIterator::hasNext(), next()
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 201
diff changeset
186 flag_drawable = 1;
76bf19f9e305 fix SceneGraphIterator::hasNext(), next()
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 201
diff changeset
187 sgid = -1;
76bf19f9e305 fix SceneGraphIterator::hasNext(), next()
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 201
diff changeset
188
142
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
189 frame = 0;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
190 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
191
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
192 SceneGraph::~SceneGraph(void)
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
193 {
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
194 (this->*finalize)();
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
195 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
196
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
197 /**
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
198 * xml ファイルから生成されたオリジナル SceneGraph なので
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
199 * polygon data を削除
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
200 */
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
201 void
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
202 SceneGraph::finalize_original(void)
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
203 {
228
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
204 //delete [] data;
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
205 free(coord_xyz);
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
206 free(coord_tex);
5bb12a76a335 remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 224
diff changeset
207 free(normal);
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
208 }
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
209
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
210 /**
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
211 * SceneGraph ID から生成された、コピー SceneGraph なので
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
212 * polygon data は削除しない。オリジナルの方で削除する。
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
213 */
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
214 void
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
215 SceneGraph::finalize_copy(void)
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
216 {
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
217 }
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
218
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
219 /* XMLファイルからポリゴンを作成 */
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
220 void
180
e3b7776b1420 いろいろ fix 。詳しくは TaskManager/Changelog、test_render/Changelog を
gongo@localhost.localdomain
parents: 178
diff changeset
221 SceneGraph::createFromXMLfile(const char *xmlfile)
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
222 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
223 xmlDocPtr doc;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
224 xmlNodePtr cur;
238
443c7ae1c7a7 warning clean
admin@mcbk.cr.ie.u-ryukyu.ac.jp
parents: 233
diff changeset
225 SceneGraphPtr root = NULL, tmp = NULL, parent;
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
226
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
227 /* パース DOM生成 */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
228 doc = xmlParseFile(xmlfile);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
229 cur = xmlDocGetRootElement(doc);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
230
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
231 /* ?? */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
232 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D");
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
233
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
234 /* XMLのノードを一つずつ解析 */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
235 for (cur=cur->children; cur; cur=cur->next) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
236 /* 扱うのはsurfaceオンリー */
224
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
237 //if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
238 // continue;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
239 //}
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
240 if (!xmlStrcmp(cur->name,(xmlChar*)"surface")) {
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
241 /* ポリゴン(SceneGraph)生成 */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
242 tmp = new SceneGraph(cur);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
243 if ( tmp->parent_name==NULL || 0==strcmp(tmp->parent_name, "NULL")) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
244 /* このsurfaceがroot */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
245 root = tmp;
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
246 scene_graph = tmp;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
247 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
248 /* 親はこのsurfaceより前に定義されているものとする (していい?) */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
249 // ここで parent_name を用いるのは間違っていて、
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
250 // *cur->properties->children から探すべきらしい kono
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
251 parent = root->searchSceneGraph(tmp->parent_name);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
252 if (parent==NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
253 fprintf(stderr, "[%s] No such parent %s\n",
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
254 tmp->name, tmp->parent_name);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
255 root->addChild(tmp);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
256 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
257 parent->addChild(tmp);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
258 }
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
259
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
260 scene_graph->add_next(tmp);
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
261 }
224
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
262 }else if (!xmlStrcmp(cur->name,(xmlChar*)"image")) {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
263
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
264 char *cont;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
265 char image_name[20] = "/tmp/image_XXXXXX";
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
266 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
267 int fd = mkstemp(image_name);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
268 FILE *outfile = fdopen(fd, "wb");
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
269 if(NULL == outfile)
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
270 {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
271 cout << "error open file\n";
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
272 }
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
273 cont = (char *)xmlNodeGetContent(cur);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
274 decode(cont, outfile);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
275 fclose(outfile);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
276
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
277 int tex_id = texture_hash.hash_regist(filename);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
278 if (tex_id < 0)
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
279 {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
280
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
281 texture_image = IMG_Load(image_name);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
282
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
283 /**
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
284 * image を 32bit(RGBA) に変換する
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
285 */
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
286
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
287 SDL_Surface *tmpImage
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
288 = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
289 texture_image->h, 32, redMask,
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
290 greenMask, blueMask, alphaMask);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
291 SDL_Surface *converted;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
292 converted = SDL_ConvertSurface(texture_image, tmpImage->format,
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
293 SDL_HWSURFACE);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
294 if (converted != NULL) {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
295 SDL_FreeSurface(texture_image);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
296 texture_image = converted;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
297 }
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
298
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
299 uint32 *tapestry;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
300 int scale = 1;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
301 int tex_w = texture_image->w;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
302 int tex_h = texture_image->h;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
303 int all_pixel_num = 0;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
304
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
305 /**
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
306 * テクスチャの w or h が 8 pixel で分割できる間、
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
307 * 1/2 の縮小画像を作る。
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
308 * ここでは、最大の scale (1/scale) を見つける
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
309 *
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
310 * (ex)
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
311 * (128,128) => 64,64 : 32,32: 16,16 : 8,8
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
312 * scale = 16
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
313 * (128, 64) => 64,32 : 32,16: 16,8
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
314 * scale = 8
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
315 */
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
316
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
317 while (tex_w % TEXTURE_SPLIT_PIXEL == 0 &&
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
318 tex_h % TEXTURE_SPLIT_PIXEL == 0) {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
319 all_pixel_num += tex_w*tex_h;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
320 tex_w >>= 1; /* tex_w /= 2 */
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
321
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
322 tex_h >>= 1;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
323 scale <<= 1; /* scale *= 2 */
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
324
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
325 }
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
326
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
327 scale >>= 1;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
328
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
329 tapestry = makeTapestry(texture_image->w, texture_image->h,
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
330 (uint32*)texture_image->pixels,
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
331 all_pixel_num,
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
332 scale);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
333
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
334 list[id_count-1].t_w = texture_image->w;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
335 list[id_count-1].t_h = texture_image->h;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
336 list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
337 list[id_count-1].pixels = tapestry;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
338 list[id_count-1].scale_max = scale;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
339
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
340 tmp->texture_id = id_count-1;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
341 tmp->texture_info.t_w = texture_image->w;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
342 tmp->texture_info.t_h = texture_image->h;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
343 tmp->texture_info.pixels_orig = (Uint32*)texture_image->pixels;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
344 tmp->texture_info.pixels = tapestry;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
345 tmp->texture_info.scale_max = scale;
233
gongo@localhost.localdomain
parents: 229
diff changeset
346
224
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
347 if (unlink(image_name))
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
348 {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
349 cout << "unlink error\n";
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
350 }
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
351
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
352 } else {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
353 /**
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
354 * 以前に Load されている Texture を共用
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
355 */
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
356
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
357 tmp->texture_id = tex_id;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
358
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
359 // こんなことすると list[] のいみあるのかなーと
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
360 // 微妙に思う、自分で書き換えた感想 by gongo
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
361
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
362 tmp->texture_info.t_w = list[tex_id].t_w;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
363 tmp->texture_info.t_h = list[tex_id].t_h;;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
364 tmp->texture_info.pixels_orig = list[tex_id].pixels_orig;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
365 tmp->texture_info.pixels = list[tex_id].pixels;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
366 tmp->texture_info.scale_max = list[tex_id].scale_max;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
367
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
368 }
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
369 }else {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
370 continue;
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
371 }
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
372 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
373
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
374 xmlFreeDoc(doc);
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
375
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
376 //return root;
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
377 scene_graph_viewer = root;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
378 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
379
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
380
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
381 /**
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
382 * add Children
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
383 * 親の登録と、brother のリストへ加える
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
384 *
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
385 * @param child new child
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
386 */
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
387 SceneGraphPtr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
388 SceneGraph::addChild(SceneGraphPtr child)
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
389 {
142
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
390 /* childrenのリストの最後に加える (brother として)*/
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
391 if (this->lastChild != NULL) {
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
392 SceneGraphPtr last = this->lastChild;
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
393 last->brother = child;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
394 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
395
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
396 this->lastChild = child;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
397
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
398 if (this->children == NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
399 this->children = child;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
400 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
401
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
402 child->parent = this;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
403
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
404 return child;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
405 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
406
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
407
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
408 /**
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
409 * add Brother
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
410 * addChild() でも brother の操作をしないといけないので、そっちに回す
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
411 *
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
412 * @param bro new Brother
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
413 */
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
414 SceneGraphPtr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
415 SceneGraph::addBrother(SceneGraphPtr bro)
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
416 {
139
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 138
diff changeset
417 if (this->parent) {
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 138
diff changeset
418 parent->addChild(bro);
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
419 } else {
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
420 fprintf(stderr, "error : SceneGraph::%s : %s doesn't have parent\n",
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
421 __FUNCTION__, this->name);
139
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 138
diff changeset
422 }
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 138
diff changeset
423
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
424 return bro;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
425 }
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
426
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
427 /* thisの子や子孫にnameのものが存在すればそいつを返す なければNULL. */
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
428 SceneGraphPtr
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
429 SceneGraph::searchSceneGraph(char *name)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
430 {
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
431 SceneGraphPtr tmp;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
432 SceneGraphPtr result;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
433
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
434 /* 本人か */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
435 if( 0==strcmp(this->name, name) ) return this;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
436
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
437 /* 子供から再帰的に探す */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
438 for(tmp = this->children; tmp; tmp = tmp->next) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
439 if ((result=tmp->searchSceneGraph(name)) != NULL)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
440 return result;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
441 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
442
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
443 /* 無かったら NULL. */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
444 return NULL;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
445 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
446
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
447 void
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
448 SceneGraph::tree_check(void)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
449 {
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
450 SceneGraphPtr t = this;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
451
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
452 while(t)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
453 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
454 cout << "my_name : " << t->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
455 if(t->children != NULL)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
456 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
457 cout << "--move children : " << t->children->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
458 t = t->children;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
459 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
460 else if(t->brother != NULL)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
461 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
462 cout << "--move brother : " << t->brother->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
463 t = t->brother;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
464 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
465 else
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
466 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
467 while(t)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
468 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
469 if(t->brother != NULL)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
470 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
471 cout << "--move brother : " << t->brother->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
472 t = t->brother;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
473 break;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
474 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
475 else
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
476 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
477 if(t->parent)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
478 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
479 cout << "--move parent : " << t->parent->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
480 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
481 t = t->parent;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
482 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
483 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
484 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
485 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
486 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
487
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
488
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
489 void
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
490 SceneGraph::print_member(void)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
491 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
492 cout << "size = " << size << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
493 cout << "name = " << name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
494 cout << "parent_name = " << parent_name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
495
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
496 if (parent != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
497 cout << "parent->name = " << parent->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
498 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
499
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
500 if (children != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
501 cout << "children->name = " << children->name << endl;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
502 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
503 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
504
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
505
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
506 /*
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
507 * surface nodeからポリゴンの情報を読み出す 再帰しない
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
508 */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
509 void
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
510 SceneGraph::get_data(xmlNodePtr cur)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
511 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
512 char *cont;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
513 //char *image_name;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
514
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
515 for(;cur;cur=cur->next)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
516 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
517 if(!xmlStrcmp(cur->name,(xmlChar*)"coordinate"))
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
518 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
519 cont = (char *)xmlNodeGetContent(cur);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
520 pickup_coordinate(cont);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
521 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
522 else if(!xmlStrcmp(cur->name,(xmlChar*)"normal"))
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
523 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
524 cont = (char *)xmlNodeGetContent(cur);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
525 pickup_normal(cont);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
526 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
527 else if(!xmlStrcmp(cur->name,(xmlChar*)"model"))
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
528 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
529 cont = (char *)xmlNodeGetContent(cur);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
530 pickup_model(cont);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
531 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
532 else if(!xmlStrcmp(cur->name,(xmlChar*)"texture"))
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
533 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
534 cont = (char *)xmlNodeGetContent(cur);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
535 pickup_texture(cont);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
536 }
224
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
537 else if(!xmlStrcmp(cur->name,(xmlChar*)"imageflag"))
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
538 {
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
539 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
540 texture_hash.hash_regist(filename);
d9f6ba033dc5 SceneGraph.cpp xmlcreate
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents: 219
diff changeset
541 }
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
542 else if(!xmlStrcmp(cur->name,(xmlChar*)"image"))
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
543 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
544 char image_name[20] = "/tmp/image_XXXXXX";
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
545 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name");
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
546 int fd = mkstemp(image_name);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
547 FILE *outfile = fdopen(fd, "wb");
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
548 if(NULL == outfile)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
549 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
550 cout << "error open file\n";
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
551 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
552 cont = (char *)xmlNodeGetContent(cur);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
553 //decode(cont, image_name);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
554 decode(cont, outfile);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
555 fclose(outfile);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
556
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
557 /**
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
558 * image_name を既に Load していれば何もしない
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
559 */
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
560 int tex_id = texture_hash.hash_regist(filename);
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
561 if (tex_id < 0) {
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
562
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
563 texture_image = IMG_Load(image_name);
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
564
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
565 /**
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
566 * image を 32bit(RGBA) に変換する
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
567 */
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
568 SDL_Surface *tmpImage
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
569 = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
570 texture_image->h, 32, redMask,
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
571 greenMask, blueMask, alphaMask);
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
572 SDL_Surface *converted;
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
573 converted = SDL_ConvertSurface(texture_image, tmpImage->format,
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
574 SDL_HWSURFACE);
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
575 if (converted != NULL) {
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
576 SDL_FreeSurface(texture_image);
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
577 texture_image = converted;
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
578 }
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
579
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
580 uint32 *tapestry;
174
2c7d9057dd5d getScale()、getTapestry から、span->length に適切なテクスチャの選択に成功
gongo@localhost.localdomain
parents: 173
diff changeset
581 int scale = 1;
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
582 int tex_w = texture_image->w;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
583 int tex_h = texture_image->h;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
584 int all_pixel_num = 0;
173
1e62bd02f820 add scale
gongo@localhost.localdomain
parents: 171
diff changeset
585
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
586 /**
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
587 * テクスチャの w or h が 8 pixel で分割できる間、
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
588 * 1/2 の縮小画像を作る。
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
589 * ここでは、最大の scale (1/scale) を見つける
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
590 *
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
591 * (ex)
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
592 * (128,128) => 64,64 : 32,32: 16,16 : 8,8
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
593 * scale = 16
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
594 * (128, 64) => 64,32 : 32,16: 16,8
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
595 * scale = 8
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
596 */
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
597 while (tex_w % TEXTURE_SPLIT_PIXEL == 0 &&
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
598 tex_h % TEXTURE_SPLIT_PIXEL == 0) {
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
599 all_pixel_num += tex_w*tex_h;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
600 tex_w >>= 1; /* tex_w /= 2 */
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
601 tex_h >>= 1;
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
602 scale <<= 1; /* scale *= 2 */
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
603 }
173
1e62bd02f820 add scale
gongo@localhost.localdomain
parents: 171
diff changeset
604
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
605 scale >>= 1;
173
1e62bd02f820 add scale
gongo@localhost.localdomain
parents: 171
diff changeset
606
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
607 tapestry = makeTapestry(texture_image->w, texture_image->h,
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
608 (uint32*)texture_image->pixels,
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
609 all_pixel_num, scale);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 142
diff changeset
610
173
1e62bd02f820 add scale
gongo@localhost.localdomain
parents: 171
diff changeset
611 list[id_count-1].t_w = texture_image->w;
1e62bd02f820 add scale
gongo@localhost.localdomain
parents: 171
diff changeset
612 list[id_count-1].t_h = texture_image->h;
149
f85ad3769897 SceneGraph.cpp での texture_list fix
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 148
diff changeset
613 list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels;
178
4efb799779d7 add makeTapestry in SceneGraph.cpp
gongo@localhost.localdomain
parents: 174
diff changeset
614 list[id_count-1].pixels = tapestry;
174
2c7d9057dd5d getScale()、getTapestry から、span->length に適切なテクスチャの選択に成功
gongo@localhost.localdomain
parents: 173
diff changeset
615 list[id_count-1].scale_max = scale;
233
gongo@localhost.localdomain
parents: 229
diff changeset
616
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
617 texture_id = id_count-1;
161
18c42658e0e7 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 150
diff changeset
618
174
2c7d9057dd5d getScale()、getTapestry から、span->length に適切なテクスチャの選択に成功
gongo@localhost.localdomain
parents: 173
diff changeset
619 if (unlink(image_name))
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
620 {
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
621 cout << "unlink error\n";
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
622 }
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
623 } else {
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
624 /**
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
625 * 以前に Load されている Texture を共用
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
626 */
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
627 texture_id = tex_id;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
628 }
203
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
629
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
630 // こんなことすると list[] のいみあるのかなーと
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
631 // 微妙に思う、自分で書き換えた感想 by gongo
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
632 texture_info.t_w = list[texture_id].t_w;
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
633 texture_info.t_h = list[texture_id].t_h;;
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
634 texture_info.pixels_orig = list[texture_id].pixels_orig;
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
635 texture_info.pixels = list[texture_id].pixels;
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 202
diff changeset
636 texture_info.scale_max = list[texture_id].scale_max;
141
56db76a03294 TileList を作ろうとしたがに動かない。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
637 }
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
638 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
639 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
640
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
641
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
642 void
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
643 SceneGraph::delete_data(void)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
644 {
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
645 SceneGraphPtr n = this->next, m;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
646
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
647 //n = this;
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
648 //delete [] n->data;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
649
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
650 if (next) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
651 while (n) {
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
652 m = n->next;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
653 delete n;
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 139
diff changeset
654 n = m;
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
655 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
656 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
657 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
658
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
659 void
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
660 SceneGraph::move_execute(int w, int h)
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
661 {
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
662 (*move)(this, w, h);
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
663 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
664
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
665 void
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
666 SceneGraph::collision_check(int w, int h, SceneGraphPtr tree)
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
667 {
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
668 (*collision)(this, w, h, tree);
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
669 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
670
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
671 void
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
672 SceneGraph::all_execute(int screen_w, int screen_h)
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
673 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
674 SceneGraphPtr top = this;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
675 SceneGraphPtr t = top;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
676
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
677 while (t) {
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
678 t->move_execute(screen_w, screen_h);
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
679 t->collision_check(screen_w, screen_h, top);
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
680
142
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
681 t->frame++;
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
682
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
683 if (t->parent != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
684 get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
685 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
686 get_matrix(t->matrix, t->angle, t->xyz, NULL);
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
687 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
688
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
689 if (t->children != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
690 t = t->children;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
691 } else if (t->brother != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
692 t = t->brother;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
693 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
694 while (t) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
695 if (t->brother != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
696 t = t->brother;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
697 break;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
698 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
699 if (t->parent == NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
700 t = NULL;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
701 break;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
702 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
703 t = t->parent;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
704 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
705 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
706 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
707 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
708 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
709 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
710
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
711 void
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
712 SceneGraph::set_move_collision(SceneGraphPtr node, move_func new_move,
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
713 collision_func new_collision)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
714 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
715 node->move = new_move;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
716 node->collision = new_collision;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
717 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
718
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
719 void
142
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
720 SceneGraph::set_move_collision(move_func new_move,
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
721 collision_func new_collision)
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
722 {
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
723 this->move = new_move;
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
724 this->collision = new_collision;
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
725 }
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
726
dc68420f705f add xml
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 141
diff changeset
727 void
137
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
728 SceneGraph::add_next(SceneGraphPtr next)
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
729 {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
730 /* next のリストの最後に加える */
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
731 if (this->next != NULL) {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
732 SceneGraphPtr tmp = this->last;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
733 tmp->next = next;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
734 } else {
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
735 this->next = next;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
736 }
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
737
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
738 this->last = next;
91c74dbc32e4 SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
739 }
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
740
229
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
741 /**
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
742 * SceneGraph の clone
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
743 * @return clone SceneGraph
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
744 */
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
745 SceneGraphPtr
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
746 SceneGraph::clone(void) {
215
59f4129a9562 fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents: 212
diff changeset
747 SceneGraphPtr p = new SceneGraph(this);
138
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
748 return p;
f35504025f73 オブジェクトを増やして複数の表示に成功。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 137
diff changeset
749 }
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
750
229
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
751 /**
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
752 * SceneGraph の clone
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
753 * 予め allocate されてる領域への placement new を行う
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
754 *
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
755 * @param buf clone 領域
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
756 * @return clone SceneGraph
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
757 */
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
758 SceneGraphPtr
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
759 SceneGraph::clone(void *buf) {
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
760 SceneGraphPtr p = new(buf) SceneGraph(this);
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
761 return p;
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
762 }
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 228
diff changeset
763
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
764 void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
765 SceneGraph::remove(void)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
766 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
767 this->flag_remove = 1;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
768 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
769
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
770 /**
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
771 * tree から node を削除する
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
772 *
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
773 * @param tree SceneGraphTree
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
774 * @return node削除後の SceneGraphTree
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
775 */
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
776 SceneGraphPtr
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
777 SceneGraph::realRemoveFromTree(SceneGraphPtr tree)
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
778 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
779 SceneGraphPtr node = this;
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
780 SceneGraphPtr parent = node->parent;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
781 SceneGraphPtr ret = tree;
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
782
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
783 if (parent) {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
784 SceneGraphPtr brother = parent->children;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
785 SceneGraphPtr p, p1 = NULL;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
786
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
787 p = brother;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
788 if (p) {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
789 if (p == node) {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
790 parent->children = NULL;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
791 parent->lastChild = NULL;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
792 } else {
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
793 p1 = p->brother;
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
794
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
795 while (p1 && p1 != node) {
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
796 p1 = p1->brother;
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
797 p = p->brother;
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
798 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
799
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
800 if (p1) {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
801 p->brother = p1->brother;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
802
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
803 // node が最後尾なら、lastChild を変更
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
804 if (parent->lastChild == p1) {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
805 parent->lastChild = p;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
806 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
807 } else {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
808 // Can't find remove node
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
809 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
810 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
811 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
812 } else {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
813 // 親が居ない = tree root なので
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
814 // NULL を返す
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
815 ret = NULL;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
816 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
817
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
818 return ret;
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
819 }
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
820
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
821 /**
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
822 * list から node を削除する
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
823 *
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
824 * @param list SceneGraphList
201
9484318b3e8f add SceneGraphIterator
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 199
diff changeset
825 * @return node削除後の SceneGraphList
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
826 */
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
827 SceneGraphPtr
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
828 SceneGraph::realRemoveFromList(SceneGraphPtr list)
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
829 {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
830 SceneGraphPtr node = this;
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
831 SceneGraphPtr prev = node->prev;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
832 SceneGraphPtr next = node->next;
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
833 SceneGraphPtr ret = list;
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
834
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
835 if (prev) {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
836 prev->next = next;
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
837 } else {
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
838 ret = next;
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
839 }
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
840
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
841 if (next) {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
842 next->prev = prev;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
843 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
844
199
1fd0107ebb25 add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 195
diff changeset
845 return ret;
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
846 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
847
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
848 int
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
849 SceneGraph::isRemoved(void)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
850 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
851 return flag_remove;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
852 }
212
gongo@localhost.localdomain
parents: 203
diff changeset
853
gongo@localhost.localdomain
parents: 203
diff changeset
854 /**
gongo@localhost.localdomain
parents: 203
diff changeset
855 * 平行移動
gongo@localhost.localdomain
parents: 203
diff changeset
856 *
gongo@localhost.localdomain
parents: 203
diff changeset
857 * @param x Ttranslate in the x direction
gongo@localhost.localdomain
parents: 203
diff changeset
858 * @param y Ttranslate in the y direction
gongo@localhost.localdomain
parents: 203
diff changeset
859 * @param z Ttranslate in the z direction
gongo@localhost.localdomain
parents: 203
diff changeset
860 */
gongo@localhost.localdomain
parents: 203
diff changeset
861 void
gongo@localhost.localdomain
parents: 203
diff changeset
862 SceneGraph::translate(float x, float y, float z)
gongo@localhost.localdomain
parents: 203
diff changeset
863 {
gongo@localhost.localdomain
parents: 203
diff changeset
864 this->xyz[0] = x;
gongo@localhost.localdomain
parents: 203
diff changeset
865 this->xyz[1] = y;
gongo@localhost.localdomain
parents: 203
diff changeset
866 this->xyz[2] = z;
gongo@localhost.localdomain
parents: 203
diff changeset
867 }
gongo@localhost.localdomain
parents: 203
diff changeset
868
gongo@localhost.localdomain
parents: 203
diff changeset
869 /**
gongo@localhost.localdomain
parents: 203
diff changeset
870 * x 軸方向への平行移動
gongo@localhost.localdomain
parents: 203
diff changeset
871 *
gongo@localhost.localdomain
parents: 203
diff changeset
872 * @param x Ttranslate in the x direction
gongo@localhost.localdomain
parents: 203
diff changeset
873 */
gongo@localhost.localdomain
parents: 203
diff changeset
874 void
gongo@localhost.localdomain
parents: 203
diff changeset
875 SceneGraph::translateX(float x)
gongo@localhost.localdomain
parents: 203
diff changeset
876 {
gongo@localhost.localdomain
parents: 203
diff changeset
877 this->xyz[0] = x;
gongo@localhost.localdomain
parents: 203
diff changeset
878 }
gongo@localhost.localdomain
parents: 203
diff changeset
879
gongo@localhost.localdomain
parents: 203
diff changeset
880 /**
gongo@localhost.localdomain
parents: 203
diff changeset
881 * y 軸方向への平行移動
gongo@localhost.localdomain
parents: 203
diff changeset
882 *
gongo@localhost.localdomain
parents: 203
diff changeset
883 * @param y Ttranslate in the y direction
gongo@localhost.localdomain
parents: 203
diff changeset
884 */
gongo@localhost.localdomain
parents: 203
diff changeset
885 void
gongo@localhost.localdomain
parents: 203
diff changeset
886 SceneGraph::translateY(float y)
gongo@localhost.localdomain
parents: 203
diff changeset
887 {
gongo@localhost.localdomain
parents: 203
diff changeset
888 this->xyz[1] = y;
gongo@localhost.localdomain
parents: 203
diff changeset
889 }
gongo@localhost.localdomain
parents: 203
diff changeset
890
gongo@localhost.localdomain
parents: 203
diff changeset
891 /**
gongo@localhost.localdomain
parents: 203
diff changeset
892 * z 軸方向への平行移動
gongo@localhost.localdomain
parents: 203
diff changeset
893 *
gongo@localhost.localdomain
parents: 203
diff changeset
894 * @param z Ttranslate in the z direction
gongo@localhost.localdomain
parents: 203
diff changeset
895 */
gongo@localhost.localdomain
parents: 203
diff changeset
896 void
gongo@localhost.localdomain
parents: 203
diff changeset
897 SceneGraph::translateZ(float z)
gongo@localhost.localdomain
parents: 203
diff changeset
898 {
gongo@localhost.localdomain
parents: 203
diff changeset
899 this->xyz[2] = z;
gongo@localhost.localdomain
parents: 203
diff changeset
900 }