Mercurial > hg > Game > Cerium
annotate Renderer/Engine/SceneGraphRoot.cc @ 1308:78248082c56d draft
reading COLLADA file minor change.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 15 Dec 2011 14:28:21 +0900 |
parents | 5b1589ce972e |
children | 857d3feaeb75 |
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 { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
311 while (*a && *a++ = *b++); |
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) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
321 if (!strcmp_a(id, cur->name)) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
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 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
328 } |
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 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
332 static int polylist=0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
333 static const char *polylist_normal=0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
334 static const char *polylist_vertex=0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
335 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
336 |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
337 static void |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
338 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
|
339 { |
1297 | 340 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
341 int in_polylist=0; |
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
|
342 /*get float array.*/ |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
343 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
|
344 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
345 if (!xmlStrcmp(cur->name, (xmlChar*)"polylist")) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
346 polylist=1; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
347 in_polylist=1; |
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 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
350 if (polylist && !xmlStrcmp(cur->name, (xmlChar*)"input") { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
351 char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
352 if (!xmlStrcmp(semantic, (xmlChar*)"VERTEX") { |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
353 char *vertex_id = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
354 int *vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
355 } |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
356 |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
357 if (!xmlStrcmp(semantic, (xmlChar*)"NORMAL") { |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
358 char *normal_id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
359 int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
360 } |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
361 /* |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
362 if (!xmlStrcmp(semantic, (xmlChar*)"TEXTURE") { |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
363 char *normal_id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
364 int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
365 } |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
366 */ |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
367 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
368 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
369 |
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
|
370 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
|
371 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
372 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
|
373 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
374 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
375 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
|
376 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
377 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
|
378 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
379 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
|
380 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
381 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
|
382 //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
|
383 //int count = atoi(get_property("count", cur)); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
384 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
385 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
|
386 cont = pickup_float(cont, src->array+i); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
387 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
388 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
389 src->next = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
390 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
|
391 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
|
392 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
393 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
394 char *p = (char*)xmlNodeGetContent(cur); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
395 printf("p:%s", p); |
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
|
396 } |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
397 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
398 } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
399 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
400 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
|
401 float *vcount = malloc(sizeof(int)*count); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
402 float *pcount = malloc(sizeof(float)*sum); |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
403 |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
404 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
|
405 char *vcont = (char*)xmlNodeGetContent(cur); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
406 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
|
407 vcont = pickup_float(vcont, vcount+i); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
408 } |
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
409 } |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
410 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
411 if (!xmlStrcmp(cur->name, (xmlChar*)"p")) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
412 char *pcont = (char*)xmlNodeGetContent(cur); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
413 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
|
414 pcont = pickup_float(pcont, pcount+i); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
415 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
416 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
417 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
418 |
1308
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
419 get_point(pid, , cur); |
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
420 |
78248082c56d
reading COLLADA file minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1307
diff
changeset
|
421 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
422 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
|
423 if (!strcmp_a(pid, iliner->id)) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
424 if (vcount == 4) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
425 |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
426 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
427 } else if (vcount == 3) { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
428 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
429 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
430 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
431 } |
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
|
432 } |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
433 |
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
|
434 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
435 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
|
436 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
|
437 } |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
438 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
439 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
440 void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
441 init_list(LIST_P list) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
442 list->first = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
443 list->end = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
444 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
445 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
446 void |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
447 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
448 { |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
449 /*make parse dom*/ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
450 xmlDocPtr doc; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
451 xmlNodePtr cur; |
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
452 //,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
|
453 //SceneGraphPtr tmp; |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
454 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
455 doc = xmlParseFile(xmlColladafile); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
456 cur = xmlDocGetRootElement(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
457 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
458 /*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/ |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
459 if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){ |
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
460 return ; |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
461 } |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
462 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
463 /* node analyze */ |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
464 for(cur=cur->children; cur; cur=cur->next){ |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
465 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
466 LIST list; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
467 init_list(&list); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
468 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
469 xml_walk(this, cur, &list); |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
470 /* 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
|
471 cur_images = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
472 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
473 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
474 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
|
475 cur_effects = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
476 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
477 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
478 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
|
479 cur_geometries = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
480 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
481 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
482 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
|
483 cur_visual_scenes = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
484 continue; |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
485 }*/ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
486 |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
487 //tmp = new SceneGraph(manager, cur); |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
488 //registSceneGraph(tmp); |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
489 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
490 xmlFreeDoc(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
491 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
492 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
493 void |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
494 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
|
495 { |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
496 xmlDocPtr doc; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
497 xmlNodePtr cur; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
498 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
499 // size は取れるはず、テスト用に mmap したデータを使う |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
500 /* パース DOM生成 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
501 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
502 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
|
503 cur = xmlDocGetRootElement(doc); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
504 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
505 /* ?? */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
506 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
|
507 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
508 /* XMLのノードを一つずつ解析 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
509 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
|
510 /* 扱うのはsurfaceオンリー */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
511 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
|
512 continue; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
513 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
514 /* ポリゴン(SceneGraph)生成 */ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
515 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
|
516 registSceneGraph(original); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
517 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
|
518 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
|
519 } |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
520 xmlFreeDoc(doc); |
539 | 521 } |
522 | |
523 SceneGraphPtr | |
524 SceneGraphRoot::createSceneGraph(int id) | |
525 { | |
526 SceneGraphPtr src; | |
527 SceneGraphPtr p; | |
528 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
529 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
|
530 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
|
531 return NULL; |
539 | 532 } |
533 | |
534 /* オリジナルの SceneGraph */ | |
562 | 535 src = sg_src[id]; |
539 | 536 |
537 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 538 p = src->clone(this->tmanager); |
539 | 539 |
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
|
540 /* 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
|
541 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
|
542 |
539 | 543 addNext(p); |
544 | |
545 return p; | |
546 } | |
547 | |
562 | 548 |
549 | |
550 | |
551 SceneGraphPtr | |
552 SceneGraphRoot::createSceneGraph(const char *name) | |
553 { | |
554 SceneGraphPtr src; | |
555 SceneGraphPtr p; | |
556 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
557 int id = getSgid(name); |
562 | 558 if (id < 0) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
559 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
|
560 return NULL; |
562 | 561 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
562 |
562 | 563 /* オリジナルの SceneGraph */ |
564 src = sg_src[id]; | |
565 | |
566 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 567 p = src->clone(this->tmanager); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
568 |
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
|
569 /* 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
|
570 p->sgroot = (void *)this; |
562 | 571 |
572 addNext(p); | |
573 | |
574 return p; | |
575 } | |
576 | |
577 int | |
578 SceneGraphRoot::getSgid(const char *name) | |
579 { | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
580 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
|
581 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
582 |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
583 int |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
584 SceneGraphRoot::getLast() |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
585 { |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
586 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
|
587 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
|
588 return -1; |
562 | 589 } |
590 | |
539 | 591 /** |
592 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
593 * いずれ、Transform3D 的なものに回す予定 | |
594 */ | |
595 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
596 SceneGraphRoot::createSceneGraph() |
539 | 597 { |
1143 | 598 SceneGraphPtr p = new SceneGraph(sgroot->tmanager); |
539 | 599 |
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
|
600 /* 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
|
601 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
|
602 |
539 | 603 addNext(p); |
604 p->flag_drawable = 0; | |
605 | |
606 return p; | |
607 } | |
608 | |
609 | |
610 void | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
611 SceneGraphRoot::lightCalc() |
539 | 612 { |
761 | 613 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
|
614 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
|
615 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
622 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
623 |
761 | 624 for (int i = 0; i < light_num; i++) { |
747 | 625 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
626 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
|
627 ApplyMatrix(&light_vector_tmp[i*4], light[i]->matrix); |
747 | 628 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
629 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
|
630 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
|
631 light_vector_tmp[i*4+2] /= light_vector_tmp[i*4+3]; |
747 | 632 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
633 /*SIMD演算のため*/ |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
634 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
|
635 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
|
636 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
637 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
|
638 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
|
639 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
|
640 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
|
641 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
|
642 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
643 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
644 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
645 |
764 | 646 |
761 | 647 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
648 } |
761 | 649 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
650 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
651 SceneGraphRoot::flip() |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
652 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
653 // 前フレームで描画した SceneGraph は削除 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
654 allRemove(sg_remove_list); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
655 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
656 // 前フレームに作られた SceneGraph は描画用に移行 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
657 // 現フレームでの操作は以下の tree,list には適用されない |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
658 sg_draw_tree = sg_exec_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
659 sg_remove_list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
660 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
661 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
662 sg_exec_tree = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
663 sg_available_list = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
664 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
665 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
666 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
667 SceneGraphRoot::allExecute(int screen_w, int screen_h) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
668 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
669 SceneGraphPtr list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
670 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
671 flip(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
672 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
673 camera->move_execute(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
674 camera->update(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
675 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
676 camera->children = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
677 camera->lastChild = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
678 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
679 /*まずは全部動作させる*/ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
680 while (list) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
681 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
682 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
|
683 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
|
684 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
685 list->frame++; |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
686 list = list->next; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
687 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
688 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
689 lightCalc(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
690 |
539 | 691 if(sg_exec_tree != NULL) { |
758 | 692 return; |
539 | 693 } |
694 | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
695 /* ここで、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
|
696 * 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
|
697 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
698 * 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
|
699 * screen 変換をするので。 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
700 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
701 * その際に、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
|
702 * 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
|
703 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
704 * 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
|
705 * 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
|
706 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
707 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
708 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
709 * (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
|
710 * (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
|
711 * (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
|
712 * (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
|
713 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
714 * --- copyTree --- |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
715 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
716 * 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
|
717 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
718 * --- CreatePolygonFromSceneGraph --- |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
719 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
720 * (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
|
721 * (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
|
722 * (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
|
723 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
724 * 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
|
725 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
726 * (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
|
727 */ |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
728 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
729 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
|
730 copyTree(sg_draw_tree, camera); |
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 // 現在、allExecute が終わった時点では |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
733 // camera->children が User SceneGraph の root になる |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
734 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
735 /** |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
736 * NULL じゃなかったら、setSceneData が呼ばれてるから |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
737 * そっちを次の Scene にする |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
738 */ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
739 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
740 sg_exec_tree = camera->children; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
741 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
742 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
743 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
744 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
745 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
746 // SceneGraphPtr t = sg_draw_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
747 |
539 | 748 /*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
|
749 |
539 | 750 while (t) { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
751 SceneGraphPtr c = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
752 if (!t->isRemoved()) { |
1136 | 753 c = t->clone(this->tmanager); |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
754 addNext(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
755 cur_parent->addChild(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
756 c->frame = t->frame; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
757 /*親の回転、座標から、子の回転、座標を算出*/ |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
758 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
|
759 } |
908 | 760 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
761 |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
762 if (t->children != NULL && c != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
763 cur_parent = c; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
764 t = t->children; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
765 } else if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
766 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
767 } else { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
768 while (t) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
769 if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
770 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
771 break; |
539 | 772 } else { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
773 if (t->parent == NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
774 t = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
775 break; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
776 } else { |
539 | 777 cur_parent = cur_parent->parent; |
778 t = t->parent; | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
779 } |
539 | 780 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
781 } |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
782 } |
539 | 783 } |
784 | |
785 } | |
786 | |
1254 | 787 |
788 void | |
1256 | 789 SceneGraphRoot::treeApply(int screen_w, int screen_h) |
1254 | 790 { |
791 // don't calcurate sg_draw_tree's brother | |
792 transTree(sg_draw_tree->children, camera); | |
793 } | |
794 | |
795 | |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
796 /** |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
797 * 破壊的に変換行列の親子関係を計算する |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
798 */ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
799 void |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
800 SceneGraphRoot::transTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
801 { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
802 // SceneGraphPtr t = sg_draw_tree; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
803 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
804 /*removeのflagをもとにtreeを形成*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
805 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
806 SceneGraphPtr c = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
807 if (!t->isRemoved()) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
808 /*親の回転、座標から、子の回転、座標を算出*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
809 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
|
810 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
811 if (t->children != NULL && c != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
812 cur_parent = t; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
813 t = t->children; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
814 } else if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
815 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
816 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
817 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
818 if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
819 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
820 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
821 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
822 if (t->parent == NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
823 t = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
824 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
825 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
826 cur_parent = cur_parent->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
827 t = t->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
828 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
829 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
830 } |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
831 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
832 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
833 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
834 } |
758 | 835 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
836 /* |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
837 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
|
838 */ |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
839 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
840 SceneGraphRoot::move_finish() |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
841 { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
842 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
|
843 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
844 list->frame++; |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
845 //list = list->next; |
761 | 846 |
847 int light_num = 4; | |
848 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
|
849 |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
850 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
|
851 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
|
852 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
853 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
|
854 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
|
855 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
|
856 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
857 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
858 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
|
859 light_vector[i*4+3] *= -1; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
860 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
861 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
862 //sgchange->viewer->light_xyz_stock = getLightVector(); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
863 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
864 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
865 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
866 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
867 SceneGraphRoot::appTaskRegist(regist_func new_register) |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
868 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
869 this->regist = new_register; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
870 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
871 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
872 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
873 SceneGraphRoot::regist_execute() |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
874 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
875 (*regist)(this); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
876 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
877 |
758 | 878 void |
539 | 879 SceneGraphRoot::allRemove(SceneGraphPtr list) |
880 { | |
881 SceneGraphPtr p = list; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
882 |
539 | 883 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
884 SceneGraphPtr p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
885 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
886 p = p1; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
887 cnt--; |
539 | 888 } |
889 } | |
890 | |
891 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
892 SceneGraphRoot::checkRemove() |
539 | 893 { |
894 SceneGraphPtr p = sg_available_list; | |
895 SceneGraphPtr p1; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
896 |
539 | 897 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
898 p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
899 if (p->isRemoved()) { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
900 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
901 sg_available_list = p->realRemoveFromList(sg_available_list); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
902 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
903 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
904 p = p1; |
539 | 905 } |
906 } | |
907 | |
908 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
909 SceneGraphRoot::getExecuteSceneGraph() |
539 | 910 { |
911 return sg_exec_tree; | |
912 } | |
913 | |
1046 | 914 |
915 void | |
916 printSceneGraph(SceneGraphPtr t) | |
917 { | |
918 while (t) { | |
919 if (!t->isRemoved()) { | |
920 if (t->name) printf("name: %s ",t->name); | |
921 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
|
922 } |
1046 | 923 if (t->children != NULL) { |
924 t = t->children; | |
925 } else if (t->brother != NULL) { | |
926 t = t->brother; | |
927 } else { | |
928 while (t) { | |
929 if (t->brother != NULL) { | |
930 t = t->brother; | |
931 break; | |
932 } else { | |
933 if (t->parent == NULL) { | |
934 t = NULL; | |
935 break; | |
936 } else { | |
937 t = t->parent; | |
938 } | |
939 } | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
940 } |
1046 | 941 } |
942 } | |
943 } | |
944 | |
539 | 945 SceneGraphPtr |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
946 SceneGraphRoot::getDrawSceneGraph() |
539 | 947 { |
948 return sg_draw_tree; | |
949 } | |
950 | |
951 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
952 SceneGraphRoot::updateControllerState() |
539 | 953 { |
954 controller->check(); | |
955 } | |
956 | |
957 void | |
958 SceneGraphRoot::setSceneData(SceneGraphPtr sg) | |
959 { | |
960 sg_exec_tree = sg; | |
961 } | |
962 | |
963 Pad* | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
964 SceneGraphRoot::getController() |
539 | 965 { |
966 return controller; | |
967 } | |
968 | |
969 SceneGraphIteratorPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
970 SceneGraphRoot::getIterator() |
539 | 971 { |
972 iterator->set(sg_remove_list); | |
973 return iterator; | |
974 } | |
975 | |
976 SceneGraphIteratorPtr | |
977 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
978 { | |
979 iterator->set(list); | |
980 return iterator; | |
981 } | |
982 | |
983 CameraPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
984 SceneGraphRoot::getCamera() |
539 | 985 { |
986 return camera; | |
987 } | |
597 | 988 |
747 | 989 |
990 SceneGraphPtr | |
761 | 991 SceneGraphRoot::getLight(int id) |
597 | 992 { |
993 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
994 return light[id]; |
597 | 995 |
996 } | |
747 | 997 |
998 | |
999 float* | |
1000 SceneGraphRoot::getLightVector() | |
1001 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1002 return light_vector; |
747 | 1003 } |
779 | 1004 |
792 | 1005 int* |
1006 SceneGraphRoot::getLightSwitch() | |
1007 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1008 return light_switch; |
792 | 1009 } |
1010 | |
1011 int | |
1012 SceneGraphRoot::getLightSysSwitch() | |
1013 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1014 return light_sysswitch; |
792 | 1015 } |
1016 | |
793 | 1017 void |
1018 SceneGraphRoot::OnLightSwitch(int id) | |
1019 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1020 light_switch[id] = 1; |
793 | 1021 } |
1022 | |
1023 void | |
1024 SceneGraphRoot::OffLightSwitch(int id) | |
1025 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1026 light_switch[id] = 0; |
793 | 1027 } |
1028 | |
1029 void | |
1030 SceneGraphRoot::OnLightSysSwitch() | |
1031 { | |
1032 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1033 light_sysswitch = 1; |
793 | 1034 |
1035 } | |
1036 | |
1037 void | |
1038 SceneGraphRoot::OffLightSysSwitch() | |
1039 { | |
1040 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1041 light_sysswitch = 0; |
793 | 1042 |
1043 } | |
1044 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1045 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1046 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
|
1047 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1048 gtask_array = new GTaskArray; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1049 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
|
1050 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1051 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1052 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1053 SceneGraphRoot::create_task_array() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1054 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1055 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
|
1056 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1057 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1058 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1059 SceneGraphRoot::task_array_finish() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1060 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1061 gtask_array->finish(); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1062 } |
869 | 1063 |
1064 void | |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1065 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func) |
1002 | 1066 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1067 gtask_array->next_task_array(id); |
1002 | 1068 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1069 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
|
1070 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
|
1071 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1072 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1073 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1074 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1075 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
|
1076 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1077 gtask_array->next_task_array(id); |
1002 | 1078 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1079 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
|
1080 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
|
1081 gtask_array->game_task->set_outData(0, property, size); |
1002 | 1082 |
869 | 1083 } |
1084 | |
884 | 1085 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1086 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
|
1087 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1088 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
|
1089 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1090 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1091 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1092 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1093 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1094 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1095 void |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1096 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
|
1097 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1098 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
|
1099 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1100 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1101 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
|
1102 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1103 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1104 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1105 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1106 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1107 void |
882 | 1108 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
1109 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1110 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
|
1111 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1112 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
|
1113 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
1006 | 1114 /* |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1115 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1116 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1117 node->xyz[1] = property->y; |
1006 | 1118 */ |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1119 sgroottmp->set_game_task(move, (void*)e, size); |
882 | 1120 } |
1121 | |
1122 void | |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1123 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
|
1124 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1125 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
|
1126 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1127 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
|
1128 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1129 void *pad = (void*)sgroottmp->getController(); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1130 |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1131 /* |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1132 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1133 property->root = node; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1134 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1135 node->xyz[1] = property->y; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1136 */ |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1137 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1138 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
|
1139 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1140 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1141 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1142 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size) |
882 | 1143 { |
1144 node->move = main_task_move; | |
1145 node->move_id = move; | |
1146 node->propertyptr = property; | |
1147 node->property_size = size; | |
1148 } | |
869 | 1149 |
969
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_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
|
1152 { |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1153 node->move = pad_task_move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1154 node->move_id = move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1155 node->propertyptr = property; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1156 node->property_size = size; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1157 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1158 |
779 | 1159 /* end */ |