view Vacuum/resources/SceneGraphRoot.js @ 0:718974a1a32b

Vacuum
author <e085737>
date Tue, 07 Dec 2010 17:31:15 +0900
parents
children
line wrap: on
line source

function SceneGraphRoot(w, h){
    sg_src = new Array()
    sg_exec_tree = null

    //controller = create_controller()

    sg_draw_tree = new Array()
    sg_available_list = null
    sg_remove_list = new Array()
    sgroot = this

    screen_w = w
    screen_h = h

    move_finish_flag = 0
    cnt = 0
}


SceneGraphRoot.prototype.createFromXMLfile = function(gl, url){
    if(gl.obj == undefined) gl.obj = new Object();
    var xmlChara = new Object();
    xmlChara = parsePanel(url);
    for (var name in xmlChara)
        {
            gl.obj[name] = makeXmlObj(gl, xmlChara[name]);
            gl.obj[name].texture = loadImageTexture(gl, xmlChara[name].image);
            gl.obj[name].name = name;
            sg_src.push(gl.obj[name])
 	}
}


SceneGraphRoot.prototype.createSceneGraph1 = function(id){
    if(id < 0){
	alert("error: createSceneGraph(id): id not found")
	return null
    }

    for(num in sg_src){
        if(id == sg_src[num].name){
	    var src = new SceneGraph(id)
	}
    }


    if(sg_exec_tree != null){
	sg_exec_tree.addChild(src)
    }

    SceneGraphRoot.prototype.addNext(src)

    return src
}


SceneGraphRoot.prototype.createSceneGraph2 = function(name){
    if(name < 0){
	alert("error: createSceneGraph(name): name object not found.")
        return null
    }

    for(num in sg_src){
	if(name == sg_src[num].name){
	    var src = new SceneGraph(name)
	}
    }


    //SceneGraphRoot.prototype.addNext(src)

    return src
}


SceneGraphRoot.prototype.createSceneGraph3 = function(){
   var p = new SceneGraph() 

   p.sgroot = this

   SceneGraphRoot.prototype.addNext(p)
   
   p.flag_drawable = 0

   return p
}


SceneGraphRoot.prototype.addNext = function(sg){
    sg_available_list = sg
    /*last = sg_available_list
    if(last == null){
        sg_available_list.push(sg)
    }else{
	while(last.next){
	    last = last.next
	}
	    last.next = sg
	    sg.prev = last
    }*/
    //cnt++
}


/* 渡された引数をもとにイメージを検索する */
SceneGraphRoot.prototype.getSgid = function(obj_name){
    for(var name in sg_src){
        if(obj_name == sg_src[name].name){
	    return sg_src[name]
	}
    }
    return -1
}


SceneGraphRoot.prototype.getController = function(){   
    var left_push     = currentlyPressedKeys[37]     /* ←  */
    var down_push     = currentlyPressedKeys[40]     /* ↓  */
    var right_push    = currentlyPressedKeys[39]     /* →  */
    var up_push       = currentlyPressedKeys[38]     /* ↑  */
    var cross_push    = currentlyPressedKeys[90]     /* z */
    var circle_push   = currentlyPressedKeys[88]     /* x */
    var start_push    = currentlyPressedKeys[13]     /* Enter */ 
    var zoom_in_push  = currentlyPressedKeys[75]     /* k */
    var zoom_out_push = currentlyPressedKeys[76]     /* l */

    this.right_isHold = function(){
	return right_push
    }

    this.right_isRelease = function(){
	return !right_push
    }

    this.left_isHold = function(){
	return left_push
    }

    this.left_isRelease = function(){
	return !left_push
    }

    this.up_isHold = function(){
	return up_push
    }

    this.up_isRelease = function(){
	return !up_push
    }

    this.down_isHold = function(){
	return down_push
    }

    this.down_isRelease = function(){
	return !down_push
    }

    this.cross_isHold = function(){
	return cross_push
    }

    this.cross_isRelease = function(){
	return !cross_push
    }

    this.circle_isHold = function(){
	return circle_push
    }

    this.circle_isRelease = function(){
	return !circle_push
    }

    this.start_isHold = function(){
	return start_push
    }

    this.start_isRelease = function(){
	return !start_push
    }

    this.zoom_in_isHold = function(){
	return zoom_in_push
    }

    this.zoom_out_isHold = function(){
	return zoom_out_push
    }

}



/* rootになるnodeを設定する */
SceneGraphRoot.prototype.setSceneData = function(sg){
    sg.parents = null
    sg_exec_tree = sg
}