diff options
author | hwc487 | 2012-05-02 17:00:12 -0700 |
---|---|---|
committer | hwc487 | 2012-05-02 17:00:12 -0700 |
commit | 8eac5582b72115969a9f915f4303535c22018033 (patch) | |
tree | b9ad1621fee37eb73824dab7de062ac4ec2abf77 /js/lib/rdge | |
parent | f6983a69649b1c274ce6fe2d278a325994d092b6 (diff) | |
download | ninja-8eac5582b72115969a9f915f4303535c22018033.tar.gz |
Material editor
Diffstat (limited to 'js/lib/rdge')
-rw-r--r-- | js/lib/rdge/materials/cloud-material.js | 13 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 4 | ||||
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 4 |
3 files changed, 17 insertions, 4 deletions
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js index 0cf428b0..b7670178 100644 --- a/js/lib/rdge/materials/cloud-material.js +++ b/js/lib/rdge/materials/cloud-material.js | |||
@@ -183,7 +183,8 @@ var CloudMaterial = function CloudMaterial() | |||
183 | if (material) | 183 | if (material) |
184 | { | 184 | { |
185 | var technique = material.shaderProgram['default']; | 185 | var technique = material.shaderProgram['default']; |
186 | var renderer = RDGE.globals.engine.getContext().renderer; | 186 | var saveContext = RDGE.globals.engine.getContext(); |
187 | var renderer = RDGE.globals.engine.getContext().renderer; | ||
187 | if (renderer && technique) | 188 | if (renderer && technique) |
188 | { | 189 | { |
189 | var texMapName = this._propValues[this._propNames[0]]; | 190 | var texMapName = this._propValues[this._propNames[0]]; |
@@ -215,6 +216,10 @@ var CloudMaterial = function CloudMaterial() | |||
215 | } | 216 | } |
216 | } | 217 | } |
217 | 218 | ||
219 | this.updateColor = function() | ||
220 | { | ||
221 | } | ||
222 | |||
218 | this.update = function( time ) | 223 | this.update = function( time ) |
219 | { | 224 | { |
220 | if (this._srcWorld) | 225 | if (this._srcWorld) |
@@ -264,6 +269,7 @@ var CloudMaterial = function CloudMaterial() | |||
264 | this.getWorld().stop(); | 269 | this.getWorld().stop(); |
265 | 270 | ||
266 | // build a world to do the rendering | 271 | // build a world to do the rendering |
272 | if (!GLWorld) GLWorld = require("js/lib/drawing/world").World; | ||
267 | this._srcWorld = new GLWorld( this._srcCanvas, true, true ); | 273 | this._srcWorld = new GLWorld( this._srcCanvas, true, true ); |
268 | var srcWorld = this._srcWorld; | 274 | var srcWorld = this._srcWorld; |
269 | if (!this._srcCanvas) throw new Error( "No source canvas in Cloud material" ); | 275 | if (!this._srcCanvas) throw new Error( "No source canvas in Cloud material" ); |
@@ -273,13 +279,13 @@ var CloudMaterial = function CloudMaterial() | |||
273 | var prim = this.buildGeometry( srcWorld, srcCanvas.width, srcCanvas.height ); | 279 | var prim = this.buildGeometry( srcWorld, srcCanvas.width, srcCanvas.height ); |
274 | 280 | ||
275 | // set up the shader | 281 | // set up the shader |
276 | var shader = new jshader(); | 282 | var shader = new RDGE.jshader(); |
277 | shader.def = cloudMaterialDef; | 283 | shader.def = cloudMaterialDef; |
278 | shader.init(); | 284 | shader.init(); |
279 | this._srcShader = shader; | 285 | this._srcShader = shader; |
280 | 286 | ||
281 | // set up the material node | 287 | // set up the material node |
282 | var materialNode = createMaterialNode("cloudMaterial" + "_" + srcWorld.generateUniqueNodeID()); | 288 | var materialNode = RDGE.createMaterialNode("cloudMaterial" + "_" + srcWorld.generateUniqueNodeID()); |
283 | materialNode.setShader(shader); | 289 | materialNode.setShader(shader); |
284 | this._srcMaterialNode = materialNode; | 290 | this._srcMaterialNode = materialNode; |
285 | 291 | ||
@@ -322,7 +328,6 @@ var CloudMaterial = function CloudMaterial() | |||
322 | this.buildGeometry = function(world, canvasWidth, canvasHeight) | 328 | this.buildGeometry = function(world, canvasWidth, canvasHeight) |
323 | { | 329 | { |
324 | var RectangleGeometry = require("js/lib/geom/rectangle").RectangleGeometry; | 330 | var RectangleGeometry = require("js/lib/geom/rectangle").RectangleGeometry; |
325 | |||
326 | RectangleGeometry.init(); | 331 | RectangleGeometry.init(); |
327 | 332 | ||
328 | // get the normalized device coordinates (NDC) for | 333 | // get the normalized device coordinates (NDC) for |
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js index 2d8e6ca7..586948bb 100755 --- a/js/lib/rdge/materials/linear-gradient-material.js +++ b/js/lib/rdge/materials/linear-gradient-material.js | |||
@@ -42,6 +42,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
42 | 42 | ||
43 | this.setColor1 = function (c) { | 43 | this.setColor1 = function (c) { |
44 | this._color1 = c.slice(); | 44 | this._color1 = c.slice(); |
45 | this._propValues[this._propNames[0]] = this._color1.slice(0); | ||
45 | 46 | ||
46 | if (this._shader && this._shader['default']) { | 47 | if (this._shader && this._shader['default']) { |
47 | this._shader['default'].u_color1.set(c); | 48 | this._shader['default'].u_color1.set(c); |
@@ -54,6 +55,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
54 | 55 | ||
55 | this.setColor2 = function (c) { | 56 | this.setColor2 = function (c) { |
56 | this._color2 = c.slice(); | 57 | this._color2 = c.slice(); |
58 | this._propValues[this._propNames[1]] = this._color2.slice(0); | ||
57 | 59 | ||
58 | if (this._shader && this._shader['default']) { | 60 | if (this._shader && this._shader['default']) { |
59 | this._shader['default'].u_color2.set(c); | 61 | this._shader['default'].u_color2.set(c); |
@@ -66,6 +68,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
66 | 68 | ||
67 | this.setColor3 = function (c) { | 69 | this.setColor3 = function (c) { |
68 | this._color3 = c.slice(); | 70 | this._color3 = c.slice(); |
71 | this._propValues[this._propNames[2]] = this._color3.slice(0); | ||
69 | 72 | ||
70 | if (this._shader && this._shader['default']) { | 73 | if (this._shader && this._shader['default']) { |
71 | this._shader['default'].u_color3.set(c); | 74 | this._shader['default'].u_color3.set(c); |
@@ -78,6 +81,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
78 | 81 | ||
79 | this.setColor4 = function (c) { | 82 | this.setColor4 = function (c) { |
80 | this._color4 = c.slice(); | 83 | this._color4 = c.slice(); |
84 | this._propValues[this._propNames[3]] = this._color4.slice(0); | ||
81 | 85 | ||
82 | if (this._shader && this._shader['default']) { | 86 | if (this._shader && this._shader['default']) { |
83 | this._shader['default'].u_color4.set(c); | 87 | this._shader['default'].u_color4.set(c); |
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js index dd40d31d..65679429 100755 --- a/js/lib/rdge/materials/radial-gradient-material.js +++ b/js/lib/rdge/materials/radial-gradient-material.js | |||
@@ -41,6 +41,7 @@ var RadialGradientMaterial = function RadialGradientMaterial() { | |||
41 | 41 | ||
42 | this.setColor1 = function (c) { | 42 | this.setColor1 = function (c) { |
43 | this._color1 = c.slice(); | 43 | this._color1 = c.slice(); |
44 | this._propValues[this._propNames[0]] = this._color1.slice(0); | ||
44 | if (this._shader && this._shader['default']) { | 45 | if (this._shader && this._shader['default']) { |
45 | this._shader['default'].u_color1.set(c); | 46 | this._shader['default'].u_color1.set(c); |
46 | } | 47 | } |
@@ -52,6 +53,7 @@ var RadialGradientMaterial = function RadialGradientMaterial() { | |||
52 | 53 | ||
53 | this.setColor2 = function (c) { | 54 | this.setColor2 = function (c) { |
54 | this._color2 = c.slice(); | 55 | this._color2 = c.slice(); |
56 | this._propValues[this._propNames[1]] = this._color2.slice(0); | ||
55 | if (this._shader && this._shader['default']) { | 57 | if (this._shader && this._shader['default']) { |
56 | this._shader['default'].u_color2.set(c); | 58 | this._shader['default'].u_color2.set(c); |
57 | } | 59 | } |
@@ -64,6 +66,7 @@ var RadialGradientMaterial = function RadialGradientMaterial() { | |||
64 | 66 | ||
65 | this.setColor3 = function (c) { | 67 | this.setColor3 = function (c) { |
66 | this._color3 = c.slice(); | 68 | this._color3 = c.slice(); |
69 | this._propValues[this._propNames[2]] = this._color3.slice(0); | ||
67 | if (this._shader && this._shader['default']) { | 70 | if (this._shader && this._shader['default']) { |
68 | this._shader['default'].u_color3.set(c); | 71 | this._shader['default'].u_color3.set(c); |
69 | } | 72 | } |
@@ -75,6 +78,7 @@ var RadialGradientMaterial = function RadialGradientMaterial() { | |||
75 | 78 | ||
76 | this.setColor4 = function (c) { | 79 | this.setColor4 = function (c) { |
77 | this._color4 = c.slice(); | 80 | this._color4 = c.slice(); |
81 | this._propValues[this._propNames[3]] = this._color4.slice(0); | ||
78 | if (this._shader && this._shader['default']) { | 82 | if (this._shader && this._shader['default']) { |
79 | this._shader['default'].u_color4.set(c); | 83 | this._shader['default'].u_color4.set(c); |
80 | } | 84 | } |