Mercurial > hg > Game > Cerium
annotate Renderer/Engine/SceneGraphRoot.cc @ 1316:53f6855985f6 draft
collada file reader minor changes.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 16 Dec 2011 16:11:35 +0900 |
parents | c0a5a9abff9c |
children | afe66d75f48a |
rev | line source |
---|---|
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
1 |
539 | 2 #include <SDL_image.h> |
3 #include <libxml/parser.h> | |
4 #include "SceneGraphRoot.h" | |
5 #include "xml.h" | |
1050 | 6 #include "matrix_calc.h" |
539 | 7 #include "TextureHash.h" |
8 #include "texture.h" | |
562 | 9 #include "Application.h" |
539 | 10 |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
11 static int cnt = 0; |
562 | 12 static const int SGLIST_LENGTH = 138; |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
13 static int sg_src_size = SGLIST_LENGTH ; |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
14 static int sg_src_id = -1; |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
15 static SceneGraphPtr *sg_src; |
1114 | 16 |
17 static TextureHash sgid_hash; | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
18 |
558 | 19 SceneGraphRoot *sgroot; |
20 | |
1143 | 21 SceneGraphRoot::SceneGraphRoot(float w, float h, TaskManager *manager) |
539 | 22 { |
1143 | 23 |
24 sgroot = this; | |
25 sgroot->tmanager = manager; | |
26 | |
562 | 27 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな |
28 // | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
29 sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH); |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
30 |
1143 | 31 camera = new Camera(w, h, this, sgroot->tmanager); |
779 | 32 |
539 | 33 iterator = new SceneGraphIterator; |
34 controller = create_controller(); | |
35 | |
36 sg_exec_tree = NULL; | |
37 sg_draw_tree = NULL; | |
38 sg_available_list = NULL; | |
39 sg_remove_list = NULL; | |
40 | |
562 | 41 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
42 screen_w = (int)w; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
43 screen_h = (int)h; |
761 | 44 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
45 light_init(); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
46 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
47 move_finish_flag = 0; |
677
24054155368c
add Load light info for some spe
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
653
diff
changeset
|
48 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
49 gtask_array = NULL; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
50 |
539 | 51 // TODO |
52 // 今はとりあえず camera を Root にしています | |
53 // 今はそれすらもしてません | |
54 //sg_exec_tree = camera; | |
55 } | |
56 | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
57 |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
58 SceneGraphRoot::~SceneGraphRoot() |
539 | 59 { |
60 SceneGraphPtr p = sg_available_list; | |
61 | |
62 while (p) { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
63 SceneGraphPtr tmp = p->next; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
64 delete p; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
65 p = tmp; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
66 cnt--; |
539 | 67 } |
68 | |
69 p = sg_remove_list; | |
70 | |
71 while (p) { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
72 SceneGraphPtr tmp = p->next; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
73 delete p; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
74 p = tmp; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
75 cnt--; |
539 | 76 } |
77 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
78 free(sg_src); |
539 | 79 delete camera; |
761 | 80 int light_num = 4; |
81 for (int i = 0; i < light_num; i++) { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
82 delete light[i]; |
761 | 83 } |
539 | 84 delete iterator; |
85 delete controller; | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
86 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
87 if (gtask_array != NULL) { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
88 delete gtask_array; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
89 } |
539 | 90 } |
91 | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
92 void |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
93 SceneGraphRoot::light_init() |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
94 { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
95 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
96 int light_num = 4; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
97 light_sysswitch = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
98 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
99 for (int i = 0; i < light_num; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
100 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
101 light[i] = new SceneGraph(sgroot->tmanager); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
102 light[i]->xyz[0] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
103 light[i]->xyz[1] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
104 light[i]->xyz[2] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
105 light[i]->xyz[3] = 1.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
106 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
107 light_switch[i] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
108 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
109 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
110 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
111 for (int i = 0; i < 4; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
112 light_vector[i*4] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
113 light_vector[i*4+1] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
114 light_vector[i*4+2] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
115 light_vector[i*4+3] = 1.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
116 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
117 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
118 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
119 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
120 |
539 | 121 /** |
122 * xml ファイルから生成された SceneGraph を sg_src に登録する。 | |
123 * | |
124 * @param sg SceneGraph created by xmlfile | |
125 */ | |
126 void | |
127 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) | |
128 { | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
129 int dup; |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
130 if ((dup = getSgid(sg->name))>=0) { // while... |
576 | 131 sg_src[dup]->name = ""; |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
132 // we should remove this. but some one may use it... |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
133 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
134 if (sg_src_id+1> sg_src_size) { |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
135 sg_src_size *= 2; |
582 | 136 sg_src = (SceneGraphPtr*)realloc(sg_src, sg_src_size*sizeof(SceneGraphPtr)); |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
137 } |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
138 sg->sgid = ++sg_src_id; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
139 sg_src[sg->sgid] = sg; |
1114 | 140 sgid_hash.sg_hash_regist((const char*)sg->name, sg->sgid); |
539 | 141 } |
142 | |
848 | 143 |
539 | 144 void |
145 SceneGraphRoot::addNext(SceneGraphPtr sg) | |
146 { | |
147 SceneGraphPtr last = sg_available_list; | |
148 | |
149 if (!last) { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
150 sg_available_list = sg; |
539 | 151 } else { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
152 while (last->next) { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
153 last = last->next; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
154 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
155 last->next = sg; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
156 sg->prev = last; |
539 | 157 } |
158 | |
159 cnt++; | |
160 } | |
161 | |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
162 /*文字列の生成*/ |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
163 void |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
164 SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root, |
1211 | 165 const char *string,int pixels,int screen_w, |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
166 int screen_h,Uint32 color) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
167 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
168 SceneGraphPtr text; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
169 float width_shift = 0; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
170 int i; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
171 int length = strlen(string); |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
172 for (i = 0; i < length;) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
173 int len = 0; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
174 unsigned char initial = string[i]; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
175 while (1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
176 unsigned char mask = 0x80; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
177 if (mask & initial) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
178 len++; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
179 } else { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
180 if (len == 0) len++; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
181 break; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
182 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
183 initial <<= 1; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
184 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
185 char *obj_name; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
186 float scale[] = {1,1,1}; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
187 sgroot->createFont(manager,"/Library/Fonts/Osaka.ttf", pixels, color, &string[i], len, &obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
188 text = sgroot->createSceneGraph(obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
189 text->xyz[0] = screen_w/2 + width_shift -100; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
190 text->xyz[1] = screen_h/2; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
191 text->xyz[2] = -100; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
192 width_shift += text->seq; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
193 root->addChild(text); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
194 get_matrix_scale(text->matrix, text->angle, text->xyz, scale, root->matrix); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
195 i += len; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
196 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
197 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
198 |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
199 void |
1211 | 200 SceneGraphRoot::createFont(TaskManager *manager,const char *font, int pixels, |
201 Uint32 color,const char *string_name, int len, | |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
202 char **obj_name) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
203 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
204 *obj_name = (char *)malloc(sizeof(char) * 12); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
205 char sname[] = "char:"; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
206 memcpy(*obj_name, sname, 5); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
207 memcpy(*obj_name + 5, string_name, len); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
208 (*obj_name)[5+len] = '\0'; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
209 printf("%d",sgid_hash.get_sgid(*obj_name)); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
210 if (sgid_hash.get_sgid(*obj_name) != -1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
211 return; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
212 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
213 SceneGraphPtr tmp = new SceneGraph(manager, font, pixels, color, |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
214 *obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
215 registSceneGraph(tmp); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
216 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
217 |
539 | 218 /* XMLファイルからポリゴンを作成 */ |
219 void | |
220 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) | |
221 { | |
222 xmlDocPtr doc; | |
223 xmlNodePtr cur; | |
224 SceneGraphPtr tmp; | |
562 | 225 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
226 /* パース DOM生成 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
227 xmlParseFile:ファイルに含まれるXML文書を分析する |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
228 xmlDocGetRootElement:ドキュメントルートを指定する。 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
229 よって、以下のcurにはドキュメントルートの位置が入っている |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
230 */ |
539 | 231 doc = xmlParseFile(xmlfile); |
232 cur = xmlDocGetRootElement(doc); | |
233 | |
234 /* ?? */ | |
235 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); | |
236 | |
237 /* XMLのノードを一つずつ解析 */ | |
238 for (cur=cur->children; cur; cur=cur->next) { | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
239 /*初期化:curをドキュメントルートの一個下に設定 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
240 継続条件:curが真である |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
241 再初期化:次のノードへ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
242 */ |
539 | 243 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
244 /* 扱うのはsurfaceオンリーなので、ノードの名前がsurfaceでないなら |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
245 以下の処理を行なわずにスキップする |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
246 */ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
247 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
248 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
249 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
250 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
251 /* ポリゴン(SceneGraph)生成 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
252 SceneGraph:SceneGraph.cc、L186 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
253 */ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
254 tmp = new SceneGraph(manager, cur); |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
255 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
256 //シーングラフを登録 |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
257 registSceneGraph(tmp); |
539 | 258 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
259 //解放 |
539 | 260 xmlFreeDoc(doc); |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
261 } |
562 | 262 |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
263 /*static const char* |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
264 get_property(const char *name, xmlNodePtr cur){ |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
265 xmlAttr *p=cur->properties; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
266 if (p==0) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
267 for ( ;p; p=p->next) { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
268 if ( xmlStrcmp(p->name, (xmlChar*)name) !=0 ) { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
269 xmlNode* n=p->children; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
270 if ( n==NULL ) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
271 const char * v=(const char*)n->content; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
272 if ( v==NULL ) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
273 return v; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
274 } |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
275 } |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
276 return ""; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
277 }*/ |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
278 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
279 typedef struct source { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
280 char *id; |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
281 union { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
282 float *array; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
283 char *alias; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
284 }u; |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
285 int count; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
286 struct source *next; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
287 } SOURCE; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
288 typedef SOURCE *SOURCE_P; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
289 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
290 typedef struct list { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
291 SOURCE_P first; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
292 SOURCE_P end; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
293 } LIST; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
294 typedef LIST *LIST_P; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
295 |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
296 /* add source list */ |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
297 static void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
298 addSource(LIST_P list, SOURCE_P src) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
299 if (list->first == NULL && list->end == NULL) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
300 list->first = list->end = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
301 return; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
302 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
303 list->end->next = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
304 list->end = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
305 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
306 |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
307 /* compare a with b. Using to compare id */ |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
308 static int |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
309 strcmp_a(const char *a, const char *b) |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
310 { |
1313
857d3feaeb75
collada file reader minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1308
diff
changeset
|
311 while (*a && *a++ == *b++); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
312 if (*a) return 0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
313 return a[-1] > b[-1] ? 1:-1; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
314 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
315 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
316 static float |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
317 get_point(char *id, int position, LIST_P list) |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
318 { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
319 SOURCE_P cur = list->first; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
320 for (;cur ; cur=cur->next) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
321 if (!strcmp_a(id, cur->id)) { |
1313
857d3feaeb75
collada file reader minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1308
diff
changeset
|
322 if (list->count == 0) //alias |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
323 return get_point(list->u.alias, position, list); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
324 float *a = cur->u.array; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
325 if (position <= list->count) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
326 return a[position]; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
327 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
328 } |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
329 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
330 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
331 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
332 static SOURCE |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
333 must_mach_id(const char *id_1 ,const char *id_2) |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
334 { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
335 int tmplength; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
336 char *tmpsrc; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
337 for (int strlength=0;normal_id[i+1]==cur->id[i];str_length++); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
338 if (tmplength < strlength) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
339 tmplength = strlength; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
340 tmpsrc = cur; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
341 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
342 return cur; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
343 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
344 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
345 static int polylist=0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
346 static const char *polylist_normal=0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
347 static const char *polylist_vertex=0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
348 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
349 |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
350 static void |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
351 xml_walk(SceneGraphRoot* self, xmlNodePtr cur, LIST_P list) |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
352 { |
1297 | 353 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
354 int in_polylist=0; |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
355 |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
356 printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
357 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
358 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
359 if (!xmlStrcmp(cur->name, (xmlChar*)"polylist")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
360 int polylist_count = atoi((char*)xmlGetProp(cur, (xmlChar*)"source")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
361 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
362 polylist=1; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
363 in_polylist=1; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
364 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
365 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
366 if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
367 char *vertices_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
368 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
369 char *pid = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
370 float *vcount = malloc(sizeof(int)*count); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
371 float *pcount = malloc(sizeof(float)*sum); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
372 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
373 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
374 } |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
375 if (polylist && !xmlStrcmp(cur->name, (xmlChar*)"input") { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
376 char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
377 if (semantic == "VERTEX") { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
378 char *vertex_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
379 int vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
380 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
381 if (vertex_src == pid) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
382 SOURCE *vertex_float = must_mach_id(vertices_src, pid) |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
383 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
384 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
385 } |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
386 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
387 if (semantic == "NORMAL") { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
388 char *normal_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
389 int normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
390 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
391 SOURCE *normal_float = must_mach_id(normal_src, cur->id); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
392 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
393 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
394 /* |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
395 if (semantic == "TEXCOORD") { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
396 char *normal_src = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
397 int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
398 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
399 */ |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
400 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
401 if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
402 char *vcont = (char*)xmlNodeGetContent(cur); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
403 for (int i=0; vcount!=NULL; i++) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
404 vcont = pickup_float(vcont, vcount+i); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
405 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
406 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
407 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
408 if (!xmlStrcmp(cur->name, (xmlChar*)"p")) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
409 char *pcont = (char*)xmlNodeGetContent(cur); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
410 for (int i=0; pcont != NULL; i++) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
411 pcont = pickup_float(pcont, pcount+i); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
412 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
413 } |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
414 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
415 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
416 get_point(pid, , cur); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
417 |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
418 int vertexp[]; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
419 int normalp[]; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
420 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
421 float *vertex_table; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
422 float *normal_table; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
423 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
424 for (int i = 0; i<polylist_count; i++) { |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
425 vertexp[i] = pcount[2*i]; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
426 normalp[i] = pcount[2*i+1]; |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
427 } |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
428 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
429 for (int i=0; ;i++) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
430 for (int j=0 ; j > vcont[i] ;j++) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
431 if (vcount[i] == 4) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
432 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
433 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
434 |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
435 } else if (vcount[i] == 3) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
436 vertex_table[i] = vertex; |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
437 |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
438 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
439 } |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
440 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
441 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
442 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
443 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
444 } |
1313
857d3feaeb75
collada file reader minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1308
diff
changeset
|
445 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
446 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
447 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
448 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
449 SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE)); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
450 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
451 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
452 src->id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
453 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
454 int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
455 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
456 src->array = (float*)malloc(sizeof(float) * src->count); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
457 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
458 char *cont =(char*)xmlNodeGetContent(cur); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
459 //const char *id = get_property("id", cur); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
460 //int count = atoi(get_property("count", cur)); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
461 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
462 for (int i = 0; cont != NULL; i++) { |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
463 cont = pickup_float(cont, src->array+i); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
464 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
465 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
466 src->next = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
467 addSource(list, src); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
468 printf("id:%s count:%d cont:%s\n", id, count, cont); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
469 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
470 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
471 /* |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
472 if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") { |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
473 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
474 char *pid = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
475 float *vcount = malloc(sizeof(int)*count); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
476 float *pcount = malloc(sizeof(float)*sum); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
477 |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
478 if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { |
1308
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
479 char *vcont = (char*)xmlNodeGetContent(cur); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
480 for (int i=0; vcount!=NULL; i++) { |
1308
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
481 vcont = pickup_float(vcont, vcount+i); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
482 } |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
483 } |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
484 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
485 if (!xmlStrcmp(cur->name, (xmlChar*)"p")) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
486 char *pcont = (char*)xmlNodeGetContent(cur); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
487 for (int i=0; pcont != NULL; i++) { |
1308
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
488 pcont = pickup_float(pcont, pcount+i); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
489 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
490 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
491 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
492 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
493 |
1308
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
494 get_point(pid, , cur); |
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
495 |
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
496 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
497 for (SOURCE *iliner = list->first; list->end != iliner; iliner = iliner->next) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
498 if (!strcmp_a(pid, iliner->id)) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
499 if (vcount == 4) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
500 |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
501 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
502 } else if (vcount == 3) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
503 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
504 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
505 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
506 } |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
507 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
508 */ |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
509 |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
510 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
511 for (cur=cur->children; cur; cur=cur->next){ |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
512 xml_walk(self, cur, list); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
513 } |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
514 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
515 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
516 void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
517 init_list(LIST_P list) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
518 list->first = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
519 list->end = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
520 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
521 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
522 void |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
523 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
524 { |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
525 /*make parse dom*/ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
526 xmlDocPtr doc; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
527 xmlNodePtr cur; |
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
528 //,cur_images,cur_effects,cur_geometries,cur_visual_scenes; |
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
529 //SceneGraphPtr tmp; |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
530 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
531 doc = xmlParseFile(xmlColladafile); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
532 cur = xmlDocGetRootElement(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
533 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
534 /*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/ |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
535 if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){ |
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
536 return ; |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
537 } |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
538 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
539 /* node analyze */ |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
540 for(cur=cur->children; cur; cur=cur->next){ |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
541 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
542 LIST list; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
543 init_list(&list); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
544 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
545 xml_walk(this, cur, &list); |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
546 /* if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
547 cur_images = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
548 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
549 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
550 if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
551 cur_effects = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
552 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
553 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
554 if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
555 cur_geometries = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
556 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
557 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
558 if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
559 cur_visual_scenes = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
560 continue; |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
561 }*/ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
562 |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
563 //tmp = new SceneGraph(manager, cur); |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
564 //registSceneGraph(tmp); |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
565 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
566 xmlFreeDoc(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
567 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
568 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
569 void |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
570 SceneGraphRoot::createFromXMLmemory(TaskManager *manager, SceneGraph *node, char *data, int len) |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
571 { |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
572 xmlDocPtr doc; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
573 xmlNodePtr cur; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
574 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
575 // size は取れるはず、テスト用に mmap したデータを使う |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
576 /* パース DOM生成 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
577 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
578 doc = xmlParseMemory(data, len); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
579 cur = xmlDocGetRootElement(doc); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
580 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
581 /* ?? */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
582 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
583 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
584 /* XMLのノードを一つずつ解析 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
585 for (cur=cur->children; cur; cur=cur->next) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
586 /* 扱うのはsurfaceオンリー */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
587 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
588 continue; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
589 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
590 /* ポリゴン(SceneGraph)生成 */ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
591 SceneGraphPtr original = new SceneGraph(manager, cur); |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
592 registSceneGraph(original); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
593 SceneGraphPtr clone = createSceneGraph(original->sgid); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
594 node->addChild(clone); |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
595 } |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
596 xmlFreeDoc(doc); |
539 | 597 } |
598 | |
599 SceneGraphPtr | |
600 SceneGraphRoot::createSceneGraph(int id) | |
601 { | |
602 SceneGraphPtr src; | |
603 SceneGraphPtr p; | |
604 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
605 if (id < 0 || id > sg_src_size) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
606 printf("error: createSceneGraph(int id): id not found.\n"); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
607 return NULL; |
539 | 608 } |
609 | |
610 /* オリジナルの SceneGraph */ | |
562 | 611 src = sg_src[id]; |
539 | 612 |
613 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 614 p = src->clone(this->tmanager); |
539 | 615 |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
616 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/ |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
617 p->sgroot = (void *)this; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
618 |
539 | 619 addNext(p); |
620 | |
621 return p; | |
622 } | |
623 | |
562 | 624 |
625 | |
626 | |
627 SceneGraphPtr | |
628 SceneGraphRoot::createSceneGraph(const char *name) | |
629 { | |
630 SceneGraphPtr src; | |
631 SceneGraphPtr p; | |
632 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
633 int id = getSgid(name); |
562 | 634 if (id < 0) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
635 printf("error: createSceneGraph(name): name object not found.\n"); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
636 return NULL; |
562 | 637 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
638 |
562 | 639 /* オリジナルの SceneGraph */ |
640 src = sg_src[id]; | |
641 | |
642 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 643 p = src->clone(this->tmanager); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
644 |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
645 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/ |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
646 p->sgroot = (void *)this; |
562 | 647 |
648 addNext(p); | |
649 | |
650 return p; | |
651 } | |
652 | |
653 int | |
654 SceneGraphRoot::getSgid(const char *name) | |
655 { | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
656 return sgid_hash.get_sgid(name); |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
657 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
658 |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
659 int |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
660 SceneGraphRoot::getLast() |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
661 { |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
662 if (sg_src_id>=0) |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
663 return sg_src[sg_src_id]->sgid; |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
664 return -1; |
562 | 665 } |
666 | |
539 | 667 /** |
668 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
669 * いずれ、Transform3D 的なものに回す予定 | |
670 */ | |
671 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
672 SceneGraphRoot::createSceneGraph() |
539 | 673 { |
1143 | 674 SceneGraphPtr p = new SceneGraph(sgroot->tmanager); |
539 | 675 |
653
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
676 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/ |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
677 p->sgroot = (void *)this; |
7a311860a76e
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
678 |
539 | 679 addNext(p); |
680 p->flag_drawable = 0; | |
681 | |
682 return p; | |
683 } | |
684 | |
685 | |
686 void | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
687 SceneGraphRoot::lightCalc() |
539 | 688 { |
761 | 689 int light_num = 4; |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
690 float light_vector_tmp[16]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
691 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
692 for (int i = 0; i < 4; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
693 light_vector_tmp[i*4] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
694 light_vector_tmp[i*4+1] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
695 light_vector_tmp[i*4+2] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
696 light_vector_tmp[i*4+3] = 1.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
697 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
698 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
699 |
761 | 700 for (int i = 0; i < light_num; i++) { |
747 | 701 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
702 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
703 ApplyMatrix(&light_vector_tmp[i*4], light[i]->matrix); |
747 | 704 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
705 light_vector_tmp[i*4] /= light_vector_tmp[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
706 light_vector_tmp[i*4+1] /= light_vector_tmp[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
707 light_vector_tmp[i*4+2] /= light_vector_tmp[i*4+3]; |
747 | 708 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
709 /*SIMD演算のため*/ |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
710 light_vector_tmp[i*4+2] *= -1; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
711 light_vector_tmp[i*4+3] *= -1; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
712 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
713 for (int i = 0; i < 4; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
714 light_vector[i*4] = light_vector_tmp[i*4]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
715 light_vector[i*4+1] = light_vector_tmp[i*4+1]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
716 light_vector[i*4+2] = light_vector_tmp[i*4+2]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
717 light_vector[i*4+3] = light_vector_tmp[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
718 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
719 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
720 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
721 |
764 | 722 |
761 | 723 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
724 } |
761 | 725 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
726 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
727 SceneGraphRoot::flip() |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
728 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
729 // 前フレームで描画した SceneGraph は削除 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
730 allRemove(sg_remove_list); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
731 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
732 // 前フレームに作られた SceneGraph は描画用に移行 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
733 // 現フレームでの操作は以下の tree,list には適用されない |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
734 sg_draw_tree = sg_exec_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
735 sg_remove_list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
736 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
737 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
738 sg_exec_tree = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
739 sg_available_list = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
740 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
741 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
742 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
743 SceneGraphRoot::allExecute(int screen_w, int screen_h) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
744 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
745 SceneGraphPtr list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
746 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
747 flip(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
748 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
749 camera->move_execute(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
750 camera->update(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
751 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
752 camera->children = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
753 camera->lastChild = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
754 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
755 /*まずは全部動作させる*/ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
756 while (list) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
757 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
758 list->move_execute(screen_w, screen_h); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
759 list->collision_check(screen_w, screen_h, list); |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
760 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
761 list->frame++; |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
762 list = list->next; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
763 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
764 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
765 lightCalc(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
766 |
539 | 767 if(sg_exec_tree != NULL) { |
758 | 768 return; |
539 | 769 } |
770 | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
771 /* ここで、scenegraph node の matrix に演算する座標変換は、 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
772 * world->view->perspective まで。 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
773 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
774 * CreatePolygonFromSceneGraph で perspective の座標系で lighting の演算を行い、その後 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
775 * screen 変換をするので。 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
776 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
777 * その際に、camera がもつ screen matrix を Task に渡す必要がある |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
778 * Task に screen matrix を渡す部分は viewer.cc にある |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
779 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
780 * world 変換は node が持つ matrix で行う |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
781 * view->perspective 変換は camera が持つ matrix で行う |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
782 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
783 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
784 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
785 * (w) = world matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
786 * (v) = view matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
787 * (p) = perspective matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
788 * (s) = screen matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
789 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
790 * --- copyTree --- |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
791 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
792 * node->(wvp) = node->(w) * node->parent->(w) * ..... camera->(v) * camera->(p) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
793 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
794 * --- CreatePolygonFromSceneGraph --- |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
795 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
796 * (polygon_vertex) * node->(wvp) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
797 * (light_position) * node->(wvp) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
798 * (normal_vector) * normal_matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
799 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
800 * lighting(polygon_vertex, light_position, normal_vector) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
801 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
802 * (polygon_vertex) * camera->(s) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
803 */ |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
804 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
805 matrix4x4(camera->matrix, camera->m_view, camera->m_pers); |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
806 copyTree(sg_draw_tree, camera); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
807 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
808 // 現在、allExecute が終わった時点では |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
809 // camera->children が User SceneGraph の root になる |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
810 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
811 /** |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
812 * NULL じゃなかったら、setSceneData が呼ばれてるから |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
813 * そっちを次の Scene にする |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
814 */ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
815 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
816 sg_exec_tree = camera->children; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
817 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
818 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
819 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
820 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
821 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
822 // SceneGraphPtr t = sg_draw_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
823 |
539 | 824 /*removeのflagをもとにtreeを形成*/ |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
825 |
539 | 826 while (t) { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
827 SceneGraphPtr c = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
828 if (!t->isRemoved()) { |
1136 | 829 c = t->clone(this->tmanager); |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
830 addNext(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
831 cur_parent->addChild(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
832 c->frame = t->frame; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
833 /*親の回転、座標から、子の回転、座標を算出*/ |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
834 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
835 } |
908 | 836 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
837 |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
838 if (t->children != NULL && c != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
839 cur_parent = c; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
840 t = t->children; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
841 } else if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
842 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
843 } else { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
844 while (t) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
845 if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
846 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
847 break; |
539 | 848 } else { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
849 if (t->parent == NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
850 t = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
851 break; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
852 } else { |
539 | 853 cur_parent = cur_parent->parent; |
854 t = t->parent; | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
855 } |
539 | 856 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
857 } |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
858 } |
539 | 859 } |
860 | |
861 } | |
862 | |
1254 | 863 |
864 void | |
1256 | 865 SceneGraphRoot::treeApply(int screen_w, int screen_h) |
1254 | 866 { |
867 // don't calcurate sg_draw_tree's brother | |
868 transTree(sg_draw_tree->children, camera); | |
869 } | |
870 | |
871 | |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
872 /** |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
873 * 破壊的に変換行列の親子関係を計算する |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
874 */ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
875 void |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
876 SceneGraphRoot::transTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
877 { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
878 // SceneGraphPtr t = sg_draw_tree; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
879 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
880 /*removeのflagをもとにtreeを形成*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
881 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
882 SceneGraphPtr c = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
883 if (!t->isRemoved()) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
884 /*親の回転、座標から、子の回転、座標を算出*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
885 matrix4x4(t->matrix,t->matrix,cur_parent->matrix); |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
886 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
887 if (t->children != NULL && c != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
888 cur_parent = t; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
889 t = t->children; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
890 } else if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
891 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
892 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
893 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
894 if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
895 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
896 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
897 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
898 if (t->parent == NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
899 t = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
900 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
901 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
902 cur_parent = cur_parent->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
903 t = t->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
904 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
905 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
906 } |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
907 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
908 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
909 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
910 } |
758 | 911 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
912 /* |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
913 ExecMove task の post func として呼んでやる |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
914 */ |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
915 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
916 SceneGraphRoot::move_finish() |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
917 { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
918 list->collision_check(screen_w, screen_h, list); |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
919 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
920 list->frame++; |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
921 //list = list->next; |
761 | 922 |
923 int light_num = 4; | |
924 for (int i = 0; i < light_num; i++) { | |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
925 |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
926 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
927 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
928 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
929 light_vector[i*4] /= light_vector[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
930 light_vector[i*4+1] /= light_vector[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
931 light_vector[i*4+2] /= light_vector[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
932 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
933 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
934 light_vector[i*4+2] *= -1; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
935 light_vector[i*4+3] *= -1; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
936 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
937 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
938 //sgchange->viewer->light_xyz_stock = getLightVector(); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
939 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
940 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
941 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
942 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
943 SceneGraphRoot::appTaskRegist(regist_func new_register) |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
944 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
945 this->regist = new_register; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
946 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
947 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
948 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
949 SceneGraphRoot::regist_execute() |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
950 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
951 (*regist)(this); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
952 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
953 |
758 | 954 void |
539 | 955 SceneGraphRoot::allRemove(SceneGraphPtr list) |
956 { | |
957 SceneGraphPtr p = list; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
958 |
539 | 959 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
960 SceneGraphPtr p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
961 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
962 p = p1; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
963 cnt--; |
539 | 964 } |
965 } | |
966 | |
967 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
968 SceneGraphRoot::checkRemove() |
539 | 969 { |
970 SceneGraphPtr p = sg_available_list; | |
971 SceneGraphPtr p1; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
972 |
539 | 973 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
974 p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
975 if (p->isRemoved()) { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
976 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
977 sg_available_list = p->realRemoveFromList(sg_available_list); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
978 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
979 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
980 p = p1; |
539 | 981 } |
982 } | |
983 | |
984 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
985 SceneGraphRoot::getExecuteSceneGraph() |
539 | 986 { |
987 return sg_exec_tree; | |
988 } | |
989 | |
1046 | 990 |
991 void | |
992 printSceneGraph(SceneGraphPtr t) | |
993 { | |
994 while (t) { | |
995 if (!t->isRemoved()) { | |
996 if (t->name) printf("name: %s ",t->name); | |
997 printf("x=%g y=%g z=%g\n",t->xyz[0],t->xyz[1],t->xyz[2]); | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
998 } |
1046 | 999 if (t->children != NULL) { |
1000 t = t->children; | |
1001 } else if (t->brother != NULL) { | |
1002 t = t->brother; | |
1003 } else { | |
1004 while (t) { | |
1005 if (t->brother != NULL) { | |
1006 t = t->brother; | |
1007 break; | |
1008 } else { | |
1009 if (t->parent == NULL) { | |
1010 t = NULL; | |
1011 break; | |
1012 } else { | |
1013 t = t->parent; | |
1014 } | |
1015 } | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
1016 } |
1046 | 1017 } |
1018 } | |
1019 } | |
1020 | |
539 | 1021 SceneGraphPtr |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
1022 SceneGraphRoot::getDrawSceneGraph() |
539 | 1023 { |
1024 return sg_draw_tree; | |
1025 } | |
1026 | |
1027 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
1028 SceneGraphRoot::updateControllerState() |
539 | 1029 { |
1030 controller->check(); | |
1031 } | |
1032 | |
1033 void | |
1034 SceneGraphRoot::setSceneData(SceneGraphPtr sg) | |
1035 { | |
1036 sg_exec_tree = sg; | |
1037 } | |
1038 | |
1039 Pad* | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
1040 SceneGraphRoot::getController() |
539 | 1041 { |
1042 return controller; | |
1043 } | |
1044 | |
1045 SceneGraphIteratorPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
1046 SceneGraphRoot::getIterator() |
539 | 1047 { |
1048 iterator->set(sg_remove_list); | |
1049 return iterator; | |
1050 } | |
1051 | |
1052 SceneGraphIteratorPtr | |
1053 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
1054 { | |
1055 iterator->set(list); | |
1056 return iterator; | |
1057 } | |
1058 | |
1059 CameraPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
1060 SceneGraphRoot::getCamera() |
539 | 1061 { |
1062 return camera; | |
1063 } | |
597 | 1064 |
747 | 1065 |
1066 SceneGraphPtr | |
761 | 1067 SceneGraphRoot::getLight(int id) |
597 | 1068 { |
1069 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1070 return light[id]; |
597 | 1071 |
1072 } | |
747 | 1073 |
1074 | |
1075 float* | |
1076 SceneGraphRoot::getLightVector() | |
1077 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1078 return light_vector; |
747 | 1079 } |
779 | 1080 |
792 | 1081 int* |
1082 SceneGraphRoot::getLightSwitch() | |
1083 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1084 return light_switch; |
792 | 1085 } |
1086 | |
1087 int | |
1088 SceneGraphRoot::getLightSysSwitch() | |
1089 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1090 return light_sysswitch; |
792 | 1091 } |
1092 | |
793 | 1093 void |
1094 SceneGraphRoot::OnLightSwitch(int id) | |
1095 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1096 light_switch[id] = 1; |
793 | 1097 } |
1098 | |
1099 void | |
1100 SceneGraphRoot::OffLightSwitch(int id) | |
1101 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1102 light_switch[id] = 0; |
793 | 1103 } |
1104 | |
1105 void | |
1106 SceneGraphRoot::OnLightSysSwitch() | |
1107 { | |
1108 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1109 light_sysswitch = 1; |
793 | 1110 |
1111 } | |
1112 | |
1113 void | |
1114 SceneGraphRoot::OffLightSysSwitch() | |
1115 { | |
1116 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1117 light_sysswitch = 0; |
793 | 1118 |
1119 } | |
1120 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1121 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1122 SceneGraphRoot::task_array_init(int id, int task_num, int param, int inData_num, int outData_num) |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1123 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1124 gtask_array = new GTaskArray; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1125 gtask_array->init(id, task_num, param, inData_num, outData_num); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1126 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1127 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1128 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1129 SceneGraphRoot::create_task_array() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1130 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1131 gtask_array->create_task_array(this->tmanager); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1132 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1133 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1134 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1135 SceneGraphRoot::task_array_finish() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1136 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1137 gtask_array->finish(); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1138 } |
869 | 1139 |
1140 void | |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1141 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func) |
1002 | 1142 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1143 gtask_array->next_task_array(id); |
1002 | 1144 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1145 gtask_array->game_task->set_inData(0, property, size); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1146 gtask_array->game_task->set_outData(0, property, size); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1147 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1148 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1149 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1150 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1151 SceneGraphRoot::set_gtask_array(int id, void *property, void *pad, int size, PostFunction post_func) |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1152 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1153 gtask_array->next_task_array(id); |
1002 | 1154 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1155 gtask_array->game_task->set_inData(0, property, size); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1156 gtask_array->game_task->set_inData(1, pad, sizeof(Pad)); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1157 gtask_array->game_task->set_outData(0, property, size); |
1002 | 1158 |
869 | 1159 } |
1160 | |
884 | 1161 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1162 SceneGraphRoot::set_game_task(int id, void *property, int size) |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1163 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1164 HTask *task = sgroot->tmanager->create_task(id); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1165 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1166 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1167 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1168 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1169 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1170 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1171 void |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1172 SceneGraphRoot::set_game_task(int id, void *property, void *pad, int size) |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1173 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1174 HTask *task = sgroot->tmanager->create_task(id); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1175 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1176 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1177 task->add_inData(pad, sizeof(Pad)); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1178 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1179 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1180 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1181 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1182 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1183 void |
882 | 1184 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
1185 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1186 int size = node->property_size; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1187 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1188 int move = node->move_id; |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1189 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
1006 | 1190 /* |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1191 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1192 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1193 node->xyz[1] = property->y; |
1006 | 1194 */ |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1195 sgroottmp->set_game_task(move, (void*)e, size); |
882 | 1196 } |
1197 | |
1198 void | |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1199 pad_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1200 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1201 int size = node->property_size; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1202 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1203 int move = node->move_id; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1204 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1205 void *pad = (void*)sgroottmp->getController(); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1206 |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1207 /* |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1208 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1209 property->root = node; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1210 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1211 node->xyz[1] = property->y; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1212 */ |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1213 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1214 sgroottmp->set_game_task(move, (void*)e, pad, size); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1215 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1216 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1217 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1218 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size) |
882 | 1219 { |
1220 node->move = main_task_move; | |
1221 node->move_id = move; | |
1222 node->propertyptr = property; | |
1223 node->property_size = size; | |
1224 } | |
869 | 1225 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1226 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1227 SceneGraphRoot::set_pad_task(SceneGraphPtr node, int move, void *property, int size) |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1228 { |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1229 node->move = pad_task_move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1230 node->move_id = move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1231 node->propertyptr = property; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1232 node->property_size = size; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1233 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1234 |
779 | 1235 /* end */ |