diff options
Diffstat (limited to 'js/lib/rdge')
22 files changed, 195 insertions, 69 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..97e4f646 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; |
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 2c52c67d..8e05e23d 100755 --- a/js/lib/rdge/materials/linear-gradient-material.js +++ b/js/lib/rdge/materials/linear-gradient-material.js | |||
@@ -212,7 +212,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
212 | this._shader.init(); | 212 | this._shader.init(); |
213 | 213 | ||
214 | // set up the material node | 214 | // set up the material node |
215 | this._materialNode = createMaterialNode( this.getShaderName() ); | 215 | this._materialNode = createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); |
216 | this._materialNode.setShader(this._shader); | 216 | this._materialNode.setShader(this._shader); |
217 | 217 | ||
218 | // send the current values to the shader | 218 | // send the current values to the shader |
diff --git a/js/lib/rdge/materials/mandel-material.js b/js/lib/rdge/materials/mandel-material.js index 07e009a2..d9f00383 100644 --- a/js/lib/rdge/materials/mandel-material.js +++ b/js/lib/rdge/materials/mandel-material.js | |||
@@ -66,7 +66,7 @@ var MandelMaterial = function MandelMaterial() { | |||
66 | this._shader.init(); | 66 | this._shader.init(); |
67 | 67 | ||
68 | // set up the material node | 68 | // set up the material node |
69 | this._materialNode = createMaterialNode("mandelMaterial"); | 69 | this._materialNode = createMaterialNode("mandelMaterial" + "_" + world.generateUniqueNodeID()); |
70 | this._materialNode.setShader(this._shader); | 70 | this._materialNode.setShader(this._shader); |
71 |