diff options
author | Jose Antonio Marquez | 2012-04-04 15:54:33 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-04 15:54:33 -0700 |
commit | a9bcc403df76ad2cb7c31ff7fdd42a85c35cf424 (patch) | |
tree | 9415f5ba25ad643df678e561719d2708fd3ead5a /js/lib/rdge/materials/square-tunnel-material.js | |
parent | 0a469a14757b8cea262c21f652e75c85c9903f4b (diff) | |
parent | e721a7c1009f298a1bd8fea583da14535e039880 (diff) | |
download | ninja-a9bcc403df76ad2cb7c31ff7fdd42a85c35cf424.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/lib/rdge/materials/square-tunnel-material.js')
-rw-r--r-- | js/lib/rdge/materials/square-tunnel-material.js | 133 |
1 files changed, 66 insertions, 67 deletions
diff --git a/js/lib/rdge/materials/square-tunnel-material.js b/js/lib/rdge/materials/square-tunnel-material.js index 9264872f..73df4073 100644 --- a/js/lib/rdge/materials/square-tunnel-material.js +++ b/js/lib/rdge/materials/square-tunnel-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 PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | 7 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; |
8 | 8 | ||
@@ -10,103 +10,102 @@ var SquareTunnelMaterial = function SquareTunnelMaterial() { | |||
10 | /////////////////////////////////////////////////////////////////////// | 10 | /////////////////////////////////////////////////////////////////////// |
11 | // Instance variables | 11 | // Instance variables |
12 | /////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////// |
13 | this._name = "SquareTunnelMaterial"; | 13 | this._name = "SquareTunnelMaterial"; |
14 | this._shaderName = "squareTunnel"; | 14 | this._shaderName = "squareTunnel"; |
15 | 15 | ||
16 | this._texMap = 'assets/images/rocky-normal.jpg'; | 16 | this._texMap = 'assets/images/rocky-normal.jpg'; |
17 | 17 | ||
18 | this._time = 0.0; | 18 | this._time = 0.0; |
19 | this._dTime = 0.01; | 19 | this._dTime = 0.01; |
20 | 20 | ||
21 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
22 | // Properties | 22 | // Properties |
23 | /////////////////////////////////////////////////////////////////////// | 23 | /////////////////////////////////////////////////////////////////////// |
24 | // all defined in parent PulseMaterial.js | 24 | // all defined in parent PulseMaterial.js |
25 | // load the local default value | 25 | // load the local default value |
26 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 26 | this._propValues[this._propNames[0]] = this._texMap.slice(0); |
27 | 27 | ||
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 SquareTunnelMaterial(); | 34 | var newMat = new SquareTunnelMaterial(); |
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 | { | 48 | // save the world |
49 | // save the world | 49 | if (world) this.setWorld(world); |
50 | if (world) this.setWorld( world ); | ||
51 | 50 | ||
52 | // set up the shader | 51 | // set up the shader |
53 | this._shader = new jshader(); | 52 | this._shader = new RDGE.jshader(); |
54 | this._shader.def = squareTunnelMaterialDef; | 53 | this._shader.def = squareTunnelMaterialDef; |
55 | this._shader.init(); | 54 | this._shader.init(); |
56 | 55 | ||
57 | // set up the material node | 56 | // set up the material node |
58 | this._materialNode = createMaterialNode("squareTunnelMaterial" + "_" + world.generateUniqueNodeID()); | 57 | this._materialNode = RDGE.createMaterialNode("squareTunnelMaterial" + "_" + world.generateUniqueNodeID()); |
59 | this._materialNode.setShader(this._shader); | 58 | this._materialNode.setShader(this._shader); |
60 | 59 | ||
61 | this._time = 0; | 60 | this._time = 0; |
62 | if (this._shader && this._shader['default']) { | 61 | if (this._shader && this._shader['default']) { |
63 | this._shader['default'].u_time.set( [this._time] ); | 62 | this._shader['default'].u_time.set([this._time]); |
64 | } | 63 | } |
65 | 64 | ||
66 | // set the shader values in the shader | 65 | // set the shader values in the shader |
67 | this.updateTexture(); | 66 | this.updateTexture(); |
68 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 67 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
69 | this.update( 0 ); | 68 | this.update(0); |
70 | } | 69 | }; |
71 | }; | 70 | }; |
72 | 71 | ||
73 | /////////////////////////////////////////////////////////////////////////////////////// | 72 | /////////////////////////////////////////////////////////////////////////////////////// |
74 | // RDGE shader | 73 | // RDGE shader |
75 | 74 | ||
76 | // 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) |
77 | var squareTunnelMaterialDef = | 76 | var squareTunnelMaterialDef = |
78 | {'shaders': | 77 | { 'shaders': |
79 | { | 78 | { |
80 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | 79 | 'defaultVShader': "assets/shaders/Basic.vert.glsl", |
81 | 'defaultFShader':"assets/shaders/SquareTunnel.frag.glsl" | 80 | 'defaultFShader': "assets/shaders/SquareTunnel.frag.glsl" |
82 | }, | 81 | }, |
83 | 'techniques': | 82 | 'techniques': |
84 | { | 83 | { |
85 | 'default': | 84 | 'default': |
86 | [ | 85 | [ |
87 | { | 86 | { |
88 | 'vshader' : 'defaultVShader', | 87 | 'vshader': 'defaultVShader', |
89 | 'fshader' : 'defaultFShader', | 88 | 'fshader': 'defaultFShader', |
90 | // attributes | 89 | // attributes |
91 | 'attributes' : | 90 | 'attributes': |
92 | { | 91 | { |
93 | 'vert' : { 'type' : 'vec3' }, | 92 | 'vert': { 'type': 'vec3' }, |
94 | 'normal' : { 'type' : 'vec3' }, | 93 | 'normal': { 'type': 'vec3' }, |
95 | 'texcoord' : { 'type' : 'vec2' } | 94 | 'texcoord': { 'type': 'vec2' } |
96 | }, | 95 | }, |
97 | // parameters | 96 | // parameters |
98 | 'params' : | 97 | 'params': |
99 | { | 98 | { |
100 | 'u_tex0': { 'type' : 'tex2d' }, | 99 | 'u_tex0': { 'type': 'tex2d' }, |
101 | 'u_time' : { 'type' : 'float' }, | 100 | 'u_time': { 'type': 'float' }, |
102 | 'u_resolution' : { 'type' : 'vec2' } | 101 | 'u_resolution': { 'type': 'vec2' } |
103 | }, | 102 | }, |
104 | 103 | ||
105 | // render states | 104 | // render states |
106 | 'states' : | 105 | 'states': |
107 | { | 106 | { |
108 | 'depthEnable' : true, | 107 | 'depthEnable': true, |
109 | 'offset':[1.0, 0.1] | 108 | 'offset': [1.0, 0.1] |
110 | } | 109 | } |
111 | } | 110 | } |
112 | ] | 111 | ] |