aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-02-13 11:59:19 -0800
committerArmen Kesablyan2012-02-13 11:59:19 -0800
commit90d0c8c0e98d062c628c061fe5765ce991fda409 (patch)
tree9780e9dcf475bf319f3cacc1a1ad52fcf9f133af /js/helper-classes/RDGE/Materials/RadialBlurMaterial.js
parent8110e01dc5093ac6baf621103dcaa5f769e5be92 (diff)
parente142611e22718b1f1d1696902ad9161ec5f33f98 (diff)
downloadninja-90d0c8c0e98d062c628c061fe5765ce991fda409.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Conflicts: css/ninja.css js/stage/stage.reel/stage.html js/tools/TextTool.js node_modules/labs/rich-text-editor.reel/rich-text-editor.css node_modules/labs/rich-text-editor.reel/rich-text-editor.html node_modules/labs/rich-text-editor.reel/rich-text-editor.js node_modules/labs/rich-text-editor.reel/rich-text-resizer.js node_modules/labs/rich-text-editor.reel/rich-text-sanitizer.js Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/Materials/RadialBlurMaterial.js')
-rw-r--r--js/helper-classes/RDGE/Materials/RadialBlurMaterial.js241
1 files changed, 0 insertions, 241 deletions
diff --git a/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js b/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js
deleted file mode 100644
index 25331b54..00000000
--- a/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js
+++ /dev/null
@@ -1,241 +0,0 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7
8
9///////////////////////////////////////////////////////////////////////
10// Class GLMaterial
11// RDGE representation of a material.
12///////////////////////////////////////////////////////////////////////
13function RadialBlurMaterial()
14{
15 // initialize the inherited members
16 this.inheritedFrom = GLMaterial;
17 this.inheritedFrom();
18
19 ///////////////////////////////////////////////////////////////////////
20 // Instance variables
21 ///////////////////////////////////////////////////////////////////////
22 this._name = "RadialBlurMaterial";
23 this._shaderName = "radialBlur";
24
25 this._texMap = 'assets/images/cubelight.png';
26 this._color = [1,0,0,1];
27
28 this._time = 0.0;
29 this._dTime = 0.01;
30
31 ///////////////////////////////////////////////////////////////////////
32 // Property Accessors
33 ///////////////////////////////////////////////////////////////////////
34 this.getName = function() { return this._name; }
35 this.getShaderName = function() { return this._shaderName; }
36
37 this.getTextureMap = function() { return this._texMap.slice(0); }
38 this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m.slice(0); this.updateTexture(); }
39
40 ///////////////////////////////////////////////////////////////////////
41 // Material Property Accessors
42 ///////////////////////////////////////////////////////////////////////
43 this._propNames = ["texmap", "color"];
44 this._propLabels = ["Texture map", "Color"];
45 this._propTypes = ["file", "color"];
46 this._propValues = [];
47
48 this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
49 this._propValues[ this._propNames[1] ] = this._color.slice(0);
50
51 this.setProperty = function( prop, value )
52 {
53 // make sure we have legitimate imput
54 var ok = this.validateProperty( prop, value );
55 if (!ok)
56 console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value );
57
58 switch (prop)
59 {
60 case "texmap":
61 this.setTextureMap(value);
62 break;
63
64 case "color":
65 this._propValues[prop] = value.slice(0);
66 if (this._shader && this._shader.default)
67 this._shader.default[prop].set(value);
68 break;
69 }
70 }
71 ///////////////////////////////////////////////////////////////////////
72
73
74 ///////////////////////////////////////////////////////////////////////
75 // Methods
76 ///////////////////////////////////////////////////////////////////////
77 // duplcate method requirde
78 this.dup = function( world )
79 {
80 // allocate a new uber material
81 var newMat = new RadialBlurMaterial();
82
83 // copy over the current values;
84 var propNames = [], propValues = [], propTypes = [], propLabels = [];
85 this.getAllProperties( propNames, propValues, propTypes, propLabels);
86 var n = propNames.length;
87 for (var i=0; i<n; i++)
88 newMat.setProperty( propNames[i], propValues[i] );
89
90 return newMat;
91 }
92
93 this.init = function( world )
94 {
95 // set up the shader
96 this._shader = new jshader();
97 this._shader.def = radialBlurMaterialDef;
98 this._shader.init();
99
100 // set up the material node
101 this._materialNode = createMaterialNode("radialBlurMaterial");
102 this._materialNode.setShader(this._shader);
103
104 this._time = 0;
105 if (this._shader && this._shader.default)
106 this._shader.default.u_time.set( [this._time] );
107 this.setProperty( "color", [this._time, 0, 0, 1] );
108
109 // set the shader values in the shader
110 this.updateTexture();
111 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
112 this.update( 0 );
113 }
114
115 this.updateTexture = function()
116 {
117 var material = this._materialNode;
118 if (material)
119 {
120 var technique = material.shaderProgram.default;
121 var renderer = g_Engine.getContext().renderer;
122 if (renderer && technique)
123 {
124 var texMapName = this._propValues[this._propNames[0]];
125 var tex = renderer.getTextureByName(texMapName, 'REPEAT');
126// if (tex)
127// {
128// var res = [tex.image.naturalWidth, tex.image.naturalHeight];
129// this.setResoloution( res );
130// }
131 technique.u_tex0.set( tex );
132 }
133 }
134 }
135
136 this.update = function( time )
137 {
138 var material = this._materialNode;
139 if (material)
140 {
141 var technique = material.shaderProgram.default;
142 var renderer = g_Engine.getContext().renderer;
143 if (renderer && technique)
144 {
145 if (this._shader && this._shader.default)
146 this._shader.default.u_time.set( [this._time] );
147 var color = this.getProperty( "color" );
148 color[0] = this._time;
149 this.setProperty( "color", color );
150 //console.log( "update color to: " + color );
151 this._time += this._dTime;
152 }
153 }
154 }
155
156 this.setResolution = function( res )
157 {
158 var material = this._materialNode;
159 if (material)
160 {
161 var technique = material.shaderProgram.default;
162 var renderer = g_Engine.getContext().renderer;
163 if (renderer && technique)
164 {
165 technique.u_resolution.set( res );
166 }
167 }
168 }
169
170 this.export = function()
171 {
172 // every material needs the base type and instance name
173 var exportStr = "material: " + this.getShaderName() + "\n";
174 exportStr += "name: " + this.getName() + "\n";
175
176 // every material needs to terminate like this
177 exportStr += "endMaterial\n";
178
179 return exportStr;
180 }
181
182 this.import = function( importStr )
183 {
184 var pu = new ParseUtils( importStr );
185 var material = pu.nextValue( "material: " );
186 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
187 this.setName( pu.nextValue( "name: ") );
188
189 var rtnStr;
190
191 return rtnStr;
192 }
193}
194
195///////////////////////////////////////////////////////////////////////////////////////
196// RDGE shader
197
198// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
199var radialBlurMaterialDef =
200{'shaders':
201 {
202 'defaultVShader':"assets/shaders/Basic.vert.glsl",
203 'def