aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
diff options
context:
space:
mode:
authorJonathan Duran2012-03-06 11:38:39 -0800
committerJonathan Duran2012-03-06 11:38:39 -0800
commit342fb451bd251358068a0dcb10e9dc218b79a176 (patch)
treeaa0195d581c3934fb6dc09981506b3c070002806 /js/lib/rdge/materials
parent2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 (diff)
downloadninja-342fb451bd251358068a0dcb10e9dc218b79a176.tar.gz
Squashed commit of the following:
commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito <valerio@motorola.com> Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito <valerio@motorola.com> commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran <jduran@motorola.com> commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman <ericg@motorola.com> Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran <jduran@motorola.com> commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js314
-rw-r--r--js/lib/rdge/materials/deform-material.js127
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js159
-rw-r--r--js/lib/rdge/materials/fly-material.js119
-rw-r--r--js/lib/rdge/materials/julia-material.js136
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js144
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js434
-rw-r--r--js/lib/rdge/materials/mandel-material.js147
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js73
-rwxr-xr-xjs/lib/rdge/materials/material.js346
-rw-r--r--js/lib/rdge/materials/plasma-material.js132
-rw-r--r--js/lib/rdge/materials/pulse-material.js258
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js244
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js351
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js122
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js120
-rw-r--r--js/lib/rdge/materials/star-material.js124
-rw-r--r--js/lib/rdge/materials/taper-material.js223
-rw-r--r--js/lib/rdge/materials/tunnel-material.js125
-rw-r--r--js/lib/rdge/materials/twist-material.js139
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js248
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js614
-rw-r--r--js/lib/rdge/materials/water-material.js126
-rw-r--r--js/lib/rdge/materials/z-invert-material.js125
24 files changed, 4950 insertions, 0 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
new file mode 100755
index 00000000..61126952
--- /dev/null
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -0,0 +1,314 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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.
5</copyright> */
6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material;
9///////////////////////////////////////////////////////////////////////
10// Class GLMaterial
11// RDGE representation of a material.
12///////////////////////////////////////////////////////////////////////
13var BumpMetalMaterial = function BumpMetalMaterial() {
14 ///////////////////////////////////////////////////////////////////////
15 // Instance variables
16 ///////////////////////////////////////////////////////////////////////
17 this._name = "BumpMetalMaterial";
18 this._shaderName = "bumpMetal";
19
20 this._lightDiff = [0.3, 0.3, 0.3, 1.0];
21 this._diffuseTexture = "assets/images/metal.png";
22 this._specularTexture = "assets/images/silver.png";
23 this._normalTexture = "assets/images/normalMap.png";
24
25 ///////////////////////////////////////////////////////////////////////
26 // Property Accessors
27 ///////////////////////////////////////////////////////////////////////
28 this.getName = function() {
29 return this._name;
30 };
31
32 this.getShaderName = function() {
33 return this._shaderName;
34 };
35
36 this.getLightDiff = function() {
37 return this._lightDiff;
38 };
39
40 this.setLightDiff = function(ld) {
41 this._lightDiff = ld;
42 // Bad property name. Commenting for now
43
44 if (this._shader && this._shader['default']){
45 this._shader['default'].u_light0Diff.set( ld );
46 }
47
48 };
49
50 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); };
52
53 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); };
55
56 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); };
58
59 this.isAnimated = function() { return true; };
60
61 ///////////////////////////////////////////////////////////////////////
62 // Material Property Accessors
63 ///////////////////////////////////////////////////////////////////////
64 this._propNames = ["lightDiff", "diffuseTexture", "normalMap", "specularTexture"];
65 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"];
66 this._propTypes = ["color", "file", "file", "file"];
67 this._propValues = [];
68
69 this._propValues[ this._propNames[0] ] = this._lightDiff.slice(0);
70 this._propValues[ this._propNames[1] ] = this._diffuseTexture.slice(0);
71 this._propValues[ this._propNames[2] ] = this._normalTexture.slice(0);
72 this._propValues[ this._propNames[3] ] = this._specularTexture.slice(0);
73
74 // TODO - shader techniques are not all named the same, i.e., FlatMaterial uses "colorMe" and BrickMaterial uses "default"
75 this.setProperty = function( prop, value )
76 {
77 // every material should do something with the "color" property
78 if (prop === "color") prop = "lightDiff";
79
80 // make sure we have legitimate imput
81 var ok = this.validateProperty( prop, value );
82 if (!ok)
83 {
84 console.log( "invalid property in Bump Metal Materia;" + prop + " : " + value );
85 return;
86 }
87
88 switch (prop)
89 {
90 case "lightDiff": this.setLightDiff( value ); break;
91 case "diffuseTexture": this.setDiffuseTexture( value ); break;
92 case "specularTexture": this.setSpecularTexture( value ); break;
93 case "normalMap": this.setNormalTexture( value ); break;
94
95 default:
96 console.log( "invalid property to Bump Metal Material: " + prop + ", value: " + value );
97 break;
98 }
99 };
100
101 ///////////////////////////////////////////////////////////////////////
102 // Methods
103 ///////////////////////////////////////////////////////////////////////
104 // duplcate method requirde
105 this.dup = function() { return new BumpMetalMaterial(); };
106
107 this.init = function( world )
108 {
109 // save the world
110 if (world) this.setWorld( world );
111
112 // set up the shader
113 this._shader = new jshader();
114 this._shader.def = bumpMetalMaterialDef;
115 this._shader.init();
116 this._shader['default'].u_light0Diff.set( this.getLightDiff() );
117
118 // set up the material node
119 this._materialNode = createMaterialNode( this.getShaderName() );
120 this._materialNode.setShader(this._shader);
121
122 // set some image maps
123 this.updateTexture(1);
124 this.updateTexture(2);
125 this.updateTexture(3);
126 };
127
128 this.updateTexture = function( index )
129 {
130 var material = this._materialNode;
131 if (material)
132 {
133 var technique = material.shaderProgram['default'];
134 var renderer = g_Engine.getContext().renderer;
135 if (renderer && technique)
136 {
137 var texMapName = this._propValues[this._propNames[index]];
138 var wrap = 'REPEAT', mips = true;
139 var tex = this.loadTexture( texMapName, wrap, mips );
140
141 if (tex)
142 {
143 switch (index)
144 {
145 case 1: technique.u_colMap.set( tex ); break;
146 case 2: technique.u_normalMap.set( tex ); break;
147 case 3: technique.u_glowMap.set( tex ); break;
148 default: console.log( "invalid map index in BumpMetalMaterial, " + index );
149 }
150 }
151 }
152 }
153 };
154