aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials')
-rwxr-xr-xjs/helper-classes/RDGE/Materials/BumpMetalMaterial.js10
-rwxr-xr-xjs/helper-classes/RDGE/Materials/FlatMaterial.js31
-rwxr-xr-xjs/helper-classes/RDGE/Materials/UberMaterial.js6
3 files changed, 32 insertions, 15 deletions
diff --git a/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js b/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
index 17be0cd7..999d4676 100755
--- a/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
+++ b/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
@@ -51,7 +51,7 @@ function BumpMetalMaterial()
51 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
52 // Material Property Accessors 52 // Material Property Accessors
53 /////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////
54 this._propNames = ["lightDiff", "diffuseMap", "normalMap", "specularMap"]; 54 this._propNames = ["lightDiff", "diffuseTexture", "normalMap", "specularTexture"];
55 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"]; 55 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"];
56 this._propTypes = ["color", "file", "file", "file"]; 56 this._propTypes = ["color", "file", "file", "file"];
57 this._propValues = []; 57 this._propValues = [];
@@ -151,7 +151,7 @@ function BumpMetalMaterial()
151 exportStr += "lightDiff: " + this.getLightDiff() + "\n"; 151 exportStr += "lightDiff: " + this.getLightDiff() + "\n";
152 exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; 152 exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n";
153 exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; 153 exportStr += "specularTexture: " + this.getSpecularTexture() + "\n";
154 exportStr += "normalTexture: " + this.getNormalTexture() + "\n"; 154 exportStr += "normalMap: " + this.getNormalTexture() + "\n";
155 155
156 // every material needs to terminate like this 156 // every material needs to terminate like this
157 exportStr += "endMaterial\n"; 157 exportStr += "endMaterial\n";
@@ -172,12 +172,12 @@ function BumpMetalMaterial()
172 var lightDiff = eval( "[" + pu.nextValue( "lightDiff: " ) + "]" ), 172 var lightDiff = eval( "[" + pu.nextValue( "lightDiff: " ) + "]" ),
173 dt = pu.nextValue( "diffuseTexture: " ), 173 dt = pu.nextValue( "diffuseTexture: " ),
174 st = pu.nextValue( "specularTexture: " ), 174 st = pu.nextValue( "specularTexture: " ),
175 nt = pu.nextValue( "normalTexture: " ); 175 nt = pu.nextValue( "normalMap: " );
176 176
177 this.setProperty( "lightDiff", lightDif); 177 this.setProperty( "lightDiff", lightDiff);
178 this.setProperty( "diffuseTexture", dt ); 178 this.setProperty( "diffuseTexture", dt );
179 this.setProperty( "specularTexture", st ); 179 this.setProperty( "specularTexture", st );
180 this.setProperty( "normalTexture", nt ); 180 this.setProperty( "normalMap", nt );
181 181
182 var endKey = "endMaterial\n"; 182 var endKey = "endMaterial\n";
183 var index = importStr.indexOf( endKey ); 183 var index = importStr.indexOf( endKey );
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js
index 3e3ae25e..e2f23d75 100755
--- a/js/helper-classes/RDGE/Materials/FlatMaterial.js
+++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js
@@ -71,10 +71,11 @@ function FlatMaterial()
71 71
72 this.setProperty = function( prop, value ) 72 this.setProperty = function( prop, value )
73 { 73 {
74 // make sure we have legitimate imput 74 // make sure we have legitimate input
75 if (this.validateProperty( prop, value )) 75 if (this.validateProperty( prop, value ))
76 { 76 {
77 this._color = value.slice(0); 77 this._propValues[prop] = value;
78 if (this._shader && this._shader.colorMe)
78 this._shader.colorMe[prop].set(value); 79 this._shader.colorMe[prop].set(value);
79 } 80 }
80 } 81 }
@@ -84,7 +85,7 @@ function FlatMaterial()
84 { 85 {
85 // this function should be overridden by subclasses 86 // this function should be overridden by subclasses
86 var exportStr = "material: " + this.getShaderName() + "\n"; 87 var exportStr = "material: " + this.getShaderName() + "\n";
87 exportStr = "name: " + this.getName() + "\n"; 88 exportStr += "name: " + this.getName() + "\n";
88 89
89 if (this._shader) 90 if (this._shader)
90 exportStr += "color: " + String(this._shader.colorMe.color) + "\n"; 91 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
@@ -100,19 +101,35 @@ function FlatMaterial()
100 var pu = new ParseUtils( importStr ); 101 var pu = new ParseUtils( importStr );
101 var material = pu.nextValue( "material: " ); 102 var material = pu.nextValue( "material: " );
102 if (material != this.getShaderName()) throw new Error( "ill-formed material" ); 103 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
103 this.setName( pu.nextValue( "material: ") ); 104 this.setName( pu.nextValue( "name: ") );
104 var color = pu.nextValue( "color: " ); 105
106 var rtnStr;
107 try
108 {
109 var color = eval( "[" + pu.nextValue( "color: " ) + "]" );
110
111 this.setProperty( "color", color);
105 112
106 var endKey = "endMaterial\n"; 113 var endKey = "endMaterial\n";
107 var index = importStr.indexOf( endKey ) + endKey.len; 114 var index = importStr.indexOf( endKey );
108 var rtnStr = importStr.substr( index ); 115 index += endKey.length;
116 rtnStr = importStr.substr( index );
117 }
118 catch (e)
119 {
120 throw new Error( "could not import material: " + importStr );
121 }
122
109 return rtnStr; 123 return rtnStr;
110 } 124 }
111 125
112 this.update = function( time ) 126 this.update = function( time )
113 { 127 {
114 } 128 }
129
115} 130}
131// used to create unique names
132var flatMaterialCounter = 0;
116 133
117/////////////////////////////////////////////////////////////////////////////////////// 134///////////////////////////////////////////////////////////////////////////////////////
118// RDGE shader 135// RDGE shader
diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js
index afb745d1..73356b03 100755
--- a/js/helper-classes/RDGE/Materials/UberMaterial.js
+++ b/js/helper-classes/RDGE/Materials/UberMaterial.js
@@ -45,9 +45,9 @@ function UberMaterial()
45 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
46 // Material Property Accessors 46 // Material Property Accessors
47 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
48 this._propNames = ["ambientColor", "diffuseColor", "specularColor", "specularPower" , "diffuseMap", "normalMap", "specularMap", "environmentMap", "environmentAmount", "dummy" ]; 48 this._propNames = ["ambientColor", "diffuseColor", "specularColor", "specularPower" , "diffuseMap", "normalMap", "specularMap", "environmentMap", "environmentAmount" ];
49 this._propLabels = ["Ambient Color", "Diffuse Color", "Specular Color", "Specular Power", "Texture Map", "Bump Map", "Specular Map", "Environment Map", "Environment Map Amount", "Dummy" ]; 49 this._propLabels = ["Ambient Color", "Diffuse Color", "Specular Color", "Specular Power", "Texture Map", "Bump Map", "Specular Map", "Environment Map", "Environment Map Amount" ];
50 this._propTypes = ["color", "color", "color", "float", "file", "file", "file", "file", "float", "checkbox"]; 50 this._propTypes = ["color", "color", "color", "float", "file", "file", "file", "file", "float" ];
51 this._propValues = []; 51 this._propValues = [];
52 52
53 this._propValues[ this._propNames[0] ] = this._ambientColor.slice(0); 53 this._propValues[ this._propNames[0] ] = this._ambientColor.slice(0);