aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/tunnel-material.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-07-09 17:28:24 -0700
committerJohn Mayhew2012-07-09 17:28:24 -0700
commit770bcb52422742ff741a88a75ecefbeb90bc9247 (patch)
tree64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/lib/rdge/materials/tunnel-material.js
parent8c5ecaf90062f9e030386f338bdc19fd62b826c8 (diff)
parent2b2b5fbb4b6a786daa4e9d4ee9eba9ac78924842 (diff)
downloadninja-770bcb52422742ff741a88a75ecefbeb90bc9247.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Conflicts: manifest.json
Diffstat (limited to 'js/lib/rdge/materials/tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/tunnel-material.js123
1 files changed, 67 insertions, 56 deletions
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js
index 0a96e23e..2bfec9c4 100644
--- a/js/lib/rdge/materials/tunnel-material.js
+++ b/js/lib/rdge/materials/tunnel-material.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -50,19 +51,19 @@ var TunnelMaterial = function TunnelMaterial() {
50 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
51 // Material Property Accessors 52 // Material Property Accessors
52 /////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////
53 var u_tex0_index = 0, u_speed_index = 1; 54 var u_tex0_index = 0, u_speed_index = 1;
54 this._propNames = ["u_tex0", "u_speed" ]; 55 this._propNames = ["u_tex0", "u_speed" ];
55 this._propLabels = ["Texture map", "Speed" ]; 56 this._propLabels = ["Texture map", "Speed" ];
56 this._propTypes = ["file", "float" ]; 57 this._propTypes = ["file", "float" ];
57 this._propValues = []; 58 this._propValues = [];
58 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); 59 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
59 this._propValues[this._propNames[u_speed_index]] = 1.0; 60 this._propValues[this._propNames[u_speed_index]] = 1.0;
60 61
61 /////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////
62 // Material Property Accessors 63 // Material Property Accessors
63 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
64 this.isAnimated = function() { return true; }; 65 this.isAnimated = function() { return true; };
65 this.getShaderDef = function() { return tunnelMaterialDef; }; 66 this.getShaderDef = function() { return tunnelMaterialDef; };
66 67
67 /////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////
68 // Methods 69 // Methods
@@ -90,50 +91,60 @@ var TunnelMaterial = function TunnelMaterial() {
90 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 91 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
91 this.update(0); 92 this.update(0);
92 }; 93 };
94
95 this.resetToDefault = function()
96 {
97 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
98 this._propValues[this._propNames[u_speed_index]] = 1.0;
99
100 var nProps = this._propNames.length;
101 for (var i=0; i<nProps; i++)
102 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
103 };
93}; 104};
94 105
95/////////////////////////////////////////////////////////////////////////////////////// 106///////////////////////////////////////////////////////////////////////////////////////
96// RDGE shader 107// RDGE shader
97 108
98// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 109// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
99var tunnelMaterialDef = 110var tunnelMaterialDef =
100{'shaders': 111{'shaders':
101 { 112 {
102 'defaultVShader':"assets/shaders/Basic.vert.glsl", 113 'defaultVShader':"assets/shaders/Basic.vert.glsl",
103 'defaultFShader':"assets/shaders/Tunnel.frag.glsl" 114 'defaultFShader':"assets/shaders/Tunnel.frag.glsl"
104 }, 115 },
105 'techniques': 116 'techniques':
106 { 117 {
107 'default': 118 'default':
108 [ 119 [
109 { 120 {
110 'vshader' : 'defaultVShader', 121 'vshader' : 'defaultVShader',
111 'fshader' : 'defaultFShader', 122 'fshader' : 'defaultFShader',
112 // attributes 123 // attributes
113 'attributes' : 124 'attributes' :
114 { 125 {
115 'vert' : { 'type' : 'vec3' }, 126 'vert' : { 'type' : 'vec3' },
116 'normal' : { 'type' : 'vec3' }, 127 'normal' : { 'type' : 'vec3' },
117 'texcoord' : { 'type' : 'vec2' } 128 'texcoord' : { 'type' : 'vec2' }
118 }, 129 },
119 // parameters 130 // parameters
120 'params' : 131 'params' :
121 { 132 {
122 'u_tex0': { 'type' : 'tex2d' }, 133 'u_tex0': { 'type' : 'tex2d' },
123 'u_time' : { 'type' : 'float' }, 134 'u_time' : { 'type' : 'float' },
124 'u_speed' : { 'type' : 'float' }, 135 'u_speed' : { 'type' : 'float' },
125 'u_resolution' : { 'type' : 'vec2' } 136 'u_resolution' : { 'type' : 'vec2' }
126 }, 137 },
127 138
128 // render states 139 // render states
129 'states' : 140 'states' :
130 { 141 {
131 'depthEnable' : true, 142 'depthEnable' : true,
132 'offset':[1.0, 0.1] 143 'offset':[1.0, 0.1]
133 } 144 }
134 } 145 }
135 ] 146 ]
136 } 147 }
137}; 148};
138 149
139TunnelMaterial.prototype = new PulseMaterial(); 150TunnelMaterial.prototype = new PulseMaterial();