diff options
author | Jose Antonio Marquez | 2012-03-10 16:30:45 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-10 16:30:45 -0800 |
commit | 7d4d8651d059a91d29142d7f07d3122eb64532fa (patch) | |
tree | 6f180ddb9f631b49271670771144759c39f3c919 /js/lib/rdge | |
parent | 94ddbc239965cb39431708e78dde5127c64b0060 (diff) | |
parent | 615be47750fb86c07acd9354da12a76abe6c24e0 (diff) | |
download | ninja-7d4d8651d059a91d29142d7f07d3122eb64532fa.tar.gz |
Merge branch 'refs/heads/FileIO-Integration' into FileIO-Build-Candidate
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 6 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 8 | ||||
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 6 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 2 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 46 | ||||
-rw-r--r-- | js/lib/rdge/runtime/CanvasDataManager.js | 83 | ||||
-rw-r--r-- | js/lib/rdge/runtime/GLRuntime.js | 357 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeGeomObj.js | 633 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeMaterial.js | 351 |
9 files changed, 59 insertions, 1433 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 67b16371..fa6f5300 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -158,10 +158,14 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
158 | var exportStr = "material: " + this.getShaderName() + "\n"; | 158 | var exportStr = "material: " + this.getShaderName() + "\n"; |
159 | exportStr += "name: " + this.getName() + "\n"; | 159 | exportStr += "name: " + this.getName() + "\n"; |
160 | 160 | ||
161 | var world = this.getWorld(); | ||
162 | if (!world) | ||
163 | throw new Error( "no world in material.export, " + this.getName() ); | ||
164 | |||
161 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; | 165 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; |
162 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; | 166 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; |
163 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; | 167 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; |
164 | exportStr += "normalMap: " + this.getNormalTexture() + "\n"; | 168 | exportStr += "normalMap: " + this.getNormalTexture() + "\n"; |
165 | 169 | ||
166 | // every material needs to terminate like this | 170 | // every material needs to terminate like this |
167 | exportStr += "endMaterial\n"; | 171 | exportStr += "endMaterial\n"; |
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 1e3137eb..81db36c6 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js | |||
@@ -179,8 +179,12 @@ var PulseMaterial = function PulseMaterial() { | |||
179 | var exportStr = "material: " + this.getShaderName() + "\n"; | 179 | var exportStr = "material: " + this.getShaderName() + "\n"; |
180 | exportStr += "name: " + this.getName() + "\n"; | 180 | exportStr += "name: " + this.getName() + "\n"; |
181 | 181 | ||
182 | var texMapName = this._propValues[this._propNames[0]]; | 182 | var world = this.getWorld(); |
183 | exportStr += "texture: " + texMapName + "\n"; | 183 | if (!world) |
184 | throw new Error( "no world in material.export, " + this.getName() ); | ||
185 | |||
186 | var texMapName = this._propValues[this._propNames[0]]; | ||
187 | exportStr += "texture: " +texMapName + "\n"; | ||
184 | 188 | ||
185 | // every material needs to terminate like this | 189 | // every material needs to terminate like this |
186 | exportStr += "endMaterial\n"; | 190 | exportStr += "endMaterial\n"; |
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index d0d05e8d..46cdda74 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js | |||
@@ -162,7 +162,11 @@ var RadialBlurMaterial = function RadialBlurMaterial() { | |||
162 | var exportStr = "material: " + this.getShaderName() + "\n"; | 162 | var exportStr = "material: " + this.getShaderName() + "\n"; |
163 | exportStr += "name: " + this.getName() + "\n"; | 163 | exportStr += "name: " + this.getName() + "\n"; |
164 | 164 | ||
165 | var texMapName = this._propValues[this._propNames[0]]; | 165 | var world = this.getWorld(); |
166 | if (!world) | ||
167 | throw new Error( "no world in material.export, " + this.getName() ); | ||
168 | |||
169 | var texMapName = this._propValues[this._propNames[0]]; | ||
166 | exportStr += "texture: " + texMapName + "\n"; | 170 | exportStr += "texture: " + texMapName + "\n"; |
167 | 171 | ||
168 | // every material needs to terminate like this | 172 | // every material needs to terminate like this |
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js index bd89f08f..03a7ba9c 100644 --- a/js/lib/rdge/materials/taper-material.js +++ b/js/lib/rdge/materials/taper-material.js | |||
@@ -104,7 +104,7 @@ function TaperMaterial() | |||
104 | exportStr += "name: " + this.getName() + "\n"; | 104 | exportStr += "name: " + this.getName() + "\n"; |
105 | 105 | ||
106 | if (this._shader) | 106 | if (this._shader) |
107 | exportStr += "color: " + String(this._shader.colorMe.color) + "\n"; | 107 | exportStr += "color: " + this._shader.colorMe.color + "\n"; |
108 | else | 108 | else |
109 | exportStr += "color: " + this.getColor() + "\n"; | 109 | exportStr += "color: " + this.getColor() + "\n"; |
110 | exportStr += "endMaterial\n"; | 110 | exportStr += "endMaterial\n"; |
diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js index 0964c9c4..655d8e2a 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js | |||
@@ -33,6 +33,8 @@ var UberMaterial = function UberMaterial() { | |||
33 | this._useEnvironmentMap = true; | 33 | this._useEnvironmentMap = true; |
34 | this._useLights = [true, true, true, true]; | 34 | this._useLights = [true, true, true, true]; |
35 | 35 | ||
36 | this._MAX_LIGHTS = 4; | ||
37 | |||
36 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
37 | // Material Property Accessors | 39 | // Material Property Accessors |
38 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
@@ -374,6 +376,18 @@ var UberMaterial = function UberMaterial() { | |||
374 | var index = importStr.indexOf( endKey ); | 376 | var index = importStr.indexOf( endKey ); |
375 | index += endKey.length; | 377 | index += endKey.length; |
376 | importStr = importStr.substr( index ); | 378 | importStr = importStr.substr( index ); |
379 | var pu = new MaterialParser( importStr ); | ||
380 | |||
381 | var matProps = pu.nextValue( "materialProps: " ); | ||
382 | if (matProps) | ||
383 | { | ||
384 | var ambientColor = Number( pu.nextValue( "ambientColor: " )); this.setProperty( "ambientColor", ambientColor ); | ||
385 | var diffuseColor = Number( pu.nextValue( "diffuseColor: " )); this.setProperty( "diffuseColor", diffuseColor ); | ||
386 | var specularColor = Number( pu.nextValue( "specularColor: " )); this.setProperty( "specularColor", specularColor ); | ||
387 | var specularPower = Number( pu.nextValue( "specularPower: " )); this.setProperty( "specularPower", specularPower ); | ||
388 | } | ||
389 | |||
390 | var lightProps = pu.nextValue( "theLights" ); | ||
377 | } | 391 | } |
378 | 392 | ||
379 | this.export = function() | 393 | this.export = function() |
@@ -387,7 +401,7 @@ var UberMaterial = function UberMaterial() { | |||
387 | // export the material properties | 401 | // export the material properties |
388 | if (typeof caps.material != 'undefined') | 402 | if (typeof caps.material != 'undefined') |
389 | { | 403 | { |
390 | exportStr += "material: true\n"; | 404 | exportStr += "materialProps: true\n"; |
391 | exportStr += "ambientColor: " + caps.material.ambientColor + "\n"; | 405 | exportStr += "ambientColor: " + caps.material.ambientColor + "\n"; |
392 | exportStr += "diffuseColor: " + caps.material.diffuseColor + "\n"; | 406 | exportStr += "diffuseColor: " + caps.material.diffuseColor + "\n"; |
393 | exportStr += "specularColor: " + caps.material.specularColor + "\n"; | 407 | exportStr += "specularColor: " + caps.material.specularColor + "\n"; |
@@ -396,8 +410,9 @@ var UberMaterial = function UberMaterial() { | |||
396 | 410 | ||
397 | if (typeof caps.lighting != 'undefined') | 411 | if (typeof caps.lighting != 'undefined') |
398 | { | 412 | { |
413 | exportStr += "lightProps: true\n"; | ||
414 | |||
399 | var light = caps.lighting['light' + i]; | 415 | var light = caps.lighting['light' + i]; |
400 | var t; | ||
401 | for (var i=0; i<this._MAX_LIGHTS; i++) | 416 | for (var i=0; i<this._MAX_LIGHTS; i++) |
402 | { | 417 | { |
403 | var light = caps.lighting["light" + i]; | 418 | var light = caps.lighting["light" + i]; |
@@ -405,6 +420,7 @@ var UberMaterial = function UberMaterial() { | |||
405 | { | 420 | { |
406 | exportStr += "light" + i + ': ' + light.type + "\n"; | 421 | exportStr += "light" + i + ': ' + light.type + "\n"; |
407 | 422 | ||
423 | // output the light secific data | ||
408 | if (light.type === 'directional') | 424 | if (light.type === 'directional') |
409 | { | 425 | { |
410 | exportStr += 'light' + i + 'Dir: ' + light['direction'] + '\n'; | 426 | exportStr += 'light' + i + 'Dir: ' + light['direction'] + '\n'; |
@@ -419,9 +435,11 @@ var UberMaterial = function UberMaterial() { | |||
419 | } | 435 | } |
420 | else // light.type === 'point' | 436 | else // light.type === 'point' |
421 | { | 437 | { |
422 | technique['u_light'+i+'Pos'].set(light['position'] || [ 0, 0, 0 ]); | 438 | exportStr += 'light' + i + 'Pos: ' + (light['position'] || [ 0, 0, 0 ]) ; |
423 | technique['u_light'+i+'Atten'].set(light['attenuation'] || [ 1,0,0 ]); | 439 | exportStr += 'light' + i + 'Attenuation: ' + (light['attenuation'] || [ 1, 0, 0 ]) ; |
424 | } | 440 | } |
441 | |||
442 | // common to all lights | ||
425 | exportStr += 'light' + i + 'Color: ' + light['diffuseColor'] || [ 1,1,1,1 ] + '\n'; | 443 | exportStr += 'light' + i + 'Color: ' + light['diffuseColor'] || [ 1,1,1,1 ] + '\n'; |
426 | exportStr += 'light' + i + 'SpecularColor: ' + light['specularColor'] || [ 1, 1, 1, 1 ] + '\n'; | 444 | exportStr += 'light' + i + 'SpecularColor: ' + light['specularColor'] || [ 1, 1, 1, 1 ] + '\n'; |
427 | 445 | ||
@@ -429,6 +447,26 @@ var UberMaterial = function UberMaterial() { | |||
429 | } | 447 | } |
430 | } | 448 | } |
431 | } | 449 | } |
450 | |||
451 | // this._diffuseMapOb = { 'texture' : 'assets/images/rocky-diffuse.jpg', 'wrap' : 'REPEAT' }; | ||
452 | // this._normalMapOb = { 'texture' : 'assets/images/rocky-normal.jpg', 'wrap' : 'REPEAT' }; | ||
453 | // this._specularMapOb = { 'texture' : 'assets/images/rocky-spec.jpg', 'wrap' : 'REPEAT' }; | ||
454 | // this._environmentMapOb = { 'texture' : 'assets/images/silver.png', 'wrap' : 'CLAMP', 'envReflection' : this._environmentAmount }; | ||
455 | var world = this.getWorld(); | ||
456 | if (!world) | ||
457 | throw new Error( "no world in material.export, " + this.getName() ); | ||
458 | |||
459 | if(typeof caps.diffuseMap != 'undefined') | ||
460 | exportStr += "diffuseMap: " + caps.diffuseMap.texture + "\n"; | ||
461 | |||
462 | if(typeof caps.normalMap != 'undefined') | ||
463 | exportStr += "normalMap: " + caps.normalMap.texture + "\n"; | ||
464 | |||
465 | if(typeof caps.specularMap != 'undefined') | ||
466 | exportStr += "specularMap: " + caps.specularMap.texture + "\n"; | ||
467 | |||
468 | if(typeof caps.environmentMap != 'undefined') | ||
469 | exportStr += "environmentMap: " + caps.environmentMap.texture + "\n"; | ||
432 | 470 | ||
433 | // every material needs to terminate like this | 471 | // every material needs to terminate like this |
434 | exportStr += "endMaterial\n"; | 472 | exportStr += "endMaterial\n"; |
diff --git a/js/lib/rdge/runtime/CanvasDataManager.js b/js/lib/rdge/runtime/CanvasDataManager.js deleted file mode 100644 index 8afc9de0..00000000 --- a/js/lib/rdge/runtime/CanvasDataManager.js +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | /* <copyright> |