0
|
1 function SceneGraphRoot(w, h){
|
|
2 sg_src = new Array()
|
|
3 sg_exec_tree = null
|
|
4
|
|
5 //controller = create_controller()
|
|
6
|
|
7 sg_draw_tree = new Array()
|
|
8 sg_available_list = null
|
|
9 sg_remove_list = new Array()
|
|
10 sgroot = this
|
|
11
|
|
12 screen_w = w
|
|
13 screen_h = h
|
|
14
|
|
15 move_finish_flag = 0
|
|
16 cnt = 0
|
|
17 }
|
|
18
|
|
19
|
|
20 SceneGraphRoot.prototype.createFromXMLfile = function(gl, url){
|
|
21 if(gl.obj == undefined) gl.obj = new Object();
|
|
22 var xmlChara = new Object();
|
|
23 xmlChara = parsePanel(url);
|
|
24 for (var name in xmlChara)
|
|
25 {
|
|
26 gl.obj[name] = makeXmlObj(gl, xmlChara[name]);
|
|
27 gl.obj[name].texture = loadImageTexture(gl, xmlChara[name].image);
|
|
28 gl.obj[name].name = name;
|
|
29 sg_src.push(gl.obj[name])
|
|
30 }
|
|
31 }
|
|
32
|
|
33
|
|
34 SceneGraphRoot.prototype.createSceneGraph1 = function(id){
|
|
35 if(id < 0){
|
|
36 alert("error: createSceneGraph(id): id not found")
|
|
37 return null
|
|
38 }
|
|
39
|
|
40 for(num in sg_src){
|
|
41 if(id == sg_src[num].name){
|
|
42 var src = new SceneGraph(id)
|
|
43 }
|
|
44 }
|
|
45
|
|
46
|
|
47 if(sg_exec_tree != null){
|
|
48 sg_exec_tree.addChild(src)
|
|
49 }
|
|
50
|
|
51 SceneGraphRoot.prototype.addNext(src)
|
|
52
|
|
53 return src
|
|
54 }
|
|
55
|
|
56
|
|
57 SceneGraphRoot.prototype.createSceneGraph2 = function(name){
|
|
58 if(name < 0){
|
|
59 alert("error: createSceneGraph(name): name object not found.")
|
|
60 return null
|
|
61 }
|
|
62
|
|
63 for(num in sg_src){
|
|
64 if(name == sg_src[num].name){
|
|
65 var src = new SceneGraph(name)
|
|
66 }
|
|
67 }
|
|
68
|
|
69
|
|
70 //SceneGraphRoot.prototype.addNext(src)
|
|
71
|
|
72 return src
|
|
73 }
|
|
74
|
|
75
|
|
76 SceneGraphRoot.prototype.createSceneGraph3 = function(){
|
|
77 var p = new SceneGraph()
|
|
78
|
|
79 p.sgroot = this
|
|
80
|
|
81 SceneGraphRoot.prototype.addNext(p)
|
|
82
|
|
83 p.flag_drawable = 0
|
|
84
|
|
85 return p
|
|
86 }
|
|
87
|
|
88
|
|
89 SceneGraphRoot.prototype.addNext = function(sg){
|
|
90 sg_available_list = sg
|
|
91 /*last = sg_available_list
|
|
92 if(last == null){
|
|
93 sg_available_list.push(sg)
|
|
94 }else{
|
|
95 while(last.next){
|
|
96 last = last.next
|
|
97 }
|
|
98 last.next = sg
|
|
99 sg.prev = last
|
|
100 }*/
|
|
101 //cnt++
|
|
102 }
|
|
103
|
|
104
|
|
105 /* 渡された引数をもとにイメージを検索する */
|
|
106 SceneGraphRoot.prototype.getSgid = function(obj_name){
|
|
107 for(var name in sg_src){
|
|
108 if(obj_name == sg_src[name].name){
|
|
109 return sg_src[name]
|
|
110 }
|
|
111 }
|
|
112 return -1
|
|
113 }
|
|
114
|
|
115
|
|
116 SceneGraphRoot.prototype.getController = function(){
|
|
117 var left_push = currentlyPressedKeys[37] /* ← */
|
|
118 var down_push = currentlyPressedKeys[40] /* ↓ */
|
|
119 var right_push = currentlyPressedKeys[39] /* → */
|
|
120 var up_push = currentlyPressedKeys[38] /* ↑ */
|
|
121 var cross_push = currentlyPressedKeys[90] /* z */
|
|
122 var circle_push = currentlyPressedKeys[88] /* x */
|
|
123 var start_push = currentlyPressedKeys[13] /* Enter */
|
|
124 var zoom_in_push = currentlyPressedKeys[75] /* k */
|
|
125 var zoom_out_push = currentlyPressedKeys[76] /* l */
|
|
126
|
|
127 this.right_isHold = function(){
|
|
128 return right_push
|
|
129 }
|
|
130
|
|
131 this.right_isRelease = function(){
|
|
132 return !right_push
|
|
133 }
|
|
134
|
|
135 this.left_isHold = function(){
|
|
136 return left_push
|
|
137 }
|
|
138
|
|
139 this.left_isRelease = function(){
|
|
140 return !left_push
|
|
141 }
|
|
142
|
|
143 this.up_isHold = function(){
|
|
144 return up_push
|
|
145 }
|
|
146
|
|
147 this.up_isRelease = function(){
|
|
148 return !up_push
|
|
149 }
|
|
150
|
|
151 this.down_isHold = function(){
|
|
152 return down_push
|
|
153 }
|
|
154
|
|
155 this.down_isRelease = function(){
|
|
156 return !down_push
|
|
157 }
|
|
158
|
|
159 this.cross_isHold = function(){
|
|
160 return cross_push
|
|
161 }
|
|
162
|
|
163 this.cross_isRelease = function(){
|
|
164 return !cross_push
|
|
165 }
|
|
166
|
|
167 this.circle_isHold = function(){
|
|
168 return circle_push
|
|
169 }
|
|
170
|
|
171 this.circle_isRelease = function(){
|
|
172 return !circle_push
|
|
173 }
|
|
174
|
|
175 this.start_isHold = function(){
|
|
176 return start_push
|
|
177 }
|
|
178
|
|
179 this.start_isRelease = function(){
|
|
180 return !start_push
|
|
181 }
|
|
182
|
|
183 this.zoom_in_isHold = function(){
|
|
184 return zoom_in_push
|
|
185 }
|
|
186
|
|
187 this.zoom_out_isHold = function(){
|
|
188 return zoom_out_push
|
|
189 }
|
|
190
|
|
191 }
|
|
192
|
|
193
|
|
194
|
|
195 /* rootになるnodeを設定する */
|
|
196 SceneGraphRoot.prototype.setSceneData = function(sg){
|
|
197 sg.parents = null
|
|
198 sg_exec_tree = sg
|
|
199 }
|
|
200
|
|
201
|