changeset 25:e8c591a01a8e

update makePanel
author NOBUYASU Oshiro
date Fri, 05 Nov 2010 08:40:26 +0900
parents 7c1ff1927da3
children 933062d8e917
files keyConfig.txt webGL/dandy/dandy5.html webGL/dandy/dandy5.html~ webGL/dandy/resources/makePanel.js webGL/dandy/resources/makePanel.js~ 問題点
diffstat 6 files changed, 258 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keyConfig.txt	Fri Nov 05 08:40:26 2010 +0900
@@ -0,0 +1,34 @@
+・Axis 1
+Low Left
+High Right
+・Axis 2
+Low Up
+High Down
+・Button1 ~ Button4
+UP
+Right
+Down
+Left
+・Button 5 ~ Button 8
+UP
+Right
+Down
+Left
+・Button 9
+Right
+・Button 10
+Up
+・Button 11
+W
+・Button12
+E
+・Button13
+A
+・Button14
+S
+・Button15
+X
+・Button16
+Z
+・Button17
+Return
\ No newline at end of file
--- a/webGL/dandy/dandy5.html	Tue Oct 26 08:41:45 2010 +0900
+++ b/webGL/dandy/dandy5.html	Fri Nov 05 08:40:26 2010 +0900
@@ -7,7 +7,7 @@
 		<script src="resources/J3DI.js"> </script>    
 		<script src="resources/J3DIMath.js"> </script>
 		<script src="resources/jkl-parsexml.js"> </script>    
-		<script src="resources/makePanel2.js"> </script> 
+		<script src="resources/makePanel.js"> </script> 
 		<script src="resources/Character_state.js"> </script> 
 		<script src="resources/Character.js"> </script> 
 		<script src="resources/schedule.js"> </script> 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webGL/dandy/dandy5.html~	Fri Nov 05 08:40:26 2010 +0900
@@ -0,0 +1,205 @@
+<!DOCTYPE html> 
+
+<html> 
+	<head> 
+		<title>WebGL dandy</title> 
+		<script src="resources/J3DI.js"> </script>    
+		<script src="resources/J3DIMath.js"> </script>
+		<script src="resources/jkl-parsexml.js"> </script>    
+		<script src="resources/makePanel2.js"> </script> 
+		<script src="resources/Character_state.js"> </script> 
+		<script src="resources/Character.js"> </script> 
+		<script src="resources/schedule.js"> </script> 
+		<script src="resources/Player.js"> </script> 
+		<script src="resources/enemy.js"> </script> 
+		<script src="resources/bullet.js"> </script> 
+		<script src="resources/collision.js"> </script> 
+		<script src="resources/constKey.js"> </script> 
+		<script src="resources/keybord.js"> </script> 
+		<script src="resources/boss.js"> </script> 
+		<script src="resources/parse.js"> </script> 
+		<script src="resources/bom.js"> </script> 
+		<script src="resources/pause.js"> </script> 
+		<script src="resources/tama.js"> </script> 
+		<script src="resources/sankaku.js"> </script> 
+		<script src="resources/syokika.js"> </script> 
+		<script src="resources/sound.js"> </script> 
+		<script src="resources/const.js"> </script> 
+		<script src="resources/charaTable.js"> </script> 
+        
+    <script id="vshader" type="x-shader/x-vertex">
+        uniform mat4 u_modelViewProjMatrix;
+        uniform mat4 u_normalMatrix;
+        uniform vec3 lightDir;
+
+        attribute vec3 vNormal;
+        attribute vec4 vTexCoord;
+        attribute vec4 vPosition;
+        
+        varying float v_Dot;
+        varying vec2 v_texCoord;
+        
+        void main()
+        {
+            gl_Position = u_modelViewProjMatrix * vPosition;
+            v_texCoord = vTexCoord.st;
+            vec4 transNormal = u_normalMatrix * vec4(vNormal,1);
+            v_Dot = max(dot(transNormal.xyz, lightDir), 0.0);
+        }
+    </script>
+
+		
+    <script id="fshader" type="x-shader/x-fragment">
+#ifdef GL_ES
+    precision mediump float;
+#endif
+    
+        uniform sampler2D sampler2d;
+
+        varying float v_Dot;
+        varying vec2 v_texCoord;
+        
+			void main()
+			{
+				vec4 color = texture2D(sampler2d,v_texCoord);
+				//				color += vec4(0.1,0.1,0.1,1);
+				//		        if(color.a == 1)color=vec4(1,0,0,1);
+				//		        else color=vec4(0,1,1,1);
+				gl_FragColor = vec4(color.xyz * v_Dot, color.a);
+				//				gl_FragColor = vec4(color.xyz * v_Dot, 0.5);
+			}
+			</script> 
+		
+		<script> 
+			
+			//画面(canvas)の大きさ
+			var w = 1024;
+			var h = 640;
+			function init()
+			{
+				var gl = initWebGL("example", "vshader", "fshader", 
+								   [ "vNormal", "vTexCoord", "vPosition"],
+								   [ 0, 0, 0, 1 ], 10000);
+				
+				gl.uniform3f(gl.getUniformLocation(gl.program, "lightDir"), 0, 0, 1);
+				gl.uniform1i(gl.getUniformLocation(gl.program, "sampler2d"), 0);
+				
+				gl.enable(gl.TEXTURE_2D);
+				
+				sankakuf();//mycos,mysinの作成 sankaku.js
+				parseXml(gl);//parse.js
+		        initEnemyTable(gl);//parseXmlの後に呼ぶこと
+
+				return gl;
+			}
+			
+			width = -1;
+			height = -1;
+			
+			function reshape(ctx, ortho)
+			{
+				var canvas = document.getElementById('example');
+				if (canvas.width == width && canvas.width == height)
+				return;
+				
+				
+				width = canvas.width;
+				height = canvas.height;
+				
+				ctx.viewport(0, 0, width, height);
+				
+                ctx.perspectiveMatrix = new J3DIMatrix4();
+//				ctx.perspectiveMatrix.ortho(50, -150, 0, -140, -1000, 10000);
+				ctx.perspectiveMatrix.ortho(ortho.left, -ortho.right, ortho.top, -ortho.bottom, 0, 10000);
+
+//	           ctx.perspectiveMatrix.perspective(30, width/height, 1, 10000);
+			}
+			
+			
+			
+			function loop(ctx, ortho)
+			{
+				reshape(ctx, ortho);
+				ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
+				
+				Player(ctx, jiki, pad, ortho);
+				
+				obj_draw(ctx);
+				
+				PutBom(ctx);
+				pause();
+				
+				
+				ctx.flush();
+				
+				filpcount++;
+				schedule();
+				
+				state_update();
+				
+				collision_detect();
+				delete_obj( ctx )
+				
+				framerate.snapshot();
+			}
+
+			function opening(ctx, ortho)
+			{
+				reshape(ctx, ortho);
+				ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
+				
+				PutSpriteF(ctx, 100, 70, 1, font[10]);
+				PutSpriteF(ctx, 170, 50, 1, font[11]);
+				PutSpriteF(ctx, 40, 120, 1, font[12]);	
+
+				ctx.flush();
+				
+				if(pad.start == 0) {setTimeout(o, 100);}
+				if(pad.start != 0) {
+					jiki.bf = true;
+					pad.st = 1;
+					gameflage = 1;
+                    SoundPlay(0);
+					setInterval(f, 10);
+				}
+			}
+			function start()
+			{
+				var ortho = makeOrthoPara(0,200,140,0);
+				
+				var c = document.getElementById("example");
+				
+				
+				//画面の大きさ
+				c.width = w;
+				c.height = h;
+				
+				var ctx = init();
+		
+				
+            currentAngle = 0;
+            incAngle = 10;
+				f = function() { loop(ctx, ortho) };
+				o = function() {opening(ctx, ortho)}
+				setTimeout(o, 10);
+				framerate = new Framerate("framerate");
+			}
+			</script> 
+		<style type="text/css"> 
+			canvas {
+				border: 2px solid black;
+			}
+			</style> 
+	</head> 
+	<body onload="start()" onkeydown="keybordDown()" onkeypress="keybordPress()" onkeyup="keybordUp()" style='overflow:hidden'>
+		<!--<body onload = "start()" style='overflow:hidden'> -->
+		<canvas id="example"> 
+			There is supposed to be an example drawing here, but it's not important.
+		</canvas> 
+		<div id="framerate"></div> 
+		<div id="console"></div> 
+		
+		<img id="test" style="border:1px solid red">
+			
+			</body> 
+</html> 
--- a/webGL/dandy/resources/makePanel.js	Tue Oct 26 08:41:45 2010 +0900
+++ b/webGL/dandy/resources/makePanel.js	Fri Nov 05 08:40:26 2010 +0900
@@ -77,9 +77,9 @@
 
     }
     for(i=0; xmlObj.normal[i]; i+=3){
-		normalData.push(parseFloat(xmlObj.normal[i]) - model.x);
-		normalData.push(parseFloat(xmlObj.normal[i+1]) - model.y);
-		normalData.push(parseFloat(xmlObj.normal[i+2]) - model.z);
+		normalData.push(parseFloat(xmlObj.normal[i]));
+		normalData.push(parseFloat(xmlObj.normal[i+1]));
+		normalData.push(parseFloat(xmlObj.normal[i+2]));
     }
 
     var retval = { };
@@ -89,20 +89,20 @@
 
     retval.normalObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
-    ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(normalData), ctx.STATIC_DRAW);
+    ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(normalData), ctx.STATIC_DRAW);
 	
     retval.texCoordObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.texCoordObject);
-    ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(texCoordData), ctx.STATIC_DRAW);
+    ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(texCoordData), ctx.STATIC_DRAW);
 	
     retval.vertexObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
-    ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(geometryData), ctx.STATIC_DRAW);
+    ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(geometryData), ctx.STATIC_DRAW);
     
     retval.numIndices = indexData.length;
     retval.indexObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, retval.indexObject);
-    ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, new WebGLUnsignedShortArray(indexData), ctx.STREAM_DRAW);
+    ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData), ctx.STREAM_DRAW);
 	
     return retval;
 }
--- a/webGL/dandy/resources/makePanel.js~	Tue Oct 26 08:41:45 2010 +0900
+++ b/webGL/dandy/resources/makePanel.js~	Fri Nov 05 08:40:26 2010 +0900
@@ -49,6 +49,7 @@
     var ymax = 0;
     var ymin = 0;    
    
+    
     for(var i=0; xmlObj.vertex[i]; i+=3){
 		geometryData.push(parseFloat(xmlObj.vertex[i]) - model.x);
 		geometryData.push(parseFloat(xmlObj.vertex[i+1]) - model.y);
@@ -88,20 +89,20 @@
 
     retval.normalObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
-    ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(normalData), ctx.STATIC_DRAW);
+    ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(normalData), ctx.STATIC_DRAW);
 	
     retval.texCoordObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.texCoordObject);
-    ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(texCoordData), ctx.STATIC_DRAW);
+    ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(texCoordData), ctx.STATIC_DRAW);
 	
     retval.vertexObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
-    ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(geometryData), ctx.STATIC_DRAW);
+    ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(geometryData), ctx.STATIC_DRAW);
     
     retval.numIndices = indexData.length;
     retval.indexObject = ctx.createBuffer();
     ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, retval.indexObject);
-    ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, new WebGLUnsignedShortArray(indexData), ctx.STREAM_DRAW);
+    ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData), ctx.STREAM_DRAW);
 	
     return retval;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/問題点	Fri Nov 05 08:40:26 2010 +0900
@@ -0,0 +1,6 @@
+敵のテーブルの作成(重要)
+scheduleのなかで rinkx,rinky に値を渡すときにd_x,d_yをわる
+ゲームオーバーの作成
+スコア表示の作成
+各ステージの作成
+敵の位置を修正