aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials')
-rw-r--r--js/helper-classes/RDGE/Materials/BumpMetalMaterial.js10
-rw-r--r--js/helper-classes/RDGE/Materials/FlatMaterial.js48
-rw-r--r--js/helper-classes/RDGE/Materials/UberMaterial.js6
3 files changed, 39 insertions, 25 deletions
diff --git a/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js b/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
index 0aa3ee78..59720611 100644
--- a/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
+++ b/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
@@ -52,7 +52,7 @@ function BumpMetalMaterial()
52 /////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////
53 // Material Property Accessors 53 // Material Property Accessors
54 /////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////
55 this._propNames = ["lightDiff", "diffuseMap", "normalMap", "specularMap"]; 55 this._propNames = ["lightDiff", "diffuseTexture", "normalMap", "specularTexture"];
56 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"]; 56 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"];
57 this._propTypes = ["color", "file", "file", "file"]; 57 this._propTypes = ["color", "file", "file", "file"];
58 this._propValues = []; 58 this._propValues = [];
@@ -122,7 +122,7 @@ function BumpMetalMaterial()
122 exportStr += "lightDiff: " + this.getLightDiff() + "\n"; 122 exportStr += "lightDiff: " + this.getLightDiff() + "\n";
123 exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; 123 exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n";
124 exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; 124 exportStr += "specularTexture: " + this.getSpecularTexture() + "\n";
125 exportStr += "normalTexture: " + this.getNormalTexture() + "\n"; 125 exportStr += "normalMap: " + this.getNormalTexture() + "\n";
126 126
127 // every material needs to terminate like this 127 // every material needs to terminate like this
128 exportStr += "endMaterial\n"; 128 exportStr += "endMaterial\n";
@@ -143,12 +143,12 @@ function BumpMetalMaterial()
143 var lightDiff = eval( "[" + pu.nextValue( "lightDiff: " ) + "]" ), 143 var lightDiff = eval( "[" + pu.nextValue( "lightDiff: " ) + "]" ),
144 dt = pu.nextValue( "diffuseTexture: " ), 144 dt = pu.nextValue( "diffuseTexture: " ),
145 st = pu.nextValue( "specularTexture: " ), 145 st = pu.nextValue( "specularTexture: " ),
146 nt = pu.nextValue( "normalTexture: " ); 146 nt = pu.nextValue( "normalMap: " );
147 147
148 this.setProperty( "lightDiff", lightDif); 148 this.setProperty( "lightDiff", lightDiff);
149 this.setProperty( "diffuseTexture", dt ); 149 this.setProperty( "diffuseTexture", dt );
150 this.setProperty( "specularTexture", st ); 150 this.setProperty( "specularTexture", st );
151 this.setProperty( "normalTexture", nt ); 151 this.setProperty( "normalMap", nt );
152 152
153 var endKey = "endMaterial\n"; 153 var endKey = "endMaterial\n";
154 var index = importStr.indexOf( endKey ); 154 var index = importStr.indexOf( endKey );
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js
index 5177a8a0..a5c079a8 100644
--- a/js/helper-classes/RDGE/Materials/FlatMaterial.js
+++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js
@@ -63,11 +63,12 @@ function FlatMaterial()
63 63
64 this.setProperty = function( prop, value ) 64 this.setProperty = function( prop, value )
65 { 65 {
66 // make sure we have legitimate imput 66 // make sure we have legitimate input
67 if (this.validateProperty( prop, value )) 67 if (this.validateProperty( prop, value ))
68 { 68 {
69 this._color = value.slice(0); 69 this._propValues[prop] = value;
70 this._shader.colorMe[prop].set(value); 70 if (this._shader && this._shader.colorMe)
71 this._shader.colorMe[prop].set(value);
71 } 72 }
72 } 73 }
73 /////////////////////////////////////////////////////////////////////// 74 ///////////////////////////////////////////////////////////////////////
@@ -76,7 +77,7 @@ function FlatMaterial()
76 { 77 {
77 // this function should be overridden by subclasses 78 // this function should be overridden by subclasses
78 var exportStr = "material: " + this.getShaderName() + "\n"; 79 var exportStr = "material: " + this.getShaderName() + "\n";
79 exportStr = "name: " + this.getName() + "\n"; 80 exportStr += "name: " + this.getName() + "\n";
80 81
81 if (this._shader) 82 if (this._shader)
82 exportStr += "color: " + String(this._shader.colorMe.color) + "\n"; 83 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
@@ -87,19 +88,32 @@ function FlatMaterial()
87 return exportStr; 88 return exportStr;
88 } 89 }
89 90
90 this.import = function( importStr ) 91 this.import = function( importStr )
91 { 92 {
92 var pu = new ParseUtils( importStr ); 93 var pu = new ParseUtils( importStr );
93 var material = pu.nextValue( "material: " ); 94 var material = pu.nextValue( "material: " );
94 if (material != this.getShaderName()) throw new Error( "ill-formed material" ); 95 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
95 this.setName( pu.nextValue( "material: ") ); 96 this.setName( pu.nextValue( "name: ") );
96 var color = pu.nextValue( "color: " ); 97
97 98 var rtnStr;
98 var endKey = "endMaterial\n"; 99 try
99 var index = importStr.indexOf( endKey ) + endKey.len; 100 {
100 var rtnStr = importStr.substr( index ); 101 var color = eval( "[" + pu.nextValue( "color: " ) + "]" );
101 return rtnStr; 102
102 } 103 this.setProperty( "color", color);
104
105 var endKey = "endMaterial\n";
106 var index = importStr.indexOf( endKey );
107 index += endKey.length;
108 rtnStr = importStr.substr( index );
109 }
110 catch (e)
111 {
112 throw new Error( "could not import material: " + importStr );
113 }
114
115 return rtnStr;
116 }
103} 117}
104 118
105// used to create unique names 119// used to create unique names
diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js
index a8254465..f3acdaa6 100644
--- 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);