aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
diff options
context:
space:
mode:
authorhwc4872012-03-05 04:51:31 -0800
committerhwc4872012-03-05 04:51:31 -0800
commitcad4d6cb3f667f6174ec05cecead675b244285b9 (patch)
treefc5c9688069043f02fb9781a60c7984dba184f83 /js/helper-classes/RDGE/runtime/RuntimeMaterial.js
parentd044b6d9755d8ca686501fc3dd5644180e2ffbf0 (diff)
downloadninja-cad4d6cb3f667f6174ec05cecead675b244285b9.tar.gz
Added more materials/canvas2D drawing to runtime.
Diffstat (limited to 'js/helper-classes/RDGE/runtime/RuntimeMaterial.js')
-rw-r--r--js/helper-classes/RDGE/runtime/RuntimeMaterial.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/js/helper-classes/RDGE/runtime/RuntimeMaterial.js b/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
index 2ba3006e..5fe29f93 100644
--- a/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
+++ b/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
@@ -90,6 +90,7 @@ function RuntimePulseMaterial()
90 90
91 this.import = function( importStr ) 91 this.import = function( importStr )
92 { 92 {
93 this._texMap = getPropertyFromString( "texture: ", importStr );
93 } 94 }
94 95
95 this.init = function() 96 this.init = function()
@@ -137,4 +138,77 @@ function RuntimePulseMaterial()
137 } 138 }
138} 139}
139 140
141function RuntimeRadialGradientMaterial()
142{
143 // inherit the members of RuntimeMaterial
144 this.inheritedFrom = RuntimeMaterial;
145 this.inheritedFrom();
146
147 // setup default values
148 this._color1 = [0.25,0,0,1]; this._colorStop1 = 0.0;
149 this._color2 = [0,0.25,0,1]; this._colorStop2 = 0.3;
150 this._color3 = [0,0.25,0,1]; this._colorStop3 = 0.6;
151 this._color4 = [0,0.25,0,1]; this._colorStop4 = 1.0;
152
153 this.init = function()
154 {
155 var material = this._materialNode;
156 if (material)
157 {
158 var technique = material.shaderProgram.default;
159 var renderer = g_Engine.getContext().renderer;
160 if (renderer && technique)
161 {
162 if (this._shader && this._shader.default)
163 {
164 this._shader.default.u_color1.set( this._color1 );
165 this._shader.default.u_color2.set( this._color2 );
166 this._shader.default.u_color3.set( this._color3 );
167 this._shader.default.u_color4.set( this._color4 );
168
169 this._shader.default.u_colorStop1.set( [this._colorStop1] );
170 this._shader.default.u_colorStop2.set( [this._colorStop2] );
171 this._shader.default.u_colorStop3.set( [this._colorStop3] );
172 this._shader.default.u_colorStop4.set( [this._colorStop4] );
173
174 if (this._angle)
175 this._shader.default.u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]);
176 }
177 }
178 }
179 }
180
181 this.import = function( importStr )
182 {
183 var colorStr;
184 colorStr = getPropertyFromString( "color1: ", importStr );
185 this._color1 = eval( "[" + colorStr + "]" );
186 colorStr = getPropertyFromString( "color2: ", importStr );
187 this._color2 = eval( "[" + colorStr + "]" );
188 colorStr = getPropertyFromString( "color3: ", importStr );
189 this._color3 = eval( "[" + colorStr + "]" );
190 colorStr = getPropertyFromString( "color4: ", importStr );
191 this._color4 = eval( "[" + colorStr + "]" );
192
193 this._colorStop1 = Number( getPropertyFromString( "colorStop1: ", importStr ) );
194 this._colorStop1 = Number( getPropertyFromString( "colorStop2: ", importStr ) );
195 this._colorStop1 = Number( getPropertyFromString( "colorStop3: ", importStr ) );
196 this._colorStop1 = Number( getPropertyFromString( "colorStop4: ", importStr ) );
197
198 if (this._angle)
199 this._angle = getPropertyFromString( "angle: ", importStr );
200 }
201
202}
203
204function RuntimeLinearGradientMaterial()
205{
206 // inherit the members of RuntimeMaterial
207 this.inheritedFrom = RuntimeRadialGradientMaterial;
208 this.inheritedFrom();
209
210 // the only difference between linear & radial gradient is the existance of an angle for linear.
211 this._angle = 0.0;
212}
213
140 214