From f775fb752cac57a0c1f6c42c8c60f5ff329eab32 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 22 Feb 2012 11:36:19 -0800 Subject: Revert "Integrating canvas-2d drawing and WebGL fixes, including adding back WebGL materials." This reverts commit 96a0a8c916533eb5625816192ed38488f639326d. --- assets/shaders/Deform.frag.glsl | 29 - assets/shaders/Flag.vert.glsl | 35 -- assets/shaders/Fly.frag.glsl | 23 - assets/shaders/Julia.frag.glsl | 25 - assets/shaders/Keleidoscope.frag.glsl | 25 - assets/shaders/Mandel.frag.glsl | 55 -- assets/shaders/Pulse.frag.glsl | 22 - assets/shaders/ReliefTunnel.frag.glsl | 35 -- assets/shaders/SquareTunnel.frag.glsl | 21 - assets/shaders/Star.frag.glsl | 28 - assets/shaders/Taper.frag.glsl | 17 - assets/shaders/Taper.vert.glsl | 122 ----- assets/shaders/Tunnel.frag.glsl | 23 - assets/shaders/Twist.frag.glsl | 23 - assets/shaders/TwistVert.frag.glsl | 32 -- assets/shaders/TwistVert.vert.glsl | 97 ---- assets/shaders/Water.frag.glsl | 55 -- assets/shaders/Water2.frag.glsl | 66 --- assets/shaders/ZInvert.frag.glsl | 23 - assets/shaders/plasma.frag.glsl | 32 -- assets/shaders/plasma.vert.glsl | 42 -- assets/shaders/radialBlur.frag.glsl | 47 -- js/helper-classes/RDGE/GLCircle.js | 10 +- js/helper-classes/RDGE/GLLine.js | 594 ++++++++++----------- js/helper-classes/RDGE/GLRectangle.js | 117 +++- js/helper-classes/RDGE/GLWorld.js | 45 +- js/helper-classes/RDGE/Materials/DeformMaterial.js | 133 ----- js/helper-classes/RDGE/Materials/FlyMaterial.js | 133 ----- js/helper-classes/RDGE/Materials/JuliaMaterial.js | 150 ------ .../RDGE/Materials/KeleidoscopeMaterial.js | 149 ------ js/helper-classes/RDGE/Materials/MandelMaterial.js | 151 ------ js/helper-classes/RDGE/Materials/PlasmaMaterial.js | 134 ----- js/helper-classes/RDGE/Materials/PulseMaterial.js | 253 --------- .../RDGE/Materials/RadialBlurMaterial.js | 246 --------- .../RDGE/Materials/ReliefTunnelMaterial.js | 133 ----- .../RDGE/Materials/SquareTunnelMaterial.js | 133 ----- js/helper-classes/RDGE/Materials/StarMaterial.js | 133 ----- js/helper-classes/RDGE/Materials/TaperMaterial.js | 223 -------- js/helper-classes/RDGE/Materials/TunnelMaterial.js | 133 ----- js/helper-classes/RDGE/Materials/TwistMaterial.js | 149 ------ .../RDGE/Materials/TwistVertMaterial.js | 248 --------- js/helper-classes/RDGE/Materials/WaterMaterial.js | 133 ----- .../RDGE/Materials/ZInvertMaterial.js | 133 ----- js/helper-classes/RDGE/MaterialsLibrary.js | 59 -- .../RDGE/src/core/script/precompiled.js | 10 +- js/helper-classes/RDGE/src/core/script/runtime.js | 14 +- .../RDGE/src/core/script/scenegraphNodes.js | 8 +- .../RDGE/src/tools/compile-rdge-core.bat | 4 - .../RDGE/src/tools/compile-rdge-core.sh | 3 - js/helper-classes/RDGE/src/tools/compiler.jar | Bin 4927265 -> 0 bytes js/helper-classes/RDGE/src/tools/rdge-compiled.js | 454 ---------------- js/io/ui/cloudpopup.reel/cloudpopup.js | 4 - js/panels/Materials/Materials.xml | 2 +- js/preloader/Preloader.js | 21 +- 54 files changed, 437 insertions(+), 4552 deletions(-) delete mode 100644 assets/shaders/Deform.frag.glsl delete mode 100644 assets/shaders/Flag.vert.glsl delete mode 100644 assets/shaders/Fly.frag.glsl delete mode 100644 assets/shaders/Julia.frag.glsl delete mode 100644 assets/shaders/Keleidoscope.frag.glsl delete mode 100644 assets/shaders/Mandel.frag.glsl delete mode 100644 assets/shaders/Pulse.frag.glsl delete mode 100644 assets/shaders/ReliefTunnel.frag.glsl delete mode 100644 assets/shaders/SquareTunnel.frag.glsl delete mode 100644 assets/shaders/Star.frag.glsl delete mode 100644 assets/shaders/Taper.frag.glsl delete mode 100644 assets/shaders/Taper.vert.glsl delete mode 100644 assets/shaders/Tunnel.frag.glsl delete mode 100644 assets/shaders/Twist.frag.glsl delete mode 100644 assets/shaders/TwistVert.frag.glsl delete mode 100644 assets/shaders/TwistVert.vert.glsl delete mode 100644 assets/shaders/Water.frag.glsl delete mode 100644 assets/shaders/Water2.frag.glsl delete mode 100644 assets/shaders/ZInvert.frag.glsl delete mode 100644 assets/shaders/plasma.frag.glsl delete mode 100644 assets/shaders/plasma.vert.glsl delete mode 100644 assets/shaders/radialBlur.frag.glsl delete mode 100644 js/helper-classes/RDGE/Materials/DeformMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/FlyMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/JuliaMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/MandelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/PlasmaMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/PulseMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/RadialBlurMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/StarMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TaperMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TwistMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TwistVertMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/WaterMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/ZInvertMaterial.js delete mode 100644 js/helper-classes/RDGE/src/tools/compile-rdge-core.bat delete mode 100644 js/helper-classes/RDGE/src/tools/compile-rdge-core.sh delete mode 100644 js/helper-classes/RDGE/src/tools/compiler.jar delete mode 100644 js/helper-classes/RDGE/src/tools/rdge-compiled.js diff --git a/assets/shaders/Deform.frag.glsl b/assets/shaders/Deform.frag.glsl deleted file mode 100644 index 1dbe45a0..00000000 --- a/assets/shaders/Deform.frag.glsl +++ /dev/null @@ -1,29 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform float u_time; -uniform vec2 u_resolution; -//uniform vec4 mouse; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - //vec2 m = -1.0 + 2.0 * mouse.xy / u_resolution.xy; - vec2 m = vec2(-.8, .8); - - float a1 = atan(p.y-m.y,p.x-m.x); - float r1 = sqrt(dot(p-m,p-m)); - float a2 = atan(p.y+m.y,p.x+m.x); - float r2 = sqrt(dot(p+m,p+m)); - - vec2 uv; - uv.x = 0.2*u_time + (r1-r2)*0.25; - uv.y = sin(2.0*(a1-a2)); - - float w = r1*r2*0.8; - vec3 col = texture2D(u_tex0,uv).xyz; - - gl_FragColor = vec4(col/(.1+w),1.0); -} \ No newline at end of file diff --git a/assets/shaders/Flag.vert.glsl b/assets/shaders/Flag.vert.glsl deleted file mode 100644 index 7dc932a7..00000000 --- a/assets/shaders/Flag.vert.glsl +++ /dev/null @@ -1,35 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - - -#ifdef GL_ES -precision highp float; -#endif - - -// attributes -attribute vec3 a_pos; -attribute vec2 texcoord; - -// scalar uniforms -uniform float u_time; - -// matrix uniforms -uniform mat4 u_mvMatrix; -uniform mat4 u_projMatrix; -uniform mat4 u_worldMatrix; - -void main() -{ - float angle = (u_time%360)*2; - - a_pos.z = sin( a_pos.x + angle); - a_pos.z += sin( a_pos.y/2 + angle); - a_pos.z *= a_pos.x * 0.09; - gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0) ; - - gl_FragColor = v_color; -} diff --git a/assets/shaders/Fly.frag.glsl b/assets/shaders/Fly.frag.glsl deleted file mode 100644 index f99b5ab8..00000000 --- a/assets/shaders/Fly.frag.glsl +++ /dev/null @@ -1,23 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float an = u_time*.25; - - float x = p.x*cos(an)-p.y*sin(an); - float y = p.x*sin(an)+p.y*cos(an); - - uv.x = .25*x/abs(y); - uv.y = .20*u_time + .25/abs(y); - - gl_FragColor = vec4(texture2D(u_tex0,uv).xyz * y*y, 1.0); -} diff --git a/assets/shaders/Julia.frag.glsl b/assets/shaders/Julia.frag.glsl deleted file mode 100644 index 68cda703..00000000 --- a/assets/shaders/Julia.frag.glsl +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 cc = vec2( cos(.25*u_time), sin(.25*u_time*1.423) ); - - float dmin = 1000.0; - vec2 z = p*vec2(1.33,1.0); - for( int i=0; i<64; i++ ) - { - z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ); - float m2 = dot(z,z); - if( m2>100.0 ) break; - dmin=min(dmin,m2); - } - - float color = sqrt(sqrt(dmin))*0.7; - gl_FragColor = vec4(color,color,color,1.0); -} \ No newline at end of file diff --git a/assets/shaders/Keleidoscope.frag.glsl b/assets/shaders/Keleidoscope.frag.glsl deleted file mode 100644 index 7d1bdb17..00000000 --- a/assets/shaders/Keleidoscope.frag.glsl +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float a = atan(p.y,p.x); - float r = sqrt(dot(p,p)); - - uv.x = 7.0*a/3.1416; - uv.y = -u_time+ sin(7.0*r+u_time) + .7*cos(u_time+7.0*a); - - float w = .5+.5*(sin(u_time+7.0*r)+ .7*cos(u_time+7.0*a)); - - vec3 col = texture2D(u_tex0,uv*.5).xyz; - - gl_FragColor = vec4(col*w,1.0); -} \ No newline at end of file diff --git a/assets/shaders/Mandel.frag.glsl b/assets/shaders/Mandel.frag.glsl deleted file mode 100644 index 6465899d..00000000 --- a/assets/shaders/Mandel.frag.glsl +++ /dev/null @@ -1,55 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - p.x *= u_resolution.x/u_resolution.y; - - float zoo = .62+.38*sin(.1*u_time); - float coa = cos( 0.1*(1.0-zoo)*u_time ); - float sia = sin( 0.1*(1.0-zoo)*u_time ); - zoo = pow( zoo,8.0); - vec2 xy = vec2( p.x*coa-p.y*sia, p.x*sia+p.y*coa); - vec2 cc = vec2(-.745,.186) + xy*zoo; - - vec2 z = vec2(0.0); - vec2 z2 = z*z; - float m2; - float co = 0.0; - - - // chrome/angelproject/nvidia/glslES don't seem to like to "break" a loop... - // so we have to rewrite it in another way -/* - for( int i=0; i<256; i++ ) - { - z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ); - m2 = dot(z,z); - if( m2>1024.0 ) break; - co += 1.0; - } -*/ - - for( int i=0; i<256; i++ ) - { - if( m2<1024.0 ) - { - z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ); - m2 = dot(z,z); - co += 1.0; - } - } - - co = co + 1.0 - log2(.5*log2(m2)); - - co = sqrt(co/256.0); - gl_FragColor = vec4( .5+.5*cos(6.2831*co+0.0), - .5+.5*cos(6.2831*co+0.4), - .5+.5*cos(6.2831*co+0.7), - 1.0 ); -} \ No newline at end of file diff --git a/assets/shaders/Pulse.frag.glsl b/assets/shaders/Pulse.frag.glsl deleted file mode 100644 index b24c9bef..00000000 --- a/assets/shaders/Pulse.frag.glsl +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform float u_time; -uniform vec2 u_resolution; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 halfres = u_resolution.xy/2.0; - vec2 cPos = gl_FragCoord.xy; - - cPos.x -= 0.5*halfres.x*sin(u_time/2.0)+0.3*halfres.x*cos(u_time)+halfres.x; - cPos.y -= 0.4*halfres.y*sin(u_time/5.0)+0.3*halfres.y*cos(u_time)+halfres.y; - float cLength = length(cPos); - - vec2 uv = gl_FragCoord.xy/u_resolution.xy+(cPos/cLength)*sin(cLength/30.0-u_time*10.0)/25.0; - vec3 col = texture2D(u_tex0,uv).xyz*50.0/cLength; - - gl_FragColor = vec4(col,1.0); -} \ No newline at end of file diff --git a/assets/shaders/ReliefTunnel.frag.glsl b/assets/shaders/ReliefTunnel.frag.glsl deleted file mode 100644 index cee707db..00000000 --- a/assets/shaders/ReliefTunnel.frag.glsl +++ /dev/null @@ -1,35 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float r = sqrt( dot(p,p) ); - float a = atan(p.y,p.x) + 0.5*sin(0.5*r-0.5*u_time); - - float s = 0.5 + 0.5*cos(7.0*a); - s = smoothstep(0.0,1.0,s); - s = smoothstep(0.0,1.0,s); - s = smoothstep(0.0,1.0,s); - s = smoothstep(0.0,1.0,s); - - uv.x = u_time + 1.0/( r + .2*s); - uv.y = 3.0*a/3.1416; - - float w = (0.5 + 0.5*s)*r*r; - - vec3 col = texture2D(u_tex0,uv).xyz; - - float ao = 0.5 + 0.5*cos(7.0*a); - ao = smoothstep(0.0,0.4,ao)-smoothstep(0.4,0.7,ao); - ao = 1.0-0.5*ao*r; - - gl_FragColor = vec4(col*w*ao,1.0); -} diff --git a/assets/shaders/SquareTunnel.frag.glsl b/assets/shaders/SquareTunnel.frag.glsl deleted file mode 100644 index 51ef7b7c..00000000 --- a/assets/shaders/SquareTunnel.frag.glsl +++ /dev/null @@ -1,21 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 ); - uv.x = .5*u_time + 0.5/r; - uv.y = 1.0*atan(p.y,p.x)/3.1416; - - vec3 col = texture2D(u_tex0,uv).xyz; - - gl_FragColor = vec4(col*r*r*r,1.0); -} diff --git a/assets/shaders/Star.frag.glsl b/assets/shaders/Star.frag.glsl deleted file mode 100644 index f63fe605..00000000 --- a/assets/shaders/Star.frag.glsl +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform float u_time; -uniform vec2 u_resolution; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 uv; - - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - float a = atan(p.y,p.x); - float r = sqrt(dot(p,p)); - float s = r * (1.0+0.8*cos(u_time*1.0)); - - uv.x = .02*p.y+.03*cos(-u_time+a*3.0)/s; - uv.y = .1*u_time +.02*p.x+.03*sin(-u_time+a*3.0)/s; - - float w = .9 + pow(max(1.5-r,0.0),4.0); - - w*=0.6+0.4*cos(u_time+3.0*a); - - vec3 col = texture2D(u_tex0,uv).xyz; - - gl_FragColor = vec4(col*w,1.0); -} \ No newline at end of file diff --git a/assets/shaders/Taper.frag.glsl b/assets/shaders/Taper.frag.glsl deleted file mode 100644 index 3a5766fb..00000000 --- a/assets/shaders/Taper.frag.glsl +++ /dev/null @@ -1,17 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - - -#ifdef GL_ES -precision highp float; -#endif - -//uniform vec4 color; -varying vec4 v_color; - -void main() { - gl_FragColor = v_color; -} diff --git a/assets/shaders/Taper.vert.glsl b/assets/shaders/Taper.vert.glsl deleted file mode 100644 index 30b73456..00000000 --- a/assets/shaders/Taper.vert.glsl +++ /dev/null @@ -1,122 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - - -#ifdef GL_ES -precision highp float; -#endif - - -// attributes -attribute vec3 vert; -attribute vec3 normal; -attribute vec2 texcoord; - -// scalar uniforms -uniform float u_limit1; -uniform float u_limit2; -uniform float u_limit3; -uniform float u_taperAmount; -uniform float u_minVal; -uniform float u_maxVal; -uniform float u_center; - -uniform vec4 color; - - -// matrix uniforms -uniform mat4 u_mvMatrix; -uniform mat4 u_projMatrix; -uniform mat4 u_worldMatrix; - -varying vec4 v_color; - - - -float TaperAmount( float param ) -{ - // Bezier coordinates of the X coordinate. - // Adjust these to get tighter or looser - float tightness = 0.8; - - float x0, y0, x1, y1, x2, y2; - float t; - if (param < 0.5) - { - t = 2.0*param; - x0 = 0.0; y0 = 0.0; - x1 = tightness; y1 = 0.0; - x2 = 1.0; y2 = 0.5; - } - else - { - t = (param - 0.5)*2.0; - x0 = 0.0; y0 = 0.5; - x1 = 1.0 - tightness; y1 = 1.0; - x2 = 1.0; y2 = 1.0; - } - - float a = x0 - 2.0*x1 + x2; - float b = 2.0*(x1 - x0); - float c = x0 - t; - - float descr = sqrt( b*b - 4.0*a*c ); - float denom = 2.0*a; - float n1 = (-b + descr)/denom; - float n2 = (-b - descr)/denom; - if ((n1 >= 0.0) || (n1 <= 1.0)) t = n1; - else if ((n2 >= 0.0) || (n2 <= 1.0)) t = n2; - else - t = 0.0; - - float ya = y0 + t*(y1 - y0); - float yb = y1 + t*(y2 - y1); - float yc = ya + t*(yb - ya); - - return yc; -} - - -void main(void) -{ - vec3 pos = vert; - vec2 uv = texcoord; - - - float limit1 = u_limit1, - limit2 = u_limit2, - limit3 = u_limit2; - - v_color = vec4(texcoord.x, texcoord.y, 0, 1); - if ((uv.x > u_limit1) && (uv.x < u_limit3)) - { - float t; - if (uv.x < u_limit2) - { - t = (uv.x - u_limit1)/(u_limit2 - u_limit1); - } - else - { - t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); - } - t = TaperAmount( t ); - - float maxVal; - if (pos.y > u_center) - { - maxVal = u_maxVal; - } - else - { - maxVal = u_minVal; - } - - float yFrac = (pos.y - u_center)/(maxVal-u_center); - pos.y = pos.y - yFrac * (maxVal - u_center)*t*u_taperAmount; - } - - gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; -} \ No newline at end of file diff --git a/assets/shaders/Tunnel.frag.glsl b/assets/shaders/Tunnel.frag.glsl deleted file mode 100644 index 9deb52fb..00000000 --- a/assets/shaders/Tunnel.frag.glsl +++ /dev/null @@ -1,23 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float a = atan(p.y,p.x); - float r = sqrt(dot(p,p)); - - uv.x = .75*u_time+.1/r; - uv.y = a/3.1416; - - vec3 col = texture2D(u_tex0,uv).xyz; - - gl_FragColor = vec4(col*r,1.0); -} \ No newline at end of file diff --git a/assets/shaders/Twist.frag.glsl b/assets/shaders/Twist.frag.glsl deleted file mode 100644 index b7477747..00000000 --- a/assets/shaders/Twist.frag.glsl +++ /dev/null @@ -1,23 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float a = atan(p.y,p.x); - float r = sqrt(dot(p,p)); - - uv.x = r - .25*u_time; - uv.y = cos(a*5.0 + 2.0*sin(u_time+7.0*r)) ; - - vec3 col = (.5+.5*uv.y)*texture2D(u_tex0,uv).xyz; - - gl_FragColor = vec4(col,1.0); -} \ No newline at end of file diff --git a/assets/shaders/TwistVert.frag.glsl b/assets/shaders/TwistVert.frag.glsl deleted file mode 100644 index f8490615..00000000 --- a/assets/shaders/TwistVert.frag.glsl +++ /dev/null @@ -1,32 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - - -#ifdef GL_ES -precision highp float; -#endif - -// texture sampler uniforms -uniform sampler2D u_tex0; -uniform sampler2D u_tex1; - -//uniform vec4 color; -//varying vec4 v_color; -varying float v_zNormal; -varying vec2 v_texcoord; - - -void main() -{ - vec3 col; - if (v_zNormal >= 0.0) - col = texture2D(u_tex0, v_texcoord).xyz; - else - col = texture2D(u_tex1, v_texcoord).xyz; - - gl_FragColor = vec4(col, 1.0); - //gl_FragColor = v_color; -} diff --git a/assets/shaders/TwistVert.vert.glsl b/assets/shaders/TwistVert.vert.glsl deleted file mode 100644 index 29cb30ea..00000000 --- a/assets/shaders/TwistVert.vert.glsl +++ /dev/null @@ -1,97 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - - -#ifdef GL_ES -precision highp float; -#endif - - -// attributes -attribute vec3 vert; -attribute vec3 normal; -attribute vec2 texcoord; - -// scalar uniforms -uniform float u_limit1; -uniform float u_limit2; -uniform float u_twistAmount; -uniform float u_center; - -// texture sampler uniforms -uniform sampler2D u_tex0; -uniform sampler2D u_tex1; - -uniform vec4 color; - - -// matrix uniforms -uniform mat4 u_mvMatrix; -uniform mat4 u_projMatrix; -uniform mat4 u_worldMatrix; - -//varying vec4 v_color; -varying float v_zNormal; -varying vec2 v_texcoord; - - -float GetAngle( float t ) -{ - float angle= 0.0; - if (t < u_limit2) - { - if (t < u_limit1) - { - angle = u_twistAmount; - } - else - { - angle = (t - u_limit2)/(u_limit1 - u_limit2)*u_twistAmount; - } - } - - return angle; -} - - -void main(void) -{ - vec3 pos = vert; - vec2 uv = texcoord; - v_texcoord = texcoord; - - //v_color = vec4(texcoord.x, texcoord.y, 0, 1); - - v_zNormal = 1.0; - if (uv.x < u_limit2) - { - float angle = GetAngle( uv.x ); - float cs = cos(angle), sn = sin(angle); - - pos.y -= u_center; - vec3 ctrPt = pos; - float y = pos.y*cs - pos.z*sn + u_center; - pos.z = pos.y*sn + pos.z*cs; - pos.y = y; - - // rotate the normal - mat3 rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); - vec3 pt0 = ctrPt, pt1 = vec3(ctrPt.x, ctrPt.y+1.0, ctrPt.z), pt2 = vec3( ctrPt.x+1.0, ctrPt.y, ctrPt.z); - pt0 = rotMat * pt0; pt1 = rotMat * pt1; - angle = GetAngle(1.0); - cs = cos(angle); sn = sin(angle); - rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); - pt2 = rotMat * pt2; - pt0.y += u_center; pt1.y += u_center; pt2.y += u_center; - //vec4 nrm = u_projMatrix * u_mvMatrix * vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); - vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); - - //v_zNormal = normal.y*sn + normal.z*cs; - v_zNormal = -nrm.z; - } - - gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; -} \ No newline at end of file diff --git a/assets/shaders/Water.frag.glsl b/assets/shaders/Water.frag.glsl deleted file mode 100644 index 5b71a658..00000000 --- a/assets/shaders/Water.frag.glsl +++ /dev/null @@ -1,55 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform sampler2D u_tex0; -uniform float u_time; -uniform vec2 u_resolution; - -const float speedx = 1./ 0.1; -const float speedy = 1./ .01; -const float speedr = 1./ 0.01; -const float delta = 20.; -const float intence = 10.; -const int dif = 7; - -float col(vec2 coord) -{ - float delta_theta = 3.1415926535897932 / float(dif); - float col = 0.; - float theta = 0.; - theta = u_time/200.; - - coord.x += u_time/speedx; - coord.y += u_time/speedy; - for (int i = 0; i < dif; i++) - { - coord.x += u_time/speedr; - theta = theta + delta_theta; - col = col + cos( (coord.x*cos(theta) - coord.y*sin(theta))*20. ); - } - - return cos(col); -} - -void main(void) -{ - vec2 p = (gl_FragCoord.xy) / u_resolution.xy; - - vec2 c1 = p; - vec2 c2 = p; - - c2.x = c2.x+u_resolution.x/delta; - float dx = (col(c1)-col(c2))/delta; - - c2 = p; - c2.y = c2.y + u_resolution.y/delta; - float dy = (col(c1)-col(c2))/delta; - - c1.x = c1.x+dx; - c1.y = -(c1.y+dy); - - float alpha = 1.+dot(dx,dy)*intence; - if (alpha < 0.7) alpha = 0.7; - gl_FragColor = texture2D(u_tex0,c1)*(alpha); -} diff --git a/assets/shaders/Water2.frag.glsl b/assets/shaders/Water2.frag.glsl deleted file mode 100644 index 39b6aa55..00000000 --- a/assets/shaders/Water2.frag.glsl +++ /dev/null @@ -1,66 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform sampler2D u_tex0; -uniform float u_time; -uniform vec2 u_resolution; -const float PI = 3.1415926535897932; - -//speed -const float speed = 0.2; -const float speed_x = 0.3; -const float speed_y = 0.3; - -// geometry -const float intensity = 3.; -const int steps = 8; -const float frequency = 4.0; -const int angle = 7; // better when a prime - -// reflection and emboss -const float delta = 20.; -const float intence = 400.; -const float emboss = 0.3; - -//---------- crystals effect - - float col(vec2 coord) - { - float delta_theta = 2.0 * PI / float(angle); - float col = 0.0; - float theta = 0.0; - for (int i = 0; i < steps; i++) - { - vec2 adjc = coord; - theta = delta_theta*float(i); - adjc.x += cos(theta)*u_time*speed + u_time * speed_x; - adjc.y -= sin(theta)*u_time*speed - u_time * speed_y; - col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity; - } - - return cos(col); - } - -//---------- main - -void main(void) -{ -vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; -float cc1 = col(c1); - -c2.x += u_resolution.x/delta; -float dx = emboss*(cc1-col(c2))/delta; - -c2.x = p.x; -c2.y += u_resolution.y/delta; -float dy = emboss*(cc1-col(c2))/delta; - -c1.x += dx; -c1.y = -(c1.y+dy); - -float alpha = 1.+dot(dx,dy)*intence; -gl_FragColor = texture2D(u_tex0,c1)*(alpha); -// gl_FragColor = vec4(col(p),0,0,1); - -} diff --git a/assets/shaders/ZInvert.frag.glsl b/assets/shaders/ZInvert.frag.glsl deleted file mode 100644 index b1fd1748..00000000 --- a/assets/shaders/ZInvert.frag.glsl +++ /dev/null @@ -1,23 +0,0 @@ -#ifdef GL_ES -precision highp float; -#endif - -uniform vec2 u_resolution; -uniform float u_time; -uniform sampler2D u_tex0; - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - vec2 uv; - - float a = atan(p.y,p.x); - float r = sqrt(dot(p,p)); - - uv.x = cos(0.6+u_time) + cos(cos(1.2+u_time)+a)/r; - uv.y = cos(0.3+u_time) + sin(cos(2.0+u_time)+a)/r; - - vec3 col = texture2D(u_tex0,uv*.25).xyz; - - gl_FragColor = vec4(col*r*r,1.0); -} \ No newline at end of file diff --git a/assets/shaders/plasma.frag.glsl b/assets/shaders/plasma.frag.glsl deleted file mode 100644 index 2ab8f49c..00000000 --- a/assets/shaders/plasma.frag.glsl +++ /dev/null @@ -1,32 +0,0 @@ -// -// Fragment shader for procedural bricks -// -// Authors: Dave Baldwin, Steve Koren, Randi Rost -// based on a shader by Darwyn Peachey -// -// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. -// -// See 3Dlabs-License.txt for license information -// - -#ifdef GL_ES -precision highp float; -#endif - - -varying vec2 v_uv; -uniform float u_time; -uniform vec4 color; - -void main(void) -{ - float x = v_uv.x ; - float y = v_uv.y ; - float time = color.x; - float wave = (cos(time + y / 0.2 + cos(x / 0.3 + cos((y / 0.1))))); - float wave1 = (sin(abs(wave + y/0.6))); - float wave2 = (sin(abs(wave1 + y/0.8))); - float tmp = u_time * 0.1; - gl_FragColor = vec4( abs(vec3(wave2,wave1,wave)),1.0); - //gl_FragColor = color; -} diff --git a/assets/shaders/plasma.vert.glsl b/assets/shaders/plasma.vert.glsl deleted file mode 100644 index f817c143..00000000 --- a/assets/shaders/plasma.vert.glsl +++ /dev/null @@ -1,42 +0,0 @@ -// -// Vertex shader for procedural bricks -// -// Authors: Dave Baldwin, Steve Koren, Randi Rost -// based on a shader by Darwyn Peachey -// -// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. -// -// See 3Dlabs-License.txt for license information -// - -//uniform vec3 LightPosition; - -#ifdef GL_ES -precision highp float; -#endif - - -// attributes -attribute vec3 vert; -attribute vec3 normal; -attribute vec2 texcoord; - -uniform mat4 u_shadowLightWorld; -uniform mat4 u_shadowBiasMatrix; -uniform mat4 u_vShadowLight; -uniform vec3 u_lightPos; - -// matrix uniforms -uniform mat4 u_mvMatrix; -uniform vec3 u_eye; -uniform mat4 u_normalMatrix; -uniform mat4 u_projMatrix; -uniform mat4 u_worldMatrix; - -varying vec2 v_uv; - -void main(void) -{ - gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; - v_uv = texcoord; -} \ No newline at end of file diff --git a/assets/shaders/radialBlur.frag.glsl b/assets/shaders/radialBlur.frag.glsl deleted file mode 100644 index 673d082a..00000000 --- a/assets/shaders/radialBlur.frag.glsl +++ /dev/null @@ -1,47 +0,0 @@ - -precision highp float; - -uniform vec2 u_resolution; -uniform float u_time; -uniform vec4 color; -uniform sampler2D u_tex0; - -vec3 deform( in vec2 p ) -{ - vec2 uv; - - //float time = color.x; - float time = u_time; - vec2 q = vec2( sin(1.1*time+p.x),sin(1.2*time+p.y) ); - - float a = atan(q.y,q.x); - float r = sqrt(dot(q,q)); - - uv.x = sin(0.0+1.0*time)+p.x*sqrt(r*r+1.0); - uv.y = sin(0.6+1.1*time)+p.y*sqrt(r*r+1.0); - - return texture2D(u_tex0,uv*.5).xyz; -} - -void main(void) -{ - vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; - //vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / vec2(500,500).xy; - vec2 s = p; - - vec3 total = vec3(0.0); - vec2 d = (vec2(0.0,0.0)-p)/40.0; - float w = 1.0; - for( int i=0; i<40; i++ ) - { - vec3 res = deform(s); - res = smoothstep(0.1,1.0,res*res); - total += w*res; - w *= .99; - s += d; - } - total /= 40.0; - float r = 1.5/(1.0+dot(p,p)); - - gl_FragColor = vec4( total*r,1.0); -} \ No newline at end of file diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index 5b32547e..08057778 100755 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js @@ -400,10 +400,7 @@ function GLCircle() ctx.lineWidth = 0; ctx.fillStyle = "#990000"; if (this._fillColor) - { - var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")"; - ctx.fillStyle = c; - } + ctx.fillStyle = MathUtils.colorToHex( this._fillColor ); // draw the fill ctx.beginPath(); @@ -463,10 +460,7 @@ function GLCircle() ctx.lineWidth = lineWidth; ctx.strokeStyle = "#0000ff"; if (this._strokeColor) - { - var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; - ctx.strokeStyle = c; - } + ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor ); // draw the stroke p = MathUtils.transformPoint( bezPts[0], mat ); diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 0d815145..5ec51230 100755 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js @@ -11,74 +11,74 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot /////////////////////////////////////////////////////////////////////// function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) { - /////////////////////////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////////////////////////// - this._width = 2.0; - this._height = 2.0; - this._xOffset = 0; - this._yOffset = 0; - - // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side - this._xAdj = 0; - this._yAdj = 0; - - this._slope = 0; + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._width = 2.0; + this._height = 2.0; + this._xOffset = 0; + this._yOffset = 0; - this._strokeWidth = 0.25; + // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side + this._xAdj = 0; + this._yAdj = 0; + + this._slope = 0; - this._strokeStyle = "Solid"; - this._scaleX = 1.0; - this._scaleY = 1.0; + this._strokeWidth = 0.25; - if (arguments.length > 0) - { - this._width = width; - this._height = height; - this._xOffset = xOffset; - this._yOffset = yOffset; + this._strokeStyle = "Solid"; + this._scaleX = 1.0; + this._scaleY = 1.0; - this._xAdj = xAdj; - this._yAdj = yAdj; + if (arguments.length > 0) + { + this._width = width; + this._height = height; + this._xOffset = xOffset; + this._yOffset = yOffset; - this._slope = slope; - this._strokeWidth = strokeSize; - this._strokeColor = strokeColor; + this._xAdj = xAdj; + this._yAdj = yAdj; - this._strokeStyle = strokeStyle; - this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); - } + this._slope = slope; + this._strokeWidth = strokeSize; + this._strokeColor = strokeColor; - this._strokeVerticesLen = 0; + this._strokeStyle = strokeStyle; + this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); + } - this.m_world = world; + this._strokeVerticesLen = 0; + + this.m_world = world; this._materialAmbient = [0.2, 0.2, 0.2, 1.0]; this._materialDiffuse = [0.4, 0.4, 0.4, 1.0]; this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; - // initialize the inherited members - this.inheritedFrom = GLGeomObj; - this.inheritedFrom(); + // initialize the inherited members + this.inheritedFrom = GLGeomObj; + this.inheritedFrom(); - if(strokeMaterial) - { - this._strokeMaterial = strokeMaterial; - } + if(strokeMaterial) + { + this._strokeMaterial = strokeMaterial; + } - /////////////////////////////////////////////////////////////////////// - // Property Accessors - /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + // Property Accessors + /////////////////////////////////////////////////////////////////////// this.getStrokeWidth = function() { return this._strokeWidth; } this.setStrokeWidth = function(w) { this._strokeWidth = w; } this.getStrokeMaterial = function() { return this._strokeMaterial; } this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } - this.getStrokeColor = function() { return this._strokeColor; } + this.getStrokeColor = function() { return this._strokeColor; } //this.setStrokeColor = function(c) { this._strokeColor = c; } - this.getStrokeStyle = function() { return this._strokeStyle; } + this.getStrokeStyle = function() { return this._strokeStyle; } this.setStrokeStyle = function(s) { this._strokeStyle = s; } this.getFillMaterial = function() { return null; } @@ -86,24 +86,24 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } this.getStrokeMaterial = function() { return this._strokeMaterial; } - this.getWidth = function() { return this._width; } + this.getWidth = function() { return this._width; } this.setWidth = function(w) { this._width = w; } this.getHeight = function() { return this._height; } this.setHeight = function(h) { this._height = h; } - this.getXAdj = function() { return this._xAdj; } + this.getXAdj = function() { return this._xAdj; } this.setXAdj = function(x) { this._xAdj = x; } - this.getYAdj = function() { return this._yAdj; } + this.getYAdj = function() { return this._yAdj; } this.setYAdj = function(y) { this._yAdj = y; } - this.getSlope = function() { return this._slope; } + this.getSlope = function() { return this._slope; } this.setSlope = function(m) { this._slope = m; } - this.geomType = function() { return this.GEOM_TYPE_LINE; } + this.geomType = function() { return this.GEOM_TYPE_LINE; } - /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// this.export = function() @@ -137,14 +137,14 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); - this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) ); - this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) ); + this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) ); + this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) ); this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); var slope = this.getPropertyFromString( "slope: ", importStr ); - if(isNaN(Number(slope))) - this._slope = slope; - else - this._slope = Number(slope); + if(isNaN(Number(slope))) + this._slope = slope; + else + this._slope = Number(slope); var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); @@ -160,28 +160,28 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro } - /////////////////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////////////////// - this.buildBuffers = function() - { - // get the world - var world = this.getWorld(); - if (!world) throw( "null world in buildBuffers" ); + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + this.buildBuffers = function() + { + // get the world + var world = this.getWorld(); + if (!world) throw( "null world in buildBuffers" ); if (!world._useWebGL) return; // make sure RDGE has the correct context g_Engine.setContext( world.getCanvas().uuid ); - // create the gl buffer - var gl = world.getGLContext(); + // create the gl buffer + var gl = world.getGLContext(); - this._strokeVerticesLen = 0; + this._strokeVerticesLen = 0; - var strokeVertices = []; - var strokeTextures = []; - var strokeNormals = []; - var strokeColors = []; + var strokeVertices = []; + var strokeTextures = []; + var strokeNormals = []; + var strokeColors = []; // var scaleMat = Matrix.I(3); // scaleMat.elements[0][0] = this._scaleX; @@ -193,7 +193,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph, xFillNDC = this._width/vpw, yFillNDC = this._height/vph, - xAdjNDC = this._xAdj/vpw, yAdjNDC = this._yAdj/vph, + xAdjNDC = this._xAdj/vpw, yAdjNDC = this._yAdj/vph, xStrokeNDC = this._strokeWidth/vpw, yStrokeNDC = this._strokeWidth/vph; var aspect = world.getAspect(); @@ -218,180 +218,160 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro var xStroke = -z*(r-l)/(2.0*zn)*xStrokeNDC, yStroke = -z*(t-b)/(2.0*zn)*yStrokeNDC; - // get the x & y adjustments size + // get the x & y adjustments size var xAdj = -z*(r-l)/(2.0*zn)*xAdjNDC*2, yAdj = -z*(t-b)/(2.0*zn)*yAdjNDC*2; - this._primArray = []; - this._materialArray = []; + this._primArray = []; + this._materialArray = []; this._materialTypeArray = []; - this._materialNodeArray = []; - - this._scaleX = (world._viewportWidth)/(world._viewportHeight); - - var innerX = xFill-xStroke; - var innerY = yFill-yStroke; - - if(this._slope === "vertical") - { - strokeVertices = [ - -xFill+x, yFill+y, 0.0, - xFill+x, yFill+y, 0.0, - -xFill+x, -yFill+y, 0.0, - - xFill+x, -yFill+y, 0.0, - -xFill+x, -yFill+y, 0.0, - xFill+x, yFill+y, 0.0 - ]; - - strokeTextures = [ - 0, 1, - 1, 1, - 0, 0, - - 1, 0, - 0, 0, - 1, 1 - ]; - } - else if(this._slope === "horizontal") - { - // right now, this is the same as vertical line because, - // our canvas is the same size as us. - // But, we will need to use this when drawing in an existing GLWorld with other shapes - strokeVertices = [ - -xFill+x, yFill+y, 0.0, - xFill+x, yFill+y, 0.0, - -xFill+x, -yFill+y, 0.0, - - xFill+x, -yFill+y, 0.0, - -xFill+x, -yFill+y, 0.0, - xFill+x, yFill+y, 0.0 - ]; - - strokeTextures = [ - 0, 1, - 1, 1, - 0, 0, - - 1, 0, - 0, 0, - 1, 1 - ]; - } - else if(this._slope > 0) - { - // if slope is positive, draw a line from top-left to bottom-right - strokeVertices = [ - -xFill+x, yFill-2*yAdj+y, 0.0, - -xFill+2*xAdj+x, yFill+y, 0.0, - xFill-2*xAdj+x, -yFill+y, 0.0, - - xFill+x, -yFill+2*yAdj+y, 0.0, - xFill-2*xAdj+x, -yFill+y, 0.0, - -xFill+2*xAdj+x, yFill+y, 0.0 - ]; - - strokeTextures = [ - 0, 0, - 0, 1, - 1, 0, - - 1, 1, - 1, 0, - 0, 1 - ]; - } - else - { - // else slope is negative, draw a line from bottom-left to top-right - strokeVertices = [ - xFill-2*xAdj+x, yFill+y, 0.0, - -xFill+2*xAdj+x, -yFill+y, 0.0, - -xFill+x, -yFill+2*yAdj+y, 0.0, - - -xFill+2*xAdj+x, -yFill+y, 0.0, - xFill-2*xAdj+x, yFill+y, 0.0, - xFill+x, yFill-2*yAdj+y, 0.0 - ]; - - strokeTextures = [ - 1, 1, - 0, 0, - 0, 1, - - 0, 0, - 1, 1, - 1, 0 - ]; - } - - var z = 0; + this._materialNodeArray = []; + + this._scaleX = (world._viewportWidth)/(world._viewportHeight); + + var innerX = xFill-xStroke; + var innerY = yFill-yStroke; + +// if( (this._strokeStyle === "Dashed") || (this._strokeStyle === "Dotted") ) +// { +// var sLen = this.createStippledStrokes(strokeVertices, this._strokeWidth, this._slope, this._strokeStyle, innerX, innerY); +// this._strokeVerticesLen += sLen; +// } +// else + { + if(this._slope === "vertical") + { + strokeVertices = [ + -xFill+x, yFill+y, 0.0, + xFill+x, yFill+y, 0.0, + -xFill+x, -yFill+y, 0.0, + + xFill+x, -yFill+y, 0.0, + -xFill+x, -yFill+y, 0.0, + xFill+x, yFill+y, 0.0 + ]; + } + else if(this._slope === "horizontal") + { + // right now, this is the same as vertical line because, + // our canvas is the same size as us. + // But, we will need to use this when drawing in an existing GLWorld with other shapes + strokeVertices = [ + -xFill+x, yFill+y, 0.0, + xFill+x, yFill+y, 0.0, + -xFill+x, -yFill+y, 0.0, + + xFill+x, -yFill+y, 0.0, + -xFill+x, -yFill+y, 0.0, + xFill+x, yFill+y, 0.0 + ]; + } + else if(this._slope > 0) + { + // if slope is positive, draw a line from top-left to bottom-right + strokeVertices = [ + -xFill+x, yFill-2*yAdj+y, 0.0, + -xFill+2*xAdj+x, yFill+y, 0.0, + xFill-2*xAdj+x, -yFill+y, 0.0, + + xFill+x, -yFill+2*yAdj+y, 0.0, + xFill-2*xAdj+x, -yFill+y, 0.0, + -xFill+2*xAdj+x, yFill+y, 0.0 + ]; + } + else + { + // else slope is negative, draw a line from bottom-left to top-right + strokeVertices = [ + -xFill+x, -yFill+2*yAdj+y, 0.0, + -xFill+2*xAdj+x, -yFill+y, 0.0, + xFill-2*xAdj+x, yFill+y, 0.0, + + xFill+x, yFill-2*yAdj+y, 0.0, + xFill-2*xAdj+x, yFill+y, 0.0, + -xFill+2*xAdj+x, -yFill+y, 0.0 + ]; + } + } + + var z = 0; var indices = []; - var nVerts = strokeVertices.length/3; - - // stroke normals + var nVerts = strokeVertices.length/3; +// for(var i=0; i 0) - { + } + else if(this._slope > 0) + { p0 = [this._xAdj, this._yAdj]; p1 = [w - this._xAdj, h - this._yAdj]; - } - else - { - p0 = [this._xAdj, h - this._yAdj]; + } + else + { + p0 = [this._xAdj, h - this._yAdj]; p1 = [w - this._xAdj, this._yAdj]; } @@ -403,105 +383,105 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro /* - // type is Dotted or Dashed - this.createStippledStrokes = function(strokeVertices, strokeSize, slope, type, innerX, innerY) - { - var stippleLength = strokeSize; - - if (type === "Dotted") - { - stippleLength = this.DOT_LENGTH; - } - else if(type === "Dashed") - { - stippleLength = this.DASH_LENGTH; - } - - var numStrokes = 0; - var startPos = -innerX; - var endPos = innerX; - - var gap = this.GAP_LENGTH; - if(slope === "horizontal") - { - gap *= this._scaleX; - stippleLength *= this._scaleX; - } - else if(slope === "vertical") - { - startPos = -innerY; - endPos = innerY; - } - else - { - if(this._scaleX < 1) - { - startPos = -innerY; - endPos = innerY; - strokeSize = (strokeSize*this._scaleX)/2; + // type is Dotted or Dashed + this.createStippledStrokes = function(strokeVertices, strokeSize, slope, type, innerX, innerY) + { + var stippleLength = strokeSize; + + if (type === "Dotted") + { + stippleLength = this.DOT_LENGTH; + } + else if(type === "Dashed") + { + stippleLength = this.DASH_LENGTH; + } + + var numStrokes = 0; + var startPos = -innerX; + var endPos = innerX; + + var gap = this.GAP_LENGTH; + if(slope === "horizontal") + { + gap *= this._scaleX; + stippleLength *= this._scaleX; + } + else if(slope === "vertical") + { + startPos = -innerY; + endPos = innerY; + } + else + { + if(this._scaleX < 1) + { + startPos = -innerY; + endPos = innerY; + strokeSize = (strokeSize*this._scaleX)/2; // strokeSize *= this._scaleX; - stippleLength *= this._scaleX; - } - else - { - strokeSize = strokeSize/2; - gap *= this._scaleX; - stippleLength *= this._scaleX; - } - - } - - while(startPos + stippleLength < endPos) - { - if(slope === "horizontal") - { - strokeVertices.push(startPos); strokeVertices.push(-strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0); - - strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos+stippleLength); strokeVertices.push(strokeSize); strokeVertices.push(0); - } - else if(slope === "vertical") - { - strokeVertices.push(-strokeSize); strokeVertices.push(startPos); strokeVertices.push(0); - strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0); - strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0); - - strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0); - strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0); - strokeVertices.push(strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0); - } - else - { - strokeVertices.push(startPos); strokeVertices.push(startPos*-slope-strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0); - - strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0); - strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope+strokeSize); strokeVertices.push(0); - } - - numStrokes += 6; - - startPos += (stippleLength+gap); - } + stippleLength *= this._scaleX; + } + else + { + strokeSize = strokeSize/2; + gap *= this._scaleX; + stippleLength *= this._scaleX; + } + + } + + while(startPos + stippleLength < endPos) + { + if(slope === "horizontal") + { + strokeVertices.push(startPos); strokeVertices.push(-strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0); + + strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos+stippleLength); strokeVertices.push(strokeSize); strokeVertices.push(0); + } + else if(slope === "vertical") + { + strokeVertices.push(-strokeSize); strokeVertices.push(startPos); strokeVertices.push(0); + strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0); + strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0); + + strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0); + strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0); + strokeVertices.push(strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0); + } + else + { + strokeVertices.push(startPos); strokeVertices.push(startPos*-slope-strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0); + + strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0); + strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope+strokeSize); strokeVertices.push(0); + } + + numStrokes += 6; + + startPos += (stippleLength+gap); + } // - return numStrokes; - } + return numStrokes; + } */ - this.collidesWithPoint = function( x, y ) - { - if(x < this._xOffset) return false; - if(x > (this._xOffset + this._width)) return false; - if(y < this._yOffset) return false; - if(y > (this._yOffset + this._height)) return false; + this.collidesWithPoint = function( x, y ) + { + if(x < this._xOffset) return false; + if(x > (this._xOffset + this._width)) return false; + if(y < this._yOffset) return false; + if(y > (this._yOffset + this._height)) return false; - return true; - } + return true; + } } diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 5b6ff94f..4216fe53 100755 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js @@ -404,18 +404,12 @@ function GLRectangle() ctx.beginPath(); ctx.fillStyle = "#990000"; if (this._fillColor) - { - var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")"; - ctx.fillStyle = c; - } + ctx.fillStyle = MathUtils.colorToHex( this._fillColor ); // set the stroke ctx.strokeStyle = "#0000ff"; if (this._strokeColor) - { - var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; - ctx.strokeStyle = c; - } + ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor ); ctx.lineWidth = lw; var inset = Math.ceil( 0.5*lw ) + 0.5; @@ -1057,12 +1051,13 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, { var paramRange = material.getVertexDeformationRange(); var tolerance = material.getVertexDeformationTolerance(); - //nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); } } // create the RDGE primitive var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); + //var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.LINES, nVertices); return prim; } @@ -1150,7 +1145,7 @@ RectangleGeometry.create = function( ctr, width, height, material ) { var paramRange = material.getVertexDeformationRange(); var tolerance = material.getVertexDeformationTolerance(); - //nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); } } @@ -1228,6 +1223,108 @@ ShapePrimitive.create = function(coords, normals, uvs, indices, primType, ver } +ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices, paramRange, tolerance ) +{ + // get the param range + var pUMin = paramRange[0], pVMin = paramRange[1], + pUMax = paramRange[2], pVMax = paramRange[3]; + var iTriangle = 0; + var nTriangles = indices.length/3; + var index = 0; + while (iTriangle < nTriangles) + { + // get the indices of the 3 vertices + var i0 = indices[index], + i1 = indices[index+1], + i2 = indices[index+2]; + + // get the uv values + //var vrtIndex = 3*iTriangle; + var iuv0 = 2 * i0, + iuv1 = 2 * i1, + iuv2 = 2 * i2; + var u0 = uvs[iuv0], v0 = uvs[iuv0+1], + u1 = uvs[iuv1], v1 = uvs[iuv1+1], + u2 = uvs[iuv2], v2 = uvs[iuv2+1]; + + // find the u and v range + var uMin = u0, vMin = v0; + if (u1 < uMin) uMin = u1; if (v1 < vMin) vMin = v1; + if (u2 < uMin) uMin = u2; if (v2 < vMin) vMin = v2; + var uMax = u0, vMax = v0; + if (u1 > uMax) uMax = u1; if (v1 > vMax) vMax = v1; + if (u2 > uMax) uMax = u2; if (v2 > vMax) vMax = v2; + + // if the parameter range of the triangle is outside the + // desired parameter range, advance to the next polygon and continue + if ((uMin > pUMax) || (uMax < pUMin) || (vMin > pVMax) || (vMax < pVMin)) + { + // go to the next triangle + iTriangle++; + index += 3; + } + else + { + // check thesize of the triangle in uv space. If small enough, advance + // to the next triangle. If not small enough, split the triangle into 3; + var du = uMax - uMin, dv = vMax - vMin; + if ((du < tolerance) && (dv < tolerance)) + { + iTriangle++; + index += 3; + } + else // split the triangle into 4 parts + { + //calculate the position of the new vertex + var iPt0 = 3 * i0, + iPt1 = 3 * i1, + iPt2 = 3 * i2; + var x0 = verts[iPt0], y0 = verts[iPt0+1], z0 = verts[iPt0+2], + x1 = verts[iPt1], y1 = verts[iPt1+1], z1 = verts[iPt1+2], + x2 = verts[iPt2], y2 = verts[iPt2+1], z2 = verts[iPt2+2]; + + // calculate the midpoints of the edges + var xA = (x0 + x1)/2.0, yA = (y0 + y1)/2.0, zA = (z0 + z1)/2.0, + xB = (x1 + x2)/2.0, yB = (y1 + y2)/2.0, zB = (z1 + z2)/2.0, + xC = (x2 + x0)/2.0, yC = (y2 + y0)/2.0, zC = (z2 + z0)/2.0; + + // calculate the uv values of the new coordinates + var uA = (u0 + u1)/2.0, vA = (v0 + v1)/2.0, + uB = (u1 + u2)/2.0, vB = (v1 + v2)/2.0, + uC = (u2 + u0)/2.0, vC = (v2 + v0)/2.0; + + // calculate the normals for the new points + var nx0 = norms[iPt0], ny0 = norms[iPt0+1], nz0 = norms[iPt0+2], + nx1 = norms[iPt1], ny1 = norms[iPt1+1], nz1 = norms[iPt1+2], + nx2 = norms[iPt2], ny2 = norms[iPt2+1], nz2 = norms[iPt2+2]; + var nxA = (nx0 + nx1), nyA = (ny0 + ny1), nzA = (nz0 + nz1); var nrmA = VecUtils.vecNormalize(3, [nxA, nyA, nzA], 1.0 ), + nxB = (nx1 + nx2), nyB = (ny1 + ny2), nzB = (nz1 + nz2); var nrmB = VecUtils.vecNormalize(3, [nxB, nyB, nzB], 1.0 ), + nxC = (nx2 + nx0), nyC = (ny2 + ny0), nzC = (nz2 + nz0); var nrmC = VecUtils.vecNormalize(3, [nxC, nyC, nzC], 1.0 ); + + // push everything + verts.push(xA); verts.push(yA); verts.push(zA); + verts.push(xB); verts.push(yB); verts.push(zB); + verts.push(xC); verts.push(yC); verts.push(zC); + uvs.push(uA), uvs.push(vA); + uvs.push(uB), uvs.push(vB); + uvs.push(uC), uvs.push(vC); + norms.push(nrmA[0]); norms.push(nrmA[1]); norms.push(nrmA[2]); + norms.push(nrmB[0]); norms.push(nrmB[1]); norms.push(nrmB[2]); + norms.push(nrmC[0]); norms.push(nrmC[1]); norms.push(nrmC[2]); + + // split the current triangle into 4 + indices[index+1] = nVertices; indices[index+2] = nVertices+2; + indices.push(nVertices); indices.push(i1); indices.push(nVertices+1); nTriangles++; + indices.push(nVertices+1); indices.push(i2); indices.push(nVertices+2); nTriangles++; + indices.push(nVertices); indices.push(nVertices+1); indices.push(nVertices+2); nTriangles++; + nVertices += 3; + + // by not advancing 'index', we examine the first of the 3 triangles generated above + } + } + } + return nVertices; +} diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index 1edd5cff..c8327064 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js @@ -163,7 +163,7 @@ function GLWorld( canvas, use3D ) this.renderer.cameraManager().setActiveCamera(cam); // change clear color - //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); + this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); this.renderer.setClearColor([1.0, 1.0, 1.0, 0.0]); //this.renderer.NinjaWorld = this; @@ -206,7 +206,6 @@ function GLWorld( canvas, use3D ) { if (!dt) dt = 0.2; - dt = 0.01; // use our own internal throttle this.elapsed += dt; if (this._useWebGL) @@ -233,35 +232,39 @@ function GLWorld( canvas, use3D ) { g_Engine.setContext( this._canvas.uuid ); var ctx = g_Engine.getContext(); + var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); + if (ctx1 != ctx) + console.log( "***** different contexts (2) *****" ); + var aRenderer = ctx1.renderer; var renderer = ctx.renderer; + if (renderer != aRenderer) + { + console.log( "***** DIFFERENT RENDERERS *****" ); + renderer = aRenderer; + } + if (renderer.unloadedTextureCount <= 0) { renderer.disableCulling(); //console.log( "GLWorld.draw " + renderer._world._worldCount ); - renderer._clear(); this.myScene.render(); if (this._firstRender) { - if (this._canvas.task) - { - this._firstRender = false; + this._firstRender = false; - if (!this.hasAnimatedMaterials()) - { - this._canvas.task.stop(); - //this._renderCount = 10; - } + if (!this.hasAnimatedMaterials()) + { + //this.myScene.render(); + this._canvas.task.stop(); + //this._renderCount = 10; } } else if (this._renderCount >= 0) { - if (this._canvas.task) - { - this._renderCount--; - if