annotate Renderer/Engine/SceneGraphRoot.cc @ 1299:f0e805c09ed6 draft

minor fix xml_walk and pickup_float, not work yet.
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Sun, 04 Dec 2011 18:50:53 +0900
parents bb8b7f179f31
children ab9b7d21b32b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <SDL_image.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <libxml/parser.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "SceneGraphRoot.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "xml.h"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1046
diff changeset
6 #include "matrix_calc.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "TextureHash.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "texture.h"
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
9 #include "Application.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
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
ee481853d5dd SgidHash remove.
tkaito
parents: 1109
diff changeset
16
ee481853d5dd SgidHash remove.
tkaito
parents: 1109
diff changeset
17 static TextureHash sgid_hash;
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
18
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
19 SceneGraphRoot *sgroot;
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
20
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
21 SceneGraphRoot::SceneGraphRoot(float w, float h, TaskManager *manager)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 {
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
23
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
24 sgroot = this;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
25 sgroot->tmanager = manager;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
26
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
27 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
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
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
31 camera = new Camera(w, h, this, sgroot->tmanager);
779
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 738 768
diff changeset
32
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 iterator = new SceneGraphIterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 controller = create_controller();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 sg_exec_tree = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 sg_draw_tree = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 sg_available_list = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 sg_remove_list = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
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
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 // TODO
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 // 今はとりあえず camera を Root にしています
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 // 今はそれすらもしてません
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 //sg_exec_tree = camera;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 SceneGraphPtr p = sg_available_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 p = sg_remove_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 delete camera;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
80 int light_num = 4;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
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
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
83 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 delete iterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 * xml ファイルから生成された SceneGraph を sg_src に登録する。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 * @param sg SceneGraph created by xmlfile
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
9b6d0da1c12d minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
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
4ee1d40823b8 fix realloc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
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
ee481853d5dd SgidHash remove.
tkaito
parents: 1109
diff changeset
140 sgid_hash.sg_hash_regist((const char*)sg->name, sg->sgid);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
848
a033d464c812 addChild fix
tkaito
parents: 845
diff changeset
143
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 SceneGraphRoot::addNext(SceneGraphPtr sg)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 SceneGraphPtr last = sg_available_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 cnt++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
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);
1254
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
195 // get_matrix(text->real_matrix, text->angle, text->xyz, root->real_matrix);
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
196 i += len;
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
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
200 void
1211
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
201 SceneGraphRoot::createFont(TaskManager *manager,const char *font, int pixels,
7763f03a94e1 const char fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1205
diff changeset
202 Uint32 color,const char *string_name, int len,
1205
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
203 char **obj_name)
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
204 {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
205 *obj_name = (char *)malloc(sizeof(char) * 12);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
206 char sname[] = "char:";
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
207 memcpy(*obj_name, sname, 5);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
208 memcpy(*obj_name + 5, string_name, len);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
209 (*obj_name)[5+len] = '\0';
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
210 printf("%d",sgid_hash.get_sgid(*obj_name));
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
211 if (sgid_hash.get_sgid(*obj_name) != -1) {
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
212 return;
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
213 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
214 SceneGraphPtr tmp = new SceneGraph(manager, font, pixels, color,
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
215 *obj_name);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
216 registSceneGraph(tmp);
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
217 }
b8adf4e95e96 add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents: 1143
diff changeset
218
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 /* XMLファイルからポリゴンを作成 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 xmlDocPtr doc;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 xmlNodePtr cur;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 SceneGraphPtr tmp;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
226
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
227 /* パース DOM生成
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
228 xmlParseFile:ファイルに含まれるXML文書を分析する
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
229 xmlDocGetRootElement:ドキュメントルートを指定する。
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
230 よって、以下のcurにはドキュメントルートの位置が入っている
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
231 */
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 doc = xmlParseFile(xmlfile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 cur = xmlDocGetRootElement(doc);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 /* ?? */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 /* XMLのノードを一つずつ解析 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 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
240 /*初期化:curをドキュメントルートの一個下に設定
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
241 継続条件:curが真である
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
242 再初期化:次のノードへ
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
243 */
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
245 /* 扱うのはsurfaceオンリーなので、ノードの名前がsurfaceでないなら
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  */
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
248 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
249 continue;
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
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
252 /* ポリゴン(SceneGraph)生成
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
253 SceneGraph:SceneGraph.cc、L186
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
254 */
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
255 tmp = new SceneGraph(manager, cur);
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
256
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
257 //シーングラフを登録
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
258 registSceneGraph(tmp);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 }
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
260 //解放
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 xmlFreeDoc(doc);
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
262 }
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
263
1289
6fc9fd03a4fd can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
264 /*static const char*
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
265 get_property(const char *name, xmlNodePtr cur){
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
266 xmlAttr *p=cur->properties;
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
267 if (p==0) return "";
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
268 for ( ;p; p=p->next) {
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
269 if ( xmlStrcmp(p->name, (xmlChar*)name) !=0 ) {
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
270 xmlNode* n=p->children;
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
271 if ( n==NULL ) return "";
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
272 const char * v=(const char*)n->content;
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
273 if ( v==NULL ) return "";
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
274 return v;
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 }
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
277 return "";
1289
6fc9fd03a4fd can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
278 }*/
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
279
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
280 typedef struct source {
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
281 char *id;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
282 int count;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
283 float *array;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
284 struct source *next;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
285 } SOURCE;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
286 typedef SOURCE *SOURCE_P;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
287
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
288 typedef struct list {
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
289 SOURCE_P first;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
290 SOURCE_P end;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
291 } LIST;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
292 typedef LIST *LIST_P;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
293
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
294 static void
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
295 addSource(LIST_P list, SOURCE_P src) {
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
296 if (list->first == NULL && list->end == NULL) {
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
297 list->first = list->end = src;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
298 return;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
299 }
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
300 list->end->next = src;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
301 list->end = src;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
302 }
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
303
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
304 static void
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
305 xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list)
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
306 {
1297
f20e6e6500db minor change
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1294
diff changeset
307
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
308 /*get float array.*/
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
309 printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children);
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
310 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
311
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
312 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
313
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
314 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id");
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
315 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
316
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
317 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
318 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count"));
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
319 src->array = (float*)malloc(sizeof(float) * src->count);
1299
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
320
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
321 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
322 //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
323 //int count = atoi(get_property("count", cur));
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
324
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
325 for (int i = 0; cont != NULL; i++) {
1299
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
326
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
327 //cont = pickup_float(cont, src->array+1);
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
328 // ここ+1じゃなくて、+iじゃない?
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
329 cont = pickup_float(cont, src->array+i);
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
330 }
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
331
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
332
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
333 src->next = NULL;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
334 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
335 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
336
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
337 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
338 char *p = (char*)xmlNodeGetContent(cur);
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
339 printf("p:%s", p);
1299
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
340 }
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
341
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
342 }
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
343
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
344 for (cur=cur->children; cur; cur=cur->next){
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
345 xml_walk(self, cur, list);
f0e805c09ed6 minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1298
diff changeset
346 }
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
347 }
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
348
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
349 void
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
350 init_list(LIST_P list) {
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
351 list->first = NULL;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
352 list->end = NULL;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
353 }
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
354
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
355 void
1251
6da91e7cbffb improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1249
diff changeset
356 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile)
1249
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
357 {
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
358 /*make parse dom*/
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
359 xmlDocPtr doc;
1289
6fc9fd03a4fd can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
360 xmlNodePtr cur;
6fc9fd03a4fd can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
361 //,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
362 //SceneGraphPtr tmp;
1249
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
363
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
364 doc = xmlParseFile(xmlColladafile);
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
365 cur = xmlDocGetRootElement(doc);
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
366
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
367 /*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/
1251
6da91e7cbffb improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1249
diff changeset
368 if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){
6da91e7cbffb improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1249
diff changeset
369 return ;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
370 };
1249
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
371
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
372 /* node analyze */
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
373 for(cur=cur->children; cur; cur=cur->next){
1249
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
374
1298
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
375 LIST list;
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
376 init_list(&list);
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
377
bb8b7f179f31 improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1297
diff changeset
378 xml_walk(this, cur, &list);
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
379 /* if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
380 cur_images = cur;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
381 continue;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
382 }
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
383 if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
384 cur_effects = cur;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
385 continue;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
386 }
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
387 if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
388 cur_geometries = cur;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
389 continue;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
390 }
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
391 if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
392 cur_visual_scenes = cur;
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
393 continue;
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
394 }*/
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
395
1284
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
396 //tmp = new SceneGraph(manager, cur);
fe598e9b7f0e improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1277
diff changeset
397 //registSceneGraph(tmp);
1249
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
398 }
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
399 xmlFreeDoc(doc);
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
400 }
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
401
fd9b7519a17b add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents: 1226
diff changeset
402 void
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
403 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
404 {
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
405 xmlDocPtr doc;
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
406 xmlNodePtr cur;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
407
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
408 // size は取れるはず、テスト用に mmap したデータを使う
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
409 /* パース DOM生成 */
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
410
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
411 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
412 cur = xmlDocGetRootElement(doc);
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
413
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
414 /* ?? */
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
415 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
416
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
417 /* XMLのノードを一つずつ解析 */
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
418 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
419 /* 扱うのはsurfaceオンリー */
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
420 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
421 continue;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
422 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
423 /* ポリゴン(SceneGraph)生成 */
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
424 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
425 registSceneGraph(original);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
426 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
427 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
428 }
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
429 xmlFreeDoc(doc);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 SceneGraphRoot::createSceneGraph(int id)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 SceneGraphPtr src;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 SceneGraphPtr p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
438 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
439 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
440 return NULL;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 /* オリジナルの SceneGraph */
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
444 src = sg_src[id];
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 /* ユーザーにはオリジナルの clone を返す */
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1122
diff changeset
447 p = src->clone(this->tmanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448
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
449 /* 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
450 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
451
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 addNext(p);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 return p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
457
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
458
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
459
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
460 SceneGraphPtr
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
461 SceneGraphRoot::createSceneGraph(const char *name)
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
462 {
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
463 SceneGraphPtr src;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
464 SceneGraphPtr p;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
465
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
466 int id = getSgid(name);
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
467 if (id < 0) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
468 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
469 return NULL;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
470 }
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
471
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
472 /* オリジナルの SceneGraph */
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
473 src = sg_src[id];
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
474
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
475 /* ユーザーにはオリジナルの clone を返す */
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1122
diff changeset
476 p = src->clone(this->tmanager);
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
477
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
478 /* 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
479 p->sgroot = (void *)this;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
480
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
481 addNext(p);
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
482
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
483 return p;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
484 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
485
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
486 int
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
487 SceneGraphRoot::getSgid(const char *name)
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
488 {
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
489 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
490 }
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
491
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
492 int
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
493 SceneGraphRoot::getLast()
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
494 {
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
495 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
496 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
497 return -1;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
498 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
499
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 * 何も表示しない、move,collision もしない SceneGraph を生成
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 * いずれ、Transform3D 的なものに回す予定
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 SceneGraphPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
505 SceneGraphRoot::createSceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 {
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
507 SceneGraphPtr p = new SceneGraph(sgroot->tmanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
508
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
509 /* 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
510 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
511
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 addNext(p);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 p->flag_drawable = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
514
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 return p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
517
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
518
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 void
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
520 SceneGraphRoot::lightCalc()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 {
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
522 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
523 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
524
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
525 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
526 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
527 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
528 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
529 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
530 }
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
531
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
532
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
533 for (int i = 0; i < light_num; i++) {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
534
1292
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
535 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
536 ApplyMatrix(&light_vector_tmp[i*4], light[i]->matrix);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
537
1292
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
538 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
539 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
540 light_vector_tmp[i*4+2] /= light_vector_tmp[i*4+3];
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
541
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
542 /*SIMD演算のため*/
1292
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
543 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
544 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
545
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
546 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
547 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
548 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
549 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
550 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
551 }
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
552
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
553
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
554
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 763
diff changeset
555
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
556 }
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
557 }
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
558
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
559 void
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
560 SceneGraphRoot::flip()
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
561 {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
562 // 前フレームで描画した SceneGraph は削除
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
563 allRemove(sg_remove_list);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
564
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
565 // 前フレームに作られた SceneGraph は描画用に移行
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
566 // 現フレームでの操作は以下の tree,list には適用されない
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
567 sg_draw_tree = sg_exec_tree;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
568 sg_remove_list = sg_available_list;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
569
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
570 // 現フレームで新しく SceneGraph がコピーされるので初期化
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
571 sg_exec_tree = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
572 sg_available_list = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
573 }
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
574
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
575 void
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
576 SceneGraphRoot::allExecute(int screen_w, int screen_h)
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
577 {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
578 SceneGraphPtr list = sg_available_list;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
579
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
580 flip();
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
581
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
582 camera->move_execute(screen_w, screen_h);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
583 camera->update(screen_w, screen_h);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
584
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
585 camera->children = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
586 camera->lastChild = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
587
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
588 /*まずは全部動作させる*/
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
589 while (list) {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
590
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
591 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
592 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
593
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
594 list->frame++;
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
595 list = list->next;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
596 }
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
597
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
598 lightCalc();
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
599
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 if(sg_exec_tree != NULL) {
758
77f936380930 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 751
diff changeset
601 return;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
604 copyTree(sg_draw_tree, camera);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
605
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
606 // 現在、allExecute が終わった時点では
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
607 // camera->children が User SceneGraph の root になる
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
608
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
609 /**
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
610 * NULL じゃなかったら、setSceneData が呼ばれてるから
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
611 * そっちを次の Scene にする
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
612 */
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
613
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
614 sg_exec_tree = camera->children;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
615 }
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
616
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
617 void
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
618 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent)
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
619 {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
620 // SceneGraphPtr t = sg_draw_tree;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
621
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 /*removeのflagをもとにtreeを形成*/
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 while (t) {
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
624 SceneGraphPtr c = NULL;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
625 if (!t->isRemoved()) {
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1122
diff changeset
626 c = t->clone(this->tmanager);
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
627 addNext(c);
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
628 cur_parent->addChild(c);
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
629 c->frame = t->frame;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
630 /*親の回転、座標から、子の回転、座標を算出*/
1094
f10ec9bbd3f6 separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
631 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
632 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
1292
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
633 get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 793
diff changeset
634 //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
908
Yutaka_Kinjyo
parents: 884
diff changeset
635
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
636 }
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
637
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
638 if (t->children != NULL && c != NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
639 cur_parent = c;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
640 t = t->children;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
641 } else if (t->brother != NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
642 t = t->brother;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
643 } else {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
644 while (t) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
645 if (t->brother != NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
646 t = t->brother;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
647 break;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 } else {
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
649 if (t->parent == NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
650 t = NULL;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
651 break;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
652 } else {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 cur_parent = cur_parent->parent;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 t = t->parent;
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
655 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 }
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
657 }
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
658 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662
1254
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
663
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
664 void
1256
880f989ce52a fix rsync
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1255
diff changeset
665 SceneGraphRoot::treeApply(int screen_w, int screen_h)
1254
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
666 {
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
667 // don't calcurate sg_draw_tree's brother
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
668 transTree(sg_draw_tree->children, camera);
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
669 }
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
670
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
671
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
672 /**
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
673 * 破壊的に変換行列の親子関係を計算する
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
674 */
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
675 void
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
676 SceneGraphRoot::transTree(SceneGraphPtr t, SceneGraphPtr cur_parent)
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
677 {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
678 // SceneGraphPtr t = sg_draw_tree;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
679
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
680 /*removeのflagをもとにtreeを形成*/
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
681 while (t) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
682 SceneGraphPtr c = NULL;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
683 if (!t->isRemoved()) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
684 /*親の回転、座標から、子の回転、座標を算出*/
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
685 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
686 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
1254
34944900f266 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
687 // matrix4x4(t->real_matrix,t->real_matrix,cur_parent->real_matrix);
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
688 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
689 if (t->children != NULL && c != NULL) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
690 cur_parent = t;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
691 t = t->children;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
692 } else if (t->brother != NULL) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
693 t = t->brother;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
694 } else {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
695 while (t) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
696 if (t->brother != NULL) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
697 t = t->brother;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
698 break;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
699 } else {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
700 if (t->parent == NULL) {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
701 t = NULL;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
702 break;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
703 } else {
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
704 cur_parent = cur_parent->parent;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
705 t = t->parent;
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
706 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
707 }
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
708 }
1226
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
709 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
710 }
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
711
636dfdc30176 new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1211
diff changeset
712 }
758
77f936380930 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 751
diff changeset
713
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
714 /*
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
715 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
716 */
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
717 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
718 SceneGraphRoot::move_finish()
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
719 {
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
720 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
721
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
722 list->frame++;
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
723 //list = list->next;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
724
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
725 int light_num = 4;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
726 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
727
1094
f10ec9bbd3f6 separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
728 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
729 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
730
1292
90efd2aac2cb add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1284
diff changeset
731 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
732 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
733 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
734
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
735
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
736 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
737 light_vector[i*4+3] *= -1;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
738 }
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
739
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
740 //sgchange->viewer->light_xyz_stock = getLightVector();
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
741 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
742
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
743
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
744 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
745 SceneGraphRoot::appTaskRegist(regist_func new_register)
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
746 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
747 this->regist = new_register;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
748 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
749
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
750 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
751 SceneGraphRoot::regist_execute()
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
752 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
753 (*regist)(this);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
754 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
755
758
77f936380930 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 751
diff changeset
756 void
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 SceneGraphRoot::allRemove(SceneGraphPtr list)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 SceneGraphPtr p = list;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
760
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 while (p) {
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
762 SceneGraphPtr p1 = p->next;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
763 delete p;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
764 p = p1;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
765 cnt--;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
768
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 void
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
770 SceneGraphRoot::checkRemove()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 SceneGraphPtr p = sg_available_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 SceneGraphPtr p1;
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
774
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 while (p) {
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
776 p1 = p->next;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
777 if (p->isRemoved()) {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
778 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
779 sg_available_list = p->realRemoveFromList(sg_available_list);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
780 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
781 delete p;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
782 p = p1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
785
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 SceneGraphPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
787 SceneGraphRoot::getExecuteSceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
788 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 return sg_exec_tree;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
791
1046
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
792
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
793 void
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
794 printSceneGraph(SceneGraphPtr t)
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
795 {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
796 while (t) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
797 if (!t->isRemoved()) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
798 if (t->name) printf("name: %s ",t->name);
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
799 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
800 }
1046
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
801 if (t->children != NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
802 t = t->children;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
803 } else if (t->brother != NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
804 t = t->brother;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
805 } else {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
806 while (t) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
807 if (t->brother != NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
808 t = t->brother;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
809 break;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
810 } else {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
811 if (t->parent == NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
812 t = NULL;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
813 break;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
814 } else {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
815 t = t->parent;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
816 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
817 }
1253
bb9c885c1cb5 COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1251
diff changeset
818 }
1046
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
819 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
820 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
821 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
822
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 SceneGraphPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
824 SceneGraphRoot::getDrawSceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 return sg_draw_tree;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
828
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 void
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
830 SceneGraphRoot::updateControllerState()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 controller->check();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
834
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 SceneGraphRoot::setSceneData(SceneGraphPtr sg)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
838 sg_exec_tree = sg;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
840
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 Pad*
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
842 SceneGraphRoot::getController()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 return controller;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
846
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 SceneGraphIteratorPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
848 SceneGraphRoot::getIterator()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 iterator->set(sg_remove_list);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 return iterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
853
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 SceneGraphIteratorPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 SceneGraphRoot::getIterator(SceneGraphPtr list)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 iterator->set(list);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 return iterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
860
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 CameraPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
862 SceneGraphRoot::getCamera()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 return camera;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 }
597
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
866
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
867
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
868 SceneGraphPtr
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
869 SceneGraphRoot::getLight(int id)
597
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
870 {
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
871
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
872 return light[id];
597
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
873
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
874 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
875
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
876
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
877 float*
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
878 SceneGraphRoot::getLightVector()
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
879 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
880 return light_vector;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
881 }
779
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 738 768
diff changeset
882
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
883 int*
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
884 SceneGraphRoot::getLightSwitch()
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
885 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
886 return light_switch;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
887 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
888
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
889 int
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
890 SceneGraphRoot::getLightSysSwitch()
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
891 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
892 return light_sysswitch;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
893 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
894
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
895 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
896 SceneGraphRoot::OnLightSwitch(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
897 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
898 light_switch[id] = 1;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
899 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
900
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
901 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
902 SceneGraphRoot::OffLightSwitch(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
903 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
904 light_switch[id] = 0;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
905 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
906
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
907 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
908 SceneGraphRoot::OnLightSysSwitch()
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
909 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
910
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
911 light_sysswitch = 1;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
912
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
913 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
914
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
915 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
916 SceneGraphRoot::OffLightSysSwitch()
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
917 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
918
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
919 light_sysswitch = 0;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
920
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
921 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
922
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
923 void
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
924 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
925 {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
926 gtask_array = new GTaskArray;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
927 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
928 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
929
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
930 void
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
931 SceneGraphRoot::create_task_array()
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
932 {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
933 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
934 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
935
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
936 void
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
937 SceneGraphRoot::task_array_finish()
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
938 {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
939 gtask_array->finish();
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
940 }
869
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
941
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
942 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
943 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func)
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
944 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
945 gtask_array->next_task_array(id);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
946
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
947 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
948 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
949
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
950 }
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
951
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
952 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
953 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
954 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
955 gtask_array->next_task_array(id);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
956
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
957 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
958 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
959 gtask_array->game_task->set_outData(0, property, size);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
960
869
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
961 }
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
962
884
efefbff1fd45 obj_move fix
tkaito
parents: 882
diff changeset
963 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
964 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
965 {
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
966 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
967 task->set_cpu(SPE_ANY);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
968 task->add_inData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
969 task->add_outData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
970 task->spawn();
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
971 }
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
972
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
973 void
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
974 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
975 {
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
976 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
977 task->set_cpu(SPE_ANY);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
978 task->add_inData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
979 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
980 task->add_outData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
981 task->spawn();
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
982 }
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
983
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
984
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
985 void
882
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
986 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
987 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
988 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
989 void *e = node->propertyptr;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
990 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
991 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_;
1006
66f1d3d328a7 correct code.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1003
diff changeset
992 /*
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
993 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
994 node->xyz[0] = property->x;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
995 node->xyz[1] = property->y;
1006
66f1d3d328a7 correct code.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1003
diff changeset
996 */
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
997 sgroottmp->set_game_task(move, (void*)e, size);
882
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
998 }
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
999
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1000 void
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1001 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
1002 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
1003 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
1004 void *e = node->propertyptr;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
1005 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
1006 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
1007 void *pad = (void*)sgroottmp->getController();
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1008
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1009 /*
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1010 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1011 property->root = node;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1012 node->xyz[0] = property->x;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1013 node->xyz[1] = property->y;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1014 */
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1015
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1016 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
1017 }
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1018
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1019 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1020 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size)
882
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1021 {
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1022 node->move = main_task_move;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1023 node->move_id = move;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1024 node->propertyptr = property;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1025 node->property_size = size;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
1026 }
869
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
1027
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1028 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
1029 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
1030 {
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1031 node->move = pad_task_move;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1032 node->move_id = move;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1033 node->propertyptr = property;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1034 node->property_size = size;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1035 }
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
1036
779
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 738 768
diff changeset
1037 /* end */