diff options
Diffstat (limited to 'js/helper-classes/backup-delete/Materials/PulseMaterial.js')
-rw-r--r-- | js/helper-classes/backup-delete/Materials/PulseMaterial.js | 263 |
1 files changed, 0 insertions, 263 deletions
diff --git a/js/helper-classes/backup-delete/Materials/PulseMaterial.js b/js/helper-classes/backup-delete/Materials/PulseMaterial.js deleted file mode 100644 index d76b9966..00000000 --- a/js/helper-classes/backup-delete/Materials/PulseMaterial.js +++ /dev/null | |||
@@ -1,263 +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 | /////////////////////////////////////////////////////////////////////// | ||
13 | function PulseMaterial() | ||
14 | { | ||
15 | // initialize the inherited members | ||
16 | this.inheritedFrom = GLMaterial; | ||
17 | this.inheritedFrom(); | ||
18 | |||
19 | /////////////////////////////////////////////////////////////////////// | ||
20 | // Instance variables | ||
21 | /////////////////////////////////////////////////////////////////////// | ||
22 | this._name = "PulseMaterial"; | ||
23 | this._shaderName = "pulse"; | ||
24 | |||
25 | this._texMap = 'assets/images/cubelight.png'; | ||
26 | |||
27 | this._time = 0.0; | ||
28 | this._dTime = 0.01; | ||
29 | |||
30 | /////////////////////////////////////////////////////////////////////// | ||
31 | // Property Accessors | ||
32 | /////////////////////////////////////////////////////////////////////// | ||
33 | this.getName = function() { return this._name; } | ||
34 | this.getShaderName = function() { return this._shaderName; } | ||
35 | |||
36 | this.getTextureMap = function() { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null } | ||
37 | this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); } | ||
38 | |||
39 | this.isAnimated = function() { return true; } | ||
40 | |||
41 | /////////////////////////////////////////////////////////////////////// | ||
42 | // Material Property Accessors | ||
43 | /////////////////////////////////////////////////////////////////////// | ||
44 | this._propNames = ["texmap"]; | ||
45 | this._propLabels = ["Texture map"]; | ||
46 | this._propTypes = ["file"]; | ||
47 | this._propValues = []; | ||
48 | |||
49 | this._propValues[ this._propNames[0] ] = this._texMap.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 | break; | ||
66 | } | ||
67 | } | ||
68 | /////////////////////////////////////////////////////////////////////// | ||
69 | |||
70 | |||
71 | /////////////////////////////////////////////////////////////////////// | ||
72 | // Methods | ||
73 | /////////////////////////////////////////////////////////////////////// | ||
74 | // duplcate method requirde | ||
75 | this.dup = function( world ) | ||
76 | { | ||
77 | // save the world | ||
78 | if (world) this.setWorld( world ); | ||
79 | |||
80 | // allocate a new uber material | ||
81 | var newMat = new PulseMaterial(); | ||
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 | // save the world | ||
96 | if (world) this.setWorld( world ); | ||
97 | |||
98 | // this variable declared above is inherited set to a smaller delta. | ||
99 | // the pulse material runs a little faster | ||
100 | this._dTime = 0.01; | ||
101 | |||
102 | // set up the shader | ||
103 | this._shader = new jshader(); | ||
104 | this._shader.def = pulseMaterialDef; | ||
105 | this._shader.init(); | ||
106 | |||
107 | // set up the material node | ||
108 | this._materialNode = createMaterialNode("pulseMaterial"); | ||
109 | this._materialNode.setShader(this._shader); | ||
110 | |||
111 | this._time = 0; | ||
112 | if (this._shader && this._shader.default) | ||
113 | this._shader.default.u_time.set( [this._time] ); | ||
114 | |||
115 | // set the shader values in the shader | ||
116 | this.updateTexture(); | ||
117 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | ||
118 | this.update( 0 ); | ||
119 | } | ||
120 | |||
121 | this.updateTexture = function() | ||
122 | { | ||
123 | var material = this._materialNode; | ||
124 | if (material) | ||
125 | { | ||
126 | var technique = material.shaderProgram.default; | ||
127 | var renderer = g_Engine.getContext().renderer; | ||
128 | if (renderer && technique) | ||
129 | { | ||
130 | var texMapName = this._propValues[this._propNames[0]]; | ||
131 | var wrap = 'REPEAT', mips = true; | ||
132 | var tex = this.loadTexture( texMapName, wrap, mips ); | ||
133 | |||
134 | /* | ||
135 | var glTex = new GLTexture( this.getWorld() ); | ||
136 | var prevWorld = this.findPreviousWorld(); | ||
137 | if (prevWorld) | ||
138 | { | ||
139 | var srcCanvas = prevWorld.getCanvas(); | ||
140 | tex = glTex.loadFromCanvas( srcCanvas ); | ||
141 | } | ||
142 | else | ||
143 | tex = glTex.loadFromFile( texMapName, wrap, mips ); | ||
144 | */ | ||
145 | |||
146 | if (tex) | ||
147 | technique.u_tex0.set( tex ); | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | |||
152 | this.update = function( time ) | ||
153 | { | ||
154 | var material = this._materialNode; | ||
155 | if (material) | ||
156 | { | ||
157 | var technique = material.shaderProgram.default; | ||
158 | var renderer = g_Engine.getContext().renderer; | ||
159 | if (renderer && technique) | ||
160 | { | ||
161 | if (this._shader && this._shader.default) | ||
162 | this._shader.default.u_time.set( [this._time] ); | ||
163 | this._time += this._dTime; | ||
164 | if (this._time > 200.0) this._time = 0.0; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | this.setResolution = function( res ) | ||
170 | { | ||
171 | var material = this._materialNode; | ||
172 | if (material) | ||
173 | { | ||
174 | var technique = material.shaderProgram.default; | ||
175 | var renderer = g_Engine.getContext().renderer; | ||
176 | if (renderer && technique) | ||
177 | { | ||
178 | technique.u_resolution.set( res ); | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | |||
183 | this.export = function() | ||
184 | { | ||
185 | // every material needs the base type and instance name | ||
186 | var exportStr = "material: " + this.getShaderName() + "\n"; | ||
187 | exportStr += "name: " + this.getName() + "\n"; | ||
188 | |||
189 | // every material needs to terminate like this | ||
190 | exportStr += "endMaterial\n"; | ||
191 | |||
192 | return exportStr; | ||
193 | } | ||
194 | |||
195 | this.import = function( importStr ) | ||
196 | { | ||
197 | var pu = new ParseUtils( importStr ); | ||
198 | var material = pu.nextValue( "material: " ); | ||
199 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); | ||
200 | this.setName( pu.nextValue( "name: ") ); | ||
201 | |||
202 | var rtnStr; | ||
203 | try | ||
204 | { | ||
205 | var endKey = "endMaterial\n"; | ||
206 | var index = importStr.indexOf( endKey ); | ||
207 | index += endKey.length; | ||
208 | rtnStr = importStr.substr( index ); | ||
209 | } | ||