diff options
author | hwc487 | 2012-04-19 13:01:43 -0700 |
---|---|---|
committer | hwc487 | 2012-04-19 13:01:43 -0700 |
commit | e6a20fe64574763483dc602bd759278ccf5e5e68 (patch) | |
tree | 69defe7200206f0257fe90697136fadef59d521e /js/lib/rdge/materials | |
parent | ae7eb87564632ce7c676bd728b8ff2710ff0bb83 (diff) | |
parent | 9284c19f076dec3b47ece7dc7bcd22d74e4246c3 (diff) | |
download | ninja-e6a20fe64574763483dc602bd759278ccf5e5e68.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts:
js/lib/drawing/world.js
js/lib/geom/geom-obj.js
js/lib/rdge/materials/cloud-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
Diffstat (limited to 'js/lib/rdge/materials')
25 files changed, 2435 insertions, 2834 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 7e192a12..981edbfd 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -114,45 +114,47 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
114 | this.init = function( world ) | 114 | this.init = function( world ) |
115 | { | 115 | { |
116 | // save the world | 116 | // save the world |
117 | if (world) this.setWorld( world ); | 117 | if (world) { |
118 | this.setWorld( world ); | ||
119 | } | ||
118 | 120 | ||
119 | // set up the shader | 121 | // set up the shader |
120 | this._shader = new jshader(); | 122 | this._shader = new RDGE.jshader(); |
121 | this._shader.def = bumpMetalMaterialDef; | 123 | this._shader.def = bumpMetalMaterialDef; |
122 | this._shader.init(); | 124 | this._shader.init(); |
123 | this._shader['default'].u_light0Diff.set( this.getLightDiff() ); | 125 | this._shader['default'].u_light0Diff.set( this.getLightDiff() ); |
124 | 126 | ||
125 | // set up the material node | 127 | // set up the material node |
126 | this._materialNode = createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); | 128 | this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); |
127 | this._materialNode.setShader(this._shader); | 129 | this._materialNode.setShader(this._shader); |
128 | 130 | ||
129 | // DEBUG CODE | 131 | // DEBUG CODE |
130 | this.initTextures(); | 132 | this.initTextures(); |
131 | }; | 133 | }; |
132 | 134 | ||
133 | this.initTexture = function( index ) | 135 | this.initTexture = function( index ) |
134 | { | 136 | { |
135 | var dstWorld = this.getWorld(); | 137 | var dstWorld = this.getWorld(); |
136 | if (dstWorld) | 138 | if (dstWorld) |
137 | { | 139 | { |
138 | var texMapName = this._propValues[this._propNames[index]]; | 140 | var texMapName = this._propValues[this._propNames[index]]; |
139 | var texture = new Texture( dstWorld, texMapName ); | 141 | var texture = new Texture( dstWorld, texMapName ); |
140 | this._textures[index] = texture; | 142 | this._textures[index] = texture; |
141 | this.updateTexture( index ); | 143 | this.updateTexture( index ); |
142 | } | 144 | } |
143 | } | 145 | } |
144 | 146 | ||
145 | this.initTextures = function() | 147 | this.initTextures = function() |
146 | { | 148 | { |
147 | var dstWorld = this.getWorld(); | 149 | var dstWorld = this.getWorld(); |
148 | if (dstWorld) | 150 | if (dstWorld) |
149 | { | 151 | { |
150 | // find the world with the given id | 152 | // find the world with the given id |
151 | for (var i=1; i<=3; i++) | 153 | for (var i=1; i<=3; i++) |
152 | { | 154 | { |
153 | this.initTexture( i ); | 155 | this.initTexture( i ); |
154 | } | 156 | } |
155 | } | 157 | } |
156 | } | 158 | } |
157 | 159 | ||
158 | this.updateTexture = function( index ) | 160 | this.updateTexture = function( index ) |
@@ -161,7 +163,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
161 | if (material) | 163 | if (material) |
162 | { | 164 | { |
163 | var technique = material.shaderProgram['default']; | 165 | var technique = material.shaderProgram['default']; |
164 | var renderer = g_Engine.getContext().renderer; | 166 | var renderer = RDGE.globals.engine.getContext().renderer; |
165 | if (renderer && technique) | 167 | if (renderer && technique) |
166 | { | 168 | { |
167 | var glTex = this._textures[ index ]; | 169 | var glTex = this._textures[ index ]; |
@@ -225,60 +227,6 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
225 | 227 | ||
226 | return; | 228 | return; |
227 | }; | 229 | }; |
228 | |||
229 | this.export = function() | ||
230 | { | ||
231 | // every material needs the base type and instance name | ||
232 | var exportStr = "material: " + this.getShaderName() + "\n"; | ||
233 | exportStr += "name: " + this.getName() + "\n"; | ||
234 | |||
235 | var world = this.getWorld(); | ||
236 | if (!world) | ||
237 | throw new Error( "no world in material.export, " + this.getName() ); | ||
238 | |||
239 | exportStr += "lightDiff: " + this.getLightDiff() + "\n"; | ||
240 | exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; | ||
241 | exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; | ||
242 | exportStr += "normalMap: " + this.getNormalTexture() + "\n"; | ||
243 | |||
244 | // every material needs to terminate like this | ||
245 | exportStr += "endMaterial\n"; | ||
246 | |||
247 | return exportStr; | ||
248 | }; | ||
249 | |||
250 | this.import = function( importStr ) | ||
251 | { | ||
252 | var pu = new MaterialParser( importStr ); | ||
253 | var material = pu.nextValue( "material: " ); | ||
254 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); | ||
255 | this.setName( pu.nextValue( "name: ") ); | ||
256 | |||
257 | var rtnStr; | ||
258 | try | ||
259 | { | ||
260 | var lightDiff = eval( "[" + pu.nextValue( "lightDiff: " ) + "]" ), | ||
261 | dt = pu.nextValue( "diffuseTexture: " ), | ||
262 | st = pu.nextValue( "specularTexture: " ), | ||
263 | nt = pu.nextValue( "normalMap: " ); | ||
264 | |||
265 | this.setProperty( "lightDiff", lightDiff); | ||
266 | this.setProperty( "diffuseTexture", dt ); | ||
267 | this.setProperty( "specularTexture", st ); | ||
268 | this.setProperty( "normalMap", nt ); | ||
269 | |||
270 | var endKey = "endMaterial\n"; | ||
271 | var index = importStr.indexOf( endKey ); | ||
272 | index += endKey.length; | ||
273 | rtnStr = importStr.substr( index ); | ||
274 | } | ||
275 | catch (e) | ||
276 | { | ||
277 | throw new Error( "could not import material: " + importStr ); | ||
278 | } | ||
279 | |||
280 | return rtnStr; | ||
281 | }; | ||
282 | }; | 230 | }; |
283 | 231 | ||
284 | /////////////////////////////////////////////////////////////////////////////////////// | 232 | /////////////////////////////////////////////////////////////////////////////////////// |
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js index 4200c1b2..0cf428b0 100644 --- a/js/lib/rdge/materials/cloud-material.js +++ b/js/lib/rdge/materials/cloud-material.js | |||
@@ -1,8 +1,8 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | 2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> |
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; | 7 | var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; |
8 | var Material = require("js/lib/rdge/materials/material").Material; | 8 | var Material = require("js/lib/rdge/materials/material").Material; |
@@ -15,25 +15,27 @@ var TagTool = require("js/tools/TagTool").TagTool; | |||
15 | // Class GLMaterial | 15 | // Class GLMaterial |
16 | // RDGE representation of a material. | 16 | // RDGE representation of a material. |
17 | ////////////////////////// |