aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/relief-tunnel-material.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-04 15:53:29 -0700
committerValerio Virgillito2012-04-04 15:53:29 -0700
commite721a7c1009f298a1bd8fea583da14535e039880 (patch)
tree9415f5ba25ad643df678e561719d2708fd3ead5a /js/lib/rdge/materials/relief-tunnel-material.js
parent8482e23cd9b8c4700b5130f2588e5eb24d376536 (diff)
parent7249d6377c8897b2f9d8115be99717be971a0981 (diff)
downloadninja-e721a7c1009f298a1bd8fea583da14535e039880.tar.gz
Merge pull request #156 from mayhewinator/WorkingBranch
Namespace and code cleanup for RDGE and related files
Diffstat (limited to 'js/lib/rdge/materials/relief-tunnel-material.js')
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js132
1 files changed, 66 insertions, 66 deletions
diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js
index 52c40543..06b0cf46 100644
--- a/js/lib/rdge/materials/relief-tunnel-material.js
+++ b/js/lib/rdge/materials/relief-tunnel-material.js
@@ -1,8 +1,8 @@
1/* <copyright> 1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2This 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/> 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. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */ 5</copyright> */
6 6
7 7
8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
@@ -11,101 +11,101 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() {
11 /////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////
12 // Instance variables 12 // Instance variables
13 /////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////
14 this._name = "ReliefTunnelMaterial"; 14 this._name = "ReliefTunnelMaterial";
15 this._shaderName = "reliefTunnel"; 15 this._shaderName = "reliefTunnel";
16 16
17 this._texMap = 'assets/images/rocky-normal.jpg'; 17 this._texMap = 'assets/images/rocky-normal.jpg';
18 18
19 this._time = 0.0; 19 this._time = 0.0;
20 this._dTime = 0.01; 20 this._dTime = 0.01;
21 21
22 /////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////
23 // Properties 23 // Properties
24 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
25 // all defined in parent PulseMaterial.js 25 // all defined in parent PulseMaterial.js
26 // load the local default value 26 // load the local default value
27 this._propValues[ this._propNames[0] ] = this._texMap.slice(0); 27 this._propValues[this._propNames[0]] = this._texMap.slice(0);
28 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
29 // Methods 29 // Methods
30 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
31 // duplcate method requirde 31 // duplcate method requirde
32 this.dup = function( world ) { 32 this.dup = function (world) {
33 // allocate a new uber material 33 // allocate a new uber material
34 var newMat = new ReliefTunnelMaterial(); 34 var newMat = new ReliefTunnelMaterial();
35 35
36 // copy over the current values; 36 // copy over the current values;
37 var propNames = [], propValues = [], propTypes = [], propLabels = []; 37 var propNames = [], propValues = [], propTypes = [], propLabels = [];
38 this.getAllProperties( propNames, propValues, propTypes, propLabels); 38 this.getAllProperties(propNames, propValues, propTypes, propLabels);
39 var n = propNames.length; 39 var n = propNames.length;
40 for (var i=0; i<n; i++) { 40 for (var i = 0; i < n; i++) {
41 newMat.setProperty( propNames[i], propValues[i] ); 41 newMat.setProperty(propNames[i], propValues[i]);
42 } 42 }
43 43
44 return newMat; 44 return newMat;
45 }; 45 };
46 46
47 this.init = function( world ) { 47 this.init = function (world) {
48 // save the world 48 // save the world
49 if (world) this.setWorld( world ); 49 if (world) this.setWorld(world);
50 50
51 // set up the shader 51 // set up the shader
52 this._shader = new jshader(); 52 this._shader = new RDGE.jshader();
53 this._shader.def = reliefTunnelMaterialDef; 53 this._shader.def = reliefTunnelMaterialDef;
54 this._shader.init(); 54 this._shader.init();
55 55
56 // set up the material node 56 // set up the material node
57 this._materialNode = createMaterialNode("reliefTunnelMaterial" + "_" + world.generateUniqueNodeID()); 57 this._materialNode = RDGE.createMaterialNode("reliefTunnelMaterial" + "_" + world.generateUniqueNodeID());
58 this._materialNode.setShader(this._shader); 58 this._materialNode.setShader(this._shader);
59 59
60 this._time = 0; 60 this._time = 0;
61 if (this._shader && this._shader['default']) { 61 if (this._shader && this._shader['default']) {
62 this._shader['default'].u_time.set( [this._time] ); 62 this._shader['default'].u_time.set([this._time]);
63 } 63 }
64 64
65 // set the shader values in the shader 65 // set the shader values in the shader
66 this.updateTexture(); 66 this.updateTexture();
67 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 67 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
68 this.update( 0 ); 68 this.update(0);
69 } 69 };
70}; 70};
71 71
72/////////////////////////////////////////////////////////////////////////////////////// 72///////////////////////////////////////////////////////////////////////////////////////
73// RDGE shader 73// RDGE shader
74 74
75// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 75// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
76var reliefTunnelMaterialDef = 76var reliefTunnelMaterialDef =
77{'shaders': 77{ 'shaders':
78 { 78 {
79 'defaultVShader':"assets/shaders/Basic.vert.glsl", 79 'defaultVShader': "assets/shaders/Basic.vert.glsl",
80 'defaultFShader':"assets/shaders/ReliefTunnel.frag.glsl" 80 'defaultFShader': "assets/shaders/ReliefTunnel.frag.glsl"
81 }, 81 },
82 'techniques': 82 'techniques':
83 { 83 {
84 'default': 84 'default':
85 [ 85 [
86 { 86 {
87 'vshader' : 'defaultVShader', 87 'vshader': 'defaultVShader',
88 'fshader' : 'defaultFShader', 88 'fshader': 'defaultFShader',
89 // attributes 89 // attributes
90 'attributes' : 90 'attributes':
91 { 91 {
92 'vert' : { 'type' : 'vec3' }, 92 'vert': { 'type': 'vec3' },
93 'normal' : { 'type' : 'vec3' }, 93 'normal': { 'type': 'vec3' },
94 'texcoord' : { 'type' : 'vec2' } 94 'texcoord': { 'type': 'vec2' }
95 }, 95 },
96 // parameters 96 // parameters
97 'params' : 97 'params':
98 { 98 {
99 'u_tex0': { 'type' : 'tex2d' }, 99 'u_tex0': { 'type': 'tex2d' },
100 'u_time' : { 'type' : 'float' }, 100 'u_time': { 'type': 'float' },
101 'u_resolution' : { 'type' : 'vec2' } 101 'u_resolution': { 'type': 'vec2' }
102 }, 102 },
103 103
104 // render states 104 // render states
105 'states' : 105 'states':
106 { 106 {
107 'depthEnable' : true, 107 'depthEnable': true,
108 'offset':[1.0, 0.1] 108 'offset': [1.0, 0.1]
109 } 109 }
110 } 110 }
111 ] 111 ]