aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
authorEric Guzman2012-03-17 00:05:14 -0700
committerEric Guzman2012-03-17 00:05:14 -0700
commita3192d8bc0f8c0698265817c14dcd2284fd89d7d (patch)
tree497ac55f550ed52f9d73b464aafb2aa6cb5f5038 /js/lib/rdge
parenta6a6f9bcc5ff92f5bb5e9275336dfaec2d8e8f4c (diff)
parent954f5a13e371febcb1c0fb8015c577ee51c23130 (diff)
downloadninja-a3192d8bc0f8c0698265817c14dcd2284fd89d7d.tar.gz
Merge branch 'refs/heads/master' into AddAnimationsLibrary
Conflicts: js/panels/presets/default-transition-presets.js
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js10
-rw-r--r--js/lib/rdge/materials/deform-material.js2
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js47
-rw-r--r--js/lib/rdge/materials/fly-material.js2
-rw-r--r--js/lib/rdge/materials/julia-material.js2
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js2
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js2
-rw-r--r--js/lib/rdge/materials/mandel-material.js2
-rw-r--r--js/lib/rdge/materials/plasma-material.js37
-rw-r--r--js/lib/rdge/materials/pulse-material.js11
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js9
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js7
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/star-material.js2
-rw-r--r--js/lib/rdge/materials/taper-material.js8
-rw-r--r--js/lib/rdge/materials/tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/twist-material.js2
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js6
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js203
-rw-r--r--js/lib/rdge/materials/water-material.js2
-rw-r--r--js/lib/rdge/materials/z-invert-material.js2
22 files changed, 289 insertions, 75 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index 61126952..fa6f5300 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -75,7 +75,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
75 this.setProperty = function( prop, value ) 75 this.setProperty = function( prop, value )
76 { 76 {
77 // every material should do something with the "color" property 77 // every material should do something with the "color" property
78 if (prop === "color") prop = "lightDiff"; 78 if (prop === "color") return;
79 79
80 // make sure we have legitimate imput 80 // make sure we have legitimate imput
81 var ok = this.validateProperty( prop, value ); 81 var ok = this.validateProperty( prop, value );
@@ -116,7 +116,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
116 this._shader['default'].u_light0Diff.set( this.getLightDiff() ); 116 this._shader['default'].u_light0Diff.set( this.getLightDiff() );
117 117
118 // set up the material node 118 // set up the material node
119 this._materialNode = createMaterialNode( this.getShaderName() ); 119 this._materialNode = createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() );
120 this._materialNode.setShader(this._shader); 120 this._materialNode.setShader(this._shader);
121 121
122 // set some image maps 122 // set some image maps
@@ -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/deform-material.js b/js/lib/rdge/materials/deform-material.js
index 1e6af6ac..dfd89d12 100644
--- a/js/lib/rdge/materials/deform-material.js
+++ b/js/lib/rdge/materials/deform-material.js
@@ -60,7 +60,7 @@ var DeformMaterial = function DeformMaterial() {
60 this._shader.init(); 60 this._shader.init();
61 61
62 // set up the material node 62 // set up the material node
63 this._materialNode = createMaterialNode("deformMaterial"); 63 this._materialNode = createMaterialNode("deformMaterial" + "_" + world.generateUniqueNodeID());
64 this._materialNode.setShader(this._shader); 64 this._materialNode.setShader(this._shader);
65 65
66 this._time = 0; 66 this._time = 0;
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js
index be8bf2b8..fff0e68e 100755
--- a/js/lib/rdge/materials/flat-material.js
+++ b/js/lib/rdge/materials/flat-material.js
@@ -36,19 +36,27 @@ var FlatMaterial = function FlatMaterial() {
36 // duplcate method requirde 36 // duplcate method requirde
37 this.dup = function() { return new FlatMaterial(); } ; 37 this.dup = function() { return new FlatMaterial(); } ;
38 38
39 this.init = function() 39 this.init = function( world )
40 { 40 {
41 // set up the shader 41 // save the world
42 this._shader = new jshader(); 42 if (world)
43 this._shader.def = flatShaderDef; 43 {
44 this._shader.init(); 44 this.setWorld( world );
45 45
46 // set the defaults 46 // set up the shader
47 this._shader.colorMe.color.set( this.getColor() ); 47 this._shader = new jshader();
48 48 this._shader.def = flatShaderDef;
49 // set up the material node 49 this._shader.init();
50 this._materialNode = createMaterialNode("flatMaterial"); 50
51 this._materialNode.setShader(this._shader); 51 // set the defaults
52 this._shader.colorMe.color.set( this.getColor() );
53
54 // set up the material node
55 this._materialNode = createMaterialNode("flatMaterial_" + world.generateUniqueNodeID() );
56 this._materialNode.setShader(this._shader);
57 }
58 else
59 throw new Error( "GLWorld not supplied to material initialization" );
52 }; 60 };
53 61
54 62
@@ -73,15 +81,12 @@ var FlatMaterial = function FlatMaterial() {
73 }; 81 };
74 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
75 83
76 this.export = function() { 84 this.export = function()
85 {
77 // this function should be overridden by subclasses 86 // this function should be overridden by subclasses
78 var exportStr = "material: " + this.getShaderName() + "\n"; 87 var exportStr = "material: " + this.getShaderName() + "\n";
79 exportStr += "name: " + this.getName() + "\n"; 88 exportStr += "name: " + this.getName() + "\n";
80 89 exportStr += "color: " + String(this._propValues["color"]) + "\n";
81 if (this._shader)
82 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
83 else
84 exportStr += "color: " + this.getColor() + "\n";
85 exportStr += "endMaterial\n"; 90 exportStr += "endMaterial\n";
86 91
87 return exportStr; 92 return exportStr;
@@ -97,13 +102,7 @@ var FlatMaterial = function FlatMaterial() {
97 try 102 try
98 { 103 {
99 var color = eval( "[" + pu.nextValue( "color: " ) + "]" ); 104 var color = eval( "[" + pu.nextValue( "color: " ) + "]" );
100
101 this.setProperty( "color", color); 105 this.setProperty( "color", color);
102
103 var endKey = "endMaterial\n";
104 var index = importStr.indexOf( endKey );
105 index += endKey.length;
106 rtnStr = importStr.substr( index );
107 } 106 }
108 catch (e) 107 catch (e)
109 { 108 {
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js
index 8eadb3ab..bd92ecd8 100644
--- a/js/lib/rdge/materials/fly-material.js
+++ b/js/lib/rdge/materials/fly-material.js
@@ -53,7 +53,7 @@ var FlyMaterial = function FlyMaterial() {
53 this._shader.init(); 53 this._shader.init();
54 54
55 // set up the material node 55 // set up the material node
56 this._materialNode = createMaterialNode("flyMaterial"); 56 this._materialNode = createMaterialNode("flyMaterial" + "_" + world.generateUniqueNodeID());
57 this._materialNode.setShader(this._shader); 57 this._materialNode.setShader(this._shader);
58 58
59 this._time = 0; 59 this._time = 0;
diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js
index 07536f33..976dfad3 100644
--- a/js/lib/rdge/materials/julia-material.js
+++ b/js/lib/rdge/materials/julia-material.js
@@ -55,7 +55,7 @@ var JuliaMaterial = function JuliaMaterial() {
55 this._shader.init(); 55 this._shader.init();
56 56
57 // set up the material node 57 // set up the material node
58 this._materialNode = createMaterialNode("juliaMaterial"); 58 this._materialNode = createMaterialNode("juliaMaterial" + "_" + world.generateUniqueNodeID());
59 this._materialNode.setShader(this._shader); 59 this._materialNode.setShader(this._shader);
60 60
61 this._time = 0; 61 this._time = 0;
diff --git a/js/lib/rdge/materials/keleidoscope-material.js b/js/lib/rdge/materials/keleidoscope-material.js
index 3ef5d613..16d1ccfa 100644
--- a/js/lib/rdge/materials/keleidoscope-material.js
+++ b/js/lib/rdge/materials/keleidoscope-material.js
@@ -60,7 +60,7 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
60 this._shader.init(); 60 this._shader.init();
61 61
62 // set up the material node 62 // set up the material node
63 this._materialNode = createMaterialNode("keleidoscopeMaterial"); 63 this._materialNode = createMaterialNode("keleidoscopeMaterial" + "_" + world.generateUniqueNodeID());
64 this._materialNode.setShader(this._shader); 64 this._materialNode.setShader(this._shader);
65 65
66 this._time = 0; 66 this._time = 0;
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js
index