aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/bump-metal-material.js
diff options
context:
space:
mode:
authorhwc4872012-03-22 13:52:09 -0700
committerhwc4872012-03-22 13:52:09 -0700
commit00cd98e49c959906d7c44bb6adcdef1f3d5148ae (patch)
treefa8c64af563263ad1f27f48e70d45f86a9711b25 /js/lib/rdge/materials/bump-metal-material.js
parent57cc00a5ef3ab525e54a030d7692b2d9eefaa68b (diff)
downloadninja-00cd98e49c959906d7c44bb6adcdef1f3d5148ae.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Texture
Conflicts: assets/shaders/plasma.frag.glsl js/helper-classes/RDGE/GLLine.js js/helper-classes/RDGE/MaterialsLibrary.js js/lib/drawing/world.js js/lib/geom/circle.js js/lib/geom/rectangle.js js/lib/rdge/materials/flat-material.js js/lib/rdge/materials/material.js js/panels/Materials/Materials.xml js/panels/Materials/materials-popup.reel/materials-popup.js js/preloader/Preloader.js
Diffstat (limited to 'js/lib/rdge/materials/bump-metal-material.js')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js40
1 files changed, 39 insertions, 1 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index fa6f5300..fe8a9dd5 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -6,6 +6,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; 7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material; 8var Material = require("js/lib/rdge/materials/material").Material;
9var Texture = require("js/lib/rdge/texture").Texture;
10
9/////////////////////////////////////////////////////////////////////// 11///////////////////////////////////////////////////////////////////////
10// Class GLMaterial 12// Class GLMaterial
11// RDGE representation of a material. 13// RDGE representation of a material.
@@ -18,7 +20,9 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
18 this._shaderName = "bumpMetal"; 20 this._shaderName = "bumpMetal";
19 21
20 this._lightDiff = [0.3, 0.3, 0.3, 1.0]; 22 this._lightDiff = [0.3, 0.3, 0.3, 1.0];
21 this._diffuseTexture = "assets/images/metal.png"; 23 //this._diffuseTexture = "assets/images/metal.png";
24 this._diffuseTexture = "texture";
25 this._diffuseWorld = null; // the world that the texture is derived from (if there is one).
22 this._specularTexture = "assets/images/silver.png"; 26 this._specularTexture = "assets/images/silver.png";
23 this._normalTexture = "assets/images/normalMap.png"; 27 this._normalTexture = "assets/images/normalMap.png";
24 28
@@ -119,12 +123,46 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
119 this._materialNode = createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); 123 this._materialNode = createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() );
120 this._materialNode.setShader(this._shader); 124 this._materialNode.setShader(this._shader);
121 125
126 // DEBUG CODE
127 this.initWorldTextures();
128
122 // set some image maps 129 // set some image maps
123 this.updateTexture(1); 130 this.updateTexture(1);
124 this.updateTexture(2); 131 this.updateTexture(2);
125 this.updateTexture(3); 132 this.updateTexture(3);
126 }; 133 };
127 134
135 this.initWorldTextures = function()
136 {
137 // find the world with the given id
138 var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils;
139 var root = viewUtils.application.ninja.currentDocument.documentRoot;
140 this._diffuseWorld = this.findWorld( this._diffuseTexture, root );
141 }
142
143 this.findWorld = function( id, elt )
144 {
145 if (elt.id && elt.id === id)
146 {
147 if (elt.eltModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
148 {
149 var world = elt.elementModel.shapeModel.GLWorld;
150 return world;
151 }
152 }
153
154 if (elt.children)
155 {
156 var nKids = elt.children.length;
157 for (var i=0; i<nKids; i++)
158 {
159 var child = elt.children[i];
160 var world = this.findWorld( id, child );
161 if (world) return world;
162 }
163 }
164 }
165
128 this.updateTexture = function( index ) 166 this.updateTexture = function( index )
129 { 167 {
130 var material = this._materialNode; 168 var material = this._materialNode;