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 position_xyz = new Array(0, 0, view_point)
|
|
16 aim_xyz = new Array(0 ,0, 0)
|
|
17 eye_xyz = new Array(0, 1, 0)
|
|
18
|
|
19 angleRate_xyz = new Array(1, 0, 0)
|
|
20
|
|
21 move_finish_flag = 0
|
|
22 cnt = 0
|
|
23 }
|
|
24
|
|
25
|
|
26 SceneGraphRoot.prototype.createFromXMLfile = function(gl, url){
|
|
27 if(gl.obj == undefined) gl.obj = new Object();
|
|
28 var xmlChara = new Object();
|
|
29 xmlChara = parsePanel(url);
|
|
30 for (var name in xmlChara)
|
|
31 {
|
|
32 gl.obj[name] = makeXmlObj(gl, xmlChara[name]);
|
|
33 gl.obj[name].texture = loadImageTexture(gl, xmlChara[name].image);
|
|
34 gl.obj[name].name = name;
|
|
35 sg_src.push(gl.obj[name])
|
|
36 }
|
|
37 }
|
|
38
|
|
39
|
|
40 SceneGraphRoot.prototype.createSceneGraph1 = function(id){
|
|
41 if(id < 0){
|
|
42 alert("error: createSceneGraph(id): id not found")
|
|
43 return null
|
|
44 }
|
|
45
|
|
46 for(num in sg_src){
|
|
47 if(id == sg_src[num].name){
|
|
48 var src = new SceneGraph(id)
|
|
49 }
|
|
50 }
|
|
51
|
|
52 if(sg_exec_tree != null){
|
|
53 sg_exec_tree.addChild(src)
|
|
54 }
|
|
55
|
|
56 SceneGraphRoot.prototype.addNext(src)
|
|
57
|
|
58 return src
|
|
59 }
|
|
60
|
|
61
|
|
62 SceneGraphRoot.prototype.createSceneGraph2 = function(name){
|
|
63 if(name < 0){
|
|
64 alert("error: createSceneGraph(name): name object not found.")
|
|
65 return null
|
|
66 }
|
|
67
|
|
68 for(num in sg_src){
|
|
69 if(name == sg_src[num].name){
|
|
70 var src = new SceneGraph(name)
|
|
71 }
|
|
72 }
|
|
73
|
|
74
|
|
75 //SceneGraphRoot.prototype.addNext(src)
|
|
76
|
|
77 return src
|
|
78 }
|
|
79
|
|
80
|
|
81 SceneGraphRoot.prototype.createSceneGraph3 = function(){
|
|
82 var p = new SceneGraph()
|
|
83
|
|
84 p.sgroot = this
|
|
85
|
|
86 SceneGraphRoot.prototype.addNext(p)
|
|
87
|
|
88 p.flag_drawable = 0
|
|
89
|
|
90 return p
|
|
91 }
|
|
92
|
|
93
|
|
94 SceneGraphRoot.prototype.addNext = function(sg){
|
|
95 sg_available_list = sg
|
|
96 /*last = sg_available_list
|
|
97 if(last == null){
|
|
98 sg_available_list.push(sg)
|
|
99 }else{
|
|
100 while(last.next){
|
|
101 last = last.next
|
|
102 }
|
|
103 last.next = sg
|
|
104 sg.prev = last
|
|
105 }*/
|
|
106 //cnt++
|
|
107 }
|
|
108
|
|
109
|
|
110 /* 渡された引数をもとにイメージを検索する */
|
|
111 SceneGraphRoot.prototype.getSgid = function(obj_name){
|
|
112 for(var name in sg_src){
|
|
113 if(obj_name == sg_src[name].name){
|
|
114 return sg_src[name]
|
|
115 }
|
|
116 }
|
|
117 return -1
|
|
118 }
|
|
119
|
|
120
|
|
121 SceneGraphRoot.prototype.getController = function(){
|
|
122 var left_push = currentlyPressedKeys[37] /* ← */
|
|
123 var down_push = currentlyPressedKeys[40] /* ↓ */
|
|
124 var right_push = currentlyPressedKeys[39] /* → */
|
|
125 var up_push = currentlyPressedKeys[38] /* ↑ */
|
|
126 var cross_push = currentlyPressedKeys[90] /* Z */
|
|
127 var circle_push = currentlyPressedKeys[88] /* X */
|
|
128 var start_push = currentlyPressedKeys[13] /* Enter */
|
|
129 var zoom_in_push = currentlyPressedKeys[75] /* K */
|
|
130 var zoom_out_push = currentlyPressedKeys[76] /* L */
|
|
131 var left_move = currentlyPressedKeys[65] /* A */
|
|
132 var right_move = currentlyPressedKeys[68] /* D */
|
|
133 var front_move = currentlyPressedKeys[87] /* W */
|
|
134 var back_move = currentlyPressedKeys[83] /* S */
|
|
135 var space_push = currentlyPressedKeys[32] /* SPACE */
|
|
136
|
|
137
|
|
138 this.right_isHold = function(){
|
|
139 return right_push
|
|
140 }
|
|
141
|
|
142 this.right_isRelease = function(){
|
|
143 return !right_push
|
|
144 }
|
|
145
|
|
146 this.left_isHold = function(){
|
|
147 return left_push
|
|
148 }
|
|
149
|
|
150 this.left_isRelease = function(){
|
|
151 return !left_push
|
|
152 }
|
|
153
|
|
154 this.up_isHold = function(){
|
|
155 return up_push
|
|
156 }
|
|
157
|
|
158 this.up_isRelease = function(){
|
|
159 return !up_push
|
|
160 }
|
|
161
|
|
162 this.down_isHold = function(){
|
|
163 return down_push
|
|
164 }
|
|
165
|
|
166 this.down_isRelease = function(){
|
|
167 return !down_push
|
|
168 }
|
|
169
|
|
170 this.cross_isHold = function(){
|
|
171 return cross_push
|
|
172 }
|
|
173
|
|
174 this.cross_isRelease = function(){
|
|
175 return !cross_push
|
|
176 }
|
|
177
|
|
178 this.circle_isHold = function(){
|
|
179 return circle_push
|
|
180 }
|
|
181
|
|
182 this.circle_isRelease = function(){
|
|
183 return !circle_push
|
|
184 }
|
|
185
|
|
186 this.start_isHold = function(){
|
|
187 return start_push
|
|
188 }
|
|
189
|
|
190 this.start_isRelease = function(){
|
|
191 return !start_push
|
|
192 }
|
|
193
|
|
194 this.zoom_in_isHold = function(){
|
|
195 return zoom_in_push
|
|
196 }
|
|
197
|
|
198 this.zoom_out_isHold = function(){
|
|
199 return zoom_out_push
|
|
200 }
|
|
201
|
|
202 this.left_move_isHold = function(){
|
|
203 return left_move
|
|
204 }
|
|
205
|
|
206 this.right_move_isHold = function(){
|
|
207 return right_move
|
|
208 }
|
|
209
|
|
210 this.front_move_isHold = function(){
|
|
211 return front_move
|
|
212 }
|
|
213
|
|
214 this.back_move_isHold = function(){
|
|
215 return back_move
|
|
216 }
|
|
217
|
|
218 this.space_isHold = function(){
|
|
219 return space_push
|
|
220 }
|
|
221 }
|
|
222
|
|
223
|
|
224
|
|
225 /* rootになるnodeを設定する */
|
|
226 SceneGraphRoot.prototype.setSceneData = function(sg){
|
|
227 sg.parents = null
|
|
228 sg_exec_tree = sg
|
|
229 }
|
|
230
|
|
231
|