aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials/LinearGradientMaterial.js')
-rwxr-xr-xjs/helper-classes/RDGE/Materials/LinearGradientMaterial.js379
1 files changed, 0 insertions, 379 deletions
diff --git a/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js b/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js
deleted file mode 100755
index 7fe2be0c..00000000
--- a/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js
+++ /dev/null
@@ -1,379 +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// Class GLMaterial
10// RDGE representation of a material.
11///////////////////////////////////////////////////////////////////////
12function LinearGradientMaterial()
13{
14 // initialize the inherited members
15 this.inheritedFrom = GLMaterial;
16 this.inheritedFrom();
17
18 ///////////////////////////////////////////////////////////////////////
19 // Instance variables
20 ///////////////////////////////////////////////////////////////////////
21 this._name = "LinearGradientMaterial";
22 this._shaderName = "linearGradient";
23
24 this._color1 = [1,0,0,1];
25 this._color2 = [0,1,0,1];
26 this._color3 = [0,0,1,1];
27 this._color4 = [0,1,1,1];
28 this._colorStop1 = 0.0;
29 this._colorStop2 = 0.3;
30 this._colorStop3 = 0.6;
31 this._colorStop4 = 1.0;
32// this._colorCount = 4;
33 this._angle = 0.0; // the shader takes [cos(a), sin(a)]
34
35 ///////////////////////////////////////////////////////////////////////
36 // Property Accessors
37 ///////////////////////////////////////////////////////////////////////
38 this.getShaderName = function() { return this._shaderName; };
39 this.getName = function() { return this._name; };
40
41 this.getColor1 = function() { return this._color1; };
42 this.setColor1 = function(c) { this._color1 = c.slice();
43 if (this._shader && this._shader.default)
44 this._shader.default.u_color1.set(c);
45 };
46
47 this.getColor2 = function() { return this._color2; };
48 this.setColor2 = function(c) { this._color2 = c.slice();
49 if (this._shader && this._shader.default)
50 this._shader.default.u_color2.set(c);
51 };
52
53 this.getColor3 = function() { return this._color3; };
54 this.setColor3 = function(c) { this._color3 = c.slice();
55 if (this._shader && this._shader.default)
56 this._shader.default.u_color3.set(c);
57 };
58
59 this.getColor4 = function() { return this._color4; };
60 this.setColor4 = function(c) { this._color4 = c.slice();
61 if (this._shader && this._shader.default)
62 this._shader.default.u_color4.set(c);
63 };
64
65 this.getColorStop1 = function() { return this._colorStop1; };
66 this.setColorStop1 = function(s) { this._colorStop1 = s;
67 if (this._shader && this._shader.default)
68 this._shader.default.u_colorStop1.set([s]);
69 };
70
71 this.getColorStop2 = function() { return this._colorStop2; };
72 this.setColorStop2 = function(s) { this._colorStop2 = s;
73 if (this._shader && this._shader.default)
74 this._shader.default.u_colorStop2.set([s]);
75 };
76
77 this.getColorStop3 = function() { return this._colorStop3; }
78 this.setColorStop3 = function(s) { this._colorStop3 = s;
79 if (this._shader && this._shader.default)
80 this._shader.default.u_colorStop3.set([s]);
81 }
82
83 this.getColorStop4 = function() { return this._colorStop4; };
84 this.setColorStop4 = function(s) { this._colorStop4 = s;
85 if (this._shader && this._shader.default)
86 this._shader.default.u_colorStop4.set([s]);
87 };
88
89// this.getColorCount = function() { return this._colorCount; };
90// this.setColorCount = function(c) { this._colorCount = c;
91// if (this._shader && this._shader.default)
92// this._shader.default.u_colorCount.set([c]);
93// };
94
95 this.getAngle = function() { return this._angle; };
96 this.setAngle = function(a) { this._angle = a;
97 if (this._shader && this._shader.default)
98 this._shader.default.u_cos_sin_angle.set([Math.cos(a), Math.sin(a)]);
99 };
100
101 this.isAnimated = function() { return false; };
102
103 ///////////////////////////////////////////////////////////////////////
104 // Material Property Accessors
105 ///////////////////////////////////////////////////////////////////////
106 this._propNames = ["color1", "color2", "color3", "color4", "colorStop1", "colorStop2", "colorStop3", "colorStop4", "angle"];
107 this._propLabels = ["Color 1", "Color 2", "Color 3", "Color 4", "Color Stop 1", "Color Stop 2", "Color Stop 3", "Color Stop 4", "Angle"];
108 this._propTypes = ["color", "color", "color", "color", "float", "float", "float", "float", "float"];
109 this._propValues = [];
110
111 this._propValues[ this._propNames[0] ] = this._color1.slice(0);
112 this._propValues[ this._propNames[1] ] = this._color2.slice(0);
113 this._propValues[ this._propNames[2] ] = this._color3.slice(0);
114 this._propValues[ this._propNames[3] ] = this._color4.slice(0);
115
116 this._propValues[ this._propNames[4] ] = this._colorStop1;
117 this._propValues[ this._propNames[5] ] = this._colorStop2;
118 this._propValues[ this._propNames[6] ] = this._colorStop3;
119 this._propValues[ this._propNames[7] ] = this._colorStop4;
120
121 this._propValues[ this._propNames[8] ] = this._angle;
122
123 this.setProperty = function( prop, value )
124 {
125 if (prop === "color") prop = "color1";
126
127 // make sure we have legitimate imput
128 var ok = this.validateProperty( prop, value );
129 if (!ok)
130 console.log( "invalid property in Linear Gradient Material" + prop + " : " + value );
131
132 switch (prop)
133 {
134 case "color1": this.setColor1( value ); break;
135 case "color2": this.setColor2( value ); break;
136 case "color3": this.setColor3( value ); break;
137 case "color4": this.setColor4( value ); break;
138 case "colorStop1": this.setColorStop1( value ); break;
139 case "colorStop2": this.setColorStop2( value ); break;
140 case "colorStop3": this.setColorStop3( value ); break;
141 case "colorStop4": this.setColorStop4( value ); break;
142 case "angle": this.setAngle( value ); break;
143 }
144 };
145
146 ///////////////////////////////////////////////////////////////////////
147 // Methods
148 ///////////////////////////////////////////////////////////////////////
149 // duplcate method requirde
150 this.dup = function() { return new LinearGradientMaterial(); };
151
152 this.init = function( world )
153 {
154 this.setWorld( world );
155
156 // set up the shader
157 this._shader = new jshader();
158 this._shader.def = linearGradientMaterialDef;
159 this._shader.init();
160
161 // set up the material node
162 this._materialNode = createMaterialNode( this.getShaderName() );
163 this._materialNode.setShader(this._shader);
164
165 // send the current values to the shader
166 this.updateShaderValues();
167
168 //console.log( "**** LinearGradientMaterial initialized" );
169 };
170
171 this.updateShaderValues= function()
172 {
173 if (this._shader && this._shader.default)
174 {
175 //this._shader.default.u_colorCount.set( [4] );
176
177 var c;
178 c = this.getColor1();
179 this._shader.default.u_color1.set( c );
180 c = this.getColor2();
181 this._shader.default.u_color2.set( c );
182 c = this.getColor3();
183 this._shader.default.u_color3.set( c );
184 c = this.getColor4();
185 this._shader.default.u_color4.set( c );
186
187 var s;
188 s = this.getColorStop1();
189 this._shader.default.u_colorStop1.set( [s] );
190 s = this.getColorStop2();
191 this._shader.default.u_colorStop2.set( [s] );
192 s = this.getColorStop3();
193 this._shader.default.u_colorStop3.set( [s] );