view gloopon/resources/main.js @ 21:87850fc55445

save
author <e085737>
date Sun, 16 Jan 2011 00:57:53 +0900
parents
children cda9d82e1fac
line wrap: on
line source

function main(gl, sgroot, w, h){
	//xmlを読む
	sgroot.createFromXMLfile(gl, sgroot, "./xml/pants.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/colorball.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/cube.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/ground.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/earth.xml");
    sgroot.createFromXMLfile(gl, sgroot, "./xml/gap_plane_test.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/moon.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/hand.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/blue.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/human.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/kata.xml");
	sgroot.createFromXMLfile(gl, sgroot, "./xml/road2.xml");


	//rootの作成
	var root = new sgroot.createSceneGraph3();
	root.set_move_collision(no_move_idle, no_collision_idle);


	//mapの作成
	//root.addChild(createMapFromXMLfile(gl,sgroot,"./xml/map2.xml"));


	//オブジェクトの作成
	var walk_man = createHuman(sgroot, w, h);
	move_length = 0;

	var combat_plane = createPlane(sgroot, w, h);

	var land = new sgroot.createSceneGraph1("Cube");
	land.set_move_collision(no_move_idle, no_collision_idle);
	land.angle[0] = -90;
	land.xyz[0] = 175;
	land.xyz[1] = -175;
	land.xyz[2] = 7;

	var wall = new sgroot.createSceneGraph1("Plane");
	//wall.angle[1] = 90;
	wall.xyz[1] = 175;
	wall.xyz[2] = 175;

	var earth = new sgroot.createSceneGraph1("Earth");
	earth.set_move_collision(earth_move, no_collision_idle);

	var moon = new sgroot.createSceneGraph1("Moon");
	moon.xyz[0] = 1000;

	var pants = new sgroot.createSceneGraph1("Pants");
	pants.set_move_collision(pants_move, pants_collision);
	pants.xyz[0] = 100;
	pants.xyz[2] = 500;
	pants.scale = 10;

	var test = new sgroot.createSceneGraph3();
	test.xyz[0] = 0;
	test.xyz[1] = 0;
	test.xyz[2] = 0;
	test.set_move_collision(no_move_idle, no_collision_idle);


	//オブジェクトをシーングラフ化
	root.addChild(land);
	//root.addChild(earth);
	//earth.addChild(moon);
	//root.addChild(test);
	//root.addChild(walk_man);
	//land.addChild(wall);
	//root.addChild(pants);
	root.addChild(combat_plane);
	//combat_plane.addChild(test);
	//root.addChild(createMapFromXMLfile(gl,sgroot,"./xml/map2.xml"));


	//カメラとか(マダ
	sgroot.setCamera(sgroot, root);
	sgroot.setSceneData(root);


	//return sgroot;
}



no_move_idle = function(){
}

no_collision_idle = function(){
}


test_move = function(){
	this.xyz[1] += this.dy * 0.1;
}


jump_move = function(node, sgroot, w, h){
	var jump = -6.0;
	var g = 0.98;
	var t = node.time;
	var height = jump*t + (g * t * t);
	if(height > -5){
		position_xyz[1] = -5;
		aim_xyz[1] = -5;
		node.time = 0;
		node.set_move_collision(body_move,body_collision);
	}else{
		position_xyz[1] = height;
		aim_xyz[1] = height;
	}

	node.time += 0.1;
}


earth_move = function(node, sgroot, w, h){
	node.angle[0] += 1
}

test_move = function(node, sgroot, w, h){
	//node.angle[1] += 1;
}