diff options
author | Eric Guzman | 2012-03-16 15:09:09 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-16 15:09:09 -0700 |
commit | f08e3660384ed6ed2ba8ecf959c90fd1ade818eb (patch) | |
tree | 49c36caa1f0cf7e5ff8ca9239609965aa1b7a8e5 /js/helper-classes/backup-delete/Materials/PulseMaterial.js | |
parent | 4afb01e3b8261ab5e9492bfc63ad17e44dfcb934 (diff) | |
parent | 3e98d9eaf6f691aa0f7a4334983537a4ee3ffd39 (diff) | |
download | ninja-f08e3660384ed6ed2ba8ecf959c90fd1ade818eb.tar.gz |
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/helper-classes/backup-delete/Materials/PulseMaterial.js')
-rw-r--r-- | js/helper-classes/backup-delete/Materials/PulseMaterial.js | 266 |
1 files changed, 0 insertions, 266 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 e55798b7..00000000 --- a/js/helper-classes/backup-delete/Materials/PulseMaterial.js +++ /dev/null | |||
@@ -1,266 +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_" + world.generateUniqueNodeID()); | ||
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 | var texMapName = this._propValues[this._propNames[0]]; | ||
190 | exportStr += "texture: " + texMapName + "\n"; | ||
191 | |||
192 | // every material needs to terminate like this | ||
193 | exportStr += "endMaterial\n"; | ||
194 | |||
195 | return exportStr; | ||
196 | } | ||
197 | |||
198 | this.import = function( importStr ) | ||
199 | { | ||
200 | var pu = new ParseUtils( importStr ); | ||
201 | var material = pu.nextValue( "material: " ); |