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