aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorhwc4872012-02-08 14:48:16 -0800
committerhwc4872012-02-08 14:48:16 -0800
commit43e713a85785cd170bf0f5312d149d93235dadf2 (patch)
tree2142672a6cefe6ae531b84f3e23920f36157d394 /js
parent468d324f8e9a5f018bc7609b58254ae468075ce9 (diff)
parent72805efb66c372bec2df8a2686dfd56c9ed26622 (diff)
downloadninja-43e713a85785cd170bf0f5312d149d93235dadf2.tar.gz
Merge branch 'ToolFixes' of github.com:mqg734/ninja-internal into working
Conflicts: js/helper-classes/RDGE/Materials/FlatMaterial.js
Diffstat (limited to 'js')
-rw-r--r--js/controllers/elements/shapes-controller.js25
-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
-rw-r--r--js/panels/properties/sections/three-d-view.reel/three-d-view.html12
8 files changed, 70 insertions, 39 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index e764de4e..b9c033aa 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -63,11 +63,11 @@ exports.ShapesController = Montage.create(CanvasController, {
63 canvas.height = el.height; 63 canvas.height = el.height;
64 this.application.ninja.elementMediator.replaceElement(el, canvas); 64 this.application.ninja.elementMediator.replaceElement(el, canvas);
65 NJevent("elementDeleted", el); 65 NJevent("elementDeleted", el);
66 this.application.ninja.selectionController.selectElement(canvas);
67 el = canvas; 66 el = canvas;
68 this.toggleWebGlMode(el, value); 67 this.toggleWebGlMode(el, value);
69 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 68 el.elementModel.shapeModel.GLWorld.render();
70 break; 69 this.application.ninja.selectionController.selectElement(el);
70 return;
71 case "strokeMaterial": 71 case "strokeMaterial":
72 var sm = Object.create(MaterialsLibrary.getMaterial(value)); 72 var sm = Object.create(MaterialsLibrary.getMaterial(value));
73 if(sm) 73 if(sm)
@@ -338,13 +338,26 @@ exports.ShapesController = Montage.create(CanvasController, {
338 { 338 {
339 return; 339 return;
340 } 340 }
341 var world, 341 var sm,
342 fm,
343 world,
342 worldData = el.elementModel.shapeModel.GLWorld.export(); 344 worldData = el.elementModel.shapeModel.GLWorld.export();
343 if(worldData) 345 if(worldData)
344 { 346 {
345 world = new GLWorld(el, true); 347 world = new GLWorld(el, true);
346 el.elementModel.shapeModel.GLWorld = world; 348 el.elementModel.shapeModel.GLWorld = world;
349 el.elementModel.shapeModel.GLGeomObj.setWorld(world);
347 el.elementModel.shapeModel.useWebGl = true; 350 el.elementModel.shapeModel.useWebGl = true;
351 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
352 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
353 if(sm && fm)
354 {
355 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
356 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
357 el.elementModel.shapeModel.strokeMaterial = sm;
358 el.elementModel.shapeModel.fillMaterial = fm;
359 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
360 }
348 world.import(worldData); 361 world.import(worldData);
349 } 362 }
350 363
@@ -365,6 +378,10 @@ exports.ShapesController = Montage.create(CanvasController, {
365 world = new GLWorld(el, false); 378 world = new GLWorld(el, false);
366 el.elementModel.shapeModel.GLWorld = world; 379 el.elementModel.shapeModel.GLWorld = world;
367 el.elementModel.shapeModel.useWebGl = false; 380 el.elementModel.shapeModel.useWebGl = false;
381 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
382 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
383 el.elementModel.shapeModel.strokeMaterial = null;
384 el.elementModel.shapeModel.fillMaterial = null;
368 world.import(worldData); 385 world.import(worldData);
369 } 386 }
370 387
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js
index a74a74e4..642fab05 100644
--- a/js/helper-classes/RDGE/GLMaterial.js
+++ b/js/helper-classes/RDGE/GLMaterial.js
@@ -226,7 +226,7 @@ function GLMaterial( world )
226 var endKey = "endMaterial\n"; 226 var endKey = "endMaterial\n";
227 var index = importStr.indexOf( endKey ); 227 var index = importStr.indexOf( endKey );
228 index += endKey.length; 228 index += endKey.length;
229 rtnStr = importStr.substr( index ); 229 var rtnStr = importStr.substr( index );
230 230
231 return rtnStr; 231 return rtnStr;
232 } 232 }
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js
index 595a5b48..e34532d2 100644
--- a/js/helper-classes/RDGE/GLRectangle.js
+++ b/js/helper-classes/RDGE/GLRectangle.js
@@ -178,8 +178,8 @@ function GLRectangle()
178 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); 178 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
179 this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); 179 this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) );
180 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) ); 180 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) );
181 var strokeMaterialName = Number( this.getPropertyFromString( "strokeMat: ", importStr ) ); 181 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
182 var fillMaterialName = Number( this.getPropertyFromString( "fillMat: ", importStr ) ); 182 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr );
183 this._strokeStyle = Number( this.getPropertyFromString( "strokeColor: ", importStr ) ); 183 this._strokeStyle = Number( this.getPropertyFromString( "strokeColor: ", importStr ) );
184 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); 184 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" );
185 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); 185 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 17be0cd7..999d4676 100644
--- 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 de039231..a250dc0a 100644
--- a/js/helper-classes/RDGE/Materials/FlatMaterial.js
+++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js
@@ -75,11 +75,12 @@ function FlatMaterial()
75 75
76 this.setProperty = function( prop, value ) 76 this.setProperty = function( prop, value )
77 { 77 {
78 // make sure we have legitimate imput 78 // make sure we have legitimate input
79 if (this.validateProperty( prop, value )) 79 if (this.validateProperty( prop, value ))
80 { 80 {
81 this._color = value.slice(0); 81 this._propValues[prop] = value;
82 this._shader.colorMe[prop].set(value); 82 if (this._shader && this._shader.colorMe)
83 this._shader.colorMe[prop].set(value);
83 } 84 }
84 } 85 }
85 /////////////////////////////////////////////////////////////////////// 86 ///////////////////////////////////////////////////////////////////////
@@ -88,7 +89,7 @@ function FlatMaterial()
88 { 89 {
89 // this function should be overridden by subclasses 90 // this function should be overridden by subclasses
90 var exportStr = "material: " + this.getShaderName() + "\n"; 91 var exportStr = "material: " + this.getShaderName() + "\n";
91 exportStr = "name: " + this.getName() + "\n"; 92 exportStr += "name: " + this.getName() + "\n";
92 93
93 if (this._shader) 94 if (this._shader)
94 exportStr += "color: " + String(this._shader.colorMe.color) + "\n"; 95 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
@@ -99,19 +100,32 @@ function FlatMaterial()
99 return exportStr; 100 return exportStr;
100 } 101 }
101 102
102 this.import = function( importStr ) 103 this.import = function( importStr )
103 { 104 {
104 var pu = new ParseUtils( importStr ); 105 var pu = new ParseUtils( importStr );
105 var material = pu.nextValue( "material: " ); 106 var material = pu.nextValue( "material: " );
106 if (material != this.getShaderName()) throw new Error( "ill-formed material" ); 107 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
107 this.setName( pu.nextValue( "material: ") ); 108 this.setName( pu.nextValue( "name: ") );
108 var color = pu.nextValue( "color: " );