aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-08 14:24:48 -0800
committerNivesh Rajbhandari2012-02-08 14:24:48 -0800
commit2d68f944e93b201deb46015392e706b7a24201c9 (patch)
tree55367f4efb8a49447753e473af52f878f1584b64 /js/helper-classes/RDGE
parent79ef4e4f51f8981feac3f3bddb6a06aa37407542 (diff)
downloadninja-2d68f944e93b201deb46015392e706b7a24201c9.tar.gz
Fixed several typos in Materials import/export code to support toggling between 2d and 3d shape modes.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE')
-rw-r--r--js/helper-classes/RDGE/GLMaterial.js2
-rw-r--r--js/helper-classes/RDGE/GLRectangle.js4
-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
-rw-r--r--js/helper-classes/RDGE/MaterialsLibrary.js2
6 files changed, 43 insertions, 29 deletions
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js
index 51c27ace..e1a68abd 100644
--- a/js/helper-classes/RDGE/GLMaterial.js
+++ b/js/helper-classes/RDGE/GLMaterial.js
@@ -186,7 +186,7 @@ function GLMaterial( world )
186 var endKey = "endMaterial\n"; 186 var endKey = "endMaterial\n";
187 var index = importStr.indexOf( endKey ); 187 var index = importStr.indexOf( endKey );
188 index += endKey.length; 188 index += endKey.length;
189 rtnStr = importStr.substr( index ); 189 var rtnStr = importStr.substr( index );
190 190
191 return rtnStr; 191 return rtnStr;
192 } 192 }
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js
index 8535a683..b88ecc71 100644
--- a/js/helper-classes/RDGE/GLRectangle.js
+++ b/js/helper-classes/RDGE/GLRectangle.js
@@ -177,8 +177,8 @@ function GLRectangle()
177 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); 177 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
178 this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); 178 this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) );
179 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) ); 179 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) );
180 var strokeMaterialName = Number( this.getPropertyFromString( "strokeMat: ", importStr ) ); 180 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
181 var fillMaterialName = Number( this.getPropertyFromString( "fillMat: ", importStr ) ); 181 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr );
182 this._strokeStyle = Number( this.getPropertyFromString( "strokeColor: ", importStr ) ); 182 this._strokeStyle = Number( this.getPropertyFromString( "strokeColor: ", importStr ) );
183 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); 183 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" );
184 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); 184 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
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);
diff --git a/js/helper-classes/RDGE/MaterialsLibrary.js b/js/helper-classes/RDGE/MaterialsLibrary.js
index 9616b525..e7fc51ac 100644
--- a/js/helper-classes/RDGE/MaterialsLibrary.js
+++ b/js/helper-classes/RDGE/MaterialsLibrary.js
@@ -141,7 +141,7 @@ var MaterialsLibrary = Object.create(Object.prototype, {
141 case "julia": mat = new JuliaMaterial(); break; 141 case "julia": mat = new JuliaMaterial(); break;
142 case "mandel": mat = new MandelMaterial(); break; 142 case "mandel": mat = new MandelMaterial(); break;
143 case "plasma": mat = new PlasmaMaterial(); break; 143 case "plasma": mat = new PlasmaMaterial(); break;
144 case "bumpMetal": mat = new PlasmaMaterial(); break; 144 case "bumpMetal": mat = new BumpMetalMaterial(); break;
145 case "uber": mat = new UberMaterial(); break; 145 case "uber": mat = new UberMaterial(); break;
146 146
147 default: 147 default: