diff options
Diffstat (limited to 'js/lib/rdge')
24 files changed, 1325 insertions, 320 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 27d5793c..4bc5dfe8 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 | ||
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; |
9 | var 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,10 +20,14 @@ 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 | |
22 | this._specularTexture = "assets/images/silver.png"; | 24 | this._diffuseTexture = "assets/images/metal.png"; |
25 | this._specularTexture = "assets/images/silver.png"; | ||
23 | this._normalTexture = "assets/images/normalMap.png"; | 26 | this._normalTexture = "assets/images/normalMap.png"; |
24 | 27 | ||
28 | // keep the array of initialized textures | ||
29 | this._textures = []; | ||
30 | |||
25 | /////////////////////////////////////////////////////////////////////// | 31 | /////////////////////////////////////////////////////////////////////// |
26 | // Property Accessors | 32 | // Property Accessors |
27 | /////////////////////////////////////////////////////////////////////// | 33 | /////////////////////////////////////////////////////////////////////// |
@@ -48,13 +54,13 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
48 | }; | 54 | }; |
49 | 55 | ||
50 | this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null }; | 56 | this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null }; |
51 | this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.updateTexture(1); }; | 57 | this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.initTexture(1); }; |
52 | 58 | ||
53 | this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null }; | 59 | this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null }; |
54 | this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.updateTexture(2); }; | 60 | this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.initTexture(2); }; |
55 | 61 | ||
56 | this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null }; | 62 | this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null }; |
57 | this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.updateTexture(3); }; | 63 | this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.initTexture(3); }; |
58 | 64 | ||
59 | this.isAnimated = function() { return true; }; | 65 | this.isAnimated = function() { return true; }; |
60 | 66 | ||
@@ -108,8 +114,8 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
108 | { | 114 | { |
109 | // save the world | 115 | // save the world |
110 | if (world) { | 116 | if (world) { |
111 | this.setWorld( world ); | 117 | this.setWorld( world ); |
112 | } | 118 | } |
113 | 119 | ||
114 | // set up the shader | 120 | // set up the shader |
115 | this._shader = new RDGE.jshader(); | 121 | this._shader = new RDGE.jshader(); |
@@ -121,12 +127,35 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
121 | this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); | 127 | this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); |
122 | this._materialNode.setShader(this._shader); | 128 | this._materialNode.setShader(this._shader); |
123 | 129 | ||
124 | // set some image maps | 130 | // DEBUG CODE |
125 | this.updateTexture(1); | 131 | this.initTextures(); |
126 | this.updateTexture(2); | ||
127 | this.updateTexture(3); | ||
128 | }; | 132 | }; |
129 | 133 | ||
134 | this.initTexture = function( index ) | ||
135 | { | ||
136 | var dstWorld = this.getWorld(); | ||
137 | if (dstWorld) | ||
138 | { | ||
139 | var texMapName = this._propValues[this._propNames[index]]; | ||
140 | var texture = new Texture( dstWorld, texMapName ); | ||
141 | this._textures[index] = texture; | ||
142 | this.updateTexture( index ); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | this.initTextures = function() | ||
147 | { | ||
148 | var dstWorld = this.getWorld(); | ||
149 | if (dstWorld) | ||
150 | { | ||
151 | // find the world with the given id | ||
152 | for (var i=1; i<=3; i++) | ||
153 | { | ||
154 | this.initTexture( i ); | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | |||
130 | this.updateTexture = function( index ) | 159 | this.updateTexture = function( index ) |
131 | { | 160 | { |
132 | var material = this._materialNode; | 161 | var material = this._materialNode; |
@@ -136,20 +165,24 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
136 | var renderer = RDGE.globals.engine.getContext().renderer; | 165 | var renderer = RDGE.globals.engine.getContext().renderer; |
137 | if (renderer && technique) | 166 | if (renderer && technique) |
138 | { | 167 | { |
139 | var texMapName = this._propValues[this._propNames[index]]; | 168 | var glTex = this._textures[ index ]; |
140 | var wrap = 'REPEAT', mips = true; | 169 | if (glTex) |
141 | var tex = this.loadTexture( texMapName, wrap, mips ); | 170 | { |
142 | 171 | if (glTex.isAnimated()) | |
143 | if (tex) | 172 | glTex.render(); |
144 | { | 173 | |
145 | switch (index) | 174 | var tex = glTex.getTexture(); |
146 | { | 175 | if (tex) |
147 | case 1: technique.u_colMap.set( tex ); break; | 176 | { |
148 | case 2: technique.u_normalMap.set( tex ); break; | 177 | switch (index) |
149 | case 3: technique.u_glowMap.set( tex ); break; | 178 | { |
150 | default: console.log( "invalid map index in BumpMetalMaterial, " + index ); | 179 | case 1: technique.u_colMap.set( tex ); break; |
151 | } | 180 | case 2: technique.u_normalMap.set( tex ); break; |
152 | } | 181 | case 3: technique.u_glowMap.set( tex ); break; |
182 | default: console.log( "invalid map index in BumpMetalMaterial, " + index ); | ||
183 | } | ||
184 | } | ||
185 | } | ||
153 | } | 186 | } |
154 | } | 187 | } |
155 | }; | 188 | }; |
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js index bde42ac3..0cf428b0 100644 --- a/js/lib/rdge/materials/cloud-material.js +++ b/js/lib/rdge/materials/cloud-material.js | |||
@@ -4,25 +4,55 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
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; |
9 | var GLWorld = require("js/lib/drawing/world").World; | ||
10 | var Texture = require("js/lib/rdge/texture").Texture; | ||
11 | var ElementMediator = require("js/mediators/element-mediator").ElementMediator; | ||
12 | var TagTool = require("js/tools/TagTool").TagTool; | ||
13 | |||
9 | /////////////////////////////////////////////////////////////////////// | 14 | /////////////////////////////////////////////////////////////////////// |
10 | // Class GLMaterial | 15 | // Class GLMaterial |
11 | // RDGE representation of a material. | 16 | // RDGE representation of a material. |
12 | /////////////////////////////////////////////////////////////////////// | 17 | /////////////////////////////////////////////////////////////////////// |
13 | var CloudMaterial = function CloudMaterial() { | 18 | var CloudMaterial = function CloudMaterial() |
19 | { | ||